connect compass smoothing to settings
This commit is contained in:
parent
86370f7273
commit
8ba7112ab9
@ -162,11 +162,12 @@
|
|||||||
id: slider_smoothing
|
id: slider_smoothing
|
||||||
background_color: rgba("#f3e8d2")
|
background_color: rgba("#f3e8d2")
|
||||||
color: rgba("#346645")
|
color: rgba("#346645")
|
||||||
min: 0
|
min: 0.05
|
||||||
max: 1
|
max: 0.99
|
||||||
step: 0.1
|
step: 0.05
|
||||||
orientation: 'horizontal'
|
orientation: 'horizontal'
|
||||||
value: 0.88
|
value: 0.88
|
||||||
|
on_value: app.set_smoothing()
|
||||||
BackgroundLabel:
|
BackgroundLabel:
|
||||||
text: "Update frequency"
|
text: "Update frequency"
|
||||||
background_color: rgba("#f3e8d2")
|
background_color: rgba("#f3e8d2")
|
||||||
|
|||||||
10
main.py
10
main.py
@ -63,6 +63,9 @@ class FlockompassApp(App):
|
|||||||
def dump(self, dt):
|
def dump(self, dt):
|
||||||
print(dt, self.gps_data, self.session_data)
|
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):
|
def set_destination(self):
|
||||||
self.compass_enable()
|
self.compass_enable()
|
||||||
self.session_data['dest_lat'] = self.ms.ids.centermark.lat
|
self.session_data['dest_lat'] = self.ms.ids.centermark.lat
|
||||||
@ -75,9 +78,9 @@ class FlockompassApp(App):
|
|||||||
|
|
||||||
def callback(permissions, results):
|
def callback(permissions, results):
|
||||||
if all([res for res in results]):
|
if all([res for res in results]):
|
||||||
print("aguas: callback. All permissions granted.")
|
print("All permissions granted.")
|
||||||
else:
|
else:
|
||||||
print("aguas: callback. Some permissions refused.", results)
|
print("Some permissions refused.", results)
|
||||||
|
|
||||||
request_permissions([Permission.ACCESS_COARSE_LOCATION,
|
request_permissions([Permission.ACCESS_COARSE_LOCATION,
|
||||||
Permission.ACCESS_FINE_LOCATION],
|
Permission.ACCESS_FINE_LOCATION],
|
||||||
@ -131,7 +134,7 @@ class FlockompassApp(App):
|
|||||||
if self.cs.facade.field != (None, None, None):
|
if self.cs.facade.field != (None, None, None):
|
||||||
x, y, z = self.cs.facade.field
|
x, y, z = self.cs.facade.field
|
||||||
|
|
||||||
smoothingFactor = 0.676
|
smoothingFactor = self.session_data.get('smoothing', 0.88)
|
||||||
angle = atan2(y, x)
|
angle = atan2(y, x)
|
||||||
self.last_angle = smoothingFactor * self.last_angle + (1 - smoothingFactor) * angle
|
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')
|
print('GPS is not implemented for your platform')
|
||||||
|
|
||||||
if platform == "android":
|
if platform == "android":
|
||||||
print("gps.py: Android detected. Requesting permissions")
|
|
||||||
self.request_android_permissions()
|
self.request_android_permissions()
|
||||||
|
|
||||||
self.gps_start(1000, 0)
|
self.gps_start(1000, 0)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user