File tree Expand file tree Collapse file tree 1 file changed +7
-13
lines changed
samples/demos/end_to_end_agriculture Expand file tree Collapse file tree 1 file changed +7
-13
lines changed Original file line number Diff line number Diff line change 147147
148148sensor = None
149149
150- LED_PIN_ID = "D9"
151-
152- led_pin = Pin (LED_PIN_ID , Pin .OUT , value = VALUE_DISABLED )
153-
154150
155151def read_properties ():
156152 """
@@ -540,14 +536,10 @@ def toggle_valve():
540536 Toggles the status of the electronic valve.
541537 """
542538 global valve_pos
543- status = valve_pos
544539
545- if status == 0 :
546- valve_pos = True
547- else :
548- valve_pos = False
549-
550- print ("- Toggling valve status to '{}'." .format ("Open" if valve_pos == True else "Closed" ))
540+ valve_pos = 1 if valve_pos == 0 else 0
541+ print ("- Toggling valve status to '{}'." .format ("Open" if valve_pos == 1 else "Closed" ))
542+ # Turn on/off the LED.
551543 led_pin .value (valve_pos )
552544
553545
@@ -617,6 +609,9 @@ def main():
617609 except AssertionError :
618610 pass
619611
612+ # Simulate temperature if no I2C sensor is detected.
613+ simulate_temp = sensor is None
614+
620615 # Configure the Bluetooth advertisement.
621616 config_advertisement ()
622617
@@ -633,8 +628,7 @@ def main():
633628 # Sleep 100 ms.
634629 time .sleep_ms (100 )
635630
636- # If the button has been pressed, swap the temperature source
637- # (reading or simulation).
631+ # If the button has been pressed, toggle the electronic valve.
638632 if not was_btn_pressed and is_button_pressed ():
639633 toggle_valve ()
640634 status_response = {
You can’t perform that action at this time.
0 commit comments