From 9dc0555182c03b4cd91a2195ccfb68353d1ed4ba Mon Sep 17 00:00:00 2001 From: Jens Dede Date: Sun, 16 Apr 2023 14:49:29 +0200 Subject: [PATCH] Add new boxes, fix status LED --- wolfnet/lib/config.py | 37 ++++++++++++++++++++++++++++++++++++- wolfnet/main.py | 9 +++++++-- 2 files changed, 43 insertions(+), 3 deletions(-) diff --git a/wolfnet/lib/config.py b/wolfnet/lib/config.py index d5d58e3..bb9a6db 100644 --- a/wolfnet/lib/config.py +++ b/wolfnet/lib/config.py @@ -117,6 +117,21 @@ "beacon_jitter" : 10, # seconds, will vary the above value by +- 10 seconds "gpio_button_irq" : 13, # IRQ on pin 13 }, + + "2628889781" : { # Buzzer 2 2023-04 + "is_sender" : True, + "msg_type" : packets.BasePacket.TYPE_ACTOR_FLASH, + "is_sniffer" : False, + "battery_type" : "max17043", + "actor_node" : None, + "action_cancel_previous" : True, + "action_frequency" : 25, # Hz (if applicable) + "action_duration" : 10000, # 10000 ms = 10 sec + "protection_time" : 1000, # 1000 ms = 1 sec + "beacon_interval" : 240, # 120 seconds + "beacon_jitter" : 10, # seconds, will vary the above value by +- 10 seconds + "gpio_button_irq" : 13, # IRQ on pin 13 + }, "1054058" : { # Ultrasonic actor "is_sender" : False, "receiver_type" : packets.BasePacket.TYPE_ACTOR_ULTRASONIC, @@ -136,4 +151,24 @@ "action_duration" : 10000, # 10000 ms = 10 sec "gpio_led_status" : 13, # Status LED on pin 13 }, -} + "2308316059" : { # Flash Actor 2, 2023-04 + "is_sender" : False, + "receiver_type" : packets.BasePacket.TYPE_ACTOR_FLASH, + "beacon_interval" : 120, # 120 seconds + "beacon_jitter" : 10, # seconds, will vary the above value by +- 10 seconds + "battery_type" : "analog", # Read battery from Pin 36 + "action_cancel_previous" : True, + "action_duration" : 10000, # 10000 ms = 10 sec + "gpio_led_status" : 13, # Status LED on pin 13 + }, + "3567154165" : { # Ultrasonic actor, 2023-04 + "is_sender" : False, + "receiver_type" : packets.BasePacket.TYPE_ACTOR_ULTRASONIC, + "beacon_interval" : 120, # 120 seconds + "beacon_jitter" : 10, # seconds, will vary the above value by +- 10 seconds + "battery_type" : "analog", # Read battery from Pin 36 + "action_cancel_previous" : True, + "action_duration" : 10000, # 10000 ms = 10 sec + "gpio_led_status" : 13, # Status LED on pin 13 + }, + } diff --git a/wolfnet/main.py b/wolfnet/main.py index 0b53835..8a70891 100644 --- a/wolfnet/main.py +++ b/wolfnet/main.py @@ -68,6 +68,7 @@ def button_handler(pin): def signal_status(onoff): global status_led if status_led is not None: + print("New LED status", onoff) status_led.value(onoff) # Heltec LoRa 32 with OLED Display @@ -129,6 +130,7 @@ def signal_status(onoff): status_led = None if "gpio_led_status" in nodeCfg: + print("Using status LED on pin", nodeCfg["gpio_led_status"]) status_led = Pin(nodeCfg["gpio_led_status"], Pin.OUT) status_led.value(0) @@ -224,7 +226,8 @@ def signal_status(onoff): ack = packet.create_ack() if ack: lora.println(dh.encrypt(ack.create_packet())) - if packet.get_type() == packet.TYPE_ACTOR_UNIVERSAL and not nodeCfg["is_sender"] and nodeCfg["receiver_type"] == packet.TYPE_ACTOR_FLASH: + if packet.get_type() in (packet.TYPE_ACTOR_UNIVERSAL, packet.TYPE_ACTOR_FLASH) and not nodeCfg["is_sender"] and nodeCfg["receiver_type"] == packet.TYPE_ACTOR_FLASH: + print("Acting as flash actor") duration, frequency, can_cancel = packet.get_params() if actor_timer != None and can_cancel: try: @@ -238,12 +241,14 @@ def signal_status(onoff): else: oled.text('f:' + str(frequency) + "Hz", 0, 35) oled.text('d:' + str(round(duration/1000.0,2)) + "s", 0,45) + signal_status(1) actor_timer = Timer(3) actor_timer_timeout = get_millis() + duration actor_timer.init(mode=Timer.PERIODIC, period=int(1.0/frequency/2.0*1000.0), callback=flash_timer_handler) - elif packet.get_type() in (packet.TYPE_ACTOR_UNIVERSAL, packet.TYPE_ACTOR_UNIVERSAL) and not nodeCfg["is_sender"] and nodeCfg["receiver_type"] == packet.TYPE_ACTOR_ULTRASONIC: + elif packet.get_type() in (packet.TYPE_ACTOR_UNIVERSAL, packet.TYPE_ACTOR_ULTRASONIC) and not nodeCfg["is_sender"] and nodeCfg["receiver_type"] == packet.TYPE_ACTOR_ULTRASONIC: + print("Acting as ultrasound actor") duration, _, can_cancel = packet.get_params() if actor_timer != None and can_cancel: try: