-
Notifications
You must be signed in to change notification settings - Fork 0
/
webserver.py
88 lines (66 loc) · 2.13 KB
/
webserver.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
#!/usr/bin/python
import cherrypy
class WebServer(object):
gyro_mon = None
user_mon = None
serial_send = None
def __init__(self, user_mon, gyro_mon, serial_send):
self.gyro_mon = gyro_mon
self.user_mon = user_mon
self.serial_send = serial_send
@cherrypy.expose
def index(self):
x, y = self.gyro_mon.get_current_vals()
return "{0:.2f} {1:.2f}".format(y, x)
@cherrypy.expose
def user_stats(self):
x, y, rotation, throttle = self.user_mon.get_current_vals()
return "X:{0}<br>Y:{1}<br>Rotation:{2}<br>Throttle:{3}<br>User Control:{4}<br>Camera Mode:{5}".format(x, y, rotation, throttle, self.serial_send.user_control, self.serial_send.camera_mode)
@cherrypy.expose
def rotate_left(self):
self.user_mon.rotate_left()
@cherrypy.expose
def rotate_right(self):
self.user_mon.rotate_right()
@cherrypy.expose
def reset_rotate(self):
self.user_mon.reset_rotate()
@cherrypy.expose
def move_left(self):
self.user_mon.move_left()
@cherrypy.expose
def move_right(self):
self.user_mon.move_right()
@cherrypy.expose
def reset_x(self):
self.user_mon.reset_x()
@cherrypy.expose
def move_forward(self):
self.user_mon.move_forward()
@cherrypy.expose
def move_back(self):
self.user_mon.move_back()
@cherrypy.expose
def reset_y(self):
self.user_mon.reset_y()
@cherrypy.expose
def increase_throttle(self):
self.user_mon.increase_throttle()
@cherrypy.expose
def slight_increase_throttle(self):
self.user_mon.slight_increase_throttle()
@cherrypy.expose
def decrease_throttle(self):
self.user_mon.decrease_throttle()
@cherrypy.expose
def slight_decrease_throttle(self):
self.user_mon.slight_decrease_throttle()
@cherrypy.expose
def reset_throttle(self):
self.user_mon.reset_throttle()
@cherrypy.expose
def user_control(self):
self.serial_send.change_control()
@cherrypy.expose
def toggle_camera_mode(self):
self.serial_send.toggle_camera_mode()