Skip to content

Commit

Permalink
add labels
Browse files Browse the repository at this point in the history
  • Loading branch information
mzakharo committed Dec 12, 2020
1 parent 3d9d672 commit 56133ae
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
1 change: 1 addition & 0 deletions compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ class Dummy:
def __init__(self, _rate, type='acc', buffer_len=1):
self.rate = _rate
self._rate = _rate
self.accuracy = 3
self.type = type
self.last_time = time.monotonic_ns()
self.q = iq((0.0, 0.0, 0.0), buffer_len)
Expand Down
7 changes: 2 additions & 5 deletions look.kv
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
size_hint: [1, .05]
orientation: "horizontal"
Button:
text: "To Orientation"
text: "ORIENTATION"
bold: True
on_press:
root.manager.transition.direction = 'left'
Expand All @@ -29,7 +29,7 @@
size_hint: [1, .05]
orientation: "horizontal"
Button:
text: "To Accelerometer"
text: "FORCE"
bold: True
on_press:
root.manager.transition.direction = 'right'
Expand All @@ -50,7 +50,6 @@
id: graph0
y_grid_label : True
y_grid: True
xlabel : 'Azimuth'
xmax : 200
ymax: 180
ymin: -180
Expand All @@ -62,7 +61,6 @@
id: graph1
y_grid_label : True
y_grid: True
xlabel : 'Pitch'
xmax : 200
ymax: 90
ymin: -90
Expand All @@ -77,7 +75,6 @@
xmax : 200
ymax: 180
ymin: -180
xlabel : 'Roll'
y_ticks_minor : 20
y_ticks_major : 40

Expand Down
7 changes: 6 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,8 @@ def get_value(self, dt):
self.worker.q.put(('orientation', (self.event_time, event_time_idx, points, points_t)))

self.update_cnt += 1
self.ids.label.text = f'Cnt #{self.worker.event_count} Rate{snsr.accuracy}: {snsr.rate:.1f} '
lookup = {3:'H', 2: 'M', 1:'L'}
self.ids.label.text = f'#{self.worker.event_count} | rate:{snsr.rate:.1f}@{lookup.get(snsr.accuracy,"?")}'

if self.update_cnt == GRAPH_DRAW_EVERY_FRAMES or detected:
self.update_cnt = 0
Expand All @@ -265,6 +266,8 @@ def get_value(self, dt):
to = -int(sensor_manager.ori.rate/4)
midpoints = np.median(points[:, fro:to], axis=-1)

labels = ['Azimuth', 'Pitch', 'Roll']

for i, plot in enumerate(self.plots):
gr = getattr(self.ids, f'graph{i}')
values = points[i]
Expand All @@ -276,6 +279,7 @@ def get_value(self, dt):

#center graphs
midpoint = int(np.round(midpoints[i]))
gr.xlabel = f'{labels[i]} @ {midpoint}'
ZOOM_DEGREES = 20
gr.ymax = midpoint + ZOOM_DEGREES
gr.ymin = midpoint - ZOOM_DEGREES
Expand All @@ -284,6 +288,7 @@ def get_value(self, dt):
cache = self.gr_cache.pop(gr, None)
if cache is not None:
gr.ymax, gr.ymin, gr.y_ticks_major = cache
gr.xlabel = f'{labels[i]} @ {np.median(values[-10:]):.1f}'

gr.xmax = len(values)
plot.points = enumerate(values)
Expand Down

0 comments on commit 56133ae

Please sign in to comment.