tinderfridge 0.4.0 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/tinderfridge/device.rb +67 -3
- data/lib/tinderfridge/device_collection.rb +52 -0
- data/lib/tinderfridge/device_info.txt +3 -0
- data/lib/tinderfridge/devices/brick_hat/brick_hat.json +11 -0
- data/lib/tinderfridge/devices/{brick_hat.rb → brick_hat/brick_hat.rb} +0 -0
- data/lib/tinderfridge/devices/brick_hat_zero/brick_hat_zero.json +11 -0
- data/lib/tinderfridge/devices/{brick_hat_zero.rb → brick_hat_zero/brick_hat_zero.rb} +0 -0
- data/lib/tinderfridge/devices/bricklet_accelerometer_v2/bricklet_accelerometer_v2.json +11 -0
- data/lib/tinderfridge/devices/bricklet_air_quality/bricklet_air_quality.json +11 -0
- data/lib/tinderfridge/devices/bricklet_air_quality/bricklet_air_quality.rb +20 -0
- data/lib/tinderfridge/devices/bricklet_ambient_light_v3/bricklet_ambient_light_v3.json +10 -0
- data/lib/tinderfridge/devices/bricklet_ambient_light_v3/bricklet_ambient_light_v3.rb +19 -0
- data/lib/tinderfridge/devices/bricklet_analog_in_v3/bricklet_analog_in_v3.json +10 -0
- data/lib/tinderfridge/devices/bricklet_analog_out_v3/bricklet_analog_out_v3.json +11 -0
- data/lib/tinderfridge/devices/bricklet_barometer_v2/bricklet_barometer_v2.json +11 -0
- data/lib/tinderfridge/devices/bricklet_can_v2/bricklet_can_v2.json +11 -0
- data/lib/tinderfridge/devices/bricklet_co2_v2/bricklet_co2_v2.json +10 -0
- data/lib/tinderfridge/devices/bricklet_color_v2/bricklet_color_v2.json +10 -0
- data/lib/tinderfridge/devices/bricklet_color_v2/bricklet_color_v2.rb +31 -0
- data/lib/tinderfridge/devices/bricklet_compass/bricklet_compass.json +10 -0
- data/lib/tinderfridge/devices/bricklet_dc_v2/bricklet_dc_v2.json +11 -0
- data/lib/tinderfridge/devices/bricklet_distance_ir_v2/bricklet_distance_ir_v2.json +11 -0
- data/lib/tinderfridge/devices/bricklet_distance_us_v2/bricklet_distance_us_v2.json +10 -0
- data/lib/tinderfridge/devices/bricklet_dmx/bricklet_dmx.json +10 -0
- data/lib/tinderfridge/devices/{bricklet_dmx.rb → bricklet_dmx/bricklet_dmx.rb} +0 -0
- data/lib/tinderfridge/devices/bricklet_dual_button_v2/bricklet_dual_button_v2.json +11 -0
- data/lib/tinderfridge/devices/bricklet_e_paper_296x128/bricklet_e_paper_296x128.json +10 -0
- data/lib/tinderfridge/devices/bricklet_energy_monitor/bricklet_energy_monitor.json +10 -0
- data/lib/tinderfridge/devices/bricklet_gps_v2/bricklet_gps_v2.json +10 -0
- data/lib/tinderfridge/devices/{bricklet_gps_v2.rb → bricklet_gps_v2/bricklet_gps_v2.rb} +0 -0
- data/lib/tinderfridge/devices/bricklet_hall_effect_v2/bricklet_hall_effect_v2.json +10 -0
- data/lib/tinderfridge/devices/bricklet_humidity_v2/bricklet_humidity_v2.json +10 -0
- data/lib/tinderfridge/devices/bricklet_imu_v3/bricklet_imu_v3.json +10 -0
- data/lib/tinderfridge/devices/bricklet_industrial_analog_out_v2/bricklet_industrial_analog_out_v2.json +11 -0
- data/lib/tinderfridge/devices/bricklet_industrial_counter/bricklet_industrial_counter.json +11 -0
- data/lib/tinderfridge/devices/bricklet_industrial_digital_in_4_v2/bricklet_industrial_digital_in_4_v2.json +11 -0
- data/lib/tinderfridge/devices/bricklet_industrial_digital_out_4_v2/bricklet_industrial_digital_out_4_v2.json +11 -0
- data/lib/tinderfridge/devices/bricklet_industrial_dual_0_20ma_v2/bricklet_industrial_dual_0_20ma_v2.json +11 -0
- data/lib/tinderfridge/devices/bricklet_industrial_dual_ac_relay/bricklet_industrial_dual_ac_relay.json +11 -0
- data/lib/tinderfridge/devices/bricklet_industrial_dual_analog_in_v2/bricklet_industrial_dual_analog_in_v2.json +11 -0
- data/lib/tinderfridge/devices/bricklet_industrial_dual_relay/bricklet_industrial_dual_relay.json +10 -0
- data/lib/tinderfridge/devices/{bricklet_industrial_dual_relay.rb → bricklet_industrial_dual_relay/bricklet_industrial_dual_relay.rb} +0 -0
- data/lib/tinderfridge/devices/bricklet_industrial_ptc/bricklet_industrial_ptc.json +11 -0
- data/lib/tinderfridge/devices/bricklet_industrial_quad_relay_v2/bricklet_industrial_quad_relay_v2.json +11 -0
- data/lib/tinderfridge/devices/bricklet_io16_v2/bricklet_io16_v2.json +11 -0
- data/lib/tinderfridge/devices/bricklet_io4_v2/bricklet_io4_v2.json +11 -0
- data/lib/tinderfridge/devices/bricklet_isolator/bricklet_isolator.json +10 -0
- data/lib/tinderfridge/devices/bricklet_isolator/bricklet_isolator.rb +17 -0
- data/lib/tinderfridge/devices/bricklet_joystick_v2/bricklet_joystick_v2.json +10 -0
- data/lib/tinderfridge/devices/bricklet_joystick_v2/bricklet_joystick_v2.rb +15 -0
- data/lib/tinderfridge/devices/bricklet_laser_range_finder_v2/bricklet_laser_range_finder_v2.json +10 -0
- data/lib/tinderfridge/devices/bricklet_lcd_128x64/bricklet_lcd_128x64.json +10 -0
- data/lib/tinderfridge/devices/{bricklet_lcd_128x64.rb → bricklet_lcd_128x64/bricklet_lcd_128x64.rb} +0 -0
- data/lib/tinderfridge/devices/bricklet_led_strip_v2/bricklet_led_strip_v2.json +11 -0
- data/lib/tinderfridge/devices/{bricklet_led_strip_v2.rb → bricklet_led_strip_v2/bricklet_led_strip_v2.rb} +0 -0
- data/lib/tinderfridge/devices/bricklet_linear_poti_v2/bricklet_linear_poti_v2.json +10 -0
- data/lib/tinderfridge/devices/bricklet_load_cell_v2/bricklet_load_cell_v2.json +11 -0
- data/lib/tinderfridge/devices/bricklet_motion_detector_v2/bricklet_motion_detector_v2.json +10 -0
- data/lib/tinderfridge/devices/bricklet_motion_detector_v2/bricklet_motion_detector_v2.rb +22 -0
- data/lib/tinderfridge/devices/bricklet_motorized_linear_poti/bricklet_motorized_linear_poti.json +10 -0
- data/lib/tinderfridge/devices/bricklet_motorized_linear_poti/bricklet_motorized_linear_poti.rb +42 -0
- data/lib/tinderfridge/devices/bricklet_multi_touch_v2/bricklet_multi_touch_v2.json +10 -0
- data/lib/tinderfridge/devices/{bricklet_multi_touch_v2.rb → bricklet_multi_touch_v2/bricklet_multi_touch_v2.rb} +0 -0
- data/lib/tinderfridge/devices/bricklet_nfc/bricklet_nfc.json +10 -0
- data/lib/tinderfridge/devices/{bricklet_nfc.rb → bricklet_nfc/bricklet_nfc.rb} +0 -0
- data/lib/tinderfridge/devices/bricklet_oled_128x64_v2/bricklet_oled_128x64_v2.json +11 -0
- data/lib/tinderfridge/devices/bricklet_one_wire/bricklet_one_wire.json +11 -0
- data/lib/tinderfridge/devices/bricklet_outdoor_weather/bricklet_outdoor_weather.json +10 -0
- data/lib/tinderfridge/devices/{bricklet_outdoor_weather.rb → bricklet_outdoor_weather/bricklet_outdoor_weather.rb} +0 -0
- data/lib/tinderfridge/devices/bricklet_particulate_matter/bricklet_particulate_matter.json +11 -0
- data/lib/tinderfridge/devices/bricklet_performance_dc/bricklet_performance_dc.json +11 -0
- data/lib/tinderfridge/devices/bricklet_piezo_speaker_v2/bricklet_piezo_speaker_v2.json +10 -0
- data/lib/tinderfridge/devices/bricklet_ptc_v2/bricklet_ptc_v2.json +11 -0
- data/lib/tinderfridge/devices/bricklet_real_time_clock_v2/bricklet_real_time_clock_v2.json +10 -0
- data/lib/tinderfridge/devices/bricklet_remote_switch_v2/bricklet_remote_switch_v2.json +10 -0
- data/lib/tinderfridge/devices/bricklet_remote_switch_v2/bricklet_remote_switch_v2.rb +15 -0
- data/lib/tinderfridge/devices/bricklet_rgb_led_button/bricklet_rgb_led_button.json +10 -0
- data/lib/tinderfridge/devices/{bricklet_rgb_led_button.rb → bricklet_rgb_led_button/bricklet_rgb_led_button.rb} +9 -0
- data/lib/tinderfridge/devices/bricklet_rgb_led_v2/bricklet_rgb_led_v2.json +10 -0
- data/lib/tinderfridge/devices/{bricklet_rgb_led_v2.rb → bricklet_rgb_led_v2/bricklet_rgb_led_v2.rb} +7 -0
- data/lib/tinderfridge/devices/bricklet_rotary_encoder_v2/bricklet_rotary_encoder_v2.json +10 -0
- data/lib/tinderfridge/devices/bricklet_rotary_encoder_v2/bricklet_rotary_encoder_v2.rb +20 -0
- data/lib/tinderfridge/devices/bricklet_rotary_poti_v2/bricklet_rotary_poti_v2.json +10 -0
- data/lib/tinderfridge/devices/bricklet_rs232_v2/bricklet_rs232_v2.json +11 -0
- data/lib/tinderfridge/devices/bricklet_rs485/bricklet_rs485.json +11 -0
- data/lib/tinderfridge/devices/bricklet_segment_display_4x7_v2/bricklet_segment_display_4x7_v2.json +11 -0
- data/lib/tinderfridge/devices/{bricklet_segment_display_4x7_v2.rb → bricklet_segment_display_4x7_v2/bricklet_segment_display_4x7_v2.rb} +23 -1
- data/lib/tinderfridge/devices/bricklet_servo_v2/bricklet_servo_v2.json +11 -0
- data/lib/tinderfridge/devices/bricklet_silent_stepper_v2/bricklet_silent_stepper_v2.json +11 -0
- data/lib/tinderfridge/devices/bricklet_solid_state_relay_v2/bricklet_solid_state_relay_v2.json +11 -0
- data/lib/tinderfridge/devices/bricklet_sound_pressure_level/bricklet_sound_pressure_level.json +10 -0
- data/lib/tinderfridge/devices/bricklet_temperature_ir_v2/bricklet_temperature_ir_v2.json +10 -0
- data/lib/tinderfridge/devices/bricklet_temperature_v2/bricklet_temperature_v2.json +10 -0
- data/lib/tinderfridge/devices/bricklet_thermal_imaging/bricklet_thermal_imaging.json +10 -0
- data/lib/tinderfridge/devices/bricklet_thermocouple_v2/bricklet_thermocouple_v2.json +10 -0
- data/lib/tinderfridge/devices/bricklet_uv_light_v2/bricklet_uv_light_v2.json +10 -0
- data/lib/tinderfridge/devices/bricklet_voltage_current_v2/bricklet_voltage_current_v2.json +10 -0
- data/lib/tinderfridge/devices/bricklet_voltage_current_v2/bricklet_voltage_current_v2.rb +18 -0
- data/lib/tinderfridge/devices/bricklet_xmc1400_breakout/bricklet_xmc1400_breakout.json +10 -0
- data/lib/tinderfridge/ip_connection.rb +56 -4
- data/lib/tinderfridge/tinkerforge.rb +3 -0
- data/lib/tinderfridge/version.rb +1 -1
- metadata +106 -23
data/lib/tinderfridge/devices/bricklet_motorized_linear_poti/bricklet_motorized_linear_poti.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
module Tinkerforge
|
2
|
+
|
3
|
+
class BrickletMotorizedLinearPoti
|
4
|
+
|
5
|
+
# Returns the position of the potentiometer (an integer in the range 0..100).
|
6
|
+
def position
|
7
|
+
get_position
|
8
|
+
end
|
9
|
+
|
10
|
+
# Moves the potentiometer to the given position.
|
11
|
+
#
|
12
|
+
# If the potentiometer was locked before, it will be locked at the new position.
|
13
|
+
# The drive mode (speed) will be the same as the last time the position was set.
|
14
|
+
def position=(position)
|
15
|
+
set_motor_position( position, *get_motor_position[1,2] )
|
16
|
+
end
|
17
|
+
|
18
|
+
alias move_to position=
|
19
|
+
|
20
|
+
# Locks the position of the potentiometer. If a position is given, moves to that position first.
|
21
|
+
def lock(position=nil)
|
22
|
+
set_motor_position( position || get_position, get_motor_position[1], true )
|
23
|
+
end
|
24
|
+
|
25
|
+
alias hold lock
|
26
|
+
|
27
|
+
# Releases the potentiometer, so its position can be changed by hand. If a position is given, moves to that position first.
|
28
|
+
def release(position=nil)
|
29
|
+
set_motor_position( position || get_position, get_motor_position[1], false )
|
30
|
+
end
|
31
|
+
|
32
|
+
# Returns the device's state.
|
33
|
+
def state
|
34
|
+
super.merge(
|
35
|
+
'position' => get_position,
|
36
|
+
'motor_position' => get_motor_position,
|
37
|
+
)
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
File without changes
|
File without changes
|
File without changes
|
@@ -20,6 +20,15 @@ module Tinkerforge
|
|
20
20
|
true
|
21
21
|
end
|
22
22
|
|
23
|
+
# Returns the device's state.
|
24
|
+
def state
|
25
|
+
super.merge(
|
26
|
+
'color_rgb' => get_color,
|
27
|
+
'color_calibration' => get_color_calibration,
|
28
|
+
'pressed' => get_button_state == 0,
|
29
|
+
)
|
30
|
+
end
|
31
|
+
|
23
32
|
end
|
24
33
|
|
25
34
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Tinkerforge
|
2
|
+
|
3
|
+
class BrickletRotaryEncoderV2
|
4
|
+
|
5
|
+
# Returns the current count of the encoder.
|
6
|
+
def count
|
7
|
+
get_count(false)
|
8
|
+
end
|
9
|
+
|
10
|
+
# Returns the device's state.
|
11
|
+
def state
|
12
|
+
super.merge(
|
13
|
+
'count' => count,
|
14
|
+
'pressed' => is_pressed,
|
15
|
+
)
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
data/lib/tinderfridge/devices/bricklet_segment_display_4x7_v2/bricklet_segment_display_4x7_v2.json
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
{
|
2
|
+
"dimensions": [
|
3
|
+
25,
|
4
|
+
65,
|
5
|
+
9
|
6
|
+
],
|
7
|
+
"weight": 11,
|
8
|
+
"documentation_en_url": "https://www.tinkerforge.com/en/doc/Hardware/Bricklets/Segment_Display_4x7_V2.html",
|
9
|
+
"versions_identifier": "bricklets:segment_display_4x7_v2",
|
10
|
+
"released": "2019-05-20"
|
11
|
+
}
|
@@ -12,7 +12,7 @@ module Tinkerforge
|
|
12
12
|
|
13
13
|
# Returns the state of all 35 segments.
|
14
14
|
def segments
|
15
|
-
|
15
|
+
get_segments.flatten
|
16
16
|
end
|
17
17
|
|
18
18
|
# Sets the state of all 35 segments.
|
@@ -123,6 +123,28 @@ module Tinkerforge
|
|
123
123
|
}
|
124
124
|
end
|
125
125
|
|
126
|
+
# Displays an 8-segment bar graph for 1 or 2 values in the range 0..1.
|
127
|
+
#
|
128
|
+
# @example
|
129
|
+
# my_bricklet.bar_graph 0.5
|
130
|
+
# my_bricklet.bar_graph 0.5, 0.8
|
131
|
+
def bar_graph(value1, value2=value1)
|
132
|
+
value1, value2 = [value1, value2].map { |v| (v.to_f.clamp(0,1) * 8).round }
|
133
|
+
|
134
|
+
frame = [false] * 35
|
135
|
+
|
136
|
+
[ 5, 1, 13, 9, 21, 17, 29, 25 ].first(value1).each do |n|
|
137
|
+
frame[n] = true
|
138
|
+
end
|
139
|
+
|
140
|
+
[ 4, 2, 12, 10, 20, 18, 28, 26 ].first(value2).each do |n|
|
141
|
+
frame[n] = true
|
142
|
+
end
|
143
|
+
|
144
|
+
self.segments = frame
|
145
|
+
[value1, value2]
|
146
|
+
end
|
147
|
+
|
126
148
|
end
|
127
149
|
|
128
150
|
end
|