-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathdroneconfig.py
executable file
·58 lines (41 loc) · 1.42 KB
/
droneconfig.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
#!/usr/bin/env python
import ConfigParser
import dronedict
CONFIG_FILE = 'drone.conf'
SECTION = 'drone'
class C(object):
def __init__(self):
self.config = ConfigParser.ConfigParser()
self.config.readfp(open(CONFIG_FILE))
def flush(self):
self.config.write(open(CONFIG_FILE, 'w'))
def get_max_alt(self):
return self.config.getfloat(SECTION, dronedict.S_MAX_ALT)
def get_max_rot_speed(self):
return self.config.getfloat(SECTION, dronedict.S_MAX_ROT)
def get_max_tilt(self):
return self.config.getfloat(SECTION, dronedict.S_MAX_TILT)
def get_max_vert_speed(self):
return self.config.getfloat(SECTION, dronedict.S_MAX_VERT)
def get_wheels(self):
return self.config.getboolean(SECTION, dronedict.S_WHEELS)
def get_cutoff(self):
return self.config.getboolean(SECTION, dronedict.S_CUTOUT)
def set_max_alt(self, value):
self.config.set(SECTION, dronedict.S_MAX_ALT, value)
self.flush()
def set_max_rot_speed(self, value):
self.config.set(SECTION, dronedict.S_MAX_ROT_SPEED, value)
self.flush()
def set_max_tilt(self, value):
self.config.set(SECTION, dronedict.S_MAX_TILT, value)
self.flush()
def set_max_vert_speed(self, value):
self.config.set(SECTION, dronedict.S_MAX_VERT_SPEED, value)
self.flush()
def set_wheels(self, value):
self.config.set(SECTION, dronedict.S_WHEELS, value)
self.flush()
def set_cutoff(self, value):
self.config.set(SECTION, dronedict.S_CUTOUT, value)
self.flush()