tinderfridge 0.2.0 → 0.7.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 +95 -1
- data/lib/tinderfridge/device_collection.rb +69 -0
- data/lib/tinderfridge/device_info.txt +5 -0
- data/lib/tinderfridge/devices/brick_hat/brick_hat.json +11 -0
- data/lib/tinderfridge/devices/brick_hat/brick_hat.rb +18 -0
- data/lib/tinderfridge/devices/brick_hat_zero/brick_hat_zero.json +11 -0
- data/lib/tinderfridge/devices/brick_hat_zero/brick_hat_zero.rb +14 -0
- data/lib/tinderfridge/devices/bricklet_air_quality/bricklet_air_quality.json +10 -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 +10 -0
- data/lib/tinderfridge/devices/bricklet_barometer_v2/bricklet_barometer_v2.json +10 -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_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/bricklet_dmx.rb +18 -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_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_relay/bricklet_industrial_dual_relay.json +10 -0
- data/lib/tinderfridge/devices/bricklet_industrial_dual_relay/bricklet_industrial_dual_relay.rb +20 -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_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 +10 -0
- data/lib/tinderfridge/devices/{bricklet_led_strip_v2.rb → bricklet_led_strip_v2/bricklet_led_strip_v2.rb} +12 -0
- data/lib/tinderfridge/devices/bricklet_linear_poti_v2/bricklet_linear_poti_v2.json +10 -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/bricklet_multi_touch_v2.rb +16 -0
- data/lib/tinderfridge/devices/bricklet_nfc/bricklet_nfc.json +10 -0
- data/lib/tinderfridge/devices/bricklet_nfc/bricklet_nfc.rb +16 -0
- data/lib/tinderfridge/devices/bricklet_oled_128x64_v2/bricklet_oled_128x64_v2.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_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_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 +10 -0
- data/lib/tinderfridge/devices/bricklet_segment_display_4x7_v2/bricklet_segment_display_4x7_v2.rb +128 -0
- 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_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 +66 -10
- data/lib/tinderfridge/tinkerforge.rb +3 -0
- data/lib/tinderfridge/version.rb +1 -1
- metadata +98 -17
- data/lib/tinderfridge/devices/bricklet_segment_display_4x7_v2.rb +0 -20
@@ -0,0 +1,16 @@
|
|
1
|
+
module Tinkerforge
|
2
|
+
|
3
|
+
class BrickletMultiTouchV2
|
4
|
+
|
5
|
+
# Returns the device's state.
|
6
|
+
def state
|
7
|
+
super.merge(
|
8
|
+
'electrode_config' => get_electrode_config.map { |c| c ? '1' : '0' }.join,
|
9
|
+
'electrode_sensitivity' => get_electrode_sensitivity,
|
10
|
+
'touch_led_config' => get_touch_led_config,
|
11
|
+
)
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Tinkerforge
|
2
|
+
|
3
|
+
class BrickletNFC
|
4
|
+
|
5
|
+
# Returns the device's state.
|
6
|
+
def state
|
7
|
+
super.merge(
|
8
|
+
'mode' => get_mode,
|
9
|
+
'detection_led_config' => get_detection_led_config,
|
10
|
+
'maximum_timeout' => get_maximum_timeout,
|
11
|
+
)
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
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.rb
ADDED
@@ -0,0 +1,128 @@
|
|
1
|
+
module Tinkerforge
|
2
|
+
|
3
|
+
class BrickletSegmentDisplay4x7V2
|
4
|
+
|
5
|
+
# Clears the display.
|
6
|
+
def clear
|
7
|
+
set_segments [false]*8, [false]*8, [false]*8, [false]*8, [false]*2, false
|
8
|
+
true
|
9
|
+
end
|
10
|
+
|
11
|
+
alias blackout clear
|
12
|
+
|
13
|
+
# Returns the state of all 35 segments.
|
14
|
+
def segments
|
15
|
+
send_request FUNCTION_GET_SEGMENTS, [], '', 14, '?35'
|
16
|
+
end
|
17
|
+
|
18
|
+
# Sets the state of all 35 segments.
|
19
|
+
def segments=(*segments)
|
20
|
+
segs = segments.flatten
|
21
|
+
set_segments segs[0,8], segs[8,8], segs[16,8], segs[24,8], segs[32,2], segs[34]
|
22
|
+
end
|
23
|
+
|
24
|
+
# Returns the state of all 35 segments as a string of 1s and 0s.
|
25
|
+
def segments_string
|
26
|
+
segments.map { |s| s ? '1' : '0' }.join
|
27
|
+
end
|
28
|
+
|
29
|
+
# Sets the state of all 35 segments using a string of 1s and 0s.
|
30
|
+
#
|
31
|
+
# For readability, the string may include spaces and underscores, which will be ignored.
|
32
|
+
# @example
|
33
|
+
# my_bricklet.segments_string = '10000110 11000110 11000110 00000110 00 0'
|
34
|
+
def segments_string=(segments)
|
35
|
+
self.segments = segments.gsub(/[ _]/, '').ljust(35, '0').chars.map { |s| s == '1' }
|
36
|
+
end
|
37
|
+
|
38
|
+
# Returns the device's state.
|
39
|
+
def state
|
40
|
+
super.merge( 'brightness' => get_brightness )
|
41
|
+
end
|
42
|
+
|
43
|
+
# Displays a string.
|
44
|
+
def print(text='')
|
45
|
+
out = ''
|
46
|
+
colon = false
|
47
|
+
|
48
|
+
text.to_s.chars.each do |c|
|
49
|
+
if glyphs.key? c
|
50
|
+
out << glyphs[c] << '0'
|
51
|
+
elsif c == '.' and out[-1] == '0'
|
52
|
+
out[-1] = '1'
|
53
|
+
elsif c == ':' and out.size == 16
|
54
|
+
colon = true
|
55
|
+
else
|
56
|
+
raise "Can not display '#{text}'"
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
self.segments_string = out[0,32].ljust(32,'0') + ( colon ? '110' : '000' )
|
61
|
+
nil
|
62
|
+
end
|
63
|
+
|
64
|
+
# Returns the definition of glyphs for Unicode chracters.
|
65
|
+
def glyphs
|
66
|
+
@@glyphs ||= {
|
67
|
+
|
68
|
+
'0' => '1111110',
|
69
|
+
'1' => '0110000',
|
70
|
+
'2' => '1101101',
|
71
|
+
'3' => '1111001',
|
72
|
+
'4' => '0110011',
|
73
|
+
'5' => '1011011',
|
74
|
+
'6' => '1011111',
|
75
|
+
'7' => '1110000',
|
76
|
+
'8' => '1111111',
|
77
|
+
'9' => '1111011',
|
78
|
+
|
79
|
+
'A' => '1110111',
|
80
|
+
'b' => '0011111',
|
81
|
+
'c' => '0001101',
|
82
|
+
'C' => '1001110',
|
83
|
+
'd' => '0111101',
|
84
|
+
'E' => '1001111',
|
85
|
+
'F' => '1000111',
|
86
|
+
'G' => '1011110',
|
87
|
+
'H' => '0110111',
|
88
|
+
'h' => '0010111',
|
89
|
+
'I' => '0110000',
|
90
|
+
'i' => '0010000',
|
91
|
+
'J' => '0111000',
|
92
|
+
'L' => '0001110',
|
93
|
+
'l' => '0001100',
|
94
|
+
'n' => '0010101',
|
95
|
+
'O' => '1111110',
|
96
|
+
'o' => '0011101',
|
97
|
+
'P' => '1100111',
|
98
|
+
'q' => '1110011',
|
99
|
+
'r' => '0000101',
|
100
|
+
'S' => '1011011',
|
101
|
+
't' => '0001111',
|
102
|
+
'U' => '0111110',
|
103
|
+
'u' => '0011100',
|
104
|
+
'V' => '0111110',
|
105
|
+
'v' => '0011100',
|
106
|
+
'y' => '0110011',
|
107
|
+
|
108
|
+
'ö' => '1011101',
|
109
|
+
'ü' => '1011100',
|
110
|
+
|
111
|
+
' ' => '0000000',
|
112
|
+
|
113
|
+
'_' => '0001000',
|
114
|
+
'-' => '0000001',
|
115
|
+
'=' => '0001001',
|
116
|
+
|
117
|
+
'(' => '1001110',
|
118
|
+
')' => '1111000',
|
119
|
+
|
120
|
+
'[' => '1001110',
|
121
|
+
']' => '1111000',
|
122
|
+
|
123
|
+
}
|
124
|
+
end
|
125
|
+
|
126
|
+
end
|
127
|
+
|
128
|
+
end
|