Initial commit

This commit is contained in:
Gabriel Augendre 2023-03-10 12:18:34 +01:00
commit 2b24d473b2
16 changed files with 365 additions and 0 deletions

1
.envrc Normal file
View file

@ -0,0 +1 @@
layout python3

214
.gitignore vendored Normal file
View file

@ -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

8
.idea/.gitignore vendored Normal file
View file

@ -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

View file

@ -0,0 +1,6 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="Eslint" enabled="true" level="WARNING" enabled_by_default="true" />
</profile>
</component>

View file

@ -0,0 +1,6 @@
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>

View file

@ -0,0 +1,11 @@
<component name="libraryTable">
<library name="MicroPython" type="python">
<CLASSES>
<root url="file://$APPLICATION_PLUGINS_DIR$/intellij-micropython/typehints/stdlib" />
<root url="file://$APPLICATION_PLUGINS_DIR$/intellij-micropython/typehints/micropython" />
<root url="file://$APPLICATION_PLUGINS_DIR$/intellij-micropython/typehints/rpi_pico" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>

4
.idea/misc.xml Normal file
View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.10 (plant-badge)" project-jdk-type="Python SDK" />
</project>

8
.idea/modules.xml Normal file
View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/plant-badge.iml" filepath="$PROJECT_DIR$/.idea/plant-badge.iml" />
</modules>
</component>
</project>

22
.idea/plant-badge.iml Normal file
View file

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="FacetManager">
<facet type="MicroPython" name="MicroPython">
<configuration>
<device name="Raspberry Pi Pico" />
</configuration>
</facet>
</component>
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="jdk" jdkName="Python 3.10 (plant-badge)" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="MicroPython" level="project" />
</component>
<component name="PyDocumentationSettings">
<option name="format" value="PLAIN" />
<option name="myDocStringFormat" value="Plain" />
</component>
</module>

6
.idea/vcs.xml Normal file
View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

1
.tool-versions Normal file
View file

@ -0,0 +1 @@
python@3.10.9

46
README.md Normal file
View file

@ -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 ..
```

3
requirements-pycharm.txt Normal file
View file

@ -0,0 +1,3 @@
docopt>=0.6.2,<0.7
adafruit-ampy>=1.0.5,<1.1
mpremote

1
requirements.txt Normal file
View file

@ -0,0 +1 @@
mpremote

22
src/main.py Normal file
View file

@ -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()

6
src/secrets.py Normal file
View file

@ -0,0 +1,6 @@
SSID = ""
PASS = ""
COUNTRY = ""
HA_ACCESS_TOKEN = ""