needle damping, correct flock bearing
This commit is contained in:
parent
75492056e7
commit
32757dfd9e
16
main.py
16
main.py
@ -79,7 +79,7 @@ class FlockompassApp(App):
|
||||
self.fbearing = atan2(sin(lon2 - lon1) * cos(lat2),
|
||||
cos(lat1) * sin(lat2)
|
||||
- sin(lat1) * cos(lat2) * cos(lon2-lon1))
|
||||
self.fbearing = self.needle_angle + degrees(self.fbearing)
|
||||
self.fbearing = self.needle_angle - degrees(self.fbearing)
|
||||
self.fbearing = (self.fbearing + 360) % 360
|
||||
|
||||
def center_map_on_gps(self):
|
||||
@ -94,10 +94,13 @@ class FlockompassApp(App):
|
||||
|
||||
needle_angle = 0
|
||||
if self.cs.facade.field != (None, None, None):
|
||||
self.x_calib, self.y_calib, self.z_calib = self.cs.facade.field
|
||||
x, y, z = self.cs.facade.field
|
||||
|
||||
needle_angle = Vector(x, y).angle((0, 1)) + 90.
|
||||
smoothingFactor = 0.9
|
||||
angle = atan2(y, x)
|
||||
self.last_angle = smoothingFactor * self.last_angle + (1 - smoothingFactor) * angle
|
||||
|
||||
needle_angle = degrees(self.last_angle)
|
||||
|
||||
# fix animation transition around the unit circle
|
||||
if (self.needle_angle % 360) - needle_angle > 180:
|
||||
@ -112,7 +115,7 @@ class FlockompassApp(App):
|
||||
self.cs._anim.stop(self)
|
||||
self.cs._anim = Animation(needle_angle=needle_angle,
|
||||
d=0.1,
|
||||
t='out_elastic')
|
||||
t='out_quad')
|
||||
self.cs._anim.start(self)
|
||||
|
||||
def compass_enable(self):
|
||||
@ -160,7 +163,10 @@ class FlockompassApp(App):
|
||||
self.cs.p = None
|
||||
screen_manager.add_widget(self.cs)
|
||||
|
||||
Clock.schedule_interval(self.dump, 2.0)
|
||||
# smoothing vars for compass
|
||||
self.last_angle = 0
|
||||
|
||||
#Clock.schedule_interval(self.dump, 2.0)
|
||||
|
||||
return screen_manager
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user