From dd787c9adf34fa960942890d341935e2331ba55a Mon Sep 17 00:00:00 2001 From: 99wombats Date: Sun, 2 Sep 2018 13:07:55 +0100 Subject: [PATCH] First submission of temp and humidity sensor data display app --- warm_and_wet/main.py | 53 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 warm_and_wet/main.py diff --git a/warm_and_wet/main.py b/warm_and_wet/main.py new file mode 100644 index 0000000..40fa4d3 --- /dev/null +++ b/warm_and_wet/main.py @@ -0,0 +1,53 @@ +""" +""" +___name___ = "my_app" +___license___ = "MIT" +___dependencies___ = ["dialogs", "ugfx_helper", "app", "sleep"] +___categories___ = ["Other"] +___bootstrapped___ = False # Whether or not apps get downloaded on first install. Defaults to "False", mostly likely you won't have to use this at all. + + +import ugfx, ugfx_helper, sleep +from tilda import Sensors, Buttons +from app import * +from dialogs import * + +ugfx_helper.init() +array_temp = [] +array_hum = [] +count = 0 +grid_size = 4 + +while (not Buttons.is_pressed(Buttons.BTN_A)) and (not Buttons.is_pressed(Buttons.BTN_B)) and (not Buttons.is_pressed(Buttons.BTN_Menu)): + ugfx.clear() + + ugfx.orientation(90) + ugfx.Label(0, ugfx.height() - 500, ugfx.width(), 90, "Warm and wet?", justification=ugfx.Label.CENTER) + + # Title + ugfx.set_default_font(ugfx.FONT_TITLE) + temp_cal = Sensors.get_tmp_temperature()-10 + string_temp = "%.1f degrees C" % temp_cal + ugfx.Label(0, ugfx.height() - 120, ugfx.width(), 60, string_temp, justification=ugfx.Label.CENTER) + + + hum = Sensors.get_hdc_humidity() + string_hum = "%.1f %% humidity" % hum + ugfx.Label(0, ugfx.height() - 60, ugfx.width(), 60, string_hum, justification=ugfx.Label.CENTER) + + if count < 58: + array_temp.append(temp_cal) + array_hum.append(hum) + else: + array_temp.pop(0) + array_hum.pop(0) + array_temp.append(temp_cal) + array_hum.append(hum) + for time, temp in enumerate(array_temp): + ugfx.area(int((time+1)*grid_size), 180-int((temp+1)*grid_size), grid_size-2, grid_size-2, ugfx.RED) + for time, hum in enumerate(array_hum): + ugfx.area(int((time+1)*grid_size), 200-int((hum/4+1)*grid_size), grid_size-2, grid_size-2, ugfx.BLUE) + count = count + 1 + sleep.sleep_ms(10000) + +restart_to_default() \ No newline at end of file