@@ -21,7 +21,8 @@ class ComponentPins(Enum):
21
21
DIGITAL_READ = 14
22
22
JOYSTICK = 16
23
23
ULTRASONIC_SENSOR = 17
24
- RFID = 18
24
+ RFID = 18 ,
25
+ TEMP = 19 ,
25
26
26
27
class ElectroBlocks :
27
28
@@ -156,19 +157,35 @@ def config_joystick(self, x, y, sw):
156
157
157
158
def joystick_angle (self ):
158
159
pin = self .pins [ComponentPins .JOYSTICK ][0 ]
159
- [pressed , angle , engaged ] = self ._find_sensor_str (pin , "js" )
160
+ [pressed , angle , engaged ] = self ._find_sensor_str (pin , "js" ). split ( '-' )
160
161
return angle
161
162
162
163
def is_joystick_button_pressed (self ):
163
164
pin = self .pins [ComponentPins .JOYSTICK ][0 ]
164
- [pressed , angle , engaged ] = self ._find_sensor_str (pin , "js" )
165
+ [pressed , angle , engaged ] = self ._find_sensor_str (pin , "js" ). split ( '-' )
165
166
return pressed
166
167
167
168
def is_joystick_engaged (self ):
168
169
pin = self .pins [ComponentPins .JOYSTICK ][0 ]
169
- [pressed , angle , engaged ] = self ._find_sensor_str (pin , "js" )
170
+ [pressed , angle , engaged ] = self ._find_sensor_str (pin , "js" ). split ( '-' )
170
171
return pressed
171
172
173
+ # Temp
174
+ def config_dht_temp (self , pin , type ):
175
+ tempType = "1" if type == "DHT11" else "2"
176
+ self ._send (f"register::dht::{ pin } ::{ tempType } " )
177
+ self ._add_pin (ComponentPins .TEMP , pin )
178
+
179
+ def dht_temp_celcius (self ):
180
+ pin = self .pins [ComponentPins .TEMP ][0 ]
181
+ [humidity , temp ] = self ._find_sensor_str (pin , "dht" ).split ('-' )
182
+ return temp
183
+
184
+ def dht_temp_humidity (self ):
185
+ pin = self .pins [ComponentPins .TEMP ][0 ]
186
+ [humidity , temp ] = self ._find_sensor_str (pin , "dht" ).split ('-' )
187
+ return humidity
188
+
172
189
173
190
#IR Remote
174
191
0 commit comments