phidgets 0.1.3 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (146) hide show
  1. checksums.yaml +4 -4
  2. data/History.txt +3 -0
  3. data/README.rdoc +32 -43
  4. data/Rakefile +4 -2
  5. data/bin/phidget +18 -72
  6. data/ext/phidgets/extconf.rb +5 -8
  7. data/ext/phidgets/phidgets.c +708 -173
  8. data/ext/phidgets/phidgets.h +54 -35
  9. data/ext/phidgets/phidgets_accelerometer.c +193 -109
  10. data/ext/phidgets/phidgets_bldc_motor.c +529 -0
  11. data/ext/phidgets/phidgets_capacitive_touch.c +302 -0
  12. data/ext/phidgets/phidgets_common.c +570 -315
  13. data/ext/phidgets/phidgets_current_input.c +229 -0
  14. data/ext/phidgets/phidgets_dc_motor.c +562 -0
  15. data/ext/phidgets/phidgets_dictionary.c +154 -213
  16. data/ext/phidgets/phidgets_digital_input.c +127 -0
  17. data/ext/phidgets/phidgets_digital_output.c +288 -0
  18. data/ext/phidgets/phidgets_distance_sensor.c +295 -0
  19. data/ext/phidgets/phidgets_encoder.c +211 -192
  20. data/ext/phidgets/phidgets_frequency_counter.c +310 -177
  21. data/ext/phidgets/phidgets_gps.c +226 -164
  22. data/ext/phidgets/phidgets_gyroscope.c +195 -0
  23. data/ext/phidgets/phidgets_hub.c +39 -0
  24. data/ext/phidgets/phidgets_humidity_sensor.c +200 -0
  25. data/ext/phidgets/phidgets_ir.c +211 -171
  26. data/ext/phidgets/phidgets_lcd.c +512 -0
  27. data/ext/phidgets/phidgets_light_sensor.c +200 -0
  28. data/ext/phidgets/phidgets_log.c +263 -0
  29. data/ext/phidgets/phidgets_magnetometer.c +279 -0
  30. data/ext/phidgets/phidgets_manager.c +86 -297
  31. data/ext/phidgets/phidgets_motor_position_controller.c +787 -0
  32. data/ext/phidgets/phidgets_phsensor.c +200 -152
  33. data/ext/phidgets/phidgets_power_guard.c +144 -0
  34. data/ext/phidgets/phidgets_pressure_sensor.c +200 -0
  35. data/ext/phidgets/phidgets_rc_servo.c +672 -0
  36. data/ext/phidgets/phidgets_resistance_input.c +227 -0
  37. data/ext/phidgets/phidgets_rfid.c +107 -221
  38. data/ext/phidgets/phidgets_sound_sensor.c +284 -0
  39. data/ext/phidgets/phidgets_spatial.c +124 -318
  40. data/ext/phidgets/phidgets_stepper.c +457 -430
  41. data/ext/phidgets/phidgets_temp_sensor.c +223 -228
  42. data/ext/phidgets/phidgets_voltage_input.c +428 -0
  43. data/ext/phidgets/phidgets_voltage_output.c +167 -0
  44. data/ext/phidgets/phidgets_voltage_ratio_input.c +435 -0
  45. data/lib/phidgets.rb +21 -14
  46. data/lib/phidgets/accelerometer.rb +11 -15
  47. data/lib/phidgets/bldc_motor.rb +45 -0
  48. data/lib/phidgets/capacitive_touch.rb +33 -0
  49. data/lib/phidgets/common.rb +40 -69
  50. data/lib/phidgets/current_input.rb +21 -0
  51. data/lib/phidgets/dc_motor.rb +45 -0
  52. data/lib/phidgets/dictionary.rb +30 -39
  53. data/lib/phidgets/digital_input.rb +21 -0
  54. data/lib/phidgets/digital_output.rb +56 -0
  55. data/lib/phidgets/distance_sensor.rb +33 -0
  56. data/lib/phidgets/encoder.rb +1 -29
  57. data/lib/phidgets/frequency_counter.rb +23 -14
  58. data/lib/phidgets/gps.rb +34 -26
  59. data/lib/phidgets/gyroscope.rb +21 -0
  60. data/lib/phidgets/humidity_sensor.rb +21 -0
  61. data/lib/phidgets/ir.rb +34 -39
  62. data/lib/phidgets/light_sensor.rb +21 -0
  63. data/lib/phidgets/magnetometer.rb +21 -0
  64. data/lib/phidgets/manager.rb +18 -66
  65. data/lib/phidgets/motor_position_controller.rb +45 -0
  66. data/lib/phidgets/ph_sensor.rb +2 -6
  67. data/lib/phidgets/pressure_sensor.rb +21 -0
  68. data/lib/phidgets/rc_servo.rb +58 -0
  69. data/lib/phidgets/resistance_input.rb +21 -0
  70. data/lib/phidgets/rfid.rb +22 -38
  71. data/lib/phidgets/sound_sensor.rb +21 -0
  72. data/lib/phidgets/spatial.rb +11 -15
  73. data/lib/phidgets/stepper.rb +48 -50
  74. data/lib/phidgets/temperature_sensor.rb +11 -15
  75. data/lib/phidgets/version.rb +5 -0
  76. data/lib/phidgets/voltage_input.rb +34 -0
  77. data/lib/phidgets/voltage_output.rb +23 -0
  78. data/lib/phidgets/voltage_ratio_input.rb +34 -0
  79. data/phidgets.gemspec +3 -22
  80. data/test/test_accelerometer.rb +42 -23
  81. data/test/test_bldc_motor.rb +134 -0
  82. data/test/test_capacitive_touch.rb +82 -0
  83. data/test/test_common.rb +125 -108
  84. data/test/test_current_input.rb +62 -0
  85. data/test/test_dc_motor.rb +146 -0
  86. data/test/test_dictionary.rb +22 -54
  87. data/test/test_digital_input.rb +30 -0
  88. data/test/test_digital_output.rb +70 -0
  89. data/test/test_distance_sensor.rb +76 -0
  90. data/test/test_encoder.rb +45 -38
  91. data/test/test_frequency_counter.rb +71 -36
  92. data/test/test_gps.rb +29 -38
  93. data/test/test_gyroscope.rb +54 -0
  94. data/test/test_helper.rb +0 -1
  95. data/test/test_hub.rb +14 -0
  96. data/test/test_humidity_sensor.rb +58 -0
  97. data/test/test_ir.rb +34 -34
  98. data/test/test_lcd.rb +146 -0
  99. data/test/test_light_sensor.rb +58 -0
  100. data/test/test_magnetometer.rb +78 -0
  101. data/test/test_manager.rb +10 -79
  102. data/test/test_motor_control.rb +146 -108
  103. data/test/test_phidgets.rb +2 -14
  104. data/test/test_phsensor.rb +46 -34
  105. data/test/test_power_guard.rb +42 -0
  106. data/test/test_pressure_sensor.rb +58 -0
  107. data/test/test_rc_servo.rb +174 -0
  108. data/test/test_resistance_input.rb +66 -0
  109. data/test/test_rfid.rb +15 -54
  110. data/test/test_sound_sensor.rb +78 -0
  111. data/test/test_spatial.rb +19 -85
  112. data/test/test_stepper.rb +89 -98
  113. data/test/test_temp_sensor.rb +42 -47
  114. data/test/test_voltage_input.rb +102 -0
  115. data/test/test_voltage_output.rb +46 -0
  116. data/test/test_voltage_ratio_input.rb +102 -0
  117. metadata +72 -89
  118. data/ext/phidgets/phidgets_advanced_servo.c +0 -567
  119. data/ext/phidgets/phidgets_analog.c +0 -139
  120. data/ext/phidgets/phidgets_bridge.c +0 -263
  121. data/ext/phidgets/phidgets_interface_kit.c +0 -340
  122. data/ext/phidgets/phidgets_led.c +0 -178
  123. data/ext/phidgets/phidgets_motor_control.c +0 -642
  124. data/ext/phidgets/phidgets_servo.c +0 -276
  125. data/ext/phidgets/phidgets_text_lcd.c +0 -381
  126. data/ext/phidgets/phidgets_text_led.c +0 -107
  127. data/ext/phidgets/phidgets_weight_sensor.c +0 -113
  128. data/lib/phidgets/advanced_servo.rb +0 -49
  129. data/lib/phidgets/analog.rb +0 -8
  130. data/lib/phidgets/bridge.rb +0 -25
  131. data/lib/phidgets/interfacekit.rb +0 -49
  132. data/lib/phidgets/led.rb +0 -8
  133. data/lib/phidgets/motor_control.rb +0 -110
  134. data/lib/phidgets/servo.rb +0 -23
  135. data/lib/phidgets/text_lcd.rb +0 -8
  136. data/lib/phidgets/text_led.rb +0 -8
  137. data/lib/phidgets/weight_sensor.rb +0 -25
  138. data/test/test_advanced_servo.rb +0 -152
  139. data/test/test_analog.rb +0 -45
  140. data/test/test_bridge.rb +0 -77
  141. data/test/test_interfacekit.rb +0 -97
  142. data/test/test_led.rb +0 -55
  143. data/test/test_servo.rb +0 -67
  144. data/test/test_text_lcd.rb +0 -115
  145. data/test/test_text_led.rb +0 -35
  146. data/test/test_weight_sensor.rb +0 -32
@@ -0,0 +1,512 @@
1
+
2
+ #include "phidgets.h"
3
+
4
+
5
+ VALUE ph_lcd_initialize(VALUE self) {
6
+ ph_data_t *ph = get_ph_data(self);
7
+ ph_raise(PhidgetLCD_create((PhidgetLCDHandle *)(&(ph->handle))));
8
+ return self;
9
+ }
10
+
11
+ VALUE ph_lcd_get_backlight(VALUE self) {
12
+ return ph_get_double(get_ph_handle(self), (phidget_get_double_func)PhidgetLCD_getBacklight);
13
+ }
14
+
15
+ VALUE ph_lcd_set_backlight(VALUE self, VALUE backlight) {
16
+ ph_raise(PhidgetLCD_setBacklight((PhidgetLCDHandle)get_ph_handle(self), NUM2DBL(backlight)));
17
+ return Qnil;
18
+ }
19
+
20
+ VALUE ph_lcd_get_min_backlight(VALUE self) {
21
+ return ph_get_double(get_ph_handle(self), (phidget_get_double_func)PhidgetLCD_getMinBacklight);
22
+ }
23
+
24
+ VALUE ph_lcd_get_max_backlight(VALUE self) {
25
+ return ph_get_double(get_ph_handle(self), (phidget_get_double_func)PhidgetLCD_getMaxBacklight);
26
+ }
27
+
28
+ VALUE ph_lcd_set_character_bitmap(VALUE self, VALUE font, VALUE character, VALUE bitmap) {
29
+ int i, bitmap_len = RARRAY_LEN(bitmap);
30
+ uint8_t *bm = malloc(bitmap_len);
31
+ for(i=0; i<bitmap_len; i++) { bm[i] = (uint8_t)NUM2CHR(rb_ary_entry(bitmap, i)); }
32
+ ph_raise(PhidgetLCD_setCharacterBitmap((PhidgetLCDHandle)get_ph_handle(self), NUM2INT(font), StringValueCStr(character), bm));
33
+ free(bm);
34
+ return Qnil;
35
+ }
36
+
37
+ VALUE ph_lcd_get_max_characters(VALUE self, VALUE font) {
38
+ int max_chars;
39
+ ph_raise(PhidgetLCD_getMaxCharacters((PhidgetLCDHandle)get_ph_handle(self), NUM2INT(font), &max_chars));
40
+ return INT2NUM(max_chars);
41
+ }
42
+
43
+ VALUE ph_lcd_clear(VALUE self) {
44
+ ph_raise(PhidgetLCD_clear((PhidgetLCDHandle)get_ph_handle(self)));
45
+ return Qnil;
46
+ }
47
+
48
+ VALUE ph_lcd_get_contrast(VALUE self) {
49
+ return ph_get_double(get_ph_handle(self), (phidget_get_double_func)PhidgetLCD_getContrast);
50
+ }
51
+
52
+ VALUE ph_lcd_set_contrast(VALUE self, VALUE contrast) {
53
+ ph_raise(PhidgetLCD_setContrast((PhidgetLCDHandle)get_ph_handle(self), NUM2DBL(contrast)));
54
+ return Qnil;
55
+ }
56
+
57
+ VALUE ph_lcd_get_min_contrast(VALUE self) {
58
+ return ph_get_double(get_ph_handle(self), (phidget_get_double_func)PhidgetLCD_getMinContrast);
59
+ }
60
+
61
+ VALUE ph_lcd_get_max_contrast(VALUE self) {
62
+ return ph_get_double(get_ph_handle(self), (phidget_get_double_func)PhidgetLCD_getMaxContrast);
63
+ }
64
+
65
+ VALUE ph_lcd_copy(VALUE self, VALUE src_fb, VALUE dest_fb, VALUE src_x1, VALUE src_y1, VALUE src_x2, VALUE src_y2, VALUE dest_x, VALUE dest_y, VALUE invert) {
66
+ ph_raise(PhidgetLCD_copy((PhidgetLCDHandle)get_ph_handle(self), NUM2INT(src_fb), NUM2INT(dest_fb), NUM2INT(src_x1), NUM2INT(src_y1), NUM2INT(src_x2), NUM2INT(src_y2), NUM2INT(dest_x), NUM2INT(dest_y), TYPE(invert) == T_TRUE ? PTRUE : PFALSE));
67
+ return Qnil;
68
+ }
69
+
70
+ VALUE ph_lcd_get_cursor_blink(VALUE self) {
71
+ return ph_get_bool(get_ph_handle(self), (phidget_get_bool_func)PhidgetLCD_getCursorBlink);
72
+ }
73
+
74
+ VALUE ph_lcd_set_cursor_blink(VALUE self, VALUE cursor_blink) {
75
+ ph_raise(PhidgetLCD_setCursorBlink((PhidgetLCDHandle)get_ph_handle(self), TYPE(cursor_blink) == T_TRUE ? PTRUE : PFALSE));
76
+ return Qnil;
77
+ }
78
+
79
+ VALUE ph_lcd_get_cursor_on(VALUE self) {
80
+ return ph_get_bool(get_ph_handle(self), (phidget_get_bool_func)PhidgetLCD_getCursorOn);
81
+ }
82
+
83
+ VALUE ph_lcd_set_cursor_on(VALUE self, VALUE cursor_on) {
84
+ ph_raise(PhidgetLCD_setCursorOn((PhidgetLCDHandle)get_ph_handle(self), TYPE(cursor_on) == T_TRUE ? PTRUE : PFALSE));
85
+ return Qnil;
86
+ }
87
+
88
+ VALUE ph_lcd_draw_line(VALUE self, VALUE x1, VALUE y1, VALUE x2, VALUE y2) {
89
+ ph_raise(PhidgetLCD_drawLine((PhidgetLCDHandle)get_ph_handle(self), NUM2INT(x1), NUM2INT(y1), NUM2INT(x2), NUM2INT(y2)));
90
+ return Qnil;
91
+ }
92
+
93
+ VALUE ph_lcd_draw_pixel(VALUE self, VALUE x, VALUE y, VALUE pixel_state) {
94
+ ph_raise(PhidgetLCD_drawPixel((PhidgetLCDHandle)get_ph_handle(self), NUM2INT(x), NUM2INT(y), NUM2INT(pixel_state)));
95
+ return Qnil;
96
+ }
97
+
98
+ VALUE ph_lcd_draw_rect(VALUE self, VALUE x1, VALUE y1, VALUE x2, VALUE y2, VALUE filled, VALUE invert) {
99
+ ph_raise(PhidgetLCD_drawRect((PhidgetLCDHandle)get_ph_handle(self), NUM2INT(x1), NUM2INT(y1), NUM2INT(x2), NUM2INT(y2), TYPE(filled) == T_TRUE ? PTRUE : PFALSE, TYPE(invert) == T_TRUE ? PTRUE : PFALSE));
100
+ return Qnil;
101
+ }
102
+
103
+ VALUE ph_lcd_flush(VALUE self) {
104
+ ph_raise(PhidgetLCD_flush((PhidgetLCDHandle)get_ph_handle(self)));
105
+ return Qnil;
106
+ }
107
+
108
+
109
+ VALUE ph_lcd_get_font_size(VALUE self, VALUE font) {
110
+ PhidgetLCDHandle handle = (PhidgetLCDHandle)get_ph_handle(self);
111
+ int width, height;
112
+ VALUE rb_font_size = rb_hash_new();
113
+
114
+ ph_raise(PhidgetLCD_getFontSize(handle, NUM2INT(font), &width, &height));
115
+ rb_hash_aset(rb_font_size, rb_str_new2("width"), INT2NUM(width));
116
+ rb_hash_aset(rb_font_size, rb_str_new2("height"), INT2NUM(height));
117
+ return rb_font_size;
118
+ }
119
+
120
+ VALUE ph_lcd_set_font_size(VALUE self, VALUE font, VALUE width, VALUE height) {
121
+ ph_raise(PhidgetLCD_setFontSize((PhidgetLCDHandle)get_ph_handle(self), NUM2INT(font), NUM2INT(width), NUM2INT(height)));
122
+ return Qnil;
123
+ }
124
+
125
+ VALUE ph_lcd_get_frame_buffer(VALUE self) {
126
+ return ph_get_int(get_ph_handle(self), (phidget_get_int_func)PhidgetLCD_getFrameBuffer);
127
+ }
128
+
129
+ VALUE ph_lcd_set_frame_buffer(VALUE self, VALUE frame_buffer) {
130
+ ph_raise(PhidgetLCD_setFrameBuffer((PhidgetLCDHandle)get_ph_handle(self), NUM2INT(frame_buffer)));
131
+ return Qnil;
132
+ }
133
+
134
+ VALUE ph_lcd_get_height(VALUE self) {
135
+ return ph_get_int(get_ph_handle(self), (phidget_get_int_func)PhidgetLCD_getHeight);
136
+ }
137
+
138
+ VALUE ph_lcd_init(VALUE self) {
139
+ ph_raise(PhidgetLCD_initialize((PhidgetLCDHandle)get_ph_handle(self)));
140
+ return Qnil;
141
+ }
142
+
143
+ VALUE ph_lcd_save_frame_buffer(VALUE self, VALUE frame_buffer) {
144
+ ph_raise(PhidgetLCD_saveFrameBuffer((PhidgetLCDHandle)get_ph_handle(self), NUM2INT(frame_buffer)));
145
+ return Qnil;
146
+ }
147
+
148
+ VALUE ph_lcd_get_screen_size(VALUE self) {
149
+ return ph_get_int(get_ph_handle(self), (phidget_get_int_func)PhidgetLCD_getScreenSize);
150
+ }
151
+
152
+ VALUE ph_lcd_set_screen_size(VALUE self, VALUE screen_size) {
153
+ ph_raise(PhidgetLCD_setScreenSize((PhidgetLCDHandle)get_ph_handle(self), NUM2INT(screen_size)));
154
+ return Qnil;
155
+ }
156
+
157
+ VALUE ph_lcd_get_sleeping(VALUE self) {
158
+ return ph_get_bool(get_ph_handle(self), (phidget_get_bool_func)PhidgetLCD_getSleeping);
159
+ }
160
+
161
+ VALUE ph_lcd_set_sleeping(VALUE self, VALUE sleeping) {
162
+ ph_raise(PhidgetLCD_setSleeping((PhidgetLCDHandle)get_ph_handle(self), TYPE(sleeping) == T_TRUE ? PTRUE : PFALSE));
163
+ return Qnil;
164
+ }
165
+
166
+ VALUE ph_lcd_get_width(VALUE self) {
167
+ return ph_get_int(get_ph_handle(self), (phidget_get_int_func)PhidgetLCD_getWidth);
168
+ }
169
+
170
+ VALUE ph_lcd_write_bitmap(VALUE self, VALUE x_pos, VALUE y_pos, VALUE x_size, VALUE y_size, VALUE bitmap) {
171
+ int i, bitmap_len = RARRAY_LEN(bitmap);
172
+ uint8_t *bm = malloc(bitmap_len);
173
+ for(i=0; i<bitmap_len; i++) { bm[i] = (uint8_t)NUM2CHR(rb_ary_entry(bitmap, i)); }
174
+ ph_raise(PhidgetLCD_writeBitmap((PhidgetLCDHandle)get_ph_handle(self), NUM2INT(x_pos), NUM2INT(y_pos), NUM2INT(x_size), NUM2INT(y_size), bm));
175
+ free(bm);
176
+ return Qnil;
177
+ }
178
+
179
+ VALUE ph_lcd_write_text(VALUE self, VALUE font, VALUE x_pos, VALUE y_pos, VALUE text) {
180
+ ph_raise(PhidgetLCD_writeText((PhidgetLCDHandle)get_ph_handle(self), NUM2INT(font), NUM2INT(x_pos), NUM2INT(y_pos), StringValueCStr(text)));
181
+ return Qnil;
182
+ }
183
+
184
+
185
+ void Init_lcd() {
186
+ VALUE ph_module = rb_const_get(rb_cObject, rb_intern("Phidgets"));
187
+ VALUE ph_common = rb_const_get(ph_module, rb_intern("Common"));
188
+ VALUE ph_lcd = rb_define_class_under(ph_module, "LCD", ph_common);
189
+
190
+
191
+ rb_define_const(ph_lcd, "FONT_User1", INT2NUM(FONT_User1));
192
+ rb_define_const(ph_lcd, "FONT_User2", INT2NUM(FONT_User2));
193
+ rb_define_const(ph_lcd, "FONT_6x10", INT2NUM(FONT_6x10));
194
+ rb_define_const(ph_lcd, "FONT_5x8", INT2NUM(FONT_5x8));
195
+ rb_define_const(ph_lcd, "FONT_6x12", INT2NUM(FONT_6x12));
196
+
197
+ rb_define_const(ph_lcd, "SCREEN_SIZE_NONE", INT2NUM(SCREEN_SIZE_NONE));
198
+ rb_define_const(ph_lcd, "SCREEN_SIZE_1x8", INT2NUM(SCREEN_SIZE_1x8));
199
+ rb_define_const(ph_lcd, "SCREEN_SIZE_2x8", INT2NUM(SCREEN_SIZE_2x8));
200
+ rb_define_const(ph_lcd, "SCREEN_SIZE_1x16", INT2NUM(SCREEN_SIZE_1x16));
201
+ rb_define_const(ph_lcd, "SCREEN_SIZE_2x16", INT2NUM(SCREEN_SIZE_2x16));
202
+ rb_define_const(ph_lcd, "SCREEN_SIZE_4x16", INT2NUM(SCREEN_SIZE_4x16));
203
+ rb_define_const(ph_lcd, "SCREEN_SIZE_2x20", INT2NUM(SCREEN_SIZE_2x20));
204
+ rb_define_const(ph_lcd, "SCREEN_SIZE_4x20", INT2NUM(SCREEN_SIZE_4x20));
205
+ rb_define_const(ph_lcd, "SCREEN_SIZE_2x24", INT2NUM(SCREEN_SIZE_2x24));
206
+ rb_define_const(ph_lcd, "SCREEN_SIZE_1x40", INT2NUM(SCREEN_SIZE_1x40));
207
+ rb_define_const(ph_lcd, "SCREEN_SIZE_2x40", INT2NUM(SCREEN_SIZE_2x40));
208
+ rb_define_const(ph_lcd, "SCREEN_SIZE_4x40", INT2NUM(SCREEN_SIZE_4x40));
209
+ rb_define_const(ph_lcd, "SCREEN_SIZE_64x128", INT2NUM(SCREEN_SIZE_64x128));
210
+
211
+ rb_define_const(ph_lcd, "PIXEL_STATE_OFF", INT2NUM(PIXEL_STATE_OFF));
212
+ rb_define_const(ph_lcd, "PIXEL_STATE_ON", INT2NUM(PIXEL_STATE_ON));
213
+ rb_define_const(ph_lcd, "PIXEL_STATE_INVERT", INT2NUM(PIXEL_STATE_INVERT));
214
+
215
+
216
+ /* Document-method: new
217
+ * call-seq: new
218
+ *
219
+ * Creates a Phidget LCD object.
220
+ */
221
+ rb_define_method(ph_lcd, "initialize", ph_lcd_initialize, 0);
222
+
223
+ /* Document-method: getBacklight
224
+ * call-seq: getBacklight -> backlight
225
+ *
226
+ * The Backlight affects the brightness of the LCD screen.
227
+ * Backlight is bounded by MinBackLight and MaxBacklight.
228
+ */
229
+ rb_define_method(ph_lcd, "getBacklight", ph_lcd_get_backlight, 0);
230
+ rb_define_alias(ph_lcd, "backlight", "getBacklight");
231
+
232
+ /* Document-method: setBacklight
233
+ * call-seq: setBacklight(backlight)
234
+ *
235
+ * The Backlight affects the brightness of the LCD screen.
236
+ * Backlight is bounded by MinBackLight and MaxBacklight.
237
+ */
238
+ rb_define_method(ph_lcd, "setBacklight", ph_lcd_set_backlight, 1);
239
+ rb_define_alias(ph_lcd, "backlight=", "setBacklight");
240
+
241
+ /* Document-method: getMinBacklight
242
+ * call-seq: getMinBacklight -> backlight
243
+ *
244
+ * The minimum value that Backlight can be set to.
245
+ */
246
+ rb_define_method(ph_lcd, "getMinBacklight", ph_lcd_get_min_backlight, 0);
247
+ rb_define_alias(ph_lcd, "min_backlight", "getMinBacklight");
248
+
249
+ /* Document-method: getMaxBacklight
250
+ * call-seq: getMaxBacklight -> backlight
251
+ *
252
+ * The maximum value that Backlight can be set to.
253
+ */
254
+ rb_define_method(ph_lcd, "getMaxBacklight", ph_lcd_get_max_backlight, 0);
255
+ rb_define_alias(ph_lcd, "max_backlight", "getMaxBacklight");
256
+
257
+ /* Document-method: setCharacterBitmap
258
+ * call-seq: setCharacterBitmap(font, character, bitmap)
259
+ *
260
+ * Create a bitmap and select a character to represent it. Now, when you use the specific character, the bitmap will show in it's place.
261
+ */
262
+ rb_define_method(ph_lcd, "setCharacterBitmap", ph_lcd_set_character_bitmap, 3);
263
+ rb_define_alias(ph_lcd, "set_character_bitmap", "setCharacterBitmap");
264
+
265
+ /* Document-method: getMaxCharacters
266
+ * call-seq: getMaxCharacters -> max_characters
267
+ *
268
+ * The maximum number of characters that can fit on the frame buffer for the specified font.
269
+ */
270
+ rb_define_method(ph_lcd, "getMaxCharacters", ph_lcd_get_max_characters, 1);
271
+ rb_define_alias(ph_lcd, "max_characters", "getMaxCharacters");
272
+
273
+ /* Document-method: clear
274
+ * call-seq: clear
275
+ *
276
+ * Clears all pixels in the current frame buffer.
277
+ * Changes made to the frame buffer must be flushed to the LCD screen using flush.
278
+ */
279
+ rb_define_method(ph_lcd, "clear", ph_lcd_clear, 0);
280
+
281
+ /* Document-method: getContrast
282
+ * call-seq: getContrast -> contrast
283
+ *
284
+ * Contrast level of the text or graphic pixels.
285
+ * A higher contrast will make the image darker.
286
+ * Contrast is bounded by MinContrast and MaxContrast.
287
+ */
288
+ rb_define_method(ph_lcd, "getContrast", ph_lcd_get_contrast, 0);
289
+ rb_define_alias(ph_lcd, "contrast", "getContrast");
290
+
291
+ /* Document-method: setContrast
292
+ * call-seq: setContrast(contrast)
293
+ *
294
+ * Contrast level of the text or graphic pixels.
295
+ * A higher contrast will make the image darker.
296
+ * Contrast is bounded by MinContrast and MaxContrast.
297
+ */
298
+ rb_define_method(ph_lcd, "setContrast", ph_lcd_set_contrast, 1);
299
+ rb_define_alias(ph_lcd, "contrast=", "setContrast");
300
+
301
+ /* Document-method: getMinContrast
302
+ * call-seq: getMinContrast -> contrast
303
+ *
304
+ * The minimum value that Contrast can be set to.
305
+ */
306
+ rb_define_method(ph_lcd, "getMinContrast", ph_lcd_get_min_contrast, 0);
307
+ rb_define_alias(ph_lcd, "min_contrast", "getMinContrast");
308
+
309
+ /* Document-method: getMaxContrast
310
+ * call-seq: getMaxContrast -> contrast
311
+ *
312
+ * The maximum value that Contrast can be set to.
313
+ */
314
+ rb_define_method(ph_lcd, "getMaxContrast", ph_lcd_get_max_contrast, 0);
315
+ rb_define_alias(ph_lcd, "max_contrast", "getMaxContrast");
316
+
317
+ /* Document-method: copy
318
+ * call-seq: copy(src_framebuffer, dest_framebuffer, src_x1, src_y1, src_x2, src_y2, dest_x, dest_y, inverted)
319
+ *
320
+ * Copies all pixels from a specified rectangular region to another.
321
+ */
322
+ rb_define_method(ph_lcd, "copy", ph_lcd_copy, 9);
323
+
324
+ /* Document-method: getCursorBlink
325
+ * call-seq: getCursorBlink -> cursor_blink
326
+ *
327
+ * When CursorBlink is true, the device will cause the cursor to periodically blink.
328
+ */
329
+ rb_define_method(ph_lcd, "getCursorBlink", ph_lcd_get_cursor_blink, 0);
330
+ rb_define_alias(ph_lcd, "cursor_blink?", "getCursorBlink");
331
+
332
+ /* Document-method: setCursorBlink
333
+ * call-seq: setCursorBlink(cursor_blink)
334
+ *
335
+ * When CursorBlink is true, the device will cause the cursor to periodically blink.
336
+ */
337
+ rb_define_method(ph_lcd, "setCursorBlink", ph_lcd_set_cursor_blink, 1);
338
+ rb_define_alias(ph_lcd, "cursor_blink=", "setCursorBlink");
339
+
340
+ /* Document-method: getCursorOn
341
+ * call-seq: getCursorOn -> cursor_on
342
+ *
343
+ * When CursorOn is true, the device will underline to the cursor position.
344
+ */
345
+ rb_define_method(ph_lcd, "getCursorOn", ph_lcd_get_cursor_on, 0);
346
+ rb_define_alias(ph_lcd, "cursor_on?", "getCursorOn");
347
+
348
+ /* Document-method: setCursorOn
349
+ * call-seq: setCursorOn(cursor_on)
350
+ *
351
+ * When CursorOn is true, the device will underline to the cursor position.
352
+ */
353
+ rb_define_method(ph_lcd, "setCursorOn", ph_lcd_set_cursor_on, 1);
354
+ rb_define_alias(ph_lcd, "cursor_on=", "setCursorOn");
355
+
356
+ /* Document-method: drawLine
357
+ * call-seq: drawLine(x1, y1, x2, y2)
358
+ *
359
+ * Draws a straight line in the current frame buffer between two specified points.
360
+ * Changes made to the frame buffer must be flushed to the LCD screen using flush.
361
+ */
362
+ rb_define_method(ph_lcd, "drawLine", ph_lcd_draw_line, 4);
363
+ rb_define_alias(ph_lcd, "draw_line", "drawLine");
364
+
365
+ /* Document-method: drawPixel
366
+ * call-seq: drawPixel(x, y, pixel_state)
367
+ *
368
+ * Draws, erases, or inverts a single specified pixel.
369
+ * Changes made to the frame buffer must be flushed to the LCD screen using flush.
370
+ */
371
+ rb_define_method(ph_lcd, "drawPixel", ph_lcd_draw_pixel, 3);
372
+ rb_define_alias(ph_lcd, "draw_pixel", "drawPixel");
373
+
374
+ /* Document-method: drawRect
375
+ * call-seq: drawRect(x1, y1, x2, y2, filled, inverted)
376
+ *
377
+ * Draws a rectangle in the current frame buffer using the specified points.
378
+ * Changes made to the frame buffer must be flushed to the LCD screen using flush.
379
+ */
380
+ rb_define_method(ph_lcd, "drawRect", ph_lcd_draw_rect, 6);
381
+ rb_define_alias(ph_lcd, "draw_rect", "drawRect");
382
+
383
+ /* Document-method: flush
384
+ * call-seq: flush
385
+ *
386
+ * Flushes the buffered LCD contents to the LCD screen.
387
+ */
388
+ rb_define_method(ph_lcd, "flush", ph_lcd_flush, 0);
389
+
390
+ /* Document-method: getFontSize
391
+ * call-seq: getFontSize(font) -> font_size
392
+ *
393
+ * Gets the size of the specified font.
394
+ */
395
+ rb_define_method(ph_lcd, "getFontSize", ph_lcd_get_font_size, 1);
396
+ rb_define_alias(ph_lcd, "font_size", "getFontSize");
397
+
398
+ /* Document-method: setFontSize
399
+ * call-seq: setFontSize(font, width, height)
400
+ *
401
+ * Sets the size of the specified font.
402
+ */
403
+ rb_define_method(ph_lcd, "setFontSize", ph_lcd_set_font_size, 3);
404
+ rb_define_alias(ph_lcd, "set_font_size", "setFontSize");
405
+
406
+ /* Document-method: getFrameBuffer
407
+ * call-seq: getFrameBuffer -> frame_buffer
408
+ *
409
+ * The frame buffer that is currently being used.
410
+ * Commands sent to the device are performed on this buffer.
411
+ */
412
+ rb_define_method(ph_lcd, "getFrameBuffer", ph_lcd_get_frame_buffer, 0);
413
+ rb_define_alias(ph_lcd, "frame_buffer", "getFrameBuffer");
414
+
415
+ /* Document-method: setFrameBuffer
416
+ * call-seq: setFrameBuffer(frame_buffer)
417
+ *
418
+ * The frame buffer that is currently being used.
419
+ * Commands sent to the device are performed on this buffer.
420
+ */
421
+ rb_define_method(ph_lcd, "setFrameBuffer", ph_lcd_set_frame_buffer, 1);
422
+ rb_define_alias(ph_lcd, "frame_buffer=", "setFrameBuffer");
423
+
424
+ /* Document-method: getHeight
425
+ * call-seq: getHeight -> height
426
+ *
427
+ * The height of the LCD screen attached to the channel.
428
+ */
429
+ rb_define_method(ph_lcd, "getHeight", ph_lcd_get_height, 0);
430
+ rb_define_alias(ph_lcd, "height", "getHeight");
431
+
432
+ /* Document-method: init
433
+ * call-seq: init
434
+ *
435
+ * Initializes the Text LCD display.
436
+ */
437
+ rb_define_method(ph_lcd, "init", ph_lcd_init, 0);
438
+
439
+ /* Document-method: saveFrameBuffer
440
+ * call-seq: saveFrameBuffer(frame_buffer)
441
+ *
442
+ * Writes the specified frame buffer to flash memory
443
+ * Use sparingly. The flash memory is only designed to be written to 10,000 times before it may
444
+ * become unusable. This method can only be called one time each time the channel is opened.
445
+ */
446
+ rb_define_method(ph_lcd, "saveFrameBuffer", ph_lcd_save_frame_buffer, 1);
447
+ rb_define_alias(ph_lcd, "save_frame_buffer", "saveFrameBuffer");
448
+
449
+ /* Document-method: getScreenSize
450
+ * call-seq: getScreenSize -> screen_size
451
+ *
452
+ * The size of the LCD screen attached to the channel.
453
+ */
454
+ rb_define_method(ph_lcd, "getScreenSize", ph_lcd_get_screen_size, 0);
455
+ rb_define_alias(ph_lcd, "screen_size", "getScreenSize");
456
+
457
+ /* Document-method: setScreenSize
458
+ * call-seq: setScreenSize(screen_size)
459
+ *
460
+ * The size of the LCD screen attached to the channel.
461
+ */
462
+ rb_define_method(ph_lcd, "setScreenSize", ph_lcd_set_screen_size, 1);
463
+ rb_define_alias(ph_lcd, "screen_size=", "setScreenSize");
464
+
465
+ /* Document-method: getSleeping
466
+ * call-seq: getSleeping -> sleeping
467
+ *
468
+ * The on/off state of Sleeping. Putting the device to sleep turns off the display and backlight in order to save power.
469
+ * The device will still take commands while asleep, and will wake up if the screen is flushed, or if the contrast or backlight are changed.
470
+ * When the device wakes up, it will return to its last known state, taking into account any changes that happened while asleep.
471
+ */
472
+ rb_define_method(ph_lcd, "getSleeping", ph_lcd_get_sleeping, 0);
473
+ rb_define_alias(ph_lcd, "sleeping?", "getSleeping");
474
+
475
+ /* Document-method: setSleeping
476
+ * call-seq: setSleeping(sleeping)
477
+ *
478
+ * The on/off state of Sleeping. Putting the device to sleep turns off the display and backlight in order to save power.
479
+ * The device will still take commands while asleep, and will wake up if the screen is flushed, or if the contrast or backlight are changed.
480
+ * When the device wakes up, it will return to its last known state, taking into account any changes that happened while asleep.
481
+ */
482
+ rb_define_method(ph_lcd, "setSleeping", ph_lcd_set_sleeping, 1);
483
+ rb_define_alias(ph_lcd, "sleeping=", "setSleeping");
484
+
485
+ /* Document-method: getWidth
486
+ * call-seq: getWidth -> width
487
+ *
488
+ * The width of the LCD screen attached to the channel.
489
+ */
490
+ rb_define_method(ph_lcd, "getWidth", ph_lcd_get_width, 0);
491
+ rb_define_alias(ph_lcd, "width", "getWidth");
492
+
493
+ /* Document-method: writeBitmap
494
+ * call-seq: writeBitmap(x_pos, y_pos, x_size, y_size, bitmap)
495
+ *
496
+ * Draws a bitmap to the current frame buffer at the given location.
497
+ * Each byte in the array represents one pixel in row-major order.
498
+ * Changes made to the frame buffer must be flushed to the LCD screen using flush.
499
+ */
500
+ rb_define_method(ph_lcd, "writeBitmap", ph_lcd_write_bitmap, 5);
501
+ rb_define_alias(ph_lcd, "write_bitmap", "writeBitmap");
502
+
503
+ /* Document-method: writeText
504
+ * call-seq: writeText(font, x_pos, y_pos, text)
505
+ *
506
+ * Writes text to the current frame buffer at the specified location
507
+ * Changes made to the frame buffer must be flushed to the LCD screen using flush.
508
+ */
509
+ rb_define_method(ph_lcd, "writeText", ph_lcd_write_text, 4);
510
+ rb_define_alias(ph_lcd, "write_text", "writeText");
511
+ }
512
+