-
Notifications
You must be signed in to change notification settings - Fork 0
/
boot_menu.py
executable file
·94 lines (84 loc) · 2.29 KB
/
boot_menu.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/usr/bin/env python
#===========================================================================
# boot_menu.py
#
# Run at boot to pick how to bring up camera:
# * pick a wifi option
# * run appropriate program(s)
#
# 2014-4-23
# Carter Nelson
#===========================================================================
import time
import os
import campi
camera = campi.Campi()
camera.LCD_LED_On()
selection = 1
#01234567890123
BLANK = ' [ ] '
CHECKED = ' [X] '
MENU1 = 'AP WIFI '
MENU2 = 'HOME WIFI'
MENU3 = 'EXIT '
MENU4 = 'EXIT '
cursor = {}
cursor['1'] = BLANK
cursor['2'] = BLANK
cursor['3'] = BLANK
cursor['4'] = BLANK
menu = {}
menu['1'] = MENU1
menu['2'] = MENU2
menu['3'] = MENU3
menu['4'] = MENU4
def clear_cursor():
for key in cursor:
cursor[key]= BLANK
def set_cursor():
clear_cursor()
cursor['%i'%selection] = CHECKED
def update_menu():
set_cursor()
msg = ''
for l in [1,2,3,4]:
key = '%s'%l
msg += '%s%s' % (cursor[key],menu[key])
camera.disp_msg(msg)
#===========================
# MAIN
#===========================
while True:
button_state = camera.get_buttons()
if (button_state[campi.BTN_UP]):
selection -= 1
if (selection<1):
selection = 4
if (button_state[campi.BTN_DOWN]):
selection += 1
if (selection>4):
selection = 1
if (button_state[campi.BTN_SEL]):
print 'selection = %i' % selection
if (selection==1):
# start access point and time lapse web server
camera.disp_msg(' access point '+\
' starting.... ')
os.system('python /home/pi/start_ap.py')
os.system('cd /home/pi/rpi-camera')
os.system('python /home/pi/rpi-camera/camera_server.py')
if (selection==2):
# start home wifi
camera.disp_msg(' home wifi '+\
' starting.... ')
os.system('python /home/pi/start_homewifi.py')
if (selection==3):
# do nothing, just exit
pass
if (selection==4):
# do nothing, just exit
pass
camera.disp_msg(' DONE')
exit()
update_menu()
time.sleep(0.1)