tinkerforge 2.1.21 → 2.1.22
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.
- checksums.yaml +5 -5
- data/lib/tinkerforge/brick_dc.rb +2 -2
- data/lib/tinkerforge/brick_hat.rb +256 -0
- data/lib/tinkerforge/brick_hat_zero.rb +196 -0
- data/lib/tinkerforge/brick_imu.rb +2 -2
- data/lib/tinkerforge/brick_imu_v2.rb +2 -2
- data/lib/tinkerforge/brick_master.rb +12 -9
- data/lib/tinkerforge/brick_red.rb +2 -2
- data/lib/tinkerforge/brick_servo.rb +2 -2
- data/lib/tinkerforge/brick_silent_stepper.rb +2 -2
- data/lib/tinkerforge/brick_stepper.rb +2 -2
- data/lib/tinkerforge/bricklet_accelerometer.rb +2 -2
- data/lib/tinkerforge/bricklet_accelerometer_v2.rb +16 -6
- data/lib/tinkerforge/bricklet_air_quality.rb +59 -3
- data/lib/tinkerforge/bricklet_ambient_light.rb +2 -2
- data/lib/tinkerforge/bricklet_ambient_light_v2.rb +2 -2
- data/lib/tinkerforge/bricklet_ambient_light_v3.rb +3 -3
- data/lib/tinkerforge/bricklet_analog_in.rb +2 -2
- data/lib/tinkerforge/bricklet_analog_in_v2.rb +2 -2
- data/lib/tinkerforge/bricklet_analog_in_v3.rb +2 -2
- data/lib/tinkerforge/bricklet_analog_out.rb +2 -2
- data/lib/tinkerforge/bricklet_analog_out_v2.rb +2 -2
- data/lib/tinkerforge/bricklet_analog_out_v3.rb +2 -2
- data/lib/tinkerforge/bricklet_barometer.rb +2 -2
- data/lib/tinkerforge/bricklet_barometer_v2.rb +2 -2
- data/lib/tinkerforge/bricklet_can.rb +2 -2
- data/lib/tinkerforge/bricklet_can_v2.rb +2 -2
- data/lib/tinkerforge/bricklet_co2.rb +2 -2
- data/lib/tinkerforge/bricklet_co2_v2.rb +479 -0
- data/lib/tinkerforge/bricklet_color.rb +2 -2
- data/lib/tinkerforge/bricklet_current12.rb +2 -2
- data/lib/tinkerforge/bricklet_current25.rb +2 -2
- data/lib/tinkerforge/bricklet_distance_ir.rb +2 -2
- data/lib/tinkerforge/bricklet_distance_ir_v2.rb +3 -3
- data/lib/tinkerforge/bricklet_distance_us.rb +2 -2
- data/lib/tinkerforge/bricklet_dmx.rb +2 -2
- data/lib/tinkerforge/bricklet_dual_button.rb +2 -2
- data/lib/tinkerforge/bricklet_dual_button_v2.rb +2 -2
- data/lib/tinkerforge/bricklet_dual_relay.rb +5 -3
- data/lib/tinkerforge/bricklet_dust_detector.rb +2 -2
- data/lib/tinkerforge/bricklet_e_paper_296x128.rb +600 -0
- data/lib/tinkerforge/bricklet_gps.rb +2 -2
- data/lib/tinkerforge/bricklet_gps_v2.rb +2 -2
- data/lib/tinkerforge/bricklet_hall_effect.rb +2 -2
- data/lib/tinkerforge/bricklet_hall_effect_v2.rb +333 -0
- data/lib/tinkerforge/bricklet_humidity.rb +2 -2
- data/lib/tinkerforge/bricklet_humidity_v2.rb +2 -2
- data/lib/tinkerforge/bricklet_industrial_analog_out.rb +2 -2
- data/lib/tinkerforge/bricklet_industrial_analog_out_v2.rb +2 -2
- data/lib/tinkerforge/bricklet_industrial_counter.rb +2 -2
- data/lib/tinkerforge/bricklet_industrial_digital_in_4.rb +3 -3
- data/lib/tinkerforge/bricklet_industrial_digital_in_4_v2.rb +2 -2
- data/lib/tinkerforge/bricklet_industrial_digital_out_4.rb +9 -4
- data/lib/tinkerforge/bricklet_industrial_digital_out_4_v2.rb +12 -2
- data/lib/tinkerforge/bricklet_industrial_dual_0_20ma.rb +2 -2
- data/lib/tinkerforge/bricklet_industrial_dual_0_20ma_v2.rb +2 -2
- data/lib/tinkerforge/bricklet_industrial_dual_analog_in.rb +2 -2
- data/lib/tinkerforge/bricklet_industrial_dual_analog_in_v2.rb +2 -2
- data/lib/tinkerforge/bricklet_industrial_dual_relay.rb +6 -3
- data/lib/tinkerforge/bricklet_industrial_quad_relay.rb +9 -4
- data/lib/tinkerforge/bricklet_industrial_quad_relay_v2.rb +7 -2
- data/lib/tinkerforge/bricklet_io16.rb +11 -2
- data/lib/tinkerforge/bricklet_io16_v2.rb +10 -2
- data/lib/tinkerforge/bricklet_io4.rb +10 -2
- data/lib/tinkerforge/bricklet_io4_v2.rb +15 -2
- data/lib/tinkerforge/bricklet_isolator.rb +2 -2
- data/lib/tinkerforge/bricklet_joystick.rb +9 -9
- data/lib/tinkerforge/bricklet_joystick_v2.rb +294 -0
- data/lib/tinkerforge/bricklet_laser_range_finder.rb +3 -3
- data/lib/tinkerforge/bricklet_laser_range_finder_v2.rb +447 -0
- data/lib/tinkerforge/bricklet_lcd_128x64.rb +2 -2
- data/lib/tinkerforge/bricklet_lcd_16x2.rb +2 -2
- data/lib/tinkerforge/bricklet_lcd_20x4.rb +2 -2
- data/lib/tinkerforge/bricklet_led_strip.rb +2 -2
- data/lib/tinkerforge/bricklet_led_strip_v2.rb +2 -2
- data/lib/tinkerforge/bricklet_line.rb +2 -2
- data/lib/tinkerforge/bricklet_linear_poti.rb +2 -2
- data/lib/tinkerforge/bricklet_linear_poti_v2.rb +259 -0
- data/lib/tinkerforge/bricklet_load_cell.rb +2 -2
- data/lib/tinkerforge/bricklet_load_cell_v2.rb +2 -2
- data/lib/tinkerforge/bricklet_moisture.rb +2 -2
- data/lib/tinkerforge/bricklet_motion_detector.rb +3 -3
- data/lib/tinkerforge/bricklet_motion_detector_v2.rb +5 -7
- data/lib/tinkerforge/bricklet_motorized_linear_poti.rb +2 -2
- data/lib/tinkerforge/bricklet_multi_touch.rb +2 -2
- data/lib/tinkerforge/bricklet_nfc.rb +2 -2
- data/lib/tinkerforge/bricklet_nfc_rfid.rb +2 -2
- data/lib/tinkerforge/bricklet_oled_128x64.rb +2 -2
- data/lib/tinkerforge/bricklet_oled_128x64_v2.rb +2 -2
- data/lib/tinkerforge/bricklet_oled_64x48.rb +2 -2
- data/lib/tinkerforge/bricklet_one_wire.rb +2 -2
- data/lib/tinkerforge/bricklet_outdoor_weather.rb +14 -2
- data/lib/tinkerforge/bricklet_particulate_matter.rb +2 -2
- data/lib/tinkerforge/bricklet_piezo_buzzer.rb +2 -2
- data/lib/tinkerforge/bricklet_piezo_speaker.rb +2 -2
- data/lib/tinkerforge/bricklet_piezo_speaker_v2.rb +311 -0
- data/lib/tinkerforge/bricklet_ptc.rb +2 -2
- data/lib/tinkerforge/bricklet_ptc_v2.rb +2 -2
- data/lib/tinkerforge/bricklet_real_time_clock.rb +2 -2
- data/lib/tinkerforge/bricklet_real_time_clock_v2.rb +2 -2
- data/lib/tinkerforge/bricklet_remote_switch.rb +2 -2
- data/lib/tinkerforge/bricklet_remote_switch_v2.rb +3 -3
- data/lib/tinkerforge/bricklet_rgb_led.rb +4 -4
- data/lib/tinkerforge/bricklet_rgb_led_button.rb +2 -2
- data/lib/tinkerforge/bricklet_rgb_led_matrix.rb +2 -2
- data/lib/tinkerforge/bricklet_rgb_led_v2.rb +203 -0
- data/lib/tinkerforge/bricklet_rotary_encoder.rb +2 -2
- data/lib/tinkerforge/bricklet_rotary_encoder_v2.rb +2 -2
- data/lib/tinkerforge/bricklet_rotary_poti.rb +2 -2
- data/lib/tinkerforge/bricklet_rs232.rb +2 -2
- data/lib/tinkerforge/bricklet_rs232_v2.rb +2 -2
- data/lib/tinkerforge/bricklet_rs485.rb +2 -2
- data/lib/tinkerforge/bricklet_segment_display_4x7.rb +2 -2
- data/lib/tinkerforge/bricklet_segment_display_4x7_v2.rb +309 -0
- data/lib/tinkerforge/bricklet_solid_state_relay.rb +3 -3
- data/lib/tinkerforge/bricklet_solid_state_relay_v2.rb +3 -3
- data/lib/tinkerforge/bricklet_sound_intensity.rb +2 -2
- data/lib/tinkerforge/bricklet_sound_pressure_level.rb +2 -2
- data/lib/tinkerforge/bricklet_temperature.rb +2 -2
- data/lib/tinkerforge/bricklet_temperature_ir.rb +2 -2
- data/lib/tinkerforge/bricklet_temperature_ir_v2.rb +5 -2
- data/lib/tinkerforge/bricklet_temperature_v2.rb +2 -2
- data/lib/tinkerforge/bricklet_thermal_imaging.rb +4 -4
- data/lib/tinkerforge/bricklet_thermocouple.rb +2 -2
- data/lib/tinkerforge/bricklet_thermocouple_v2.rb +2 -2
- data/lib/tinkerforge/bricklet_tilt.rb +2 -2
- data/lib/tinkerforge/bricklet_uv_light.rb +2 -2
- data/lib/tinkerforge/bricklet_uv_light_v2.rb +2 -2
- data/lib/tinkerforge/bricklet_voltage.rb +2 -2
- data/lib/tinkerforge/bricklet_voltage_current.rb +2 -2
- data/lib/tinkerforge/bricklet_voltage_current_v2.rb +2 -2
- data/lib/tinkerforge/ip_connection.rb +21 -4
- data/lib/tinkerforge/version.rb +1 -1
- metadata +14 -3
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# -*- ruby encoding: utf-8 -*-
|
|
2
2
|
#############################################################
|
|
3
|
-
# This file was automatically generated on 2019-
|
|
3
|
+
# This file was automatically generated on 2019-05-21. #
|
|
4
4
|
# #
|
|
5
|
-
# Ruby Bindings Version 2.1.
|
|
5
|
+
# Ruby Bindings Version 2.1.22 #
|
|
6
6
|
# #
|
|
7
7
|
# If you have a bugfix for this file and want to commit it, #
|
|
8
8
|
# please fix the bug in the generator. You can find a link #
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# -*- ruby encoding: utf-8 -*-
|
|
2
2
|
#############################################################
|
|
3
|
-
# This file was automatically generated on 2019-
|
|
3
|
+
# This file was automatically generated on 2019-05-21. #
|
|
4
4
|
# #
|
|
5
|
-
# Ruby Bindings Version 2.1.
|
|
5
|
+
# Ruby Bindings Version 2.1.22 #
|
|
6
6
|
# #
|
|
7
7
|
# If you have a bugfix for this file and want to commit it, #
|
|
8
8
|
# please fix the bug in the generator. You can find a link #
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# -*- ruby encoding: utf-8 -*-
|
|
2
2
|
#############################################################
|
|
3
|
-
# This file was automatically generated on 2019-
|
|
3
|
+
# This file was automatically generated on 2019-05-21. #
|
|
4
4
|
# #
|
|
5
|
-
# Ruby Bindings Version 2.1.
|
|
5
|
+
# Ruby Bindings Version 2.1.22 #
|
|
6
6
|
# #
|
|
7
7
|
# If you have a bugfix for this file and want to commit it, #
|
|
8
8
|
# please fix the bug in the generator. You can find a link #
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# -*- ruby encoding: utf-8 -*-
|
|
2
2
|
#############################################################
|
|
3
|
-
# This file was automatically generated on 2019-
|
|
3
|
+
# This file was automatically generated on 2019-05-21. #
|
|
4
4
|
# #
|
|
5
|
-
# Ruby Bindings Version 2.1.
|
|
5
|
+
# Ruby Bindings Version 2.1.22 #
|
|
6
6
|
# #
|
|
7
7
|
# If you have a bugfix for this file and want to commit it, #
|
|
8
8
|
# please fix the bug in the generator. You can find a link #
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# -*- ruby encoding: utf-8 -*-
|
|
2
2
|
#############################################################
|
|
3
|
-
# This file was automatically generated on 2019-
|
|
3
|
+
# This file was automatically generated on 2019-05-21. #
|
|
4
4
|
# #
|
|
5
|
-
# Ruby Bindings Version 2.1.
|
|
5
|
+
# Ruby Bindings Version 2.1.22 #
|
|
6
6
|
# #
|
|
7
7
|
# If you have a bugfix for this file and want to commit it, #
|
|
8
8
|
# please fix the bug in the generator. You can find a link #
|
|
@@ -220,7 +220,7 @@ module Tinkerforge
|
|
|
220
220
|
end
|
|
221
221
|
|
|
222
222
|
# Sets the length of a `moving averaging <https://en.wikipedia.org/wiki/Moving_average>`__
|
|
223
|
-
# for the
|
|
223
|
+
# for the distance.
|
|
224
224
|
#
|
|
225
225
|
# Setting the length to 1 will turn the averaging off. With less averaging, there
|
|
226
226
|
# is more noise on the data.
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# -*- ruby encoding: utf-8 -*-
|
|
2
2
|
#############################################################
|
|
3
|
-
# This file was automatically generated on 2019-
|
|
3
|
+
# This file was automatically generated on 2019-05-21. #
|
|
4
4
|
# #
|
|
5
|
-
# Ruby Bindings Version 2.1.
|
|
5
|
+
# Ruby Bindings Version 2.1.22 #
|
|
6
6
|
# #
|
|
7
7
|
# If you have a bugfix for this file and want to commit it, #
|
|
8
8
|
# please fix the bug in the generator. You can find a link #
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# -*- ruby encoding: utf-8 -*-
|
|
2
2
|
#############################################################
|
|
3
|
-
# This file was automatically generated on 2019-
|
|
3
|
+
# This file was automatically generated on 2019-05-21. #
|
|
4
4
|
# #
|
|
5
|
-
# Ruby Bindings Version 2.1.
|
|
5
|
+
# Ruby Bindings Version 2.1.22 #
|
|
6
6
|
# #
|
|
7
7
|
# If you have a bugfix for this file and want to commit it, #
|
|
8
8
|
# please fix the bug in the generator. You can find a link #
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# -*- ruby encoding: utf-8 -*-
|
|
2
2
|
#############################################################
|
|
3
|
-
# This file was automatically generated on 2019-
|
|
3
|
+
# This file was automatically generated on 2019-05-21. #
|
|
4
4
|
# #
|
|
5
|
-
# Ruby Bindings Version 2.1.
|
|
5
|
+
# Ruby Bindings Version 2.1.22 #
|
|
6
6
|
# #
|
|
7
7
|
# If you have a bugfix for this file and want to commit it, #
|
|
8
8
|
# please fix the bug in the generator. You can find a link #
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# -*- ruby encoding: utf-8 -*-
|
|
2
2
|
#############################################################
|
|
3
|
-
# This file was automatically generated on 2019-
|
|
3
|
+
# This file was automatically generated on 2019-05-21. #
|
|
4
4
|
# #
|
|
5
|
-
# Ruby Bindings Version 2.1.
|
|
5
|
+
# Ruby Bindings Version 2.1.22 #
|
|
6
6
|
# #
|
|
7
7
|
# If you have a bugfix for this file and want to commit it, #
|
|
8
8
|
# please fix the bug in the generator. You can find a link #
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# -*- ruby encoding: utf-8 -*-
|
|
2
2
|
#############################################################
|
|
3
|
-
# This file was automatically generated on 2019-
|
|
3
|
+
# This file was automatically generated on 2019-05-21. #
|
|
4
4
|
# #
|
|
5
|
-
# Ruby Bindings Version 2.1.
|
|
5
|
+
# Ruby Bindings Version 2.1.22 #
|
|
6
6
|
# #
|
|
7
7
|
# If you have a bugfix for this file and want to commit it, #
|
|
8
8
|
# please fix the bug in the generator. You can find a link #
|
|
@@ -53,7 +53,7 @@ module Tinkerforge
|
|
|
53
53
|
# of the other relay, you can get the state with BrickletDualRelay#get_state or you
|
|
54
54
|
# can use BrickletDualRelay#set_selected_state.
|
|
55
55
|
#
|
|
56
|
-
#
|
|
56
|
+
# All running monoflop timers will be aborted if this function is called.
|
|
57
57
|
#
|
|
58
58
|
# The default value is (*false*, *false*).
|
|
59
59
|
def set_state(relay1, relay2)
|
|
@@ -93,6 +93,8 @@ module Tinkerforge
|
|
|
93
93
|
|
|
94
94
|
# Sets the state of the selected relay (1 or 2), *true* means on and *false* means off.
|
|
95
95
|
#
|
|
96
|
+
# A running monoflop timer for the selected relay will be aborted if this function is called.
|
|
97
|
+
#
|
|
96
98
|
# The other relay remains untouched.
|
|
97
99
|
def set_selected_state(relay, state)
|
|
98
100
|
send_request FUNCTION_SET_SELECTED_STATE, [relay, state], 'C ?', 0, ''
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# -*- ruby encoding: utf-8 -*-
|
|
2
2
|
#############################################################
|
|
3
|
-
# This file was automatically generated on 2019-
|
|
3
|
+
# This file was automatically generated on 2019-05-21. #
|
|
4
4
|
# #
|
|
5
|
-
# Ruby Bindings Version 2.1.
|
|
5
|
+
# Ruby Bindings Version 2.1.22 #
|
|
6
6
|
# #
|
|
7
7
|
# If you have a bugfix for this file and want to commit it, #
|
|
8
8
|
# please fix the bug in the generator. You can find a link #
|
|
@@ -0,0 +1,600 @@
|
|
|
1
|
+
# -*- ruby encoding: utf-8 -*-
|
|
2
|
+
#############################################################
|
|
3
|
+
# This file was automatically generated on 2019-05-21. #
|
|
4
|
+
# #
|
|
5
|
+
# Ruby Bindings Version 2.1.22 #
|
|
6
|
+
# #
|
|
7
|
+
# If you have a bugfix for this file and want to commit it, #
|
|
8
|
+
# please fix the bug in the generator. You can find a link #
|
|
9
|
+
# to the generators git repository on tinkerforge.com #
|
|
10
|
+
#############################################################
|
|
11
|
+
|
|
12
|
+
module Tinkerforge
|
|
13
|
+
# Three color 296x128 e-paper display
|
|
14
|
+
class BrickletEPaper296x128 < Device
|
|
15
|
+
DEVICE_IDENTIFIER = 2146 # :nodoc:
|
|
16
|
+
DEVICE_DISPLAY_NAME = 'E-Paper 296x128 Bricklet' # :nodoc:
|
|
17
|
+
|
|
18
|
+
# Callback for the current draw status. Will be called every time the
|
|
19
|
+
# draw status changes (see BrickletEPaper296x128#get_draw_status).
|
|
20
|
+
CALLBACK_DRAW_STATUS = 11
|
|
21
|
+
|
|
22
|
+
FUNCTION_DRAW = 1 # :nodoc:
|
|
23
|
+
FUNCTION_GET_DRAW_STATUS = 2 # :nodoc:
|
|
24
|
+
FUNCTION_WRITE_BLACK_WHITE_LOW_LEVEL = 3 # :nodoc:
|
|
25
|
+
FUNCTION_READ_BLACK_WHITE_LOW_LEVEL = 4 # :nodoc:
|
|
26
|
+
FUNCTION_WRITE_COLOR_LOW_LEVEL = 5 # :nodoc:
|
|
27
|
+
FUNCTION_READ_COLOR_LOW_LEVEL = 6 # :nodoc:
|
|
28
|
+
FUNCTION_FILL_DISPLAY = 7 # :nodoc:
|
|
29
|
+
FUNCTION_DRAW_TEXT = 8 # :nodoc:
|
|
30
|
+
FUNCTION_DRAW_LINE = 9 # :nodoc:
|
|
31
|
+
FUNCTION_DRAW_BOX = 10 # :nodoc:
|
|
32
|
+
FUNCTION_SET_UPDATE_MODE = 12 # :nodoc:
|
|
33
|
+
FUNCTION_GET_UPDATE_MODE = 13 # :nodoc:
|
|
34
|
+
FUNCTION_SET_DISPLAY_TYPE = 14 # :nodoc:
|
|
35
|
+
FUNCTION_GET_DISPLAY_TYPE = 15 # :nodoc:
|
|
36
|
+
FUNCTION_GET_SPITFP_ERROR_COUNT = 234 # :nodoc:
|
|
37
|
+
FUNCTION_SET_BOOTLOADER_MODE = 235 # :nodoc:
|
|
38
|
+
FUNCTION_GET_BOOTLOADER_MODE = 236 # :nodoc:
|
|
39
|
+
FUNCTION_SET_WRITE_FIRMWARE_POINTER = 237 # :nodoc:
|
|
40
|
+
FUNCTION_WRITE_FIRMWARE = 238 # :nodoc:
|
|
41
|
+
FUNCTION_SET_STATUS_LED_CONFIG = 239 # :nodoc:
|
|
42
|
+
FUNCTION_GET_STATUS_LED_CONFIG = 240 # :nodoc:
|
|
43
|
+
FUNCTION_GET_CHIP_TEMPERATURE = 242 # :nodoc:
|
|
44
|
+
FUNCTION_RESET = 243 # :nodoc:
|
|
45
|
+
FUNCTION_WRITE_UID = 248 # :nodoc:
|
|
46
|
+
FUNCTION_READ_UID = 249 # :nodoc:
|
|
47
|
+
FUNCTION_GET_IDENTITY = 255 # :nodoc:
|
|
48
|
+
|
|
49
|
+
DRAW_STATUS_IDLE = 0 # :nodoc:
|
|
50
|
+
DRAW_STATUS_COPYING = 1 # :nodoc:
|
|
51
|
+
DRAW_STATUS_DRAWING = 2 # :nodoc:
|
|
52
|
+
COLOR_BLACK = 0 # :nodoc:
|
|
53
|
+
COLOR_WHITE = 1 # :nodoc:
|
|
54
|
+
COLOR_RED = 2 # :nodoc:
|
|
55
|
+
COLOR_GRAY = 2 # :nodoc:
|
|
56
|
+
FONT_6X8 = 0 # :nodoc:
|
|
57
|
+
FONT_6X16 = 1 # :nodoc:
|
|
58
|
+
FONT_6X24 = 2 # :nodoc:
|
|
59
|
+
FONT_6X32 = 3 # :nodoc:
|
|
60
|
+
FONT_12X16 = 4 # :nodoc:
|
|
61
|
+
FONT_12X24 = 5 # :nodoc:
|
|
62
|
+
FONT_12X32 = 6 # :nodoc:
|
|
63
|
+
FONT_18X24 = 7 # :nodoc:
|
|
64
|
+
FONT_18X32 = 8 # :nodoc:
|
|
65
|
+
FONT_24X32 = 9 # :nodoc:
|
|
66
|
+
ORIENTATION_HORIZONTAL = 0 # :nodoc:
|
|
67
|
+
ORIENTATION_VERTICAL = 1 # :nodoc:
|
|
68
|
+
UPDATE_MODE_DEFAULT = 0 # :nodoc:
|
|
69
|
+
UPDATE_MODE_BLACK_WHITE = 1 # :nodoc:
|
|
70
|
+
UPDATE_MODE_DELTA = 2 # :nodoc:
|
|
71
|
+
DISPLAY_TYPE_BLACK_WHITE_RED = 0 # :nodoc:
|
|
72
|
+
DISPLAY_TYPE_BLACK_WHITE_GRAY = 1 # :nodoc:
|
|
73
|
+
BOOTLOADER_MODE_BOOTLOADER = 0 # :nodoc:
|
|
74
|
+
BOOTLOADER_MODE_FIRMWARE = 1 # :nodoc:
|
|
75
|
+
BOOTLOADER_MODE_BOOTLOADER_WAIT_FOR_REBOOT = 2 # :nodoc:
|
|
76
|
+
BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_REBOOT = 3 # :nodoc:
|
|
77
|
+
BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_ERASE_AND_REBOOT = 4 # :nodoc:
|
|
78
|
+
BOOTLOADER_STATUS_OK = 0 # :nodoc:
|
|
79
|
+
BOOTLOADER_STATUS_INVALID_MODE = 1 # :nodoc:
|
|
80
|
+
BOOTLOADER_STATUS_NO_CHANGE = 2 # :nodoc:
|
|
81
|
+
BOOTLOADER_STATUS_ENTRY_FUNCTION_NOT_PRESENT = 3 # :nodoc:
|
|
82
|
+
BOOTLOADER_STATUS_DEVICE_IDENTIFIER_INCORRECT = 4 # :nodoc:
|
|
83
|
+
BOOTLOADER_STATUS_CRC_MISMATCH = 5 # :nodoc:
|
|
84
|
+
STATUS_LED_CONFIG_OFF = 0 # :nodoc:
|
|
85
|
+
STATUS_LED_CONFIG_ON = 1 # :nodoc:
|
|
86
|
+
STATUS_LED_CONFIG_SHOW_HEARTBEAT = 2 # :nodoc:
|
|
87
|
+
STATUS_LED_CONFIG_SHOW_STATUS = 3 # :nodoc:
|
|
88
|
+
|
|
89
|
+
# Creates an object with the unique device ID <tt>uid</tt> and adds it to
|
|
90
|
+
# the IP Connection <tt>ipcon</tt>.
|
|
91
|
+
def initialize(uid, ipcon)
|
|
92
|
+
super uid, ipcon
|
|
93
|
+
|
|
94
|
+
@api_version = [2, 0, 0]
|
|
95
|
+
|
|
96
|
+
@response_expected[FUNCTION_DRAW] = RESPONSE_EXPECTED_FALSE
|
|
97
|
+
@response_expected[FUNCTION_GET_DRAW_STATUS] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
98
|
+
@response_expected[FUNCTION_WRITE_BLACK_WHITE_LOW_LEVEL] = RESPONSE_EXPECTED_TRUE
|
|
99
|
+
@response_expected[FUNCTION_READ_BLACK_WHITE_LOW_LEVEL] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
100
|
+
@response_expected[FUNCTION_WRITE_COLOR_LOW_LEVEL] = RESPONSE_EXPECTED_TRUE
|
|
101
|
+
@response_expected[FUNCTION_READ_COLOR_LOW_LEVEL] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
102
|
+
@response_expected[FUNCTION_FILL_DISPLAY] = RESPONSE_EXPECTED_FALSE
|
|
103
|
+
@response_expected[FUNCTION_DRAW_TEXT] = RESPONSE_EXPECTED_FALSE
|
|
104
|
+
@response_expected[FUNCTION_DRAW_LINE] = RESPONSE_EXPECTED_FALSE
|
|
105
|
+
@response_expected[FUNCTION_DRAW_BOX] = RESPONSE_EXPECTED_FALSE
|
|
106
|
+
@response_expected[FUNCTION_SET_UPDATE_MODE] = RESPONSE_EXPECTED_FALSE
|
|
107
|
+
@response_expected[FUNCTION_GET_UPDATE_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
108
|
+
@response_expected[FUNCTION_SET_DISPLAY_TYPE] = RESPONSE_EXPECTED_FALSE
|
|
109
|
+
@response_expected[FUNCTION_GET_DISPLAY_TYPE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
110
|
+
@response_expected[FUNCTION_GET_SPITFP_ERROR_COUNT] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
111
|
+
@response_expected[FUNCTION_SET_BOOTLOADER_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
112
|
+
@response_expected[FUNCTION_GET_BOOTLOADER_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
113
|
+
@response_expected[FUNCTION_SET_WRITE_FIRMWARE_POINTER] = RESPONSE_EXPECTED_FALSE
|
|
114
|
+
@response_expected[FUNCTION_WRITE_FIRMWARE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
115
|
+
@response_expected[FUNCTION_SET_STATUS_LED_CONFIG] = RESPONSE_EXPECTED_FALSE
|
|
116
|
+
@response_expected[FUNCTION_GET_STATUS_LED_CONFIG] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
117
|
+
@response_expected[FUNCTION_GET_CHIP_TEMPERATURE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
118
|
+
@response_expected[FUNCTION_RESET] = RESPONSE_EXPECTED_FALSE
|
|
119
|
+
@response_expected[FUNCTION_WRITE_UID] = RESPONSE_EXPECTED_FALSE
|
|
120
|
+
@response_expected[FUNCTION_READ_UID] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
121
|
+
@response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
122
|
+
|
|
123
|
+
@callback_formats[CALLBACK_DRAW_STATUS] = 'C'
|
|
124
|
+
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
# Draws the current black/white and red or gray buffer to the e-paper display.
|
|
128
|
+
#
|
|
129
|
+
# The Bricklet does not have any double-buffering. You should not call
|
|
130
|
+
# this function while writing to the buffer. See BrickletEPaper296x128#get_draw_status.
|
|
131
|
+
def draw
|
|
132
|
+
send_request FUNCTION_DRAW, [], '', 0, ''
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
# Returns one of three draw statuses:
|
|
136
|
+
#
|
|
137
|
+
# * Idle
|
|
138
|
+
# * Copying: Data is being copied from the buffer of the Bricklet to the buffer of the display.
|
|
139
|
+
# * Drawing: The display is updating its content (during this phase the flickering etc happens).
|
|
140
|
+
#
|
|
141
|
+
# You can write to the buffer (through one of the write or draw functions) when the status is
|
|
142
|
+
# either *idle* or *drawing*. You should not write to the buffer while it is being *copied* to the
|
|
143
|
+
# display. There is no double-buffering.
|
|
144
|
+
def get_draw_status
|
|
145
|
+
send_request FUNCTION_GET_DRAW_STATUS, [], '', 1, 'C'
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
# Writes black/white pixels to the specified window into the buffer.
|
|
149
|
+
#
|
|
150
|
+
# The x-axis goes from 0 to 295 and the y-axis from 0 to 127. The pixels are written
|
|
151
|
+
# into the window line by line top to bottom and each line is written from left to
|
|
152
|
+
# right.
|
|
153
|
+
#
|
|
154
|
+
# The value 0 (false) corresponds to a black pixel and the value 1 (true) to a
|
|
155
|
+
# white pixel.
|
|
156
|
+
#
|
|
157
|
+
# This function writes the pixels into the black/white pixel buffer, to draw the
|
|
158
|
+
# buffer to the display use BrickletEPaper296x128#draw.
|
|
159
|
+
#
|
|
160
|
+
# Use BrickletEPaper296x128#write_color to write red or gray pixels.
|
|
161
|
+
def write_black_white_low_level(x_start, y_start, x_end, y_end, pixels_length, pixels_chunk_offset, pixels_chunk_data)
|
|
162
|
+
send_request FUNCTION_WRITE_BLACK_WHITE_LOW_LEVEL, [x_start, y_start, x_end, y_end, pixels_length, pixels_chunk_offset, pixels_chunk_data], 'S C S C S S ?432', 0, ''
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
# Returns the current content of the black/white pixel buffer for the specified window.
|
|
166
|
+
#
|
|
167
|
+
# The x-axis goes from 0 to 295 and the y-axis from 0 to 127. The pixels are written
|
|
168
|
+
# into the window line by line top to bottom and each line is written from left to
|
|
169
|
+
# right.
|
|
170
|
+
#
|
|
171
|
+
# The current content of the buffer does not have to be the current content of the display.
|
|
172
|
+
# It is possible that the data was not drawn to the display yet and after a restart of
|
|
173
|
+
# the Bricklet the buffer will be reset to black, while the display retains its content.
|
|
174
|
+
def read_black_white_low_level(x_start, y_start, x_end, y_end)
|
|
175
|
+
send_request FUNCTION_READ_BLACK_WHITE_LOW_LEVEL, [x_start, y_start, x_end, y_end], 'S C S C', 468, 'S S ?464'
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
# The E-Paper 296x128 Bricklet is available with the colors black/white/red and
|
|
179
|
+
# black/white/gray. Depending on the model this function writes either red or
|
|
180
|
+
# gray pixels to the specified window into the buffer.
|
|
181
|
+
#
|
|
182
|
+
# The x-axis goes from 0 to 295 and the y-axis from 0 to 127. The pixels are written
|
|
183
|
+
# into the window line by line top to bottom and each line is written from left to
|
|
184
|
+
# right.
|
|
185
|
+
#
|
|
186
|
+
# The value 0 (false) means that this pixel does not have color. It will be either black
|
|
187
|
+
# or white (see BrickletEPaper296x128#write_black_white). The value 1 (true) corresponds to a red or gray
|
|
188
|
+
# pixel, depending on the Bricklet model.
|
|
189
|
+
#
|
|
190
|
+
# This function writes the pixels into the red or gray pixel buffer, to draw the buffer
|
|
191
|
+
# to the display use BrickletEPaper296x128#draw.
|
|
192
|
+
#
|
|
193
|
+
# Use BrickletEPaper296x128#write_black_white to write black/white pixels.
|
|
194
|
+
def write_color_low_level(x_start, y_start, x_end, y_end, pixels_length, pixels_chunk_offset, pixels_chunk_data)
|
|
195
|
+
send_request FUNCTION_WRITE_COLOR_LOW_LEVEL, [x_start, y_start, x_end, y_end, pixels_length, pixels_chunk_offset, pixels_chunk_data], 'S C S C S S ?432', 0, ''
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
# Returns the current content of the red or gray pixel buffer for the specified window.
|
|
199
|
+
#
|
|
200
|
+
# The x-axis goes from 0 to 295 and the y-axis from 0 to 127. The pixels are written
|
|
201
|
+
# into the window line by line top to bottom and each line is written from left to
|
|
202
|
+
# right.
|
|
203
|
+
#
|
|
204
|
+
# The current content of the buffer does not have to be the current content of the display.
|
|
205
|
+
# It is possible that the data was not drawn to the display yet and after a restart of
|
|
206
|
+
# the Bricklet the buffer will be reset to black, while the display retains its content.
|
|
207
|
+
def read_color_low_level(x_start, y_start, x_end, y_end)
|
|
208
|
+
send_request FUNCTION_READ_COLOR_LOW_LEVEL, [x_start, y_start, x_end, y_end], 'S C S C', 468, 'S S ?464'
|
|
209
|
+
end
|
|
210
|
+
|
|
211
|
+
# Fills the complete content of the display with the given color.
|
|
212
|
+
def fill_display(color)
|
|
213
|
+
send_request FUNCTION_FILL_DISPLAY, [color], 'C', 0, ''
|
|
214
|
+
end
|
|
215
|
+
|
|
216
|
+
# Draws a text with up to 50 characters at the pixel position (x, y).
|
|
217
|
+
#
|
|
218
|
+
# The x values have to be within the range of 0 to 295 and the y
|
|
219
|
+
# values have to be within the range of 0 to 127.
|
|
220
|
+
#
|
|
221
|
+
# You can use one of 9 different font sizes and draw the text in
|
|
222
|
+
# black/white/red|gray. The text can be drawn horizontal or vertical.
|
|
223
|
+
def draw_text(position_x, position_y, font, color, orientation, text)
|
|
224
|
+
send_request FUNCTION_DRAW_TEXT, [position_x, position_y, font, color, orientation, text], 'S C C C C Z50', 0, ''
|
|
225
|
+
end
|
|
226
|
+
|
|
227
|
+
# Draws a line from (x, y)-start to (x, y)-end in the given color.
|
|
228
|
+
# The x values have to be within the range of 0 to 295 and the y
|
|
229
|
+
# values have t be within the range of 0 to 127.
|
|
230
|
+
def draw_line(position_x_start, position_y_start, position_x_end, position_y_end, color)
|
|
231
|
+
send_request FUNCTION_DRAW_LINE, [position_x_start, position_y_start, position_x_end, position_y_end, color], 'S C S C C', 0, ''
|
|
232
|
+
end
|
|
233
|
+
|
|
234
|
+
# Draws a box from (x, y)-start to (x, y)-end in the given color.
|
|
235
|
+
# The x values have to be within the range of 0 to 295 and the y
|
|
236
|
+
# values have to be within the range of 0 to 127.
|
|
237
|
+
#
|
|
238
|
+
# If you set fill to true, the box will be filled with the
|
|
239
|
+
# color. Otherwise only the outline will be drawn.
|
|
240
|
+
def draw_box(position_x_start, position_y_start, position_x_end, position_y_end, fill, color)
|
|
241
|
+
send_request FUNCTION_DRAW_BOX, [position_x_start, position_y_start, position_x_end, position_y_end, fill, color], 'S C S C ? C', 0, ''
|
|
242
|
+
end
|
|
243
|
+
|
|
244
|
+
# .. note::
|
|
245
|
+
# The default update mode corresponds to the default e-paper display
|
|
246
|
+
# manufacturer settings. All of the other modes are experimental and
|
|
247
|
+
# will result in increased ghosting and possibly other long-term
|
|
248
|
+
# side effects.
|
|
249
|
+
#
|
|
250
|
+
# If you want to know more about the inner workings of an e-paper display
|
|
251
|
+
# take a look at this excellent video from Ben Krasnow:
|
|
252
|
+
# `https://www.youtube.com/watch?v=MsbiO8EAsGw <https://www.youtube.com/watch?v=MsbiO8EAsGw>`__.
|
|
253
|
+
#
|
|
254
|
+
# If you are not sure about this option, leave the update mode at default.
|
|
255
|
+
#
|
|
256
|
+
# Currently there are three update modes available:
|
|
257
|
+
#
|
|
258
|
+
# * Default: Settings as given by the manufacturer. An update will take about
|
|
259
|
+
# 7.5 seconds and during the update the screen will flicker several times.
|
|
260
|
+
# * Black/White: This will only update the black/white pixel. It uses the manufacturer
|
|
261
|
+
# settings for black/white and ignores the red or gray pixel buffer. With this mode the
|
|
262
|
+
# display will flicker once and it takes about 2.5 seconds. Compared to the default settings
|
|
263
|
+
# there is more ghosting.
|
|
264
|
+
# * Delta: This will only update the black/white pixel. It uses an aggressive method where
|
|
265
|
+
# the changes are not applied for a whole buffer but only for the delta between the last
|
|
266
|
+
# and the next buffer. With this mode the display will not flicker during an update and
|
|
267
|
+
# it takes about 900-950ms. Compared to the other two settings there is more ghosting. This
|
|
268
|
+
# mode can be used for something like a flicker-free live update of a text.
|
|
269
|
+
#
|
|
270
|
+
# With the black/white/red display if you use either the black/white or the delta mode,
|
|
271
|
+
# after a while of going back and forth between black and white the white color will
|
|
272
|
+
# start to appear red-ish or pink-ish.
|
|
273
|
+
#
|
|
274
|
+
# If you use the aggressive delta mode and rapidly change the content, we recommend that you
|
|
275
|
+
# change back to the default mode every few hours and in the default mode cycle between the
|
|
276
|
+
# three available colors a few times. This will get rid of the ghosting and after that you can
|
|
277
|
+
# go back to the delta mode with flicker-free updates.
|
|
278
|
+
def set_update_mode(update_mode)
|
|
279
|
+
send_request FUNCTION_SET_UPDATE_MODE, [update_mode], 'C', 0, ''
|
|
280
|
+
end
|
|
281
|
+
|
|
282
|
+
# Returns the update mode as set by BrickletEPaper296x128#set_update_mode.
|
|
283
|
+
def get_update_mode
|
|
284
|
+
send_request FUNCTION_GET_UPDATE_MODE, [], '', 1, 'C'
|
|
285
|
+
end
|
|
286
|
+
|
|
287
|
+
# Sets the type of the display. The e-paper display is available
|
|
288
|
+
# in black/white/red and black/white/gray. This will be factory set
|
|
289
|
+
# during the flashing and testing phase. The value is saved in
|
|
290
|
+
# non-volatile memory and will stay after a power cycle.
|
|
291
|
+
def set_display_type(display_type)
|
|
292
|
+
send_request FUNCTION_SET_DISPLAY_TYPE, [display_type], 'C', 0, ''
|
|
293
|
+
end
|
|
294
|
+
|
|
295
|
+
# Returns the type of the e-paper display. It can either be
|
|
296
|
+
# black/white/red or black/white/gray.
|
|
297
|
+
def get_display_type
|
|
298
|
+
send_request FUNCTION_GET_DISPLAY_TYPE, [], '', 1, 'C'
|
|
299
|
+
end
|
|
300
|
+
|
|
301
|
+
# Returns the error count for the communication between Brick and Bricklet.
|
|
302
|
+
#
|
|
303
|
+
# The errors are divided into
|
|
304
|
+
#
|
|
305
|
+
# * ACK checksum errors,
|
|
306
|
+
# * message checksum errors,
|
|
307
|
+
# * framing errors and
|
|
308
|
+
# * overflow errors.
|
|
309
|
+
#
|
|
310
|
+
# The errors counts are for errors that occur on the Bricklet side. All
|
|
311
|
+
# Bricks have a similar function that returns the errors on the Brick side.
|
|
312
|
+
def get_spitfp_error_count
|
|
313
|
+
send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 16, 'L L L L'
|
|
314
|
+
end
|
|
315
|
+
|
|
316
|
+
# Sets the bootloader mode and returns the status after the requested
|
|
317
|
+
# mode change was instigated.
|
|
318
|
+
#
|
|
319
|
+
# You can change from bootloader mode to firmware mode and vice versa. A change
|
|
320
|
+
# from bootloader mode to firmware mode will only take place if the entry function,
|
|
321
|
+
# device identifier and CRC are present and correct.
|
|
322
|
+
#
|
|
323
|
+
# This function is used by Brick Viewer during flashing. It should not be
|
|
324
|
+
# necessary to call it in a normal user program.
|
|
325
|
+
def set_bootloader_mode(mode)
|
|
326
|
+
send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 1, 'C'
|
|
327
|
+
end
|
|
328
|
+
|
|
329
|
+
# Returns the current bootloader mode, see BrickletEPaper296x128#set_bootloader_mode.
|
|
330
|
+
def get_bootloader_mode
|
|
331
|
+
send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 1, 'C'
|
|
332
|
+
end
|
|
333
|
+
|
|
334
|
+
# Sets the firmware pointer for BrickletEPaper296x128#write_firmware. The pointer has
|
|
335
|
+
# to be increased by chunks of size 64. The data is written to flash
|
|
336
|
+
# every 4 chunks (which equals to one page of size 256).
|
|
337
|
+
#
|
|
338
|
+
# This function is used by Brick Viewer during flashing. It should not be
|
|
339
|
+
# necessary to call it in a normal user program.
|
|
340
|
+
def set_write_firmware_pointer(pointer)
|
|
341
|
+
send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 0, ''
|
|
342
|
+
end
|
|
343
|
+
|
|
344
|
+
# Writes 64 Bytes of firmware at the position as written by
|
|
345
|
+
# BrickletEPaper296x128#set_write_firmware_pointer before. The firmware is written
|
|
346
|
+
# to flash every 4 chunks.
|
|
347
|
+
#
|
|
348
|
+
# You can only write firmware in bootloader mode.
|
|
349
|
+
#
|
|
350
|
+
# This function is used by Brick Viewer during flashing. It should not be
|
|
351
|
+
# necessary to call it in a normal user program.
|
|
352
|
+
def write_firmware(data)
|
|
353
|
+
send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 1, 'C'
|
|
354
|
+
end
|
|
355
|
+
|
|
356
|
+
# Sets the status LED configuration. By default the LED shows
|
|
357
|
+
# communication traffic between Brick and Bricklet, it flickers once
|
|
358
|
+
# for every 10 received data packets.
|
|
359
|
+
#
|
|
360
|
+
# You can also turn the LED permanently on/off or show a heartbeat.
|
|
361
|
+
#
|
|
362
|
+
# If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
|
|
363
|
+
def set_status_led_config(config)
|
|
364
|
+
send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 0, ''
|
|
365
|
+
end
|
|
366
|
+
|
|
367
|
+
# Returns the configuration as set by BrickletEPaper296x128#set_status_led_config
|
|
368
|
+
def get_status_led_config
|
|
369
|
+
send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 1, 'C'
|
|
370
|
+
end
|
|
371
|
+
|
|
372
|
+
# Returns the temperature in °C as measured inside the microcontroller. The
|
|
373
|
+
# value returned is not the ambient temperature!
|
|
374
|
+
#
|
|
375
|
+
# The temperature is only proportional to the real temperature and it has bad
|
|
376
|
+
# accuracy. Practically it is only useful as an indicator for
|
|
377
|
+
# temperature changes.
|
|
378
|
+
def get_chip_temperature
|
|
379
|
+
send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 2, 's'
|
|
380
|
+
end
|
|
381
|
+
|
|
382
|
+
# Calling this function will reset the Bricklet. All configurations
|
|
383
|
+
# will be lost.
|
|
384
|
+
#
|
|
385
|
+
# After a reset you have to create new device objects,
|
|
386
|
+
# calling functions on the existing ones will result in
|
|
387
|
+
# undefined behavior!
|
|
388
|
+
def reset
|
|
389
|
+
send_request FUNCTION_RESET, [], '', 0, ''
|
|
390
|
+
end
|
|
391
|
+
|
|
392
|
+
# Writes a new UID into flash. If you want to set a new UID
|
|
393
|
+
# you have to decode the Base58 encoded UID string into an
|
|
394
|
+
# integer first.
|
|
395
|
+
#
|
|
396
|
+
# We recommend that you use Brick Viewer to change the UID.
|
|
397
|
+
def write_uid(uid)
|
|
398
|
+
send_request FUNCTION_WRITE_UID, [uid], 'L', 0, ''
|
|
399
|
+
end
|
|
400
|
+
|
|
401
|
+
# Returns the current UID as an integer. Encode as
|
|
402
|
+
# Base58 to get the usual string version.
|
|
403
|
+
def read_uid
|
|
404
|
+
send_request FUNCTION_READ_UID, [], '', 4, 'L'
|
|
405
|
+
end
|
|
406
|
+
|
|
407
|
+
# Returns the UID, the UID where the Bricklet is connected to,
|
|
408
|
+
# the position, the hardware and firmware version as well as the
|
|
409
|
+
# device identifier.
|
|
410
|
+
#
|
|
411
|
+
# The position can be 'a', 'b', 'c' or 'd'.
|
|
412
|
+
#
|
|
413
|
+
# The device identifier numbers can be found :ref:`here <device_identifier>`.
|
|
414
|
+
# |device_identifier_constant|
|
|
415
|
+
def get_identity
|
|
416
|
+
send_request FUNCTION_GET_IDENTITY, [], '', 25, 'Z8 Z8 k C3 C3 S'
|
|
417
|
+
end
|
|
418
|
+
|
|
419
|
+
# Writes black/white pixels to the specified window into the buffer.
|
|
420
|
+
#
|
|
421
|
+
# The x-axis goes from 0 to 295 and the y-axis from 0 to 127. The pixels are written
|
|
422
|
+
# into the window line by line top to bottom and each line is written from left to
|
|
423
|
+
# right.
|
|
424
|
+
#
|
|
425
|
+
# The value 0 (false) corresponds to a black pixel and the value 1 (true) to a
|
|
426
|
+
# white pixel.
|
|
427
|
+
#
|
|
428
|
+
# This function writes the pixels into the black/white pixel buffer, to draw the
|
|
429
|
+
# buffer to the display use BrickletEPaper296x128#draw.
|
|
430
|
+
#
|
|
431
|
+
# Use BrickletEPaper296x128#write_color to write red or gray pixels.
|
|
432
|
+
def write_black_white(x_start, y_start, x_end, y_end, pixels)
|
|
433
|
+
if pixels.length > 65535
|
|
434
|
+
raise ArgumentError, 'Pixels can be at most 65535 items long'
|
|
435
|
+
end
|
|
436
|
+
|
|
437
|
+
pixels_length = pixels.length
|
|
438
|
+
pixels_chunk_offset = 0
|
|
439
|
+
|
|
440
|
+
if pixels_length == 0
|
|
441
|
+
pixels_chunk_data = [false] * 432
|
|
442
|
+
ret = write_black_white_low_level x_start, y_start, x_end, y_end, pixels_length, pixels_chunk_offset, pixels_chunk_data
|
|
443
|
+
else
|
|
444
|
+
ret = nil # assigned in block
|
|
445
|
+
|
|
446
|
+
@stream_mutex.synchronize {
|
|
447
|
+
while pixels_chunk_offset < pixels_length
|
|
448
|
+
pixels_chunk_data = pixels[pixels_chunk_offset, 432]
|
|
449
|
+
|
|
450
|
+
if pixels_chunk_data.length < 432
|
|
451
|
+
pixels_chunk_data += [false] * (432 - pixels_chunk_data.length)
|
|
452
|
+
end
|
|
453
|
+
|
|
454
|
+
ret = write_black_white_low_level x_start, y_start, x_end, y_end, pixels_length, pixels_chunk_offset, pixels_chunk_data
|
|
455
|
+
pixels_chunk_offset += 432
|
|
456
|
+
end
|
|
457
|
+
}
|
|
458
|
+
end
|
|
459
|
+
|
|
460
|
+
ret
|
|
461
|
+
end
|
|
462
|
+
|
|
463
|
+
# Returns the current content of the black/white pixel buffer for the specified window.
|
|
464
|
+
#
|
|
465
|
+
# The x-axis goes from 0 to 295 and the y-axis from 0 to 127. The pixels are written
|
|
466
|
+
# into the window line by line top to bottom and each line is written from left to
|
|
467
|
+
# right.
|
|
468
|
+
#
|
|
469
|
+
# The current content of the buffer does not have to be the current content of the display.
|
|
470
|
+
# It is possible that the data was not drawn to the display yet and after a restart of
|
|
471
|
+
# the Bricklet the buffer will be reset to black, while the display retains its content.
|
|
472
|
+
def read_black_white(x_start, y_start, x_end, y_end)
|
|
473
|
+
pixels_length = nil # assigned in block
|
|
474
|
+
pixels_data = nil # assigned in block
|
|
475
|
+
|
|
476
|
+
@stream_mutex.synchronize {
|
|
477
|
+
ret = read_black_white_low_level x_start, y_start, x_end, y_end
|
|
478
|
+
pixels_length = ret[0]
|
|
479
|
+
pixels_chunk_offset = ret[1]
|
|
480
|
+
pixels_out_of_sync = pixels_chunk_offset != 0
|
|
481
|
+
pixels_data = ret[2]
|
|
482
|
+
|
|
483
|
+
while not pixels_out_of_sync and pixels_data.length < pixels_length
|
|
484
|
+
ret = read_black_white_low_level x_start, y_start, x_end, y_end
|
|
485
|
+
pixels_length = ret[0]
|
|
486
|
+
pixels_chunk_offset = ret[1]
|
|
487
|
+
pixels_out_of_sync = pixels_chunk_offset != pixels_data.length
|
|
488
|
+
pixels_data += ret[2]
|
|
489
|
+
end
|
|
490
|
+
|
|
491
|
+
if pixels_out_of_sync # discard remaining stream to bring it back in-sync
|
|
492
|
+
while pixels_chunk_offset + 464 < pixels_length
|
|
493
|
+
ret = read_black_white_low_level x_start, y_start, x_end, y_end
|
|
494
|
+
pixels_length = ret[0]
|
|
495
|
+
pixels_chunk_offset = ret[1]
|
|
496
|
+
end
|
|
497
|
+
|
|
498
|
+
raise StreamOutOfSyncException, 'Pixels stream is out-of-sync'
|
|
499
|
+
end
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
pixels_data[0, pixels_length]
|
|
503
|
+
end
|
|
504
|
+
|
|
505
|
+
# The E-Paper 296x128 Bricklet is available with the colors black/white/red and
|
|
506
|
+
# black/white/gray. Depending on the model this function writes either red or
|
|
507
|
+
# gray pixels to the specified window into the buffer.
|
|
508
|
+
#
|
|
509
|
+
# The x-axis goes from 0 to 295 and the y-axis from 0 to 127. The pixels are written
|
|
510
|
+
# into the window line by line top to bottom and each line is written from left to
|
|
511
|
+
# right.
|
|
512
|
+
#
|
|
513
|
+
# The value 0 (false) means that this pixel does not have color. It will be either black
|
|
514
|
+
# or white (see BrickletEPaper296x128#write_black_white). The value 1 (true) corresponds to a red or gray
|
|
515
|
+
# pixel, depending on the Bricklet model.
|
|
516
|
+
#
|
|
517
|
+
# This function writes the pixels into the red or gray pixel buffer, to draw the buffer
|
|
518
|
+
# to the display use BrickletEPaper296x128#draw.
|
|
519
|
+
#
|
|
520
|
+
# Use BrickletEPaper296x128#write_black_white to write black/white pixels.
|
|
521
|
+
def write_color(x_start, y_start, x_end, y_end, pixels)
|
|
522
|
+
if pixels.length > 65535
|
|
523
|
+
raise ArgumentError, 'Pixels can be at most 65535 items long'
|
|
524
|
+
end
|
|
525
|
+
|
|
526
|
+
pixels_length = pixels.length
|
|
527
|
+
pixels_chunk_offset = 0
|
|
528
|
+
|
|
529
|
+
if pixels_length == 0
|
|
530
|
+
pixels_chunk_data = [false] * 432
|
|
531
|
+
ret = write_color_low_level x_start, y_start, x_end, y_end, pixels_length, pixels_chunk_offset, pixels_chunk_data
|
|
532
|
+
else
|
|
533
|
+
ret = nil # assigned in block
|
|
534
|
+
|
|
535
|
+
@stream_mutex.synchronize {
|
|
536
|
+
while pixels_chunk_offset < pixels_length
|
|
537
|
+
pixels_chunk_data = pixels[pixels_chunk_offset, 432]
|
|
538
|
+
|
|
539
|
+
if pixels_chunk_data.length < 432
|
|
540
|
+
pixels_chunk_data += [false] * (432 - pixels_chunk_data.length)
|
|
541
|
+
end
|
|
542
|
+
|
|
543
|
+
ret = write_color_low_level x_start, y_start, x_end, y_end, pixels_length, pixels_chunk_offset, pixels_chunk_data
|
|
544
|
+
pixels_chunk_offset += 432
|
|
545
|
+
end
|
|
546
|
+
}
|
|
547
|
+
end
|
|
548
|
+
|
|
549
|
+
ret
|
|
550
|
+
end
|
|
551
|
+
|
|
552
|
+
# Returns the current content of the red or gray pixel buffer for the specified window.
|
|
553
|
+
#
|
|
554
|
+
# The x-axis goes from 0 to 295 and the y-axis from 0 to 127. The pixels are written
|
|
555
|
+
# into the window line by line top to bottom and each line is written from left to
|
|
556
|
+
# right.
|
|
557
|
+
#
|
|
558
|
+
# The current content of the buffer does not have to be the current content of the display.
|
|
559
|
+
# It is possible that the data was not drawn to the display yet and after a restart of
|
|
560
|
+
# the Bricklet the buffer will be reset to black, while the display retains its content.
|
|
561
|
+
def read_color(x_start, y_start, x_end, y_end)
|
|
562
|
+
pixels_length = nil # assigned in block
|
|
563
|
+
pixels_data = nil # assigned in block
|
|
564
|
+
|
|
565
|
+
@stream_mutex.synchronize {
|
|
566
|
+
ret = read_color_low_level x_start, y_start, x_end, y_end
|
|
567
|
+
pixels_length = ret[0]
|
|
568
|
+
pixels_chunk_offset = ret[1]
|
|
569
|
+
pixels_out_of_sync = pixels_chunk_offset != 0
|
|
570
|
+
pixels_data = ret[2]
|
|
571
|
+
|
|
572
|
+
while not pixels_out_of_sync and pixels_data.length < pixels_length
|
|
573
|
+
ret = read_color_low_level x_start, y_start, x_end, y_end
|
|
574
|
+
pixels_length = ret[0]
|
|
575
|
+
pixels_chunk_offset = ret[1]
|
|
576
|
+
pixels_out_of_sync = pixels_chunk_offset != pixels_data.length
|
|
577
|
+
pixels_data += ret[2]
|
|
578
|
+
end
|
|
579
|
+
|
|
580
|
+
if pixels_out_of_sync # discard remaining stream to bring it back in-sync
|
|
581
|
+
while pixels_chunk_offset + 464 < pixels_length
|
|
582
|
+
ret = read_color_low_level x_start, y_start, x_end, y_end
|
|
583
|
+
pixels_length = ret[0]
|
|
584
|
+
pixels_chunk_offset = ret[1]
|
|
585
|
+
end
|
|
586
|
+
|
|
587
|
+
raise StreamOutOfSyncException, 'Pixels stream is out-of-sync'
|
|
588
|
+
end
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
pixels_data[0, pixels_length]
|
|
592
|
+
end
|
|
593
|
+
|
|
594
|
+
# Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
|
|
595
|
+
def register_callback(id, &block)
|
|
596
|
+
callback = block
|
|
597
|
+
@registered_callbacks[id] = callback
|
|
598
|
+
end
|
|
599
|
+
end
|
|
600
|
+
end
|