From 0d29636de7705e7ecaea5e7a90c5c27849e8b5f7 Mon Sep 17 00:00:00 2001 From: Kevin Whitaker Date: Tue, 5 Nov 2019 13:27:52 -0500 Subject: [PATCH] Make basic screen with graphs, but lots of bugs. --- Pipfile | 9 ++++-- Pipfile.lock | 14 ++++++++- main.py | 1 + qiflora/QiFlora.py | 10 +++++++ qiflora/qiflora.kv | 75 +++++++++++++++++++++++++++++++++++++++++++--- 5 files changed, 102 insertions(+), 7 deletions(-) diff --git a/Pipfile b/Pipfile index 1455208..ffb07a3 100644 --- a/Pipfile +++ b/Pipfile @@ -3,13 +3,18 @@ name = "pypi" url = "https://pypi.org/simple" verify_ssl = true +[[source]] +name = "kivy_garden" +url = "https://kivy-garden.github.io/simple" +verify_ssl = true + [dev-packages] [packages] Pillow = "*" kivy = "*" kivymd = "==0.102.0" - +"kivy_garden.graph" = {version="==0.4.dev0", index="kivy_garden"} [requires] -python_version = "3" +python_version = "3" diff --git a/Pipfile.lock b/Pipfile.lock index 2a074df..214c601 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "7a08f394b44c221105908a4210f052b838128b14f63b2ce999aa9834380d7111" + "sha256": "51bf5ddb9e803b22b92e57b842c37b473e82802072cdcb7628b4c6a07370c0c3" }, "pipfile-spec": 6, "requires": { @@ -12,6 +12,11 @@ "name": "pypi", "url": "https://pypi.org/simple", "verify_ssl": true + }, + { + "name": "kivy_garden", + "url": "https://kivy-garden.github.io/simple", + "verify_ssl": true } ] }, @@ -73,6 +78,13 @@ ], "version": "==0.1.4" }, + "kivy-garden.graph": { + "hashes": [ + "sha256:9d5938b9de98c4af610b72f9d9d2d637c4f0098fbf53278b267870f425e1bd37" + ], + "index": "kivy_garden", + "version": "==0.4.dev0" + }, "kivymd": { "hashes": [ "sha256:0b9fa3f5b67c08f607981e49b41f367f35e2c2bca0beffdd0e809246a5d110b7", diff --git a/main.py b/main.py index 9f96863..1226aec 100644 --- a/main.py +++ b/main.py @@ -3,6 +3,7 @@ kivy.require('1.10.1') from kivy.config import Config Config.set('kivy', 'log_enable', 0) +Config.set('modules','inspector','') if __name__ in ('__main__', '__android__'): from qiflora import QiFlora diff --git a/qiflora/QiFlora.py b/qiflora/QiFlora.py index e1a3bbf..5e576fc 100644 --- a/qiflora/QiFlora.py +++ b/qiflora/QiFlora.py @@ -1,5 +1,9 @@ +from math import sin + from kivy.app import App +from kivy.clock import Clock from kivymd.theming import ThemeManager +from kivy_garden.graph import Graph, MeshLinePlot class QiFlora(App): @@ -7,3 +11,9 @@ class QiFlora(App): theme_cls.primary_palette = 'Blue' theme_cls.accent_palette = 'DeepOrange' theme_cls.theme_style = 'Light' + + def refresh_data(self, *args): + plot = MeshLinePlot(color=[1,0,0,1]) + plot.points = [(x, sin(x / 10.)) for x in range(0, 101)] + self.root.ids.temp_graph.add_plot(plot) + self.root.ids.moist_graph.add_plot(plot) diff --git a/qiflora/qiflora.kv b/qiflora/qiflora.kv index 94bc1c7..ed7062f 100644 --- a/qiflora/qiflora.kv +++ b/qiflora/qiflora.kv @@ -6,7 +6,74 @@ BoxLayout: md_bg_color: app.theme_cls.primary_color background_palette: 'Primary' background_hue: '500' - AnchorLayout: - anchor_x: 'center' - MDRaisedButton: - text: "Fetch Updates" \ No newline at end of file + ScrollView: + do_scroll_x: False + do_scroll_y: True + GridLayout: + id: graphs + padding: [10,10,10,15] + spacing: [5,10] + rows: 5 + cols: 1 + size_hint_y: None + height: self.minimum_height + AnchorLayout: + anchor_x: "center" + size_hint_y: None + MDRaisedButton: + text: "refresh" + on_press: app.refresh_data() + MDCard: + orientation: "vertical" + size_hint_y: None + MDLabel: + halign: "center" + text: "Temperature" + Graph: + id: temp_graph + padding: 5 + xmin: -0 + ymin: -1 + xmax: 100 + ymax: 1 + x_ticks_major: 25 + y_ticks_major: 1 + x_grid_label: True + y_grid_label: True + x_grid: True + y_grid: True + xlabel: "temp (C)" + ylabel: "time" + MDCard: + orientation: "vertical" + size_hint_y: None + MDLabel: + halign: "center" + text: "Moisture" + Graph: + id: moist_graph + padding: 5 + xmin: -0 + ymin: -1 + xmax: 100 + ymax: 1 + x_ticks_major: 25 + y_ticks_major: 1 + x_grid_label: True + y_grid_label: True + x_grid: True + y_grid: True + xlabel: "temp (C)" + ylabel: "time" + MDCard: + orientation: "vertical" + size_hint_y: None + MDLabel: + halign: "center" + text: "Conductivity" + MDCard: + orientation: "vertical" + size_hint_y: None + MDLabel: + halign: "center" + text: "Brightness" \ No newline at end of file -- GitLab