-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
70 lines (62 loc) · 1.83 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
from utils.config import get_args, process_config
from utils.LedManager import LedManager
from utils.ButtonManager import ButtonManager
from window import Window
from network_mode.network_mode import start as network_mode_start
from RF24 import *
import logging
import subprocess
config = None
args = None
# Get arguments and initialize transceiver
try:
args = get_args()
config = process_config(args.config)
config.update({
"Rx_CS": RPI_V2_GPIO_P1_15,
"Rx_CSN": BCM2835_SPI_CS1,
"Tx_CS": RPI_V2_GPIO_P1_13,
"Tx_CSN": BCM2835_SPI_CS0,
"Log_Level": logging.CRITICAL,
"json_path": '/home/pi/mtp_software/network_mode/config.json'
})
except:
print("missing or invalid arguments")
exit(0)
# Initialize buttons and leds
buttons = ButtonManager()
led = LedManager()
# Define end condition variables
end = False
while not end:
if buttons.start:
led.off()
if buttons.mode == 0:
window = Window.Window(config, 2, led)
if buttons.role == 'tx':
window.tx()
else:
window.rx()
elif buttons.mode == 1:
network_mode_start(buttons.role, led, config)
elif buttons.mode == 2:
end = True
buttons.start = False
else:
if buttons.enter:
if buttons.mode == 2:
led.green()
else:
if buttons.role == 'tx':
led.yellow()
else:
led.blue()
else:
if buttons.mode == 0:
led.violet()
elif buttons.mode == 1:
led.white()
elif buttons.mode == 2:
led.red()
led.red()
subprocess.call(["sudo", "poweroff"])