rad 0.2.2 → 0.2.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (123) hide show
  1. data/History.txt +34 -0
  2. data/Manifest.txt +113 -7
  3. data/{README.txt → README.rdoc} +17 -5
  4. data/Rakefile +3 -0
  5. data/bin/rad +106 -1
  6. data/lib/examples/add_hysteresis.rb +13 -0
  7. data/lib/examples/basic_blink.rb +10 -0
  8. data/lib/examples/blink_m_address_assignment.rb +104 -0
  9. data/lib/examples/blink_m_hello.rb +14 -0
  10. data/lib/examples/blink_m_multi.rb +61 -0
  11. data/lib/examples/blink_with_serial.rb +16 -0
  12. data/lib/examples/configure_pa_lcd_boot.rb +91 -0
  13. data/lib/examples/debounce_methods.rb +49 -0
  14. data/lib/examples/external_variable_fu.rb +26 -0
  15. data/lib/examples/external_variables.rb +32 -0
  16. data/lib/examples/first_sound.rb +23 -0
  17. data/lib/examples/frequency_generator.rb +30 -0
  18. data/lib/examples/hello_array.rb +48 -0
  19. data/lib/examples/hello_array2.rb +79 -0
  20. data/lib/examples/hello_array_eeprom.rb +59 -0
  21. data/lib/examples/hello_clock.rb +84 -0
  22. data/lib/examples/hello_eeprom.rb +51 -0
  23. data/lib/examples/hello_eeprom_lcdpa.rb +81 -0
  24. data/lib/examples/hello_format_print.rb +94 -0
  25. data/lib/examples/hello_lcd_charset.rb +75 -0
  26. data/lib/examples/hello_pa_lcd.rb +59 -0
  27. data/lib/examples/hello_servos.rb +88 -0
  28. data/lib/examples/hello_spectra_sound.rb +38 -0
  29. data/lib/examples/hello_world.rb +11 -0
  30. data/lib/examples/hello_xbee.rb +12 -0
  31. data/lib/examples/hysteresis_duel.rb +39 -0
  32. data/lib/examples/i2c_with_clock_chip.rb +124 -0
  33. data/lib/examples/midi_beat_box.rb +86 -0
  34. data/lib/examples/midi_scales.rb +94 -0
  35. data/lib/examples/motor_knob.rb +30 -0
  36. data/lib/examples/servo_buttons.rb +23 -0
  37. data/lib/examples/servo_calibrate_continuous.rb +92 -0
  38. data/lib/examples/servo_throttle.rb +40 -0
  39. data/lib/examples/sparkfun_lcd.rb +48 -0
  40. data/lib/examples/spectra_soft_pot.rb +34 -0
  41. data/lib/examples/times_method.rb +8 -0
  42. data/lib/examples/toggle.rb +10 -0
  43. data/lib/examples/twitter.rb +57 -0
  44. data/lib/examples/two_wire.rb +14 -0
  45. data/lib/libraries/AFSoftSerial/AFSoftSerial.cpp +321 -0
  46. data/lib/libraries/AFSoftSerial/AFSoftSerial.h +61 -0
  47. data/lib/libraries/AFSoftSerial/keywords.txt +18 -0
  48. data/lib/libraries/AF_XPort/AF_XPort.cpp +166 -0
  49. data/lib/libraries/AF_XPort/AF_XPort.h +48 -0
  50. data/lib/libraries/DS1307/DS1307.cpp +162 -0
  51. data/lib/libraries/DS1307/DS1307.h +66 -0
  52. data/lib/libraries/{SWSerLCDpa → DS1307}/keywords.txt +1 -1
  53. data/lib/libraries/FrequencyTimer2/FrequencyTimer2.cpp +144 -0
  54. data/lib/libraries/FrequencyTimer2/FrequencyTimer2.h +42 -0
  55. data/lib/libraries/FrequencyTimer2/keywords.txt +22 -0
  56. data/lib/libraries/I2CEEPROM/I2CEEPROM.cpp +120 -0
  57. data/lib/libraries/I2CEEPROM/I2CEEPROM.h +70 -0
  58. data/lib/libraries/I2CEEPROM/keywords.txt +21 -0
  59. data/lib/libraries/LoopTimer/LoopTimer.cpp +35 -0
  60. data/lib/libraries/LoopTimer/LoopTimer.h +34 -0
  61. data/lib/libraries/LoopTimer/keywords.txt +27 -0
  62. data/lib/libraries/OneWire/OneWire.cpp +194 -0
  63. data/lib/libraries/OneWire/OneWire.h +63 -0
  64. data/lib/libraries/OneWire/keywords.txt +35 -0
  65. data/lib/libraries/OneWire/readme.txt +13 -0
  66. data/lib/libraries/SWSerLCDpa/SWSerLCDpa.cpp +93 -47
  67. data/lib/libraries/SWSerLCDpa/SWSerLCDpa.h +16 -9
  68. data/lib/libraries/SWSerLCDsf/SWSerLCDsf.cpp +311 -0
  69. data/lib/libraries/SWSerLCDsf/SWSerLCDsf.h +67 -0
  70. data/lib/libraries/Servo/Servo.cpp +192 -0
  71. data/lib/libraries/Servo/Servo.h +61 -0
  72. data/lib/libraries/Stepper/Stepper.cpp +220 -0
  73. data/lib/libraries/Stepper/Stepper.h +86 -0
  74. data/lib/libraries/Stepper/keywords.txt +28 -0
  75. data/lib/libraries/Wire/Wire.cpp +262 -0
  76. data/lib/libraries/Wire/Wire.h +67 -0
  77. data/lib/libraries/Wire/keywords.txt +31 -0
  78. data/lib/libraries/Wire/twi.h +57 -0
  79. data/lib/libraries/Wire/utility/twi.c +449 -0
  80. data/lib/libraries/Wire/utility/twi.h +57 -0
  81. data/lib/plugins/bitwise_ops.rb +54 -0
  82. data/lib/plugins/blink.rb +25 -0
  83. data/lib/plugins/blink_m.rb +356 -0
  84. data/lib/plugins/debounce.rb +138 -0
  85. data/lib/plugins/debug_output_to_lcd.rb +71 -0
  86. data/lib/plugins/hysteresis.rb +52 -0
  87. data/lib/plugins/input_output_state.rb +84 -0
  88. data/lib/plugins/lcd_padding.rb +58 -0
  89. data/lib/plugins/mem_test.rb +37 -0
  90. data/lib/plugins/midi.rb +60 -0
  91. data/lib/plugins/parallax_ping.rb +50 -0
  92. data/lib/plugins/servo_pulse.rb +31 -0
  93. data/lib/plugins/servo_setup.rb +86 -0
  94. data/lib/plugins/smoother.rb +54 -0
  95. data/lib/plugins/spark_fun_serial_lcd.rb +100 -0
  96. data/lib/plugins/spectra_symbol.rb +79 -0
  97. data/lib/plugins/twitter_connect.rb +145 -0
  98. data/lib/rad/README.rdoc +5 -0
  99. data/lib/rad/arduino_plugin.rb +246 -0
  100. data/lib/rad/arduino_sketch.rb +351 -257
  101. data/lib/rad/generators/makefile/makefile.erb +1 -1
  102. data/lib/rad/generators/makefile/makefile.rb +9 -10
  103. data/lib/rad/hardware_library.rb +813 -0
  104. data/lib/rad/init.rb +3 -1
  105. data/lib/rad/rad_processor.rb +128 -0
  106. data/lib/rad/rad_rewriter.rb +94 -0
  107. data/lib/rad/rad_type_checker.rb +26 -0
  108. data/lib/rad/sim/arduino_sketch.rb +57 -0
  109. data/lib/rad/sketch_compiler.rb +47 -0
  110. data/lib/rad/tasks/build_and_make.rake +146 -24
  111. data/lib/rad/variable_processing.rb +153 -0
  112. data/lib/rad/version.rb +1 -1
  113. data/spec/examples/hello_world.rb +11 -0
  114. data/spec/examples/serial_motor.rb +12 -0
  115. data/spec/models/sketch_compiler_spec.rb +96 -0
  116. data/spec/sim/hello_world_spec.rb +42 -0
  117. data/test/test_array_processing.rb +179 -0
  118. data/test/test_plugin_loading.rb +151 -0
  119. data/test/test_translation_post_processing.rb +185 -0
  120. data/test/test_variable_processing.rb +238 -0
  121. data/website/index.html +22 -7
  122. data/website/stylesheets/screen.css +32 -1
  123. metadata +130 -13
@@ -0,0 +1,50 @@
1
+ class ParallaxPing < ArduinoPlugin
2
+
3
+ # RAD plugins are c methods, directives, external variables and assignments and calls
4
+ # that may be added to the main setup method
5
+ # function prototypes not needed since we generate them automatically
6
+
7
+ # directives, external variables and setup assignments and calls can be added rails style (not c style)
8
+
9
+ # add to directives
10
+ # plugin_directives "#define EXAMPLE 10"
11
+
12
+ # add to external variables
13
+ # external_variables "int foo, bar"
14
+
15
+ # add the following to the setup method
16
+ # add_to_setup "foo = 1";, "bar = 1;" "sub_setup();"
17
+
18
+ # one or more methods may be added and prototypes are
19
+
20
+ # Methods for the Parallax Ping)) UltraSonic Distance Sensor.
21
+ #
22
+ # Example:
23
+ #
24
+ # class RangeFinder < ArduinoSketch
25
+ # serial_begin
26
+ #
27
+ # external_vars :sig_pin => 'int, 7'
28
+ #
29
+ # def loop
30
+ # serial_println(ping(sig_pin))
31
+ # delay(200)
32
+ # end
33
+ # end
34
+
35
+ # Triggers a pulse and returns the delay in microseconds for the echo.
36
+ int ping(int pin) {
37
+ pinMode(pin, OUTPUT);
38
+
39
+ digitalWrite(pin, LOW);
40
+ delayMicroseconds(2);
41
+ digitalWrite(pin, HIGH);
42
+ delayMicroseconds(5);
43
+ digitalWrite(pin, LOW);
44
+
45
+ pinMode(pin, INPUT);
46
+
47
+ return pulseIn(pin, HIGH);
48
+ }
49
+
50
+ end
@@ -0,0 +1,31 @@
1
+ class ServoPulse < ArduinoPlugin
2
+
3
+ # RAD plugins are c methods, directives, external variables and assignments and calls
4
+ # that may be added to the main setup method
5
+ # function prototypes not needed since we generate them automatically
6
+
7
+ # directives, external variables and setup assignments and calls can be added rails style (not c style)
8
+
9
+ # add to directives
10
+ #plugin_directives "#define EXAMPLE 10"
11
+
12
+ # add to external variables
13
+ # external_variables "int foo, bar"
14
+
15
+ # add the following to the setup method
16
+ # add_to_setup "foo = 1";, "bar = 1;" "sub_setup();"
17
+
18
+ # one or more methods may be added and prototypes are generated automatically with rake make:upload
19
+
20
+ # call pulse(us) to pulse a servo
21
+ # this can be eliminate since we have an identical pulse_servo in servo_setup
22
+
23
+ void pulse(int pin, int us) {
24
+ digitalWrite( pin, HIGH );
25
+ delayMicroseconds( us );
26
+ digitalWrite( pin, LOW );
27
+ serv[pin].pulseWidth = us;
28
+ }
29
+
30
+
31
+ end
@@ -0,0 +1,86 @@
1
+ class ServoSetup < ArduinoPlugin
2
+
3
+ # RAD plugins are c methods, directives, external variables and assignments and calls
4
+ # that may be added to the main setup method
5
+ # function prototypes not needed since we generate them automatically
6
+
7
+ # directives, external variables and setup assignments and calls can be added rails style (not c style)
8
+
9
+ # add to directives
10
+ #plugin_directives "#define EXAMPLE 10"
11
+
12
+ # add to external variables
13
+ # external_variables "int foo, bar"
14
+
15
+ # add the following to the setup method
16
+ # add_to_setup "foo = 1";, "bar = 1;" "sub_setup();"
17
+
18
+ # one or more methods may be added and prototypes are generated automatically with rake make:upload
19
+
20
+
21
+ # one line servo control
22
+ #
23
+ # move_servo my_servo, amount
24
+ #
25
+ # example:
26
+ #
27
+ # class MoveServo < ArduinoSketch
28
+ #
29
+ # external_vars :sensor_position => "int, 0", :servo_amount => "int, 0"
30
+ #
31
+ # output_pin 4, :as => :my_servo, :min => 700, :max => 2200
32
+ # input_pin 1, :as => :sensor
33
+ # def loop
34
+ # sensor_position = analogRead(sensor)
35
+ # servo_amount = (sensor_position*2 + 500)
36
+ # move_servo my_servo, servo_amount
37
+ # end
38
+ # end
39
+ #
40
+ #
41
+ # supports multiple servos by storing variables in the serv struc array that is constructed when
42
+ # the :min and :max options are added to the output_pin method
43
+
44
+
45
+ add_servo_struct
46
+
47
+ void move_servo(int servo_num, int pulse_width)
48
+ {
49
+ struct servo servo_name = serv[servo_num];
50
+
51
+ int pw = pulse_width;
52
+ /* apply the servo limits */
53
+ if (pw > servo_name.max)
54
+ pw = servo_name.max;
55
+ if (pw < servo_name.min)
56
+ pw = servo_name.min;
57
+
58
+ if (millis() - servo_name.lastPulse >= servo_name.refreshTime)
59
+ {
60
+ pulse_servo(servo_name.pin, pw);
61
+ servo_name.lastPulse = millis();
62
+ // if (find_total_loop_time() < 10)
63
+ // for debug:
64
+ // digitalWrite( 5, HIGH );
65
+ // 18 seems optimal, but we should let the users adjust with a servo option
66
+ delay(18);
67
+ }
68
+
69
+ }
70
+
71
+ void pulse_servo(int pin, int us) {
72
+ digitalWrite( pin, HIGH );
73
+ // pulseWidth
74
+ delayMicroseconds( us );
75
+ digitalWrite( pin, LOW );
76
+ serv[pin].pulseWidth = us;
77
+ }
78
+
79
+
80
+
81
+
82
+
83
+
84
+
85
+
86
+ end
@@ -0,0 +1,54 @@
1
+ class Smoother < ArduinoPlugin
2
+
3
+ # RAD plugins are c methods, directives, external variables and assignments and calls
4
+ # that may be added to the main setup method
5
+ # function prototypes not needed since we generate them automatically
6
+
7
+ # directives, external variables and setup assignments and calls can be added rails style (not c style)
8
+
9
+ # add to directives
10
+ plugin_directives "#define ARY_SIZE 10"
11
+
12
+ # add to external variables
13
+ external_variables "int *cur, *scan, *start, *end;", "int sm_ary[ARY_SIZE];", "int last_reading = 0;"
14
+
15
+ # add the following to the setup method
16
+ add_to_setup "scan = &sm_ary[0];", "cur = &sm_ary[0];", "start = &sm_ary[0];", "end = &sm_ary[ARY_SIZE-1];"
17
+
18
+ # add an element to the array and return the average
19
+
20
+ int add_hysteresis(int reading, int hysteresis)
21
+ {
22
+ if ( ((reading - last_reading) > hysteresis) || ((last_reading - reading) > hysteresis)) {
23
+
24
+ last_reading = reading;
25
+ return reading;
26
+ }
27
+ else
28
+ return last_reading;
29
+ }
30
+
31
+ int smooth_average(int reading)
32
+ {
33
+ int sum, cnt;
34
+ cnt = 0;
35
+ sum = 0;
36
+ *cur = reading;
37
+ cur++;
38
+ for (scan = &sm_ary[0]; scan < &sm_ary[ARY_SIZE-1]; cnt++, scan++)
39
+ sum += *scan;
40
+ ptr_reset();
41
+ return sum/cnt;
42
+ }
43
+
44
+ void ptr_reset(void)
45
+ {
46
+ if (cur == end)
47
+ {
48
+ cur = &sm_ary[0];
49
+ }
50
+ }
51
+
52
+
53
+
54
+ end
@@ -0,0 +1,100 @@
1
+ class SparkFunSerialLcd < ArduinoPlugin
2
+
3
+ # RAD plugins are c methods, directives, external variables and assignments and calls
4
+ # that may be added to the main setup method
5
+ # function prototypes not needed since we generate them automatically
6
+
7
+ # directives, external variables and setup assignments and calls can be added rails style (not c style)
8
+ # hack from http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1209050315
9
+
10
+ plugin_directives "#undef int", "#include <stdio.h>", "char _str[32];", "#define writeln(...) sprintf(_str, __VA_ARGS__); Serial.println(_str)"
11
+ # add to directives
12
+ #plugin_directives "#define EXAMPLE 10"
13
+
14
+ # add to external variables
15
+ external_variables "char status_message[40] = \"very cool\"", "char* msg[40]"
16
+
17
+ # add the following to the setup method
18
+ # add_to_setup "foo = 1";, "bar = 1;" "sub_setup();"
19
+
20
+ # one or more methods may be added and prototypes are generated automatically with rake make:upload
21
+
22
+ # methods for sparkfun serial lcd SerLCD v2.5
23
+
24
+ void print_sensor_position_plus(int reading){
25
+
26
+
27
+ /* writeln("sensor: %d ", reading); */
28
+ Serial.print("sensor: ");
29
+ Serial.print(reading);
30
+
31
+
32
+ }
33
+
34
+ void print_sensor_position(long pos){
35
+ Serial.print(pos);
36
+ }
37
+
38
+ void lcd_first_line(){ //puts the cursor at line 0 char 0.
39
+ Serial.print(0xFE, BYTE); //command flag
40
+ Serial.print(128, BYTE); //position
41
+ }
42
+
43
+ void lcd_second_line(){ //puts the cursor at line 0 char 0.
44
+ Serial.print(0xFE, BYTE); //command flag
45
+ Serial.print(192, BYTE); //position
46
+ }
47
+
48
+ void selectLineOne(){ //puts the cursor at line 0 char 0.
49
+ Serial.print(0xFE, BYTE); //command flag
50
+ Serial.print(128, BYTE); //position
51
+ }
52
+ void selectLineTwo(){ //puts the cursor at line 0 char 0.
53
+ Serial.print(0xFE, BYTE); //command flag
54
+ Serial.print(192, BYTE); //position
55
+ }
56
+ void clearLCD(){
57
+ Serial.print(0xFE, BYTE); //command flag
58
+ Serial.print(0x01, BYTE); //clear command.
59
+ }
60
+ void backlightOn(){ //turns on the backlight
61
+ Serial.print(0x7C, BYTE); //command flag for backlight stuff
62
+ Serial.print(157, BYTE); //light level.
63
+ }
64
+
65
+ void set_backlight_level(int level){ //turns on the backlight
66
+ if (level > 29)
67
+ level = 29;
68
+ Serial.print(0x7C, BYTE); //command flag for backlight stuff
69
+ Serial.print(157 + level, BYTE); //light level.
70
+ }
71
+
72
+ void toggle_backlight(){ //turns off the backlight
73
+ Serial.print(0x7C, BYTE); //command flag for backlight stuff
74
+ Serial.print("|"); //light level for off.
75
+ Serial.print(1);
76
+ }
77
+
78
+ void set_splash(){
79
+ selectLineOne();
80
+ Serial.print(" Ruby + Auduino");
81
+ selectLineTwo();
82
+ Serial.print(" RAD 0.2.4+ ");
83
+ Serial.print(0x7C, BYTE); // decimal 124, command flag for backlight stuff
84
+ Serial.print(10, BYTE);
85
+ }
86
+
87
+ void backlightOff(){ //turns off the backlight
88
+ Serial.print(0x7C, BYTE); // decimal 124, command flag for backlight stuff
89
+ Serial.print(128, BYTE); //light level for off.
90
+ }
91
+ void serCommand(){ // decimal 254, a general function to call the command flag for issuing all other commands
92
+ Serial.print(0xFE, BYTE);
93
+ }
94
+
95
+
96
+
97
+
98
+
99
+
100
+ end
@@ -0,0 +1,79 @@
1
+ class SpectraSymbol < ArduinoPlugin
2
+
3
+ # jdbarnhart
4
+ # 20080729
5
+ #
6
+ # crazy experiment in progress
7
+ # purpose
8
+ #
9
+ # retain last reading after finger is removed from spectrasymbol
10
+ # soft pot
11
+ #
12
+ # use
13
+ # two steps
14
+ #
15
+ # one
16
+ # declare :device => :sensor
17
+ # example:
18
+ # input_pin 1, :as => :sensor_one, :device => :spectra
19
+ #
20
+ # two
21
+ # instead of:
22
+ # my_lcd.print analogRead sensor_two
23
+ # use soft_lock
24
+ # my_lcd.print sensor_one.spectra_lock
25
+ #
26
+ #
27
+ # notes:
28
+ # experimental settings for 100mm spectrasymbol
29
+ #
30
+ # hysteresis is set at 5
31
+ # amount of sensor drop is set to 3
32
+ # delay time (dtime) is 4
33
+ # cutoff set to 10
34
+ #
35
+ int soft_lock(int pin)
36
+
37
+ {
38
+ int hyst = 5;
39
+ int drop = 3;
40
+ int dtime = 4;
41
+ int cutoff = 10;
42
+ int read;
43
+ int r1;
44
+ int r2;
45
+ int r3;
46
+ unsigned int i;
47
+ read = analogRead(pin)/4;
48
+ delay(dtime);
49
+ r1 = analogRead(pin)/4;
50
+ delay(dtime);
51
+ r2 = analogRead(pin)/4;
52
+ delay(dtime);
53
+ r3 = analogRead(pin)/4;
54
+ delay(dtime);
55
+ for (i = 0; i < (int) (sizeof(spec) / sizeof(spec[0])); i++) {
56
+ if (pin == spec[i].pin) {
57
+ if (((r3 - r2) > drop) && ((r2 - r1) > drop) && ((r1 - read) > drop))
58
+ return spec[i].state - 10;
59
+ else
60
+ {
61
+ if (read < cutoff)
62
+ return spec[i].state - 10;
63
+ else
64
+ {
65
+ if (((read - spec[i].state) > hyst ) || ((spec[i].state - read) > hyst )) {
66
+ spec[i].state = read;
67
+ return spec[i].state - 10;
68
+ }
69
+ else
70
+ return spec[i].state - 10;
71
+ }
72
+ }
73
+ }
74
+ }
75
+ }
76
+
77
+
78
+
79
+ end
@@ -0,0 +1,145 @@
1
+ class TwitterConnect < ArduinoPlugin
2
+
3
+
4
+
5
+
6
+ void get_tweet() {
7
+ // hack to pull
8
+ }
9
+
10
+ uint32_t parsenumber(char *str) {
11
+ uint32_t num = 0;
12
+ char c;
13
+
14
+ // grabs a number out of a string
15
+ while (c = str[0]) {
16
+ if ((c < '0') || (c > '9'))
17
+ return num;
18
+ num *= 10;
19
+ num += c - '0';
20
+ str++;
21
+ }
22
+ return num;
23
+ }
24
+
25
+
26
+ char * fetchtweet(void) {
27
+ Serial.print("... fetching tweets....");
28
+ uint8_t ret;
29
+ char *found=0, *start=0, *end=0;
30
+
31
+ tweet[0] = 0; // reset the tweet
32
+ ret = xport.reset();
33
+ //Serial.print("Ret: "); Serial.print(ret, HEX);
34
+ switch (ret) {
35
+ case ERROR_TIMEDOUT: {
36
+ Serial.println("Timed out on reset!");
37
+ return 0;
38
+ }
39
+ case ERROR_BADRESP: {
40
+ Serial.println("Bad response on reset!");
41
+ return 0;
42
+ }
43
+ case ERROR_NONE: {
44
+ Serial.println("Reset OK!");
45
+ break;
46
+ }
47
+ default:
48
+ Serial.println("Unknown error");
49
+ return 0;
50
+ }
51
+
52
+ // time to connect...
53
+
54
+ ret = xport.connect(IPADDR, PORT);
55
+ switch (ret) {
56
+ case ERROR_TIMEDOUT: {
57
+ Serial.println("Timed out on connect");
58
+ return 0;
59
+ }
60
+ case ERROR_BADRESP: {
61
+ Serial.println("Failed to connect");
62
+ return 0;
63
+ }
64
+ case ERROR_NONE: {
65
+ Serial.println("Connected..."); break;
66
+ }
67
+ default:
68
+ Serial.println("Unknown error");
69
+ return 0;
70
+ }
71
+
72
+ // send the HTTP command, ie "GET /username/"
73
+
74
+ xport.print("GET "); xport.println(HTTPPATH);
75
+ // the following works with instiki, but not on twitter...
76
+ // xport.print("GET ");
77
+ // xport.print(HTTPPATH);
78
+ // xport.println(" HTTP/1.1");
79
+ // xport.print("Host: "); xport.println(HOSTNAME);
80
+ // xport.println("");
81
+
82
+
83
+
84
+ while (1) {
85
+ // read one line from the xport at a time
86
+ ret = xport.readline_timeout(linebuffer, 255, 4000); // 3s timeout
87
+ // if we're using flow control, we can actually dump the line at the same time!
88
+ // Serial.print(linebuffer);
89
+
90
+ // look for an entry (the first one)
91
+ found = strstr(linebuffer, "entry-title entry-content");
92
+ if (((int)found) != 0) {
93
+ start = strstr(found, ">") + 1;
94
+ end = strstr(found, "</p>");
95
+ if ((start != 0) && (end != 0)) {
96
+ Serial.println("\n******Found first entry!*******");
97
+ end[0] = 0;
98
+ Serial.print(start);
99
+ // save the tweet so we can display it later
100
+ strncpy(tweet, start, TWEETLEN);
101
+ tweet[TWEETLEN-1] = 0;
102
+ }
103
+ }
104
+
105
+ // next we look for a status ID (which should correspond to the previous tweet)e
106
+ // Serial.print(".");
107
+ // Serial.print(linebuffer);
108
+ found = strstr(linebuffer, "<div id=\"status_actions_");
109
+ if (((int)found) != 0) {
110
+ start = found + 25; // strlen("<span id=\"status_actions_")
111
+ end = strstr(found, "\">");
112
+ if ((start != 0) && (end != 0)) {
113
+ Serial.println("\n******Found status ID!*******");
114
+ end[0] = 0;
115
+ Serial.println(start);
116
+ // turn the string into a number
117
+ __currstatus = parsenumber(start);
118
+ Serial.println(__currstatus, DEC);
119
+
120
+ // check if this is a nu tweet
121
+ if (__currstatus > __laststatus) {
122
+ __laststatus = __currstatus;
123
+ Serial.println("New message");
124
+ Serial.print(tweet);
125
+ } else {
126
+ tweet[0] = 0;
127
+ }
128
+ // flush the conn
129
+ xport.flush(5000); // 5 second timeout
130
+
131
+ if (tweet[0] == 0) { return 0; }
132
+ else {return tweet; }
133
+ }
134
+ }
135
+
136
+ if (((__errno == ERROR_TIMEDOUT) && xport.disconnected()) ||
137
+ ((XPORT_DTRPIN == 0) &&
138
+ (linebuffer[0] == 'D') && (linebuffer[1] == 0))) {
139
+ Serial.println("\nDisconnected...");
140
+ return 0;
141
+ }
142
+ }
143
+ }
144
+
145
+ end