Skip to content

Commit

Permalink
Rewrite Open Trickler w/ Python (#51)
Browse files Browse the repository at this point in the history
* Drop JS files

* First commit of python files -- not working

* Drop more node files

* Update README with python info

* rename scale.py to scales.py

* Code cleanups

* Drop variables file. Not needed.

* More progress. Ready to start testing.

* Bug fixes, functional changes for logging and executable scripts

* Break out motor control, add motor tests

* Set memcache values on script startup to avoid conflicts from prior runs

* Move memcache updates into appropriate files, such as scale and motor

* Drop test serial file, replaced my scales.py

* Make motors.py executable

* Change motor test script, ramp up then down.

* Fix commands to be sent as bytes. Fix CLI interface to use strings for scale units

* Ignore DS_store files

* Add PID tuning output option.

* Update default PID values and new min PWM speed

* Some code cleanups and fixes. Scale reading not working in main loop

* Refactor loops for simplicity. Moved memcache client to be an arg. Fixed some pylint issues.

* More cleanups. Unit changing on scale works. Prevent trickling in more cases. Verified some TODOs are fixed.

* Remove TOOD about unit switching, confirmed working

* Add grpcio req

* Initial pass at v1 bluetooth module for compatibility. Still needs testing

* Support config file, version scale status, lint cleanups, add helpers, update server.sh launcher.

* Use config to enable pid tuner mode

* Add OpenAPI definition

* Update memcache for scale stability. Add comments

* Add temporary new readme

* Update scripts

* Fix open file bug in main trickler. Update server script for ini file without flag.

* Add manifest and setup files for proper python packaging

* Update packaging script for creating local python zip package

* use open when reading config files

* Bluetooth bugfix, arg should be a dictionary

* Daemonize bluetooth module.

* Fix reading values over bluetoothe

* Fix write from bluetooth functions

* Add status LED control.

* Define memcache strings in constants.py to avoid bugs and make typos easier to catch

* Update newer ble script, still not ready to use

* Remove quotes from config file, they get copied in

* Make leds.py executable

* Comment out led disable command

* Fix bug in leds script

* Fix bug in bluetooth write request for automode

* Fix reference to scale units in ble module

* Add reverse unit map to scales module

* Set better default memcache values

* Make trickler unit match correct type in memcache. Add logging

* use default values to get values from memcache for leds script.

* Switch gitignore from node to python

* Reformat large conditional for readability

* Add a second of sleep to allow scale to update when changing units

* Reset the input buffer before reading serial device.

* improve setup script and requirements file for non-arm machines

* Lint fixes

* Remove node variable from setup script

* Add lint script

* Improve bluetooth logging

* Use percentages for PID controller

* Change log setup to accept log level to correct verbosity

* Change LED behavior. Don't change state in every loop cycle

* Catch error from potential bad state and log. Don't default to False for auto_mode

* Upgrade flutter and deps for mobile app. Build iOS app again to restore version in TestFlight.

* Decrease font size in unit toggle button to avoid text being cut off. Update build number for iOS

* Fix notifications for bluetooth.

* Set generous timeouts for memcache client

* Refactor for simplicity. Catch memcache exceptions.

* Add sleep delay for led script.

* Disable pylint import errors

* Check memcache variables before starting LED script loop. Use try catch on memcache calls. Add timer delay in loop.

* More logging in ble module. Change function name from update to all_mc_update, conflicts with exisiting function from parent class.

* Less noisy logging for bluetooth

* Rename config.ini to opentrickler_config.ini to avoid confusion with config.txt on the BOOT partition.

* Allow verbose logging to be controlled from config file

* No verbose flag for leds.py, copy paste typo

* Set BLENO_DEVICE_NAME environment variable to ensure device name is properly set.

* Update flutter and mobile package to reup to Apple.

* Drop JS files

* First commit of python files -- not working

* Drop more node files

* Update README with python info

* rename scale.py to scales.py

* Code cleanups

* Drop variables file. Not needed.

* More progress. Ready to start testing.

* Bug fixes, functional changes for logging and executable scripts

* Break out motor control, add motor tests

* Set memcache values on script startup to avoid conflicts from prior runs

* Move memcache updates into appropriate files, such as scale and motor

* Drop test serial file, replaced my scales.py

* Make motors.py executable

* Change motor test script, ramp up then down.

* Fix commands to be sent as bytes. Fix CLI interface to use strings for scale units

* Ignore DS_store files

* Add PID tuning output option.

* Update default PID values and new min PWM speed

* Some code cleanups and fixes. Scale reading not working in main loop

* Refactor loops for simplicity. Moved memcache client to be an arg. Fixed some pylint issues.

* More cleanups. Unit changing on scale works. Prevent trickling in more cases. Verified some TODOs are fixed.

* Remove TOOD about unit switching, confirmed working

* Add grpcio req

* Initial pass at v1 bluetooth module for compatibility. Still needs testing

* Support config file, version scale status, lint cleanups, add helpers, update server.sh launcher.

* Use config to enable pid tuner mode

* Add OpenAPI definition

* Update memcache for scale stability. Add comments

* Add temporary new readme

* Update scripts

* Fix open file bug in main trickler. Update server script for ini file without flag.

* Add manifest and setup files for proper python packaging

* Update packaging script for creating local python zip package

* use open when reading config files

* Bluetooth bugfix, arg should be a dictionary

* Daemonize bluetooth module.

* Fix reading values over bluetoothe

* Fix write from bluetooth functions

* Add status LED control.

* Define memcache strings in constants.py to avoid bugs and make typos easier to catch

* Update newer ble script, still not ready to use

* Remove quotes from config file, they get copied in

* Make leds.py executable

* Comment out led disable command

* Fix bug in leds script

* Fix bug in bluetooth write request for automode

* Fix reference to scale units in ble module

* Add reverse unit map to scales module

* Set better default memcache values

* Make trickler unit match correct type in memcache. Add logging

* use default values to get values from memcache for leds script.

* Switch gitignore from node to python

* Reformat large conditional for readability

* Add a second of sleep to allow scale to update when changing units

* Reset the input buffer before reading serial device.

* improve setup script and requirements file for non-arm machines

* Lint fixes

* Remove node variable from setup script

* Add lint script

* Improve bluetooth logging

* Use percentages for PID controller

* Change log setup to accept log level to correct verbosity

* Change LED behavior. Don't change state in every loop cycle

* Catch error from potential bad state and log. Don't default to False for auto_mode

* Fix notifications for bluetooth.

* Set generous timeouts for memcache client

* Refactor for simplicity. Catch memcache exceptions.

* Add sleep delay for led script.

* Disable pylint import errors

* Check memcache variables before starting LED script loop. Use try catch on memcache calls. Add timer delay in loop.

* More logging in ble module. Change function name from update to all_mc_update, conflicts with exisiting function from parent class.

* Less noisy logging for bluetooth

* Rename config.ini to opentrickler_config.ini to avoid confusion with config.txt on the BOOT partition.

* Allow verbose logging to be controlled from config file

* No verbose flag for leds.py, copy paste typo

* Set BLENO_DEVICE_NAME environment variable to ensure device name is properly set.

* Update READMEs

* Update SD firmware links and checksums
  • Loading branch information
erichiggins committed Aug 15, 2021
1 parent 2d33646 commit ded4b51
Show file tree
Hide file tree
Showing 52 changed files with 2,289 additions and 4,060 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.DS_Store
4 changes: 2 additions & 2 deletions trickler/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ The Open Trickler is described in greater detail [in this article](https://blog.

## Support

Need help? [Join our Discord Server](https://discord.gg/WqTbyK2) to chat with other folks who are building the Open Trickler and helping each other out.
Need help? [Check the FAQ](https://github.com/ammolytics/projects/tree/develop/trickler#frequently-asked-questions) or [join our Discord Server](https://discord.gg/WqTbyK2) to chat with other folks who are building the Open Trickler and helping each other out.

This is a free, open-source project which does not come with any official support or warranty.

Expand All @@ -13,7 +13,7 @@ This is a free, open-source project which does not come with any official suppor

The Mobile app for this project uses the [Flutter framework](https://flutter.dev/). The code can be found in the [`mobile/`](https://github.com/ammolytics/projects/blob/develop/trickler/mobile/) directory.

The Controller is a [NodeJS (`v12.x`)](https://nodejs.org/docs/latest-v12.x/api/) application which reads from the scale's serial port and controls the trickler. It was designed to be run on a Raspberry Pi Zero W. The code can be found in the [`peripheral/`](https://github.com/ammolytics/projects/blob/develop/trickler/peripheral/) directory.
The Controller is a [Python (`v3.9`)](https://docs.python.org/3.9/) application which reads from the scale's serial port and controls the trickler. It was designed to be run on a Raspberry Pi Zero W. The code can be found in the [`peripheral/`](https://github.com/ammolytics/projects/blob/develop/trickler/peripheral/) directory.

## Hardware

Expand Down
17 changes: 0 additions & 17 deletions trickler/peripheral/.eslintrc.js

This file was deleted.

184 changes: 116 additions & 68 deletions trickler/peripheral/.gitignore
Original file line number Diff line number Diff line change
@@ -1,90 +1,138 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# C extensions
*.so

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output
# 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

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Flask stuff:
instance/
.webassets-cache

# Bower dependency directory (https://bower.io/)
bower_components
# Scrapy stuff:
.scrapy

# node-waf configuration
.lock-wscript
# Sphinx documentation
docs/_build/

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# PyBuilder
.pybuilder/
target/

# Dependency directories
node_modules/
jspm_packages/
# Jupyter Notebook
.ipynb_checkpoints

# TypeScript v1 declaration files
typings/
# IPython
profile_default/
ipython_config.py

# Optional npm cache directory
.npm
# 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

# Optional eslint cache
.eslintcache
# 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

# Optional REPL history
.node_repl_history
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Output of 'npm pack'
*.tgz
# Celery stuff
celerybeat-schedule
celerybeat.pid

# Yarn Integrity file
.yarn-integrity
# SageMath parsed files
*.sage.py

# dotenv environment variables file
# Environments
.env
.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# next.js build output
.next
# Spyder project settings
.spyderproject
.spyproject

# nuxt.js build output
.nuxt
# Rope project settings
.ropeproject

# vuepress build output
.vuepress/dist
# mkdocs documentation
/site

# Serverless directories
.serverless/
# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# FuseBox cache
.fusebox/
# Pyre type checker
.pyre/

# DynamoDB Local files
.dynamodb/
# pytype static type analyzer
.pytype/

# NodeEnv
.venv/

# Build
build/
# Cython debug symbols
cython_debug/
1 change: 0 additions & 1 deletion trickler/peripheral/.node-version

This file was deleted.

Loading

0 comments on commit ded4b51

Please sign in to comment.