From 57a071473886a9c249b8c7b759231a4bbd6c22d0 Mon Sep 17 00:00:00 2001 From: BlueFox Date: Sat, 16 Mar 2024 14:37:21 +0100 Subject: [PATCH] Removed old programs for uniformity in this repo --- lora_pingpong.py | 21 ++++++++++++++++++--- main_+lcd.py | 35 ++++++++++------------------------- main_-lcd.py | 10 ++++++---- 3 files changed, 34 insertions(+), 32 deletions(-) diff --git a/lora_pingpong.py b/lora_pingpong.py index 8a72e27..d080936 100644 --- a/lora_pingpong.py +++ b/lora_pingpong.py @@ -148,6 +148,8 @@ def pingpong(lora, initializer: bool, lcd_connected=True, interrupt_pin=None): as_responder(lora, lcd, lcd_connected, interrupt_pin) +# initialize LoRa + device_spi = SPI(baudrate = 10000000, polarity = 0, phase = 0, bits = 8, firstbit = SPI.MSB, id=0, sck = Pin(2, Pin.OUT, Pin.PULL_DOWN), @@ -168,9 +170,22 @@ parameters = { 'invert_IQ': False, } -def run(): - lora = SX127x(device_spi, pins={"dio_0": 6, "ss": 5, "led": 27}, parameters=parameters) +lora = SX127x(device_spi, pins={"dio_0": 6, "ss": 5, "led": 27}, parameters=parameters)" + + +# The run function (for different options; see below the "if __name__ == ..." section) + +def run_lcd_init(): + pingpong(lora, initializer=True, lcd_connected=True) +def run_wo_lcd_init(): + pingpong(lora, initializer=True, lcd_connected=False) +def run_lcd_resp(): pingpong(lora, initializer=False, lcd_connected=True) +def run_wo_lcd_resp(): + pingpong(lora, initializer=False, lcd_connected=False)" if __name__ == "__main__": - run() + #run_lcd_resp() # run as responder (with lcd) + #run_wo_lcd_resp() # run as responder (without lcd) + #run_lcd_init() # run as initializer (with lcd) + run_wo_lcd_init() # run as initializer (without lcd) diff --git a/main_+lcd.py b/main_+lcd.py index 63d3267..e46a824 100644 --- a/main_+lcd.py +++ b/main_+lcd.py @@ -2,10 +2,6 @@ from ProgramChooser import ProgramChooser import sys import gc -def micronec_run(): - from micronEC import micronec - micronec.run() - gc.collect() def lora_receiver_run(): from lora_simple import lora_receiver lora_receiver.run() @@ -14,32 +10,21 @@ def lora_sender_run(): from lora_simple import lora_sender lora_sender.run() gc.collect() -def lora_pingpong_run(): +def lora_pingpong_init(): import lora_pingpong - lora_pingpong.run() + lora_pingpong.run_lcd_init() gc.collect() -def lcd_big_hello_run(): - from lcd_examples import lcd_big_hello - lcd_big_hello.run() - gc.collect() -def lcd_libtest_run(): - from lcd_examples import lcd_libtest - lcd_libtest.run() - gc.collect() -def led_test_run(): - from excercise import led_test - led_test.run() +def lora_pingpong_resp(): + import lora_pingpong + lora_pingpong.run_lcd_resp() gc.collect() programs = { - "micronEC": micronec_run, - "lorareceiver": lora_receiver_run, - "lorasender": lora_sender_run, - "lora_pingpong": lora_pingpong_run, - "lcd_big_hello": lcd_big_hello_run, - "lcd_libtest": lcd_libtest_run, - "led_blink": led_test_run, + "simplereceiver": lora_receiver_run, + "simplesender": lora_sender_run, + "pingpong_init": lora_pingpong_init, + "pingpong_resp": lora_pingpong_resp, } pc = ProgramChooser(programs, 7, 8, debug=True) -pc.run() \ No newline at end of file +pc.run() diff --git a/main_-lcd.py b/main_-lcd.py index 0c6d3ac..364b15b 100644 --- a/main_-lcd.py +++ b/main_-lcd.py @@ -1,11 +1,13 @@ from simplelora import sender, receiver import lora_pingpong -to_run = 0 # 0: ping-pong | 1: sender | 2: receiver +to_run = 0 # 0: ping-pong as responder | 1: ping-pong as initializer | 2: sender | 3: receiver if to_run == 0: - lora_pingpong.run() -elif to_run == 1: - sender.run() + lora_pingpong.run_wo_lcd_resp() +if to_run == 1: + lora_pingpong.run_wo_lcd_init() elif to_run == 2: + sender.run() +elif to_run == 3: receiver.run()