+ Wi-Fi Connection + +
+ + ++ Access Point + +
+ + ++ Smart Plug + +
++ +
+ +diff --git a/.version b/.version new file mode 100644 index 0000000..81fd7ba --- /dev/null +++ b/.version @@ -0,0 +1 @@ +v0.2.0 \ No newline at end of file diff --git a/boot.py b/boot.py new file mode 100644 index 0000000..38e45ba --- /dev/null +++ b/boot.py @@ -0,0 +1,9 @@ +import esp +import gc +import machine + +esp.osdebug(None) + +# Take out the trash +gc.enable() +gc.collect() diff --git a/lib/microdot.mpy b/lib/microdot.mpy new file mode 100644 index 0000000..1c7cf49 Binary files /dev/null and b/lib/microdot.mpy differ diff --git a/lib/microdot_asyncio.mpy b/lib/microdot_asyncio.mpy new file mode 100644 index 0000000..e9bf9c2 Binary files /dev/null and b/lib/microdot_asyncio.mpy differ diff --git a/lib/ulogging.mpy b/lib/ulogging.mpy new file mode 100644 index 0000000..6194b3a Binary files /dev/null and b/lib/ulogging.mpy differ diff --git a/lib/urequests.mpy b/lib/urequests.mpy new file mode 100644 index 0000000..6c2bce8 Binary files /dev/null and b/lib/urequests.mpy differ diff --git a/lib/utemplate/compiled.mpy b/lib/utemplate/compiled.mpy new file mode 100644 index 0000000..b12bb42 Binary files /dev/null and b/lib/utemplate/compiled.mpy differ diff --git a/lib/utemplate/recompile.mpy b/lib/utemplate/recompile.mpy new file mode 100644 index 0000000..6c64390 Binary files /dev/null and b/lib/utemplate/recompile.mpy differ diff --git a/lib/utemplate/source.mpy b/lib/utemplate/source.mpy new file mode 100644 index 0000000..cd9fd54 Binary files /dev/null and b/lib/utemplate/source.mpy differ diff --git a/main.py b/main.py new file mode 100644 index 0000000..4fde99e --- /dev/null +++ b/main.py @@ -0,0 +1,72 @@ +import gc +import machine +import time + +import uasyncio as asyncio +import ulogging as logging + +from pasp import ota, plug, pm25, web, wifi, system +from pasp.beacon import beacon +from pasp.collector import collector +from pasp.config import settings +from pasp.controller import controller +from pasp.beacon import beacon + +gc.collect() + +logging.basicConfig(level=logging.DEBUG if settings.DEBUG else logging.INFO) +log = logging.getLogger('main') + + +async def collect_garbage(): + while True: + gc.collect() + await asyncio.sleep(5) + + +def main(): + log.info(f'PASP Version: {system.version()}') + log.info(f'Wemos C3-Mini: {system.board_version()}') + + # Signal that we've started. + beacon.off() + asyncio.run(beacon.animate()) + + # Wifi, OTA, and AP setup. + asyncio.run(wifi.connect()) + ota.check_for_updates() + asyncio.run(wifi.ap_setup()) + + # Core functionality. + collector.run() + controller.run() + web.run() + + # Automatic garbage collection. + asyncio.create_task(collect_garbage()) + + # Let's get to work! + asyncio.run(beacon.animate()) + asyncio.run(beacon.pulse(delay=69)) + beacon.on() + + loop = asyncio.get_event_loop() + + try: + loop.run_forever() + except: + loop.stop() + loop.close() + + +if __name__ == '__main__': + try: + main() + except Exception as err: + log.error(str(err)) + for x in range(20): + beacon.on() + time.sleep(.5) + beacon.off() + time.sleep(.5) + machine.restart() diff --git a/pasp/__init__.mpy b/pasp/__init__.mpy new file mode 100644 index 0000000..fbbc56a Binary files /dev/null and b/pasp/__init__.mpy differ diff --git a/pasp/beacon/__init__.mpy b/pasp/beacon/__init__.mpy new file mode 100644 index 0000000..f33cd4f Binary files /dev/null and b/pasp/beacon/__init__.mpy differ diff --git a/pasp/beacon/base.mpy b/pasp/beacon/base.mpy new file mode 100644 index 0000000..613c314 Binary files /dev/null and b/pasp/beacon/base.mpy differ diff --git a/pasp/beacon/led.mpy b/pasp/beacon/led.mpy new file mode 100644 index 0000000..74e52bb Binary files /dev/null and b/pasp/beacon/led.mpy differ diff --git a/pasp/beacon/rgb_led.mpy b/pasp/beacon/rgb_led.mpy new file mode 100644 index 0000000..4e22980 Binary files /dev/null and b/pasp/beacon/rgb_led.mpy differ diff --git a/pasp/collector.mpy b/pasp/collector.mpy new file mode 100644 index 0000000..35a4593 Binary files /dev/null and b/pasp/collector.mpy differ diff --git a/pasp/config.mpy b/pasp/config.mpy new file mode 100644 index 0000000..e0b4a57 Binary files /dev/null and b/pasp/config.mpy differ diff --git a/pasp/controller.mpy b/pasp/controller.mpy new file mode 100644 index 0000000..bbf3839 Binary files /dev/null and b/pasp/controller.mpy differ diff --git a/pasp/ota.mpy b/pasp/ota.mpy new file mode 100644 index 0000000..dc76e5f Binary files /dev/null and b/pasp/ota.mpy differ diff --git a/pasp/path.mpy b/pasp/path.mpy new file mode 100644 index 0000000..cc11f0b Binary files /dev/null and b/pasp/path.mpy differ diff --git a/pasp/plug.mpy b/pasp/plug.mpy new file mode 100644 index 0000000..5aaa647 Binary files /dev/null and b/pasp/plug.mpy differ diff --git a/pasp/pm25.mpy b/pasp/pm25.mpy new file mode 100644 index 0000000..3c793f7 Binary files /dev/null and b/pasp/pm25.mpy differ diff --git a/pasp/static/css/style.css.gz b/pasp/static/css/style.css.gz new file mode 100644 index 0000000..f0bb094 Binary files /dev/null and b/pasp/static/css/style.css.gz differ diff --git a/pasp/static/img/outlet.svg b/pasp/static/img/outlet.svg new file mode 100644 index 0000000..55f301b --- /dev/null +++ b/pasp/static/img/outlet.svg @@ -0,0 +1 @@ + diff --git a/pasp/static/img/signal-disconnected.svg b/pasp/static/img/signal-disconnected.svg new file mode 100644 index 0000000..0113cc4 --- /dev/null +++ b/pasp/static/img/signal-disconnected.svg @@ -0,0 +1 @@ + diff --git a/pasp/static/img/signal-fair.svg b/pasp/static/img/signal-fair.svg new file mode 100644 index 0000000..d3ab863 --- /dev/null +++ b/pasp/static/img/signal-fair.svg @@ -0,0 +1 @@ + diff --git a/pasp/static/img/signal-good.svg b/pasp/static/img/signal-good.svg new file mode 100644 index 0000000..37c76c7 --- /dev/null +++ b/pasp/static/img/signal-good.svg @@ -0,0 +1 @@ + diff --git a/pasp/static/img/signal-great.svg b/pasp/static/img/signal-great.svg new file mode 100644 index 0000000..f364a41 --- /dev/null +++ b/pasp/static/img/signal-great.svg @@ -0,0 +1 @@ + diff --git a/pasp/static/img/signal-poor.svg b/pasp/static/img/signal-poor.svg new file mode 100644 index 0000000..5843712 --- /dev/null +++ b/pasp/static/img/signal-poor.svg @@ -0,0 +1 @@ + diff --git a/pasp/static/img/wifi-exclamation.svg b/pasp/static/img/wifi-exclamation.svg new file mode 100644 index 0000000..e84ff16 --- /dev/null +++ b/pasp/static/img/wifi-exclamation.svg @@ -0,0 +1 @@ + diff --git a/pasp/static/img/wifi.svg b/pasp/static/img/wifi.svg new file mode 100644 index 0000000..b872ea4 --- /dev/null +++ b/pasp/static/img/wifi.svg @@ -0,0 +1 @@ + diff --git a/pasp/static/js/main.js.gz b/pasp/static/js/main.js.gz new file mode 100644 index 0000000..18e54ba Binary files /dev/null and b/pasp/static/js/main.js.gz differ diff --git a/pasp/system.mpy b/pasp/system.mpy new file mode 100644 index 0000000..3fb65fd Binary files /dev/null and b/pasp/system.mpy differ diff --git a/pasp/templates/includes/head.html b/pasp/templates/includes/head.html new file mode 100644 index 0000000..9d6f944 --- /dev/null +++ b/pasp/templates/includes/head.html @@ -0,0 +1,6 @@ +{% args ctx %} + + + + + diff --git a/pasp/templates/includes/modal.html b/pasp/templates/includes/modal.html new file mode 100644 index 0000000..92234d9 --- /dev/null +++ b/pasp/templates/includes/modal.html @@ -0,0 +1,9 @@ + diff --git a/pasp/templates/includes/nav.html b/pasp/templates/includes/nav.html new file mode 100644 index 0000000..f843789 --- /dev/null +++ b/pasp/templates/includes/nav.html @@ -0,0 +1,11 @@ +{% args ctx %} + diff --git a/pasp/templates/index.html b/pasp/templates/index.html new file mode 100644 index 0000000..88c6a35 --- /dev/null +++ b/pasp/templates/index.html @@ -0,0 +1,122 @@ +{% args ctx %} + + +
++ Wi-Fi Connection + +
+ + ++ Access Point + +
+ + ++ Smart Plug + +
++ +
+ +{{ key }} | +
+ {% if type(value) != tuple %}
+ {{ value }}
+ {% else %}
+
|
+
---|