-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSettings.py
More file actions
29 lines (23 loc) · 779 Bytes
/
Copy pathSettings.py
File metadata and controls
29 lines (23 loc) · 779 Bytes
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
import os
import ujson
class Settings:
def __init__(self, settings_filename):
self.settings_filename = settings_filename
self.settings = {}
self.display_on = True
def save_settings(self):
f = open(self.settings_filename, 'w')
f.write(ujson.dumps(self.settings))
f.close()
return self.settings
def load_settings(self):
if self.settings_filename in os.listdir(""):
f = open(self.settings_filename)
self.settings = ujson.loads(f.read())
f.close()
return self.settings
else:
self.settings['set_speed'] = 70
self.settings['manual_speed'] = 50
self.settings['mode'] = 'A'
return self.save_settings()