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
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 7992b4183f407bb3f941b2a6e526f8b5825797451a3a3df1b947203681934df5
|
|
4
|
+
data.tar.gz: c9d4b8d0945b8b25cd656d2041fc923ba7055780d4e52b04a94accd344d1f2f8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 11b45fd4643794ab3f53e8c5a534f0f31c1f2b8853c33bd3eda85ecd0a2441e3c698ea50a99e4762ac1a49f6baf92d968cd461571215b9d78d1b3eb32d6c1b0f
|
|
7
|
+
data.tar.gz: d6dddff82d677f23a37b09f19e4c47ab8ed2c4d3ff1452262d4c38e0a67618da68e73431a822d9acf2c95991883cc96115a00764525f4a46a865b0867ceadcd5
|
data/lib/tinkerforge/brick_dc.rb
CHANGED
|
@@ -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,256 @@
|
|
|
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
|
+
# HAT for Raspberry Pi with 8 Bricklets ports and real-time clock
|
|
14
|
+
class BrickHAT < Device
|
|
15
|
+
DEVICE_IDENTIFIER = 111 # :nodoc:
|
|
16
|
+
DEVICE_DISPLAY_NAME = 'HAT Brick' # :nodoc:
|
|
17
|
+
|
|
18
|
+
FUNCTION_SET_SLEEP_MODE = 1 # :nodoc:
|
|
19
|
+
FUNCTION_GET_SLEEP_MODE = 2 # :nodoc:
|
|
20
|
+
FUNCTION_SET_BRICKLET_POWER = 3 # :nodoc:
|
|
21
|
+
FUNCTION_GET_BRICKLET_POWER = 4 # :nodoc:
|
|
22
|
+
FUNCTION_GET_VOLTAGES = 5 # :nodoc:
|
|
23
|
+
FUNCTION_GET_SPITFP_ERROR_COUNT = 234 # :nodoc:
|
|
24
|
+
FUNCTION_SET_BOOTLOADER_MODE = 235 # :nodoc:
|
|
25
|
+
FUNCTION_GET_BOOTLOADER_MODE = 236 # :nodoc:
|
|
26
|
+
FUNCTION_SET_WRITE_FIRMWARE_POINTER = 237 # :nodoc:
|
|
27
|
+
FUNCTION_WRITE_FIRMWARE = 238 # :nodoc:
|
|
28
|
+
FUNCTION_SET_STATUS_LED_CONFIG = 239 # :nodoc:
|
|
29
|
+
FUNCTION_GET_STATUS_LED_CONFIG = 240 # :nodoc:
|
|
30
|
+
FUNCTION_GET_CHIP_TEMPERATURE = 242 # :nodoc:
|
|
31
|
+
FUNCTION_RESET = 243 # :nodoc:
|
|
32
|
+
FUNCTION_WRITE_UID = 248 # :nodoc:
|
|
33
|
+
FUNCTION_READ_UID = 249 # :nodoc:
|
|
34
|
+
FUNCTION_GET_IDENTITY = 255 # :nodoc:
|
|
35
|
+
|
|
36
|
+
BOOTLOADER_MODE_BOOTLOADER = 0 # :nodoc:
|
|
37
|
+
BOOTLOADER_MODE_FIRMWARE = 1 # :nodoc:
|
|
38
|
+
BOOTLOADER_MODE_BOOTLOADER_WAIT_FOR_REBOOT = 2 # :nodoc:
|
|
39
|
+
BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_REBOOT = 3 # :nodoc:
|
|
40
|
+
BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_ERASE_AND_REBOOT = 4 # :nodoc:
|
|
41
|
+
BOOTLOADER_STATUS_OK = 0 # :nodoc:
|
|
42
|
+
BOOTLOADER_STATUS_INVALID_MODE = 1 # :nodoc:
|
|
43
|
+
BOOTLOADER_STATUS_NO_CHANGE = 2 # :nodoc:
|
|
44
|
+
BOOTLOADER_STATUS_ENTRY_FUNCTION_NOT_PRESENT = 3 # :nodoc:
|
|
45
|
+
BOOTLOADER_STATUS_DEVICE_IDENTIFIER_INCORRECT = 4 # :nodoc:
|
|
46
|
+
BOOTLOADER_STATUS_CRC_MISMATCH = 5 # :nodoc:
|
|
47
|
+
STATUS_LED_CONFIG_OFF = 0 # :nodoc:
|
|
48
|
+
STATUS_LED_CONFIG_ON = 1 # :nodoc:
|
|
49
|
+
STATUS_LED_CONFIG_SHOW_HEARTBEAT = 2 # :nodoc:
|
|
50
|
+
STATUS_LED_CONFIG_SHOW_STATUS = 3 # :nodoc:
|
|
51
|
+
|
|
52
|
+
# Creates an object with the unique device ID <tt>uid</tt> and adds it to
|
|
53
|
+
# the IP Connection <tt>ipcon</tt>.
|
|
54
|
+
def initialize(uid, ipcon)
|
|
55
|
+
super uid, ipcon
|
|
56
|
+
|
|
57
|
+
@api_version = [2, 0, 0]
|
|
58
|
+
|
|
59
|
+
@response_expected[FUNCTION_SET_SLEEP_MODE] = RESPONSE_EXPECTED_FALSE
|
|
60
|
+
@response_expected[FUNCTION_GET_SLEEP_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
61
|
+
@response_expected[FUNCTION_SET_BRICKLET_POWER] = RESPONSE_EXPECTED_FALSE
|
|
62
|
+
@response_expected[FUNCTION_GET_BRICKLET_POWER] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
63
|
+
@response_expected[FUNCTION_GET_VOLTAGES] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
64
|
+
@response_expected[FUNCTION_GET_SPITFP_ERROR_COUNT] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
65
|
+
@response_expected[FUNCTION_SET_BOOTLOADER_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
66
|
+
@response_expected[FUNCTION_GET_BOOTLOADER_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
67
|
+
@response_expected[FUNCTION_SET_WRITE_FIRMWARE_POINTER] = RESPONSE_EXPECTED_FALSE
|
|
68
|
+
@response_expected[FUNCTION_WRITE_FIRMWARE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
69
|
+
@response_expected[FUNCTION_SET_STATUS_LED_CONFIG] = RESPONSE_EXPECTED_FALSE
|
|
70
|
+
@response_expected[FUNCTION_GET_STATUS_LED_CONFIG] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
71
|
+
@response_expected[FUNCTION_GET_CHIP_TEMPERATURE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
72
|
+
@response_expected[FUNCTION_RESET] = RESPONSE_EXPECTED_FALSE
|
|
73
|
+
@response_expected[FUNCTION_WRITE_UID] = RESPONSE_EXPECTED_FALSE
|
|
74
|
+
@response_expected[FUNCTION_READ_UID] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
75
|
+
@response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
# Sets the sleep mode.
|
|
81
|
+
#
|
|
82
|
+
# Parameters:
|
|
83
|
+
#
|
|
84
|
+
# * Power Off Delay: Time before the RPi/Bricklets are powered off in seconds.
|
|
85
|
+
# * Power Off Duration: Duration that the RPi/Bricklets stay powered off in seconds.
|
|
86
|
+
# * Raspberry Pi Off: RPi if powereed off if set to true.
|
|
87
|
+
# * Bricklets Off: Bricklets are powered off if set to true.
|
|
88
|
+
# * Enable Sleep Indicator: If set to true, the status LED will blink in a 1s interval
|
|
89
|
+
# during the whole power off duration. This will draw an additional 0.3mA.
|
|
90
|
+
#
|
|
91
|
+
# Example: To turn RPi and Bricklets off in 5 seconds for 10 minutes with sleep
|
|
92
|
+
# indicator enabled call (5, 60*10, true, true, true).
|
|
93
|
+
#
|
|
94
|
+
# This function can also be used to implement a watchdog. To do this you can
|
|
95
|
+
# write a program that calls this function once per second in a loop with
|
|
96
|
+
# (10, 2, true, false, false). If the RPi crashes or gets stuck
|
|
97
|
+
# the HAT will reset the RPi after 10 seconds.
|
|
98
|
+
def set_sleep_mode(power_off_delay, power_off_duration, raspberry_pi_off, bricklets_off, enable_sleep_indicator)
|
|
99
|
+
send_request FUNCTION_SET_SLEEP_MODE, [power_off_delay, power_off_duration, raspberry_pi_off, bricklets_off, enable_sleep_indicator], 'L L ? ? ?', 0, ''
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
# Returns the sleep mode settings as set by BrickHAT#set_sleep_mode.
|
|
103
|
+
def get_sleep_mode
|
|
104
|
+
send_request FUNCTION_GET_SLEEP_MODE, [], '', 11, 'L L ? ? ?'
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
# Set to true/false to turn the power supply of the connected Bricklets on/off.
|
|
108
|
+
#
|
|
109
|
+
# By default the Bricklets are on.
|
|
110
|
+
def set_bricklet_power(bricklet_power)
|
|
111
|
+
send_request FUNCTION_SET_BRICKLET_POWER, [bricklet_power], '?', 0, ''
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
# Returns the power status of the connected Bricklets as set by BrickHAT#set_bricklet_power.
|
|
115
|
+
def get_bricklet_power
|
|
116
|
+
send_request FUNCTION_GET_BRICKLET_POWER, [], '', 1, '?'
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
# Returns the USB supply voltage and the DC input supply voltage in mV.
|
|
120
|
+
#
|
|
121
|
+
# There are three possible combinations:
|
|
122
|
+
#
|
|
123
|
+
# * Only USB connected: The USB supply voltage will be fed back to the
|
|
124
|
+
# DC input connector. You will read the USB voltage and a slightly lower
|
|
125
|
+
# voltage on the DC input.
|
|
126
|
+
# * Only DC input connected: The DC voltage will not be fed back to the
|
|
127
|
+
# USB connector. You will read the DC input voltage and the USB voltage
|
|
128
|
+
# will be 0.
|
|
129
|
+
# * USB and DC input connected: You will read both voltages. In this case
|
|
130
|
+
# the USB supply will be without load, but it will work as backup if you
|
|
131
|
+
# disconnect the DC input (or if the DC input voltage falls below the
|
|
132
|
+
# USB voltage).
|
|
133
|
+
def get_voltages
|
|
134
|
+
send_request FUNCTION_GET_VOLTAGES, [], '', 4, 'S S'
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
# Returns the error count for the communication between Brick and Bricklet.
|
|
138
|
+
#
|
|
139
|
+
# The errors are divided into
|
|
140
|
+
#
|
|
141
|
+
# * ACK checksum errors,
|
|
142
|
+
# * message checksum errors,
|
|
143
|
+
# * framing errors and
|
|
144
|
+
# * overflow errors.
|
|
145
|
+
#
|
|
146
|
+
# The errors counts are for errors that occur on the Bricklet side. All
|
|
147
|
+
# Bricks have a similar function that returns the errors on the Brick side.
|
|
148
|
+
def get_spitfp_error_count
|
|
149
|
+
send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 16, 'L L L L'
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
# Sets the bootloader mode and returns the status after the requested
|
|
153
|
+
# mode change was instigated.
|
|
154
|
+
#
|
|
155
|
+
# You can change from bootloader mode to firmware mode and vice versa. A change
|
|
156
|
+
# from bootloader mode to firmware mode will only take place if the entry function,
|
|
157
|
+
# device identifier and CRC are present and correct.
|
|
158
|
+
#
|
|
159
|
+
# This function is used by Brick Viewer during flashing. It should not be
|
|
160
|
+
# necessary to call it in a normal user program.
|
|
161
|
+
def set_bootloader_mode(mode)
|
|
162
|
+
send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 1, 'C'
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
# Returns the current bootloader mode, see BrickHAT#set_bootloader_mode.
|
|
166
|
+
def get_bootloader_mode
|
|
167
|
+
send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 1, 'C'
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
# Sets the firmware pointer for BrickHAT#write_firmware. The pointer has
|
|
171
|
+
# to be increased by chunks of size 64. The data is written to flash
|
|
172
|
+
# every 4 chunks (which equals to one page of size 256).
|
|
173
|
+
#
|
|
174
|
+
# This function is used by Brick Viewer during flashing. It should not be
|
|
175
|
+
# necessary to call it in a normal user program.
|
|
176
|
+
def set_write_firmware_pointer(pointer)
|
|
177
|
+
send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 0, ''
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
# Writes 64 Bytes of firmware at the position as written by
|
|
181
|
+
# BrickHAT#set_write_firmware_pointer before. The firmware is written
|
|
182
|
+
# to flash every 4 chunks.
|
|
183
|
+
#
|
|
184
|
+
# You can only write firmware in bootloader mode.
|
|
185
|
+
#
|
|
186
|
+
# This function is used by Brick Viewer during flashing. It should not be
|
|
187
|
+
# necessary to call it in a normal user program.
|
|
188
|
+
def write_firmware(data)
|
|
189
|
+
send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 1, 'C'
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
# Sets the status LED configuration. By default the LED shows
|
|
193
|
+
# communication traffic between Brick and Bricklet, it flickers once
|
|
194
|
+
# for every 10 received data packets.
|
|
195
|
+
#
|
|
196
|
+
# You can also turn the LED permanently on/off or show a heartbeat.
|
|
197
|
+
#
|
|
198
|
+
# If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
|
|
199
|
+
def set_status_led_config(config)
|
|
200
|
+
send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 0, ''
|
|
201
|
+
end
|
|
202
|
+
|
|
203
|
+
# Returns the configuration as set by BrickHAT#set_status_led_config
|
|
204
|
+
def get_status_led_config
|
|
205
|
+
send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 1, 'C'
|
|
206
|
+
end
|
|
207
|
+
|
|
208
|
+
# Returns the temperature in °C as measured inside the microcontroller. The
|
|
209
|
+
# value returned is not the ambient temperature!
|
|
210
|
+
#
|
|
211
|
+
# The temperature is only proportional to the real temperature and it has bad
|
|
212
|
+
# accuracy. Practically it is only useful as an indicator for
|
|
213
|
+
# temperature changes.
|
|
214
|
+
def get_chip_temperature
|
|
215
|
+
send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 2, 's'
|
|
216
|
+
end
|
|
217
|
+
|
|
218
|
+
# Calling this function will reset the Bricklet. All configurations
|
|
219
|
+
# will be lost.
|
|
220
|
+
#
|
|
221
|
+
# After a reset you have to create new device objects,
|
|
222
|
+
# calling functions on the existing ones will result in
|
|
223
|
+
# undefined behavior!
|
|
224
|
+
def reset
|
|
225
|
+
send_request FUNCTION_RESET, [], '', 0, ''
|
|
226
|
+
end
|
|
227
|
+
|
|
228
|
+
# Writes a new UID into flash. If you want to set a new UID
|
|
229
|
+
# you have to decode the Base58 encoded UID string into an
|
|
230
|
+
# integer first.
|
|
231
|
+
#
|
|
232
|
+
# We recommend that you use Brick Viewer to change the UID.
|
|
233
|
+
def write_uid(uid)
|
|
234
|
+
send_request FUNCTION_WRITE_UID, [uid], 'L', 0, ''
|
|
235
|
+
end
|
|
236
|
+
|
|
237
|
+
# Returns the current UID as an integer. Encode as
|
|
238
|
+
# Base58 to get the usual string version.
|
|
239
|
+
def read_uid
|
|
240
|
+
send_request FUNCTION_READ_UID, [], '', 4, 'L'
|
|
241
|
+
end
|
|
242
|
+
|
|
243
|
+
# Returns the UID, the UID where the Bricklet is connected to,
|
|
244
|
+
# the position, the hardware and firmware version as well as the
|
|
245
|
+
# device identifier.
|
|
246
|
+
#
|
|
247
|
+
# The position can be 'a', 'b', 'c' or 'd'.
|
|
248
|
+
#
|
|
249
|
+
# The device identifier numbers can be found :ref:`here <device_identifier>`.
|
|
250
|
+
# |device_identifier_constant|
|
|
251
|
+
def get_identity
|
|
252
|
+
send_request FUNCTION_GET_IDENTITY, [], '', 25, 'Z8 Z8 k C3 C3 S'
|
|
253
|
+
end
|
|
254
|
+
|
|
255
|
+
end
|
|
256
|
+
end
|
|
@@ -0,0 +1,196 @@
|
|
|
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
|
+
# HAT for Raspberry Pi Zero with 4 Bricklets ports
|
|
14
|
+
class BrickHATZero < Device
|
|
15
|
+
DEVICE_IDENTIFIER = 112 # :nodoc:
|
|
16
|
+
DEVICE_DISPLAY_NAME = 'HAT Zero Brick' # :nodoc:
|
|
17
|
+
|
|
18
|
+
FUNCTION_GET_USB_VOLTAGE = 1 # :nodoc:
|
|
19
|
+
FUNCTION_GET_SPITFP_ERROR_COUNT = 234 # :nodoc:
|
|
20
|
+
FUNCTION_SET_BOOTLOADER_MODE = 235 # :nodoc:
|
|
21
|
+
FUNCTION_GET_BOOTLOADER_MODE = 236 # :nodoc:
|
|
22
|
+
FUNCTION_SET_WRITE_FIRMWARE_POINTER = 237 # :nodoc:
|
|
23
|
+
FUNCTION_WRITE_FIRMWARE = 238 # :nodoc:
|
|
24
|
+
FUNCTION_SET_STATUS_LED_CONFIG = 239 # :nodoc:
|
|
25
|
+
FUNCTION_GET_STATUS_LED_CONFIG = 240 # :nodoc:
|
|
26
|
+
FUNCTION_GET_CHIP_TEMPERATURE = 242 # :nodoc:
|
|
27
|
+
FUNCTION_RESET = 243 # :nodoc:
|
|
28
|
+
FUNCTION_WRITE_UID = 248 # :nodoc:
|
|
29
|
+
FUNCTION_READ_UID = 249 # :nodoc:
|
|
30
|
+
FUNCTION_GET_IDENTITY = 255 # :nodoc:
|
|
31
|
+
|
|
32
|
+
BOOTLOADER_MODE_BOOTLOADER = 0 # :nodoc:
|
|
33
|
+
BOOTLOADER_MODE_FIRMWARE = 1 # :nodoc:
|
|
34
|
+
BOOTLOADER_MODE_BOOTLOADER_WAIT_FOR_REBOOT = 2 # :nodoc:
|
|
35
|
+
BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_REBOOT = 3 # :nodoc:
|
|
36
|
+
BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_ERASE_AND_REBOOT = 4 # :nodoc:
|
|
37
|
+
BOOTLOADER_STATUS_OK = 0 # :nodoc:
|
|
38
|
+
BOOTLOADER_STATUS_INVALID_MODE = 1 # :nodoc:
|
|
39
|
+
BOOTLOADER_STATUS_NO_CHANGE = 2 # :nodoc:
|
|
40
|
+
BOOTLOADER_STATUS_ENTRY_FUNCTION_NOT_PRESENT = 3 # :nodoc:
|
|
41
|
+
BOOTLOADER_STATUS_DEVICE_IDENTIFIER_INCORRECT = 4 # :nodoc:
|
|
42
|
+
BOOTLOADER_STATUS_CRC_MISMATCH = 5 # :nodoc:
|
|
43
|
+
STATUS_LED_CONFIG_OFF = 0 # :nodoc:
|
|
44
|
+
STATUS_LED_CONFIG_ON = 1 # :nodoc:
|
|
45
|
+
STATUS_LED_CONFIG_SHOW_HEARTBEAT = 2 # :nodoc:
|
|
46
|
+
STATUS_LED_CONFIG_SHOW_STATUS = 3 # :nodoc:
|
|
47
|
+
|
|
48
|
+
# Creates an object with the unique device ID <tt>uid</tt> and adds it to
|
|
49
|
+
# the IP Connection <tt>ipcon</tt>.
|
|
50
|
+
def initialize(uid, ipcon)
|
|
51
|
+
super uid, ipcon
|
|
52
|
+
|
|
53
|
+
@api_version = [2, 0, 0]
|
|
54
|
+
|
|
55
|
+
@response_expected[FUNCTION_GET_USB_VOLTAGE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
56
|
+
@response_expected[FUNCTION_GET_SPITFP_ERROR_COUNT] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
57
|
+
@response_expected[FUNCTION_SET_BOOTLOADER_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
58
|
+
@response_expected[FUNCTION_GET_BOOTLOADER_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
59
|
+
@response_expected[FUNCTION_SET_WRITE_FIRMWARE_POINTER] = RESPONSE_EXPECTED_FALSE
|
|
60
|
+
@response_expected[FUNCTION_WRITE_FIRMWARE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
61
|
+
@response_expected[FUNCTION_SET_STATUS_LED_CONFIG] = RESPONSE_EXPECTED_FALSE
|
|
62
|
+
@response_expected[FUNCTION_GET_STATUS_LED_CONFIG] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
63
|
+
@response_expected[FUNCTION_GET_CHIP_TEMPERATURE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
64
|
+
@response_expected[FUNCTION_RESET] = RESPONSE_EXPECTED_FALSE
|
|
65
|
+
@response_expected[FUNCTION_WRITE_UID] = RESPONSE_EXPECTED_FALSE
|
|
66
|
+
@response_expected[FUNCTION_READ_UID] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
67
|
+
@response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
# Returns the USB supply voltage of the Raspberry Pi in mV.
|
|
73
|
+
def get_usb_voltage
|
|
74
|
+
send_request FUNCTION_GET_USB_VOLTAGE, [], '', 2, 'S'
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
# Returns the error count for the communication between Brick and Bricklet.
|
|
78
|
+
#
|
|
79
|
+
# The errors are divided into
|
|
80
|
+
#
|
|
81
|
+
# * ACK checksum errors,
|
|
82
|
+
# * message checksum errors,
|
|
83
|
+
# * framing errors and
|
|
84
|
+
# * overflow errors.
|
|
85
|
+
#
|
|
86
|
+
# The errors counts are for errors that occur on the Bricklet side. All
|
|
87
|
+
# Bricks have a similar function that returns the errors on the Brick side.
|
|
88
|
+
def get_spitfp_error_count
|
|
89
|
+
send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 16, 'L L L L'
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
# Sets the bootloader mode and returns the status after the requested
|
|
93
|
+
# mode change was instigated.
|
|
94
|
+
#
|
|
95
|
+
# You can change from bootloader mode to firmware mode and vice versa. A change
|
|
96
|
+
# from bootloader mode to firmware mode will only take place if the entry function,
|
|
97
|
+
# device identifier and CRC are present and correct.
|
|
98
|
+
#
|
|
99
|
+
# This function is used by Brick Viewer during flashing. It should not be
|
|
100
|
+
# necessary to call it in a normal user program.
|
|
101
|
+
def set_bootloader_mode(mode)
|
|
102
|
+
send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 1, 'C'
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
# Returns the current bootloader mode, see BrickHATZero#set_bootloader_mode.
|
|
106
|
+
def get_bootloader_mode
|
|
107
|
+
send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 1, 'C'
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
# Sets the firmware pointer for BrickHATZero#write_firmware. The pointer has
|
|
111
|
+
# to be increased by chunks of size 64. The data is written to flash
|
|
112
|
+
# every 4 chunks (which equals to one page of size 256).
|
|
113
|
+
#
|
|
114
|
+
# This function is used by Brick Viewer during flashing. It should not be
|
|
115
|
+
# necessary to call it in a normal user program.
|
|
116
|
+
def set_write_firmware_pointer(pointer)
|
|
117
|
+
send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 0, ''
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
# Writes 64 Bytes of firmware at the position as written by
|
|
121
|
+
# BrickHATZero#set_write_firmware_pointer before. The firmware is written
|
|
122
|
+
# to flash every 4 chunks.
|
|
123
|
+
#
|
|
124
|
+
# You can only write firmware in bootloader mode.
|
|
125
|
+
#
|
|
126
|
+
# This function is used by Brick Viewer during flashing. It should not be
|
|
127
|
+
# necessary to call it in a normal user program.
|
|
128
|
+
def write_firmware(data)
|
|
129
|
+
send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 1, 'C'
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
# Sets the status LED configuration. By default the LED shows
|
|
133
|
+
# communication traffic between Brick and Bricklet, it flickers once
|
|
134
|
+
# for every 10 received data packets.
|
|
135
|
+
#
|
|
136
|
+
# You can also turn the LED permanently on/off or show a heartbeat.
|
|
137
|
+
#
|
|
138
|
+
# If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
|
|
139
|
+
def set_status_led_config(config)
|
|
140
|
+
send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 0, ''
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
# Returns the configuration as set by BrickHATZero#set_status_led_config
|
|
144
|
+
def get_status_led_config
|
|
145
|
+
send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 1, 'C'
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
# Returns the temperature in °C as measured inside the microcontroller. The
|
|
149
|
+
# value returned is not the ambient temperature!
|
|
150
|
+
#
|
|
151
|
+
# The temperature is only proportional to the real temperature and it has bad
|
|
152
|
+
# accuracy. Practically it is only useful as an indicator for
|
|
153
|
+
# temperature changes.
|
|
154
|
+
def get_chip_temperature
|
|
155
|
+
send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 2, 's'
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
# Calling this function will reset the Bricklet. All configurations
|
|
159
|
+
# will be lost.
|
|
160
|
+
#
|
|
161
|
+
# After a reset you have to create new device objects,
|
|
162
|
+
# calling functions on the existing ones will result in
|
|
163
|
+
# undefined behavior!
|
|
164
|
+
def reset
|
|
165
|
+
send_request FUNCTION_RESET, [], '', 0, ''
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
# Writes a new UID into flash. If you want to set a new UID
|
|
169
|
+
# you have to decode the Base58 encoded UID string into an
|
|
170
|
+
# integer first.
|
|
171
|
+
#
|
|
172
|
+
# We recommend that you use Brick Viewer to change the UID.
|
|
173
|
+
def write_uid(uid)
|
|
174
|
+
send_request FUNCTION_WRITE_UID, [uid], 'L', 0, ''
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
# Returns the current UID as an integer. Encode as
|
|
178
|
+
# Base58 to get the usual string version.
|
|
179
|
+
def read_uid
|
|
180
|
+
send_request FUNCTION_READ_UID, [], '', 4, 'L'
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
# Returns the UID, the UID where the Bricklet is connected to,
|
|
184
|
+
# the position, the hardware and firmware version as well as the
|
|
185
|
+
# device identifier.
|
|
186
|
+
#
|
|
187
|
+
# The position can be 'a', 'b', 'c' or 'd'.
|
|
188
|
+
#
|
|
189
|
+
# The device identifier numbers can be found :ref:`here <device_identifier>`.
|
|
190
|
+
# |device_identifier_constant|
|
|
191
|
+
def get_identity
|
|
192
|
+
send_request FUNCTION_GET_IDENTITY, [], '', 25, 'Z8 Z8 k C3 C3 S'
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
end
|
|
196
|
+
end
|