diff --git a/assets/to_map.png b/assets/to_map.png new file mode 100644 index 0000000..0091cc4 Binary files /dev/null and b/assets/to_map.png differ diff --git a/assets/to_map.svg b/assets/to_map.svg index 5939f02..e9feb47 100644 --- a/assets/to_map.svg +++ b/assets/to_map.svg @@ -1,3 +1,52 @@ - - + +image/svg+xml + \ No newline at end of file diff --git a/flockompass.kv b/flockompass.kv index 446cb29..99ea981 100644 --- a/flockompass.kv +++ b/flockompass.kv @@ -1,6 +1,20 @@ #:import random random.random #:import RiseInTransition kivy.uix.screenmanager.RiseInTransition #:import facade plyer.compass +#:import rgba kivy.utils.get_color_from_hex + +: + background_color: 1, 1, 1, 1 + canvas.before: + Color: + rgba: root.background_color + Rectangle: + size: self.size + pos: self.pos + +: + background_color: 0, 0, 0, 0 + background_color: rgba("#c0464b") : @@ -62,51 +76,55 @@ orientation: 'vertical' padding: '20dp' spacing: '10dp' - BoxLayout: - orientation: 'vertical' - ActionBar: - pos_hint: {'top':1} - ActionView: - use_separator: True - ActionPrevious: - title: 'Social Cycling' - with_previous: False - ActionButton: - important: True - text: 'set destination' - on_press: root.manager.current = 'map'; - FloatLayout: - canvas: - Color: - rgb: .9, .9, .9 - Rectangle: - size: self.size - Label: - text: app.dest_distance - color: 0, 0, 0.3, 1 - size_hint: 0.5, 0.1 - pos: 0, 0.1 - font_size: '40sp' - Image: - source: 'assets/needle.png' - canvas.before: - PushMatrix - Rotate: - angle: app.needle_angle - axis: 0, 0, 1 - origin: self.center - canvas.after: - PopMatrix - Image: - id: to_dest - source: 'assets/needle_to_dest.png' - canvas.before: - PushMatrix - Rotate: - angle: app.fbearing - axis: 0, 0, 1 - origin: self.center - canvas.after: - PopMatrix - Image: - source: 'assets/pivot.png' \ No newline at end of file + FloatLayout: + canvas: + Color: + rgba: rgba("#336645") + Rectangle: + size: self.size + Image: + source: 'assets/needle.png' + pos_hint: {"center_x": 0.5, "center_y": 0.7} + canvas.before: + PushMatrix + Rotate: + angle: app.needle_angle + axis: 0, 0, 1 + origin: self.center + canvas.after: + PopMatrix + Image: + id: to_dest + source: 'assets/needle_to_dest.png' + pos_hint: {"center_x": 0.5, "center_y": 0.7} + canvas.before: + PushMatrix + Rotate: + angle: app.fbearing + axis: 0, 0, 1 + origin: self.center + canvas.after: + PopMatrix + Image: + source: 'assets/pivot.png' + pos_hint: {"center_x": 0.5, "center_y": 0.7} + size_hint: 1, 1 + IconButton: + source: 'assets/to_map.png' + pos_hint: {"center_x": 0.1, "center_y": 0.95} + size_hint: 0.2, 0.2 + on_press: root.manager.current = 'map'; + BackgroundLabel: + text: app.dest_distance + background_color: rgba("#c0464b") + color: rgba("#f3e8d2") + size_hint: 1, 0.2 + pos_hint: {"x": 0, "top": 0.4} + font_size: '40sp' + BackgroundLabel: + text: app.dashboard_flock + background_color: rgba("#679958") + color: rgba("#f3e8d2") + size_hint: 1, 0.2 + pos_hint: {"x": 0, "top": 0.2} + font_size: '40sp' diff --git a/main.py b/main.py index d6e33bd..c1009d1 100644 --- a/main.py +++ b/main.py @@ -35,6 +35,8 @@ class FlockompassApp(App): fbearing = NumericProperty(0) dest_distance = StringProperty("") + dashboard_dest = StringProperty("") + dashboard_flock = StringProperty("") def dump(self, dt): print(dt, self.gps_data, self.session_data) @@ -79,9 +81,19 @@ class FlockompassApp(App): self.ms.ids.mapview.center_on(self.session_data['dest_lat'], self.session_data['dest_lon']) else: - self.dest_distance = "D: %0.1f km" % geodesic( + + dest_distance = geodesic( (self.gps_data['lat'], self.gps_data['lon']), (self.session_data['dest_lat'], self.session_data['dest_lon'])).kilometers + if dest_distance < 1: + dest_distance *= 1000 + dest_distance = "%i metros" % dest_distance + else: + dest_distance = "%0.1f km" % dest_distance + + self.dest_distance = "Destino: %s\nVel: %0.1f km/h" % (dest_distance, + self.gps_data['speed']) + def center_map_on_gps(self): self.ms.ids.mapview.center_on(self.gps_data['lat'],