connect compass smoothing to settings

This commit is contained in:
rgarcia-herrera 2020-08-30 15:22:19 -05:00
parent 86370f7273
commit 8ba7112ab9
2 changed files with 10 additions and 7 deletions

View File

@ -162,11 +162,12 @@
id: slider_smoothing
background_color: rgba("#f3e8d2")
color: rgba("#346645")
min: 0
max: 1
step: 0.1
min: 0.05
max: 0.99
step: 0.05
orientation: 'horizontal'
value: 0.88
on_value: app.set_smoothing()
BackgroundLabel:
text: "Update frequency"
background_color: rgba("#f3e8d2")

10
main.py
View File

@ -63,6 +63,9 @@ class FlockompassApp(App):
def dump(self, dt):
print(dt, self.gps_data, self.session_data)
def set_smoothing(self):
self.session_data['smoothing'] = self.ss.ids.slider_smoothing.value
def set_destination(self):
self.compass_enable()
self.session_data['dest_lat'] = self.ms.ids.centermark.lat
@ -75,9 +78,9 @@ class FlockompassApp(App):
def callback(permissions, results):
if all([res for res in results]):
print("aguas: callback. All permissions granted.")
print("All permissions granted.")
else:
print("aguas: callback. Some permissions refused.", results)
print("Some permissions refused.", results)
request_permissions([Permission.ACCESS_COARSE_LOCATION,
Permission.ACCESS_FINE_LOCATION],
@ -131,7 +134,7 @@ class FlockompassApp(App):
if self.cs.facade.field != (None, None, None):
x, y, z = self.cs.facade.field
smoothingFactor = 0.676
smoothingFactor = self.session_data.get('smoothing', 0.88)
angle = atan2(y, x)
self.last_angle = smoothingFactor * self.last_angle + (1 - smoothingFactor) * angle
@ -200,7 +203,6 @@ class FlockompassApp(App):
print('GPS is not implemented for your platform')
if platform == "android":
print("gps.py: Android detected. Requesting permissions")
self.request_android_permissions()
self.gps_start(1000, 0)