madrona-rad 0.2.7 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. data/History.txt +6 -15
  2. data/Manifest.txt +38 -5
  3. data/README.rdoc +19 -7
  4. data/Rakefile +4 -3
  5. data/bin/rad +214 -130
  6. data/lib/examples/basic_blink.rb +10 -0
  7. data/lib/examples/blink_with_serial.rb +16 -0
  8. data/lib/examples/external_variable_fu.rb +21 -19
  9. data/lib/examples/external_variables.rb +0 -3
  10. data/lib/examples/hello_array2.rb +34 -1
  11. data/lib/examples/hello_array_eeprom.rb +4 -6
  12. data/lib/examples/hello_clock.rb +84 -0
  13. data/lib/examples/hello_eeprom.rb +3 -3
  14. data/lib/examples/hello_eeprom_lcdpa.rb +2 -2
  15. data/lib/examples/hello_format_print.rb +94 -0
  16. data/lib/examples/hello_spectra_sound.rb +38 -0
  17. data/lib/examples/hello_world.rb +3 -3
  18. data/lib/examples/hello_xbee.rb +12 -0
  19. data/lib/examples/midi_beat_box.rb +86 -0
  20. data/lib/examples/midi_scales.rb +94 -0
  21. data/lib/examples/servo_throttle.rb +11 -8
  22. data/lib/examples/software_serial.rb +10 -0
  23. data/lib/examples/twitter.rb +57 -0
  24. data/lib/libraries/AFSoftSerial/AFSoftSerial.cpp +321 -0
  25. data/lib/libraries/AFSoftSerial/AFSoftSerial.h +61 -0
  26. data/lib/libraries/{Servo → AFSoftSerial}/keywords.txt +18 -25
  27. data/lib/libraries/AF_XPort/AF_XPort.cpp +166 -0
  28. data/lib/libraries/AF_XPort/AF_XPort.h +48 -0
  29. data/lib/libraries/DS1307/DS1307.cpp +10 -9
  30. data/lib/libraries/DS1307/DS1307.h +6 -4
  31. data/lib/libraries/I2CEEPROM/I2CEEPROM.cpp +120 -0
  32. data/lib/libraries/I2CEEPROM/I2CEEPROM.h +70 -0
  33. data/lib/libraries/I2CEEPROM/keywords.txt +21 -0
  34. data/lib/libraries/LoopTimer/LoopTimer.cpp +35 -0
  35. data/lib/libraries/LoopTimer/LoopTimer.h +34 -0
  36. data/lib/libraries/LoopTimer/keywords.txt +27 -0
  37. data/lib/libraries/SWSerLCDpa/SWSerLCDpa.cpp +42 -48
  38. data/lib/libraries/SWSerLCDpa/SWSerLCDpa.h +11 -12
  39. data/lib/libraries/SWSerLCDsf/SWSerLCDsf.cpp +38 -0
  40. data/lib/libraries/SWSerLCDsf/SWSerLCDsf.h +9 -2
  41. data/lib/plugins/blink.rb +25 -0
  42. data/lib/plugins/blink_m.rb +3 -3
  43. data/lib/plugins/lcd_padding.rb +19 -0
  44. data/lib/plugins/midi.rb +60 -0
  45. data/lib/plugins/parallax_ping.rb +50 -0
  46. data/lib/plugins/servo_setup.rb +1 -1
  47. data/lib/plugins/twitter_connect.rb +145 -0
  48. data/lib/rad/README.rdoc +5 -0
  49. data/lib/rad/arduino_sketch.rb +91 -904
  50. data/lib/rad/darwin_installer.rb +23 -0
  51. data/lib/rad/generators/makefile/makefile.erb +1 -1
  52. data/lib/rad/generators/makefile/makefile.rb +3 -3
  53. data/lib/rad/hardware_library.rb +813 -0
  54. data/lib/rad/init.rb +4 -2
  55. data/lib/rad/linux_installer.rb +132 -0
  56. data/lib/rad/progressbar.rb +236 -0
  57. data/lib/rad/rad_processor.rb +56 -9
  58. data/lib/rad/rad_rewriter.rb +7 -2
  59. data/lib/rad/rad_type_checker.rb +1 -1
  60. data/lib/rad/sketch_compiler.rb +47 -0
  61. data/lib/rad/tasks/build_and_make.rake +41 -48
  62. data/lib/rad/version.rb +2 -2
  63. data/spec/examples/hello_world.rb +11 -0
  64. data/spec/examples/serial_motor.rb +12 -0
  65. data/spec/models/sketch_compiler_spec.rb +96 -0
  66. data/spec/sim/hello_world_spec.rb +0 -0
  67. data/test/hello_world_test/Makefile +436 -0
  68. data/test/hello_world_test/hello_world.cpp +23 -0
  69. data/test/test_array_processing.rb +1 -1
  70. data/test/test_plugin_loading.rb +1 -1
  71. data/test/test_translation_post_processing.rb +14 -70
  72. metadata +52 -39
  73. data/lib/examples/orig_servo_throttle.rb +0 -39
  74. data/lib/plugins/i2c_eeprom.rb +0 -70
@@ -0,0 +1,12 @@
1
+ class HelloXbee < ArduinoSketch
2
+
3
+ output_pin 13, :as => :led
4
+
5
+ serial_begin
6
+ def loop
7
+ led.blink 200
8
+ serial_print "...testing..."
9
+ delay 1000
10
+ end
11
+
12
+ end
@@ -0,0 +1,86 @@
1
+ class MidiBeatBox < ArduinoSketch
2
+
3
+ # midi synthesiser output on channel 2
4
+ # with speed controlled by spectra soft pot
5
+
6
+ @channel = 2
7
+ input_pin 1, :as => :sensor_one, :device => :spectra
8
+ output_pin 13, :as => :led
9
+
10
+ serial_begin :rate => 31250
11
+
12
+ def setup
13
+ delay 3000
14
+ end
15
+
16
+ def loop
17
+ 8.times {first}
18
+ 2.times do
19
+ second
20
+ third
21
+ end
22
+ 4.times {first}
23
+ 2.times {second}
24
+ end
25
+
26
+ def first
27
+ play 39, 52, 37
28
+ play 0, 0, 0
29
+ play 36, 52, 0
30
+ play 37, 52, 39
31
+
32
+ play 37, 0, 0
33
+ play 36, 0, 0
34
+ play 39, 50, 0
35
+ play 0, 0, 0
36
+
37
+ play 52, 36, 37
38
+ play 0, 0, 0
39
+ play 39, 0, 0
40
+ play 36, 37, 0
41
+
42
+ play 36, 37, 39
43
+ play 36, 38, 0
44
+ play 50, 0, 0
45
+ play 0, 0, 0
46
+ end
47
+
48
+ def second
49
+ play 39, 52, 37
50
+ play 36, 0, 0
51
+ play 0, 0, 0
52
+ play 37, 52, 39
53
+
54
+ play 38, 0, 0
55
+ play 36, 0, 0
56
+ play 39, 50, 0
57
+ play 0, 0, 0
58
+ end
59
+
60
+ def third
61
+ play 0, 36, 37
62
+ play 0, 0, 0
63
+ play 39, 36, 0
64
+ play 36, 37, 50
65
+
66
+ play 36, 37, 39
67
+ play 36, 37, 0
68
+ play 50, 0, 0
69
+ play 39, 0, 0
70
+ end
71
+
72
+
73
+ def play(one, two, three)
74
+ n = 1 + one + two + three # ack to coerce parameters to int
75
+ note_on(@channel, one, 127) unless one == 0
76
+ note_on(@channel, two, 127) unless two == 0
77
+ note_on(@channel, three, 127) unless three == 0
78
+ delay 310 - sensor_one.soft_lock # start slowly
79
+ note_off(@channel, one, 0) unless one == 0
80
+ note_off(@channel, two, 0) unless two == 0
81
+ note_off(@channel, three, 0) unless three == 0
82
+ end
83
+
84
+
85
+
86
+ end
@@ -0,0 +1,94 @@
1
+ class MidiScales < ArduinoSketch
2
+
3
+ # purpose
4
+ # trigger midi output with buttons and
5
+ # spectra soft pots
6
+ #
7
+ #
8
+
9
+
10
+ @current_note = int
11
+ @last_note_one = 0
12
+ @last_note_two = 0
13
+ @last_note_three = 0
14
+ @note = int
15
+
16
+ input_pin 1, :as => :sensor_one, :device => :spectra
17
+ input_pin 2, :as => :sensor_two, :device => :spectra
18
+ input_pin 3, :as => :sensor_three, :device => :spectra
19
+ input_pin 7, :as => :button_one, :device => :button
20
+ input_pin 8, :as => :button_two, :device => :button
21
+ input_pin 9, :as => :button_three, :device => :button
22
+ output_pin 13, :as => :led
23
+
24
+ serial_begin :rate => 31250
25
+
26
+ def setup
27
+ delay 3000
28
+ end
29
+
30
+ def loop
31
+ change_tone if button_one.read_input
32
+ change_pressure if button_two.read_input
33
+ change_channels if button_three.read_input
34
+ read_sensor_one
35
+ read_sensor_two
36
+ read_sensor_three
37
+ end
38
+
39
+ def change_tone
40
+ 110.upto(127) do |note|
41
+ play 0, note, 127
42
+ end
43
+ end
44
+
45
+ def change_pressure
46
+ 110.upto(127) do |pressure|
47
+ play 0, 45, pressure
48
+ end
49
+ end
50
+
51
+ def change_channels
52
+ 0.upto(6) do |channel|
53
+ play channel, 50, 100
54
+ end
55
+ end
56
+
57
+ def read_sensor_one
58
+ @current_note = sensor_one.soft_lock
59
+ pre_play(@current_note, @last_note_one, 13)
60
+ @last_note_one = @current_note
61
+ end
62
+
63
+ def read_sensor_two
64
+ @current_note = sensor_two.soft_lock
65
+ pre_play(@current_note, @last_note_two, 14)
66
+ @last_note_two = @current_note
67
+ end
68
+
69
+ def read_sensor_three
70
+ @current_note = sensor_three.soft_lock
71
+ pre_play(@current_note, @last_note_three, 15)
72
+ @last_note_three = @current_note
73
+ end
74
+
75
+ def pre_play(current_note, last_note, channel) # warning, don't use last as a parameter...
76
+ n = 1 + channel
77
+ unless current_note == last_note
78
+ @note = ((current_note /16) + 40)
79
+ play_with_no_delay( channel, @note, 100 )
80
+ end
81
+ end
82
+
83
+ def play(chan, note, pressure)
84
+ note_on(chan, note, pressure)
85
+ delay 100 # adjust to need
86
+ note_off(chan, note, 0)
87
+ end
88
+
89
+ def play_with_no_delay(chan, note, pressure) # note is not turned off
90
+ note_on(chan, note, pressure)
91
+ end
92
+
93
+
94
+ end
@@ -1,12 +1,15 @@
1
1
  class ServoThrottle < ArduinoSketch
2
-
2
+
3
+ # updated 20080731
4
+ # replaced external variables with instance style variables
5
+
3
6
  # potentiometer to control servo
4
7
  # with a bit of hysteresis
5
8
  # use analog pin for sensor
6
9
  # need to format the output of sensor_position and sensor_amount
7
10
 
8
-
9
- external_vars :sensor_position => "int, 0", :servo_amount => "int, 0"
11
+ @sensor_position = 0
12
+ @servo_amount = 0
10
13
 
11
14
  output_pin 5, :as => :my_lcd, :device => :sf_lcd
12
15
  input_pin 1, :as => :sensor
@@ -16,9 +19,9 @@ class ServoThrottle < ArduinoSketch
16
19
  def loop
17
20
  servo_refresh
18
21
  #delay 9 # comment out if using servo status, since it will add enough delay
19
- sensor_position = analogRead(sensor)
20
- servo_amount = (add_hysteresis(sensor_position, 10)*0.36)
21
- my_servo.position servo_amount
22
+ @sensor_position = analogRead(sensor)
23
+ @servo_amount = (add_hysteresis(@sensor_position, 10)*0.36)
24
+ my_servo.position @servo_amount
22
25
  servo_status
23
26
 
24
27
  end
@@ -28,9 +31,9 @@ class ServoThrottle < ArduinoSketch
28
31
  my_lcd.setxy 0,0 # line 0, col 0
29
32
  my_lcd.print "Read Send"
30
33
  my_lcd.setxy 0,1 # line 1, col 0
31
- my_lcd.print sensor_position # need method of blanking out previous reading
34
+ my_lcd.print @sensor_position # need method of blanking out previous reading
32
35
  my_lcd.setxy 6,1
33
- my_lcd.print servo_amount
36
+ my_lcd.print @servo_amount
34
37
  end
35
38
 
36
39
 
@@ -0,0 +1,10 @@
1
+ class SoftwareSerial < ArduinoSketch
2
+ output_pin 13, :as => :led
3
+ software_serial 6, 7, :as => :gps
4
+ serial_begin
5
+
6
+ def loop
7
+ digitalWrite(led, true)
8
+ serial_print(gps.read)
9
+ end
10
+ end
@@ -0,0 +1,57 @@
1
+ class Twitter < ArduinoSketch
2
+
3
+ #include <avr/io.h>
4
+ #include <string.h>
5
+
6
+
7
+
8
+ define "TWEETLEN 141"
9
+ define "HOSTNAME www.twitter.com"
10
+
11
+ define 'IPADDR "128.121.146.100"' # twitter.com
12
+ define "PORT 80" # // HTTP
13
+ define "HTTPPATH /atduskgreg/" # // the person we want to follow
14
+
15
+
16
+ define "TWEETLEN 141"
17
+ array "char linebuffer[256]" # // our large buffer for data
18
+ array "char tweet[TWEETLEN]" # // the tweet
19
+ @lines = 0
20
+
21
+
22
+ define "XPORT_RXPIN 2"
23
+ define "XPORT_TXPIN 3"
24
+ define "XPORT_RESETPIN 4"
25
+ define "XPORT_DTRPIN 5"
26
+ define "XPORT_CTSPIN 6"
27
+ define "XPORT_RTSPIN 7"
28
+
29
+
30
+ @errno = 0
31
+ @laststatus = 0
32
+ @currstatus = 0
33
+
34
+
35
+
36
+ # in setup
37
+ #xport = AF_XPort(XPORT_RX, XPORT_TX, XPORT_RESET, XPORT_DTR, XPORT_RTS, XPORT_CTS)
38
+
39
+
40
+ output_pin 10, :as => :shield, :device => :ethernet
41
+
42
+ serial_begin :rate => 57600
43
+
44
+ def loop
45
+
46
+ # local_connect()
47
+ # kind of a problem... fixed
48
+ get_tweet
49
+ fetchtweet
50
+ delay 30000
51
+
52
+
53
+ end
54
+
55
+
56
+
57
+ end
@@ -0,0 +1,321 @@
1
+ /*
2
+ SoftwareSerial.cpp - Software serial library
3
+ Copyright (c) 2006 David A. Mellis. All right reserved. - hacked by ladyada
4
+
5
+ This library is free software; you can redistribute it and/or
6
+ modify it under the terms of the GNU Lesser General Public
7
+ License as published by the Free Software Foundation; either
8
+ version 2.1 of the License, or (at your option) any later version.
9
+
10
+ This library is distributed in the hope that it will be useful,
11
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
+ Lesser General Public License for more details.
14
+
15
+ You should have received a copy of the GNU Lesser General Public
16
+ License along with this library; if not, write to the Free Software
17
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18
+ */
19
+
20
+ /******************************************************************************
21
+ * Includes
22
+ ******************************************************************************/
23
+ #include <avr/interrupt.h>
24
+ #include "WConstants.h"
25
+ #include "AFSoftSerial.h"
26
+
27
+ /******************************************************************************
28
+ * Definitions
29
+ ******************************************************************************/
30
+
31
+ #define AFSS_MAX_RX_BUFF 64
32
+
33
+ /******************************************************************************
34
+ * Statics
35
+ ******************************************************************************/
36
+ static uint8_t _receivePin;
37
+ static uint8_t _transmitPin;
38
+ static int _bitDelay;
39
+
40
+ static char _receive_buffer[AFSS_MAX_RX_BUFF];
41
+ static uint8_t _receive_buffer_index;
42
+
43
+ #if (F_CPU == 16000000)
44
+ void whackDelay(uint16_t delay) {
45
+ uint8_t tmp=0;
46
+
47
+ asm volatile("sbiw %0, 0x01 \n\t"
48
+ "ldi %1, 0xFF \n\t"
49
+ "cpi %A0, 0xFF \n\t"
50
+ "cpc %B0, %1 \n\t"
51
+ "brne .-10 \n\t"
52
+ : "+r" (delay), "+a" (tmp)
53
+ : "0" (delay)
54
+ );
55
+ }
56
+ #endif
57
+
58
+ /******************************************************************************
59
+ * Interrupts
60
+ ******************************************************************************/
61
+
62
+ SIGNAL(SIG_PIN_CHANGE0) {
63
+ if ((_receivePin >=8) && (_receivePin <= 13)) {
64
+ recv();
65
+ }
66
+ }
67
+ SIGNAL(SIG_PIN_CHANGE2)
68
+ {
69
+ if (_receivePin <8) {
70
+ recv();
71
+ }
72
+ }
73
+
74
+
75
+ void recv(void) {
76
+ char i, d = 0;
77
+ if (digitalRead(_receivePin))
78
+ return; // not ready!
79
+ whackDelay(_bitDelay - 8);
80
+ for (i=0; i<8; i++) {
81
+ //PORTB |= _BV(5);
82
+ whackDelay(_bitDelay*2 - 6); // digitalread takes some time
83
+ //PORTB &= ~_BV(5);
84
+ if (digitalRead(_receivePin))
85
+ d |= (1 << i);
86
+ }
87
+ whackDelay(_bitDelay*2);
88
+ if (_receive_buffer_index >= AFSS_MAX_RX_BUFF)
89
+ return;
90
+ _receive_buffer[_receive_buffer_index] = d; // save data
91
+ _receive_buffer_index++; // got a byte
92
+ }
93
+
94
+
95
+
96
+ /******************************************************************************
97
+ * Constructors
98
+ ******************************************************************************/
99
+
100
+ AFSoftSerial::AFSoftSerial(uint8_t receivePin, uint8_t transmitPin)
101
+ {
102
+ _receivePin = receivePin;
103
+ _transmitPin = transmitPin;
104
+ _baudRate = 0;
105
+ }
106
+
107
+ void AFSoftSerial::setTX(uint8_t tx) {
108
+ _transmitPin = tx;
109
+ }
110
+ void AFSoftSerial::setRX(uint8_t rx) {
111
+ _receivePin = rx;
112
+ }
113
+
114
+ /******************************************************************************
115
+ * User API
116
+ ******************************************************************************/
117
+
118
+ void AFSoftSerial::begin(long speed)
119
+ {
120
+ pinMode(_transmitPin, OUTPUT);
121
+ digitalWrite(_transmitPin, HIGH);
122
+
123
+ pinMode(_receivePin, INPUT);
124
+ digitalWrite(_receivePin, HIGH); // pullup!
125
+
126
+ _baudRate = speed;
127
+ switch (_baudRate) {
128
+ case 115200: // For xmit -only-!
129
+ _bitDelay = 4; break;
130
+ case 57600:
131
+ _bitDelay = 14; break;
132
+ case 38400:
133
+ _bitDelay = 24; break;
134
+ case 31250:
135
+ _bitDelay = 31; break;
136
+ case 19200:
137
+ _bitDelay = 54; break;
138
+ case 9600:
139
+ _bitDelay = 113; break;
140
+ case 4800:
141
+ _bitDelay = 232; break;
142
+ case 2400:
143
+ _bitDelay = 470; break;
144
+ default:
145
+ _bitDelay = 0;
146
+ }
147
+
148
+ if (_receivePin < 8) {
149
+ // a PIND pin, PCINT16-23
150
+ PCMSK2 |= _BV(_receivePin);
151
+ PCICR |= _BV(2);
152
+ } else if (_receivePin <= 13) {
153
+ // a PINB pin, PCINT0-5
154
+ PCICR |= _BV(0);
155
+ PCMSK0 |= _BV(_receivePin-8);
156
+ }
157
+
158
+ whackDelay(_bitDelay*2); // if we were low this establishes the end
159
+ }
160
+
161
+ int AFSoftSerial::read(void)
162
+ {
163
+ uint8_t d,i;
164
+
165
+ if (! _receive_buffer_index)
166
+ return -1;
167
+
168
+ d = _receive_buffer[0]; // grab first byte
169
+ // if we were awesome we would do some nifty queue action
170
+ // sadly, i dont care
171
+ for (i=0; i<_receive_buffer_index; i++) {
172
+ _receive_buffer[i] = _receive_buffer[i+1];
173
+ }
174
+ _receive_buffer_index--;
175
+ return d;
176
+ }
177
+
178
+ uint8_t AFSoftSerial::available(void)
179
+ {
180
+ return _receive_buffer_index;
181
+ }
182
+
183
+ void AFSoftSerial::print(uint8_t b)
184
+ {
185
+ if (_baudRate == 0)
186
+ return;
187
+ byte mask;
188
+
189
+ cli(); // turn off interrupts for a clean txmit
190
+
191
+ digitalWrite(_transmitPin, LOW); // startbit
192
+ whackDelay(_bitDelay*2);
193
+
194
+ for (mask = 0x01; mask; mask <<= 1) {
195
+ if (b & mask){ // choose bit
196
+ digitalWrite(_transmitPin,HIGH); // send 1
197
+ }
198
+ else{
199
+ digitalWrite(_transmitPin,LOW); // send 1
200
+ }
201
+ whackDelay(_bitDelay*2);
202
+ }
203
+
204
+ digitalWrite(_transmitPin, HIGH);
205
+ sei(); // turn interrupts back on. hooray!
206
+ whackDelay(_bitDelay*2);
207
+ }
208
+
209
+ void AFSoftSerial::print(const char *s)
210
+ {
211
+ while (*s)
212
+ print(*s++);
213
+ }
214
+
215
+ void AFSoftSerial::print(char c)
216
+ {
217
+ print((uint8_t) c);
218
+ }
219
+
220
+ void AFSoftSerial::print(int n)
221
+ {
222
+ print((long) n);
223
+ }
224
+
225
+ void AFSoftSerial::print(unsigned int n)
226
+ {
227
+ print((unsigned long) n);
228
+ }
229
+
230
+ void AFSoftSerial::print(long n)
231
+ {
232
+ if (n < 0) {
233
+ print('-');
234
+ n = -n;
235
+ }
236
+ printNumber(n, 10);
237
+ }
238
+
239
+ void AFSoftSerial::print(unsigned long n)
240
+ {
241
+ printNumber(n, 10);
242
+ }
243
+
244
+ void AFSoftSerial::print(long n, int base)
245
+ {
246
+ if (base == 0)
247
+ print((char) n);
248
+ else if (base == 10)
249
+ print(n);
250
+ else
251
+ printNumber(n, base);
252
+ }
253
+
254
+ void AFSoftSerial::println(void)
255
+ {
256
+ print('\r');
257
+ print('\n');
258
+ }
259
+
260
+ void AFSoftSerial::println(char c)
261
+ {
262
+ print(c);
263
+ println();
264
+ }
265
+
266
+ void AFSoftSerial::println(const char c[])
267
+ {
268
+ print(c);
269
+ println();
270
+ }
271
+
272
+ void AFSoftSerial::println(uint8_t b)
273
+ {
274
+ print(b);
275
+ println();
276
+ }
277
+
278
+ void AFSoftSerial::println(int n)
279
+ {
280
+ print(n);
281
+ println();
282
+ }
283
+
284
+ void AFSoftSerial::println(long n)
285
+ {
286
+ print(n);
287
+ println();
288
+ }
289
+
290
+ void AFSoftSerial::println(unsigned long n)
291
+ {
292
+ print(n);
293
+ println();
294
+ }
295
+
296
+ void AFSoftSerial::println(long n, int base)
297
+ {
298
+ print(n, base);
299
+ println();
300
+ }
301
+
302
+ // Private Methods /////////////////////////////////////////////////////////////
303
+
304
+ void AFSoftSerial::printNumber(unsigned long n, uint8_t base)
305
+ {
306
+ unsigned char buf[8 * sizeof(long)]; // Assumes 8-bit chars.
307
+ unsigned long i = 0;
308
+
309
+ if (n == 0) {
310
+ print('0');
311
+ return;
312
+ }
313
+
314
+ while (n > 0) {
315
+ buf[i++] = n % base;
316
+ n /= base;
317
+ }
318
+
319
+ for (; i > 0; i--)
320
+ print((char) (buf[i - 1] < 10 ? '0' + buf[i - 1] : 'A' + buf[i - 1] - 10));
321
+ }