From e3f978e1d3c0eb7e80d701a88facfc3df5818996 Mon Sep 17 00:00:00 2001 From: Rob Miles Date: Wed, 19 Sep 2018 15:32:56 +0100 Subject: [PATCH] Air Quality Sensor Badge --- air_quality/main.py | 198 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 198 insertions(+) create mode 100644 air_quality/main.py diff --git a/air_quality/main.py b/air_quality/main.py new file mode 100644 index 0000000..1b863db --- /dev/null +++ b/air_quality/main.py @@ -0,0 +1,198 @@ +"""This app needs an SDS011 sensor attacthed to UART 4 """ + +___name___ = "Air Quality" +___license___ = "MIT" +___dependencies___ = ["sleep", "app", "ugfx_helper", "buttons", "homescreen"] +___categories___ = ["EMF"] +___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 app +import ugfx, os, time, sleep +from tilda import Buttons +from tilda import Sensors +from machine import Pin +from machine import UART +from machine import Neopix +import random + +class DustSensorTester(object): + + verbose = False + + def contains_sequence (self,data, test): + """ Checks to see if the data sequence contains the test sewquence + + Args: + data: sequence of data items + test: test sequence + Returns: + True if the test sequence is in the data sequence + """ + + if len(data) 0: + sensor_port.readinto(buffer,1) + sensor.pump_byte(buffer[0]) + sleep.wfi() + +ugfx.clear() + +app.restart_to_default() +