tinkerforge 2.1.22 → 2.1.27

Sign up to get free protection for your applications and to get access to all the features.
Files changed (144) hide show
  1. checksums.yaml +5 -5
  2. data/lib/tinkerforge/brick_dc.rb +157 -76
  3. data/lib/tinkerforge/brick_hat.rb +115 -32
  4. data/lib/tinkerforge/brick_hat_zero.rb +119 -21
  5. data/lib/tinkerforge/brick_imu.rb +192 -87
  6. data/lib/tinkerforge/brick_imu_v2.rb +220 -119
  7. data/lib/tinkerforge/brick_master.rb +498 -198
  8. data/lib/tinkerforge/brick_red.rb +197 -74
  9. data/lib/tinkerforge/brick_servo.rb +187 -103
  10. data/lib/tinkerforge/brick_silent_stepper.rb +249 -169
  11. data/lib/tinkerforge/brick_stepper.rb +214 -102
  12. data/lib/tinkerforge/bricklet_accelerometer.rb +61 -36
  13. data/lib/tinkerforge/bricklet_accelerometer_v2.rb +167 -48
  14. data/lib/tinkerforge/bricklet_air_quality.rb +123 -76
  15. data/lib/tinkerforge/bricklet_ambient_light.rb +62 -46
  16. data/lib/tinkerforge/bricklet_ambient_light_v2.rb +41 -28
  17. data/lib/tinkerforge/bricklet_ambient_light_v3.rb +61 -28
  18. data/lib/tinkerforge/bricklet_analog_in.rb +66 -45
  19. data/lib/tinkerforge/bricklet_analog_in_v2.rb +60 -43
  20. data/lib/tinkerforge/bricklet_analog_in_v3.rb +68 -32
  21. data/lib/tinkerforge/bricklet_analog_out.rb +25 -16
  22. data/lib/tinkerforge/bricklet_analog_out_v2.rb +21 -10
  23. data/lib/tinkerforge/bricklet_analog_out_v3.rb +55 -22
  24. data/lib/tinkerforge/bricklet_barometer.rb +108 -58
  25. data/lib/tinkerforge/bricklet_barometer_v2.rb +109 -67
  26. data/lib/tinkerforge/bricklet_can.rb +84 -24
  27. data/lib/tinkerforge/bricklet_can_v2.rb +173 -72
  28. data/lib/tinkerforge/bricklet_co2.rb +36 -25
  29. data/lib/tinkerforge/bricklet_co2_v2.rb +119 -60
  30. data/lib/tinkerforge/bricklet_color.rb +77 -49
  31. data/lib/tinkerforge/bricklet_color_v2.rb +493 -0
  32. data/lib/tinkerforge/bricklet_compass.rb +397 -0
  33. data/lib/tinkerforge/bricklet_current12.rb +61 -40
  34. data/lib/tinkerforge/bricklet_current25.rb +61 -40
  35. data/lib/tinkerforge/bricklet_distance_ir.rb +60 -38
  36. data/lib/tinkerforge/bricklet_distance_ir_v2.rb +85 -45
  37. data/lib/tinkerforge/bricklet_distance_us.rb +43 -30
  38. data/lib/tinkerforge/bricklet_distance_us_v2.rb +335 -0
  39. data/lib/tinkerforge/bricklet_dmx.rb +92 -48
  40. data/lib/tinkerforge/bricklet_dual_button.rb +23 -12
  41. data/lib/tinkerforge/bricklet_dual_button_v2.rb +64 -29
  42. data/lib/tinkerforge/bricklet_dual_relay.rb +27 -14
  43. data/lib/tinkerforge/bricklet_dust_detector.rb +43 -30
  44. data/lib/tinkerforge/bricklet_e_paper_296x128.rb +115 -63
  45. data/lib/tinkerforge/bricklet_energy_monitor.rb +416 -0
  46. data/lib/tinkerforge/bricklet_gps.rb +72 -48
  47. data/lib/tinkerforge/bricklet_gps_v2.rb +124 -73
  48. data/lib/tinkerforge/bricklet_hall_effect.rb +43 -28
  49. data/lib/tinkerforge/bricklet_hall_effect_v2.rb +76 -44
  50. data/lib/tinkerforge/bricklet_humidity.rb +54 -38
  51. data/lib/tinkerforge/bricklet_humidity_v2.rb +86 -49
  52. data/lib/tinkerforge/bricklet_imu_v3.rb +784 -0
  53. data/lib/tinkerforge/bricklet_industrial_analog_out.rb +41 -18
  54. data/lib/tinkerforge/bricklet_industrial_analog_out_v2.rb +84 -40
  55. data/lib/tinkerforge/bricklet_industrial_counter.rb +102 -59
  56. data/lib/tinkerforge/bricklet_industrial_digital_in_4.rb +51 -24
  57. data/lib/tinkerforge/bricklet_industrial_digital_in_4_v2.rb +79 -40
  58. data/lib/tinkerforge/bricklet_industrial_digital_out_4.rb +36 -15
  59. data/lib/tinkerforge/bricklet_industrial_digital_out_4_v2.rb +75 -33
  60. data/lib/tinkerforge/bricklet_industrial_dual_0_20ma.rb +43 -29
  61. data/lib/tinkerforge/bricklet_industrial_dual_0_20ma_v2.rb +81 -44
  62. data/lib/tinkerforge/bricklet_industrial_dual_ac_relay.rb +325 -0
  63. data/lib/tinkerforge/bricklet_industrial_dual_analog_in.rb +51 -30
  64. data/lib/tinkerforge/bricklet_industrial_dual_analog_in_v2.rb +139 -40
  65. data/lib/tinkerforge/bricklet_industrial_dual_relay.rb +63 -28
  66. data/lib/tinkerforge/bricklet_industrial_quad_relay.rb +36 -15
  67. data/lib/tinkerforge/bricklet_industrial_quad_relay_v2.rb +67 -28
  68. data/lib/tinkerforge/bricklet_io16.rb +57 -32
  69. data/lib/tinkerforge/bricklet_io16_v2.rb +93 -48
  70. data/lib/tinkerforge/bricklet_io4.rb +56 -31
  71. data/lib/tinkerforge/bricklet_io4_v2.rb +109 -57
  72. data/lib/tinkerforge/bricklet_isolator.rb +111 -35
  73. data/lib/tinkerforge/bricklet_joystick.rb +63 -42
  74. data/lib/tinkerforge/bricklet_joystick_v2.rb +71 -35
  75. data/lib/tinkerforge/bricklet_laser_range_finder.rb +87 -59
  76. data/lib/tinkerforge/bricklet_laser_range_finder_v2.rb +101 -53
  77. data/lib/tinkerforge/bricklet_lcd_128x64.rb +241 -131
  78. data/lib/tinkerforge/bricklet_lcd_16x2.rb +49 -25
  79. data/lib/tinkerforge/bricklet_lcd_20x4.rb +59 -29
  80. data/lib/tinkerforge/bricklet_led_strip.rb +69 -47
  81. data/lib/tinkerforge/bricklet_led_strip_v2.rb +105 -48
  82. data/lib/tinkerforge/bricklet_line.rb +35 -22
  83. data/lib/tinkerforge/bricklet_linear_poti.rb +53 -35
  84. data/lib/tinkerforge/bricklet_linear_poti_v2.rb +55 -24
  85. data/lib/tinkerforge/bricklet_load_cell.rb +64 -40
  86. data/lib/tinkerforge/bricklet_load_cell_v2.rb +81 -41
  87. data/lib/tinkerforge/bricklet_moisture.rb +43 -30
  88. data/lib/tinkerforge/bricklet_motion_detector.rb +21 -10
  89. data/lib/tinkerforge/bricklet_motion_detector_v2.rb +62 -29
  90. data/lib/tinkerforge/bricklet_motorized_linear_poti.rb +71 -32
  91. data/lib/tinkerforge/bricklet_multi_touch.rb +30 -17
  92. data/lib/tinkerforge/bricklet_multi_touch_v2.rb +371 -0
  93. data/lib/tinkerforge/bricklet_nfc.rb +130 -80
  94. data/lib/tinkerforge/bricklet_nfc_rfid.rb +32 -13
  95. data/lib/tinkerforge/bricklet_oled_128x64.rb +30 -17
  96. data/lib/tinkerforge/bricklet_oled_128x64_v2.rb +97 -40
  97. data/lib/tinkerforge/bricklet_oled_64x48.rb +30 -17
  98. data/lib/tinkerforge/bricklet_one_wire.rb +65 -24
  99. data/lib/tinkerforge/bricklet_outdoor_weather.rb +84 -41
  100. data/lib/tinkerforge/bricklet_particulate_matter.rb +85 -37
  101. data/lib/tinkerforge/bricklet_piezo_buzzer.rb +19 -13
  102. data/lib/tinkerforge/bricklet_piezo_speaker.rb +22 -19
  103. data/lib/tinkerforge/bricklet_piezo_speaker_v2.rb +84 -57
  104. data/lib/tinkerforge/bricklet_ptc.rb +76 -51
  105. data/lib/tinkerforge/bricklet_ptc_v2.rb +96 -54
  106. data/lib/tinkerforge/bricklet_real_time_clock.rb +45 -36
  107. data/lib/tinkerforge/bricklet_real_time_clock_v2.rb +78 -47
  108. data/lib/tinkerforge/bricklet_remote_switch.rb +38 -29
  109. data/lib/tinkerforge/bricklet_remote_switch_v2.rb +86 -49
  110. data/lib/tinkerforge/bricklet_rgb_led.rb +17 -8
  111. data/lib/tinkerforge/bricklet_rgb_led_button.rb +61 -30
  112. data/lib/tinkerforge/bricklet_rgb_led_matrix.rb +78 -33
  113. data/lib/tinkerforge/bricklet_rgb_led_v2.rb +51 -20
  114. data/lib/tinkerforge/bricklet_rotary_encoder.rb +40 -25
  115. data/lib/tinkerforge/bricklet_rotary_encoder_v2.rb +60 -27
  116. data/lib/tinkerforge/bricklet_rotary_poti.rb +55 -37
  117. data/lib/tinkerforge/bricklet_rotary_poti_v2.rb +290 -0
  118. data/lib/tinkerforge/bricklet_rs232.rb +89 -28
  119. data/lib/tinkerforge/bricklet_rs232_v2.rb +121 -47
  120. data/lib/tinkerforge/bricklet_rs485.rb +303 -207
  121. data/lib/tinkerforge/bricklet_segment_display_4x7.rb +24 -14
  122. data/lib/tinkerforge/bricklet_segment_display_4x7_v2.rb +75 -36
  123. data/lib/tinkerforge/bricklet_solid_state_relay.rb +24 -13
  124. data/lib/tinkerforge/bricklet_solid_state_relay_v2.rb +58 -25
  125. data/lib/tinkerforge/bricklet_sound_intensity.rb +36 -24
  126. data/lib/tinkerforge/bricklet_sound_pressure_level.rb +77 -41
  127. data/lib/tinkerforge/bricklet_temperature.rb +43 -28
  128. data/lib/tinkerforge/bricklet_temperature_ir.rb +63 -47
  129. data/lib/tinkerforge/bricklet_temperature_ir_v2.rb +75 -53
  130. data/lib/tinkerforge/bricklet_temperature_v2.rb +62 -31
  131. data/lib/tinkerforge/bricklet_thermal_imaging.rb +118 -68
  132. data/lib/tinkerforge/bricklet_thermocouple.rb +46 -30
  133. data/lib/tinkerforge/bricklet_thermocouple_v2.rb +65 -30
  134. data/lib/tinkerforge/bricklet_tilt.rb +23 -10
  135. data/lib/tinkerforge/bricklet_uv_light.rb +37 -24
  136. data/lib/tinkerforge/bricklet_uv_light_v2.rb +87 -46
  137. data/lib/tinkerforge/bricklet_voltage.rb +54 -37
  138. data/lib/tinkerforge/bricklet_voltage_current.rb +94 -85
  139. data/lib/tinkerforge/bricklet_voltage_current_v2.rb +103 -77
  140. data/lib/tinkerforge/bricklet_xmc1400_breakout.rb +410 -0
  141. data/lib/tinkerforge/device_display_names.rb +165 -0
  142. data/lib/tinkerforge/ip_connection.rb +155 -33
  143. data/lib/tinkerforge/version.rb +1 -1
  144. metadata +14 -4
@@ -1,14 +1,16 @@
1
1
  # -*- ruby encoding: utf-8 -*-
2
2
  #############################################################
3
- # This file was automatically generated on 2019-05-21. #
3
+ # This file was automatically generated on 2020-11-02. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.22 #
5
+ # Ruby Bindings Version 2.1.27 #
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 #
9
9
  # to the generators git repository on tinkerforge.com #
10
10
  #############################################################
11
11
 
12
+ require_relative './ip_connection'
13
+
12
14
  module Tinkerforge
13
15
  # Capacitive touch sensor for 12 electrodes
14
16
  class BrickletMultiTouch < Device
@@ -33,7 +35,7 @@ module Tinkerforge
33
35
  # Creates an object with the unique device ID <tt>uid</tt> and adds it to
34
36
  # the IP Connection <tt>ipcon</tt>.
35
37
  def initialize(uid, ipcon)
36
- super uid, ipcon
38
+ super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
37
39
 
38
40
  @api_version = [2, 0, 0]
39
41
 
@@ -45,8 +47,9 @@ module Tinkerforge
45
47
  @response_expected[FUNCTION_GET_ELECTRODE_SENSITIVITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
46
48
  @response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
47
49
 
48
- @callback_formats[CALLBACK_TOUCH_STATE] = 'S'
50
+ @callback_formats[CALLBACK_TOUCH_STATE] = [10, 'S']
49
51
 
52
+ @ipcon.add_device self
50
53
  end
51
54
 
52
55
  # Returns the current touch state. The state is given as a bitfield.
@@ -68,13 +71,17 @@ module Tinkerforge
68
71
  # or similar on top of a electrode to build a touch panel with
69
72
  # a professional look.
70
73
  def get_touch_state
71
- send_request FUNCTION_GET_TOUCH_STATE, [], '', 2, 'S'
74
+ check_validity
75
+
76
+ send_request FUNCTION_GET_TOUCH_STATE, [], '', 10, 'S'
72
77
  end
73
78
 
74
79
  # Recalibrates the electrodes. Call this function whenever you changed
75
80
  # or moved you electrodes.
76
81
  def recalibrate
77
- send_request FUNCTION_RECALIBRATE, [], '', 0, ''
82
+ check_validity
83
+
84
+ send_request FUNCTION_RECALIBRATE, [], '', 8, ''
78
85
  end
79
86
 
80
87
  # Enables/disables electrodes with a bitfield (see BrickletMultiTouch#get_touch_state).
@@ -90,14 +97,18 @@ module Tinkerforge
90
97
  #
91
98
  # Disabling electrodes will also reduce power consumption.
92
99
  #
93
- # Default: 8191 = 0x1FFF = 0b1111111111111 (all electrodes enabled)
100
+ # Default: 8191 = 0x1FFF = 0b1111111111111 (all electrodes and proximity feature enabled)
94
101
  def set_electrode_config(enabled_electrodes)
95
- send_request FUNCTION_SET_ELECTRODE_CONFIG, [enabled_electrodes], 'S', 0, ''
102
+ check_validity
103
+
104
+ send_request FUNCTION_SET_ELECTRODE_CONFIG, [enabled_electrodes], 'S', 8, ''
96
105
  end
97
106
 
98
107
  # Returns the electrode configuration, as set by BrickletMultiTouch#set_electrode_config.
99
108
  def get_electrode_config
100
- send_request FUNCTION_GET_ELECTRODE_CONFIG, [], '', 2, 'S'
109
+ check_validity
110
+
111
+ send_request FUNCTION_GET_ELECTRODE_CONFIG, [], '', 10, 'S'
101
112
  end
102
113
 
103
114
  # Sets the sensitivity of the electrodes. An electrode with a high sensitivity
@@ -109,29 +120,31 @@ module Tinkerforge
109
120
  #
110
121
  # After a new sensitivity is set, you likely want to call BrickletMultiTouch#recalibrate
111
122
  # to calibrate the electrodes with the newly defined sensitivity.
112
- #
113
- # The valid sensitivity value range is 5-201.
114
- #
115
- # The default sensitivity value is 181.
116
123
  def set_electrode_sensitivity(sensitivity)
117
- send_request FUNCTION_SET_ELECTRODE_SENSITIVITY, [sensitivity], 'C', 0, ''
124
+ check_validity
125
+
126
+ send_request FUNCTION_SET_ELECTRODE_SENSITIVITY, [sensitivity], 'C', 8, ''
118
127
  end
119
128
 
120
129
  # Returns the current sensitivity, as set by BrickletMultiTouch#set_electrode_sensitivity.
121
130
  def get_electrode_sensitivity
122
- send_request FUNCTION_GET_ELECTRODE_SENSITIVITY, [], '', 1, 'C'
131
+ check_validity
132
+
133
+ send_request FUNCTION_GET_ELECTRODE_SENSITIVITY, [], '', 9, 'C'
123
134
  end
124
135
 
125
136
  # Returns the UID, the UID where the Bricklet is connected to,
126
137
  # the position, the hardware and firmware version as well as the
127
138
  # device identifier.
128
139
  #
129
- # The position can be 'a', 'b', 'c' or 'd'.
140
+ # The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
141
+ # A Bricklet connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always at
142
+ # position 'z'.
130
143
  #
131
144
  # The device identifier numbers can be found :ref:`here <device_identifier>`.
132
145
  # |device_identifier_constant|
133
146
  def get_identity
134
- send_request FUNCTION_GET_IDENTITY, [], '', 25, 'Z8 Z8 k C3 C3 S'
147
+ send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
135
148
  end
136
149
 
137
150
  # Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
@@ -0,0 +1,371 @@
1
+ # -*- ruby encoding: utf-8 -*-
2
+ #############################################################
3
+ # This file was automatically generated on 2020-11-02. #
4
+ # #
5
+ # Ruby Bindings Version 2.1.27 #
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
+ require_relative './ip_connection'
13
+
14
+ module Tinkerforge
15
+ # Capacitive touch sensor for 12 electrodes
16
+ class BrickletMultiTouchV2 < Device
17
+ DEVICE_IDENTIFIER = 2129 # :nodoc:
18
+ DEVICE_DISPLAY_NAME = 'Multi Touch Bricklet 2.0' # :nodoc:
19
+
20
+ # Returns the current touch state, see BrickletMultiTouchV2#get_touch_state for
21
+ # information about the state.
22
+ #
23
+ # This callback is triggered every time the touch state changes with
24
+ # a given period (see BrickletMultiTouchV2#set_touch_state_callback_configuration)
25
+ CALLBACK_TOUCH_STATE = 4
26
+
27
+ FUNCTION_GET_TOUCH_STATE = 1 # :nodoc:
28
+ FUNCTION_SET_TOUCH_STATE_CALLBACK_CONFIGURATION = 2 # :nodoc:
29
+ FUNCTION_GET_TOUCH_STATE_CALLBACK_CONFIGURATION = 3 # :nodoc:
30
+ FUNCTION_RECALIBRATE = 5 # :nodoc:
31
+ FUNCTION_SET_ELECTRODE_CONFIG = 6 # :nodoc:
32
+ FUNCTION_GET_ELECTRODE_CONFIG = 7 # :nodoc:
33
+ FUNCTION_SET_ELECTRODE_SENSITIVITY = 8 # :nodoc:
34
+ FUNCTION_GET_ELECTRODE_SENSITIVITY = 9 # :nodoc:
35
+ FUNCTION_SET_TOUCH_LED_CONFIG = 10 # :nodoc:
36
+ FUNCTION_GET_TOUCH_LED_CONFIG = 11 # :nodoc:
37
+ FUNCTION_GET_SPITFP_ERROR_COUNT = 234 # :nodoc:
38
+ FUNCTION_SET_BOOTLOADER_MODE = 235 # :nodoc:
39
+ FUNCTION_GET_BOOTLOADER_MODE = 236 # :nodoc:
40
+ FUNCTION_SET_WRITE_FIRMWARE_POINTER = 237 # :nodoc:
41
+ FUNCTION_WRITE_FIRMWARE = 238 # :nodoc:
42
+ FUNCTION_SET_STATUS_LED_CONFIG = 239 # :nodoc:
43
+ FUNCTION_GET_STATUS_LED_CONFIG = 240 # :nodoc:
44
+ FUNCTION_GET_CHIP_TEMPERATURE = 242 # :nodoc:
45
+ FUNCTION_RESET = 243 # :nodoc:
46
+ FUNCTION_WRITE_UID = 248 # :nodoc:
47
+ FUNCTION_READ_UID = 249 # :nodoc:
48
+ FUNCTION_GET_IDENTITY = 255 # :nodoc:
49
+
50
+ TOUCH_LED_CONFIG_OFF = 0 # :nodoc:
51
+ TOUCH_LED_CONFIG_ON = 1 # :nodoc:
52
+ TOUCH_LED_CONFIG_SHOW_HEARTBEAT = 2 # :nodoc:
53
+ TOUCH_LED_CONFIG_SHOW_TOUCH = 3 # :nodoc:
54
+ BOOTLOADER_MODE_BOOTLOADER = 0 # :nodoc:
55
+ BOOTLOADER_MODE_FIRMWARE = 1 # :nodoc:
56
+ BOOTLOADER_MODE_BOOTLOADER_WAIT_FOR_REBOOT = 2 # :nodoc:
57
+ BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_REBOOT = 3 # :nodoc:
58
+ BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_ERASE_AND_REBOOT = 4 # :nodoc:
59
+ BOOTLOADER_STATUS_OK = 0 # :nodoc:
60
+ BOOTLOADER_STATUS_INVALID_MODE = 1 # :nodoc:
61
+ BOOTLOADER_STATUS_NO_CHANGE = 2 # :nodoc:
62
+ BOOTLOADER_STATUS_ENTRY_FUNCTION_NOT_PRESENT = 3 # :nodoc:
63
+ BOOTLOADER_STATUS_DEVICE_IDENTIFIER_INCORRECT = 4 # :nodoc:
64
+ BOOTLOADER_STATUS_CRC_MISMATCH = 5 # :nodoc:
65
+ STATUS_LED_CONFIG_OFF = 0 # :nodoc:
66
+ STATUS_LED_CONFIG_ON = 1 # :nodoc:
67
+ STATUS_LED_CONFIG_SHOW_HEARTBEAT = 2 # :nodoc:
68
+ STATUS_LED_CONFIG_SHOW_STATUS = 3 # :nodoc:
69
+
70
+ # Creates an object with the unique device ID <tt>uid</tt> and adds it to
71
+ # the IP Connection <tt>ipcon</tt>.
72
+ def initialize(uid, ipcon)
73
+ super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
74
+
75
+ @api_version = [2, 0, 0]
76
+
77
+ @response_expected[FUNCTION_GET_TOUCH_STATE] = RESPONSE_EXPECTED_ALWAYS_TRUE
78
+ @response_expected[FUNCTION_SET_TOUCH_STATE_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_TRUE
79
+ @response_expected[FUNCTION_GET_TOUCH_STATE_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
80
+ @response_expected[FUNCTION_RECALIBRATE] = RESPONSE_EXPECTED_FALSE
81
+ @response_expected[FUNCTION_SET_ELECTRODE_CONFIG] = RESPONSE_EXPECTED_FALSE
82
+ @response_expected[FUNCTION_GET_ELECTRODE_CONFIG] = RESPONSE_EXPECTED_ALWAYS_TRUE
83
+ @response_expected[FUNCTION_SET_ELECTRODE_SENSITIVITY] = RESPONSE_EXPECTED_FALSE
84
+ @response_expected[FUNCTION_GET_ELECTRODE_SENSITIVITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
85
+ @response_expected[FUNCTION_SET_TOUCH_LED_CONFIG] = RESPONSE_EXPECTED_FALSE
86
+ @response_expected[FUNCTION_GET_TOUCH_LED_CONFIG] = RESPONSE_EXPECTED_ALWAYS_TRUE
87
+ @response_expected[FUNCTION_GET_SPITFP_ERROR_COUNT] = RESPONSE_EXPECTED_ALWAYS_TRUE
88
+ @response_expected[FUNCTION_SET_BOOTLOADER_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE
89
+ @response_expected[FUNCTION_GET_BOOTLOADER_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE
90
+ @response_expected[FUNCTION_SET_WRITE_FIRMWARE_POINTER] = RESPONSE_EXPECTED_FALSE
91
+ @response_expected[FUNCTION_WRITE_FIRMWARE] = RESPONSE_EXPECTED_ALWAYS_TRUE
92
+ @response_expected[FUNCTION_SET_STATUS_LED_CONFIG] = RESPONSE_EXPECTED_FALSE
93
+ @response_expected[FUNCTION_GET_STATUS_LED_CONFIG] = RESPONSE_EXPECTED_ALWAYS_TRUE
94
+ @response_expected[FUNCTION_GET_CHIP_TEMPERATURE] = RESPONSE_EXPECTED_ALWAYS_TRUE
95
+ @response_expected[FUNCTION_RESET] = RESPONSE_EXPECTED_FALSE
96
+ @response_expected[FUNCTION_WRITE_UID] = RESPONSE_EXPECTED_FALSE
97
+ @response_expected[FUNCTION_READ_UID] = RESPONSE_EXPECTED_ALWAYS_TRUE
98
+ @response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
99
+
100
+ @callback_formats[CALLBACK_TOUCH_STATE] = [10, '?13']
101
+
102
+ @ipcon.add_device self
103
+ end
104
+
105
+ # Returns the current touch state. The state is given as a array of
106
+ # bools.
107
+ #
108
+ # Element 0 to 11 represent the 12 electrodes and element 12 represents
109
+ # the proximity.
110
+ #
111
+ # If an electrode is touched, the corresponding element is *true*. If
112
+ # a hand or similar is in proximity to the electrodes, element 12 is
113
+ # *true*.
114
+ #
115
+ # The proximity is activated with a distance of 1-2cm. An electrode
116
+ # is already counted as touched if a finger is nearly touching the
117
+ # electrode. This means that you can put a piece of paper or foil
118
+ # or similar on top of a electrode to build a touch panel with
119
+ # a professional look.
120
+ #
121
+ # If you want to get the value periodically, it is recommended to use the
122
+ # CALLBACK_TOUCH_STATE callback. You can set the callback configuration
123
+ # with BrickletMultiTouchV2#set_touch_state_callback_configuration.
124
+ def get_touch_state
125
+ check_validity
126
+
127
+ send_request FUNCTION_GET_TOUCH_STATE, [], '', 10, '?13'
128
+ end
129
+
130
+ # The period is the period with which the CALLBACK_TOUCH_STATE callback
131
+ # is triggered periodically. A value of 0 turns the callback off.
132
+ #
133
+ # If the `value has to change`-parameter is set to true, the callback is only
134
+ # triggered after the value has changed. If the value didn't change within the
135
+ # period, the callback is triggered immediately on change.
136
+ #
137
+ # If it is set to false, the callback is continuously triggered with the period,
138
+ # independent of the value.
139
+ def set_touch_state_callback_configuration(period, value_has_to_change)
140
+ check_validity
141
+
142
+ send_request FUNCTION_SET_TOUCH_STATE_CALLBACK_CONFIGURATION, [period, value_has_to_change], 'L ?', 8, ''
143
+ end
144
+
145
+ # Returns the callback configuration as set by
146
+ # BrickletMultiTouchV2#set_touch_state_callback_configuration.
147
+ def get_touch_state_callback_configuration
148
+ check_validity
149
+
150
+ send_request FUNCTION_GET_TOUCH_STATE_CALLBACK_CONFIGURATION, [], '', 13, 'L ?'
151
+ end
152
+
153
+ # Recalibrates the electrodes. Call this function whenever you changed
154
+ # or moved you electrodes.
155
+ def recalibrate
156
+ check_validity
157
+
158
+ send_request FUNCTION_RECALIBRATE, [], '', 8, ''
159
+ end
160
+
161
+ # Enables/disables electrodes with a bool array (see BrickletMultiTouchV2#get_touch_state).
162
+ #
163
+ # *True* enables the electrode, *false* disables the electrode. A
164
+ # disabled electrode will always return *false* as its state. If you
165
+ # don't need all electrodes you can disable the electrodes that are
166
+ # not needed.
167
+ #
168
+ # It is recommended that you disable the proximity electrode (element 12) if
169
+ # the proximity feature is not needed. This will reduce the amount of
170
+ # traffic that is produced by the CALLBACK_TOUCH_STATE callback.
171
+ #
172
+ # Disabling electrodes will also reduce power consumption.
173
+ def set_electrode_config(enabled_electrodes)
174
+ check_validity
175
+
176
+ send_request FUNCTION_SET_ELECTRODE_CONFIG, [enabled_electrodes], '?13', 8, ''
177
+ end
178
+
179
+ # Returns the electrode configuration, as set by BrickletMultiTouchV2#set_electrode_config.
180
+ def get_electrode_config
181
+ check_validity
182
+
183
+ send_request FUNCTION_GET_ELECTRODE_CONFIG, [], '', 10, '?13'
184
+ end
185
+
186
+ # Sets the sensitivity of the electrodes. An electrode with a high sensitivity
187
+ # will register a touch earlier then an electrode with a low sensitivity.
188
+ #
189
+ # If you build a big electrode you might need to decrease the sensitivity, since
190
+ # the area that can be charged will get bigger. If you want to be able to
191
+ # activate an electrode from further away you need to increase the sensitivity.
192
+ #
193
+ # After a new sensitivity is set, you likely want to call BrickletMultiTouchV2#recalibrate
194
+ # to calibrate the electrodes with the newly defined sensitivity.
195
+ def set_electrode_sensitivity(sensitivity)
196
+ check_validity
197
+
198
+ send_request FUNCTION_SET_ELECTRODE_SENSITIVITY, [sensitivity], 'C', 8, ''
199
+ end
200
+
201
+ # Returns the current sensitivity, as set by BrickletMultiTouchV2#set_electrode_sensitivity.
202
+ def get_electrode_sensitivity
203
+ check_validity
204
+
205
+ send_request FUNCTION_GET_ELECTRODE_SENSITIVITY, [], '', 9, 'C'
206
+ end
207
+
208
+ # Configures the touch LED to be either turned off, turned on, blink in
209
+ # heartbeat mode or show the touch state (electrode touched = LED on).
210
+ def set_touch_led_config(config)
211
+ check_validity
212
+
213
+ send_request FUNCTION_SET_TOUCH_LED_CONFIG, [config], 'C', 8, ''
214
+ end
215
+
216
+ # Returns the LED configuration as set by BrickletMultiTouchV2#set_touch_led_config
217
+ def get_touch_led_config
218
+ check_validity
219
+
220
+ send_request FUNCTION_GET_TOUCH_LED_CONFIG, [], '', 9, 'C'
221
+ end
222
+
223
+ # Returns the error count for the communication between Brick and Bricklet.
224
+ #
225
+ # The errors are divided into
226
+ #
227
+ # * ACK checksum errors,
228
+ # * message checksum errors,
229
+ # * framing errors and
230
+ # * overflow errors.
231
+ #
232
+ # The errors counts are for errors that occur on the Bricklet side. All
233
+ # Bricks have a similar function that returns the errors on the Brick side.
234
+ def get_spitfp_error_count
235
+ check_validity
236
+
237
+ send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 24, 'L L L L'
238
+ end
239
+
240
+ # Sets the bootloader mode and returns the status after the requested
241
+ # mode change was instigated.
242
+ #
243
+ # You can change from bootloader mode to firmware mode and vice versa. A change
244
+ # from bootloader mode to firmware mode will only take place if the entry function,
245
+ # device identifier and CRC are present and correct.
246
+ #
247
+ # This function is used by Brick Viewer during flashing. It should not be
248
+ # necessary to call it in a normal user program.
249
+ def set_bootloader_mode(mode)
250
+ check_validity
251
+
252
+ send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 9, 'C'
253
+ end
254
+
255
+ # Returns the current bootloader mode, see BrickletMultiTouchV2#set_bootloader_mode.
256
+ def get_bootloader_mode
257
+ check_validity
258
+
259
+ send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 9, 'C'
260
+ end
261
+
262
+ # Sets the firmware pointer for BrickletMultiTouchV2#write_firmware. The pointer has
263
+ # to be increased by chunks of size 64. The data is written to flash
264
+ # every 4 chunks (which equals to one page of size 256).
265
+ #
266
+ # This function is used by Brick Viewer during flashing. It should not be
267
+ # necessary to call it in a normal user program.
268
+ def set_write_firmware_pointer(pointer)
269
+ check_validity
270
+
271
+ send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 8, ''
272
+ end
273
+
274
+ # Writes 64 Bytes of firmware at the position as written by
275
+ # BrickletMultiTouchV2#set_write_firmware_pointer before. The firmware is written
276
+ # to flash every 4 chunks.
277
+ #
278
+ # You can only write firmware in bootloader mode.
279
+ #
280
+ # This function is used by Brick Viewer during flashing. It should not be
281
+ # necessary to call it in a normal user program.
282
+ def write_firmware(data)
283
+ check_validity
284
+
285
+ send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 9, 'C'
286
+ end
287
+
288
+ # Sets the status LED configuration. By default the LED shows
289
+ # communication traffic between Brick and Bricklet, it flickers once
290
+ # for every 10 received data packets.
291
+ #
292
+ # You can also turn the LED permanently on/off or show a heartbeat.
293
+ #
294
+ # If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
295
+ def set_status_led_config(config)
296
+ check_validity
297
+
298
+ send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 8, ''
299
+ end
300
+
301
+ # Returns the configuration as set by BrickletMultiTouchV2#set_status_led_config
302
+ def get_status_led_config
303
+ check_validity
304
+
305
+ send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 9, 'C'
306
+ end
307
+
308
+ # Returns the temperature as measured inside the microcontroller. The
309
+ # value returned is not the ambient temperature!
310
+ #
311
+ # The temperature is only proportional to the real temperature and it has bad
312
+ # accuracy. Practically it is only useful as an indicator for
313
+ # temperature changes.
314
+ def get_chip_temperature
315
+ check_validity
316
+
317
+ send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 10, 's'
318
+ end
319
+
320
+ # Calling this function will reset the Bricklet. All configurations
321
+ # will be lost.
322
+ #
323
+ # After a reset you have to create new device objects,
324
+ # calling functions on the existing ones will result in
325
+ # undefined behavior!
326
+ def reset
327
+ check_validity
328
+
329
+ send_request FUNCTION_RESET, [], '', 8, ''
330
+ end
331
+
332
+ # Writes a new UID into flash. If you want to set a new UID
333
+ # you have to decode the Base58 encoded UID string into an
334
+ # integer first.
335
+ #
336
+ # We recommend that you use Brick Viewer to change the UID.
337
+ def write_uid(uid)
338
+ check_validity
339
+
340
+ send_request FUNCTION_WRITE_UID, [uid], 'L', 8, ''
341
+ end
342
+
343
+ # Returns the current UID as an integer. Encode as
344
+ # Base58 to get the usual string version.
345
+ def read_uid
346
+ check_validity
347
+
348
+ send_request FUNCTION_READ_UID, [], '', 12, 'L'
349
+ end
350
+
351
+ # Returns the UID, the UID where the Bricklet is connected to,
352
+ # the position, the hardware and firmware version as well as the
353
+ # device identifier.
354
+ #
355
+ # The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
356
+ # A Bricklet connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always at
357
+ # position 'z'.
358
+ #
359
+ # The device identifier numbers can be found :ref:`here <device_identifier>`.
360
+ # |device_identifier_constant|
361
+ def get_identity
362
+ send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
363
+ end
364
+
365
+ # Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
366
+ def register_callback(id, &block)
367
+ callback = block
368
+ @registered_callbacks[id] = callback
369
+ end
370
+ end
371
+ end