Skip to content

Commit

Permalink
Add new boxes, fix status LED
Browse files Browse the repository at this point in the history
  • Loading branch information
jdede committed Apr 16, 2023
1 parent 3151e7f commit 9dc0555
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 3 deletions.
37 changes: 36 additions & 1 deletion wolfnet/lib/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
},
}
9 changes: 7 additions & 2 deletions wolfnet/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand Down

0 comments on commit 9dc0555

Please sign in to comment.