commit 2b24d473b260387b8edbedcd4caca41ad1b9531c Author: Gabriel Augendre Date: Fri Mar 10 12:18:34 2023 +0100 Initial commit diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..94840b3 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +layout python3 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..fe6d40c --- /dev/null +++ b/.gitignore @@ -0,0 +1,214 @@ +.direnv +src/secrets.py + + +# Created by https://www.toptal.com/developers/gitignore/api/osx +# Edit at https://www.toptal.com/developers/gitignore?templates=osx + +### OSX ### +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +# End of https://www.toptal.com/developers/gitignore/api/osx + +# Created by https://www.toptal.com/developers/gitignore/api/python +# Edit at https://www.toptal.com/developers/gitignore?templates=python + +### Python ### +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +cover/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +.pybuilder/ +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# poetry +# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. +# This is especially recommended for binary packages to ensure reproducibility, and is more +# commonly ignored for libraries. +# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control +#poetry.lock + +# pdm +# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. +#pdm.lock +# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it +# in version control. +# https://pdm.fming.dev/#use-with-ide +.pdm.toml + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +# Cython debug symbols +cython_debug/ + +# PyCharm +# JetBrains specific template is maintained in a separate JetBrains.gitignore that can +# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore +# and can be added to the global gitignore or merged into this file. For a more nuclear +# option (not recommended) you can uncomment the following to ignore the entire idea folder. +#.idea/ + +### Python Patch ### +# Poetry local configuration file - https://python-poetry.org/docs/configuration/#local-configuration +poetry.toml + +# ruff +.ruff_cache/ + +# LSP config files +pyrightconfig.json + +# End of https://www.toptal.com/developers/gitignore/api/python diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..03d9549 --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/libraries/MicroPython.xml b/.idea/libraries/MicroPython.xml new file mode 100644 index 0000000..4e7358c --- /dev/null +++ b/.idea/libraries/MicroPython.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..0bbdfbc --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..23c5e93 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/plant-badge.iml b/.idea/plant-badge.iml new file mode 100644 index 0000000..d61a996 --- /dev/null +++ b/.idea/plant-badge.iml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.tool-versions b/.tool-versions new file mode 100644 index 0000000..09895e5 --- /dev/null +++ b/.tool-versions @@ -0,0 +1 @@ +python@3.10.9 diff --git a/README.md b/README.md new file mode 100644 index 0000000..e751037 --- /dev/null +++ b/README.md @@ -0,0 +1,46 @@ +## Install dependencies + +If you only manage this project from a shell, then you only need these dependencies. +```shell +pip install -r requirements.txt +``` + +When running with PyCharm, instead use `requirements-pycharm.txt`: +```shell +pip install -r requirements-pycharm.txt +``` + +This will install dependencies required by PyCharm to run its MicroPython tools. + +## List boards +```shell +mpremote devs +``` + +## Setup / Clean flash + +```shell +# Wipe the board's flash (remove all files) +mpremote connect id:e6614104032e192a \ + exec --no-follow "import os, machine, rp2; os.umount('/'); bdev = rp2.Flash(); os.VfsLfs2.mkfs(bdev, progsize=256); vfs = os.VfsLfs2(bdev, progsize=256); os.mount(vfs, '/'); machine.reset()" +echo "Board clean" +sleep 3 + +# Install dependencies and copy project +cd src/ +mpremote connect id:e6614104032e192a \ + mip install github:miguelgrinberg/microdot/src/microdot.py \ + github:miguelgrinberg/microdot/src/microdot_asyncio.py + \ + cp -r . : + \ + reset +cd .. +``` + +## Update code +```shell +cd src/ +mpremote connect id:e6614104032e192a \ + cp -r . : + \ + reset +cd .. +``` diff --git a/requirements-pycharm.txt b/requirements-pycharm.txt new file mode 100644 index 0000000..c9e5f3a --- /dev/null +++ b/requirements-pycharm.txt @@ -0,0 +1,3 @@ +docopt>=0.6.2,<0.7 +adafruit-ampy>=1.0.5,<1.1 +mpremote diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..a97e503 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +mpremote \ No newline at end of file diff --git a/src/main.py b/src/main.py new file mode 100644 index 0000000..653a92f --- /dev/null +++ b/src/main.py @@ -0,0 +1,22 @@ +from picographics import PicoGraphics, DISPLAY_INKY_PACK + +import wifi + + +PEN_BLACK = 0 +PEN_WHITE = 15 + +display = PicoGraphics(DISPLAY_INKY_PACK) +display.set_pen(PEN_WHITE) +display.clear() +display.set_pen(PEN_BLACK) +display.text("Connecting...", 10, 10) +display.update() + +wifi.setup() +display.set_pen(PEN_WHITE) +display.clear() +display.set_pen(PEN_BLACK) +display.text("Connected!", 10, 10) +display.update() + diff --git a/src/secrets.py b/src/secrets.py new file mode 100644 index 0000000..c4f5099 --- /dev/null +++ b/src/secrets.py @@ -0,0 +1,6 @@ +SSID = "" +PASS = "" +COUNTRY = "" + +HA_ACCESS_TOKEN = "" +