@@ -24,6 +24,7 @@ class ComponentPins(Enum):
2424 RFID = 18 ,
2525 TEMP = 19 ,
2626 THERMISTOR = 20
27+ ANALOG_WRITE = 21
2728
2829
2930class ElectroBlocks :
@@ -145,14 +146,7 @@ def _send(self, cmd):
145146 self .ser .write ((cmd + "|\n " ).encode ())
146147 self ._wait_for_message ("OK" )
147148
148- # Digital Write Method
149- def config_digital_read (self , pin ):
150- self ._add_pin (ComponentPins .DIGITAL_READ , pin )
151- self ._send (f"register::dr::{ pin } " )
152149
153- def digital_read (self , pin ):
154- return self ._find_sensor_str (pin , "dr" ) == "1"
155-
156150 # RFID
157151 def config_rfid (self , rxPin , txPin ):
158152 self ._add_pin (ComponentPins .RFID , rxPin )
@@ -279,8 +273,8 @@ def set_color_rgbled(self, r, g, b):
279273
280274 # LCD Methods
281275 def config_lcd (self , rows = 2 , cols = 16 , addr = 39 ):
282- self ._add_pin (ComponentPins .DIGITAL_WRITE , "A5" )
283- self ._add_pin (ComponentPins .DIGITAL_WRITE , "A4" )
276+ self ._add_pin (ComponentPins .LCD , "A5" )
277+ self ._add_pin (ComponentPins .LCD , "A4" )
284278 self ._send (f"register::lcd::{ rows } ::{ cols } ::{ addr } " )
285279
286280 def lcd_print (self , row , col , message ):
@@ -307,9 +301,21 @@ def lcd_scrollright(self):
307301 def lcd_scrollleft (self ):
308302 self ._send ("write::lcd::A5::7" )
309303
310- # LED Methods
304+ # Pins
305+
306+ def analog_write_config (self , pin ):
307+ self ._send (f"register::aw::{ pin } " )
308+ self ._add_pin (ComponentPins .ANALOG_WRITE , pin )
309+
310+ def analog_read_config (self , pin ):
311+ self ._send (f"register::ar::{ pin } " )
312+ self ._add_pin (ComponentPins .ANALOG_WRITE , pin )
313+
314+ def config_digital_read (self , pin ):
315+ self ._add_pin (ComponentPins .DIGITAL_READ , pin )
316+ self ._send (f"register::dr::{ pin } " )
311317
312- def digital_config (self , pin ):
318+ def digital_write_config (self , pin ):
313319 self ._add_pin (ComponentPins .DIGITAL_WRITE , pin )
314320 self ._send (f"register::dw::{ pin } " )
315321
@@ -319,9 +325,13 @@ def digital_write(self, pin, value):
319325 def analog_write (self , pin , value ):
320326 self ._send (f"write::aw::{ pin } ::{ value } " )
321327
322- def analog_config (self , pin ):
323- self ._send (f"register::aw::{ pin } " )
324- self ._add_pin (ComponentPins .ANALOG_WRITE , pin )
328+
329+ def digital_read (self , pin ):
330+ return self ._find_sensor_str (pin , "dr" ) == "1"
331+
332+ def analog_read (self , pin ):
333+ return self ._find_sensor_str (pin , "ar" )
334+
325335
326336 # LED MATRIX
327337
0 commit comments