Initial commit

This commit is contained in:
2026-03-31 13:26:46 +02:00
parent 9f2f6ee462
commit b51deb6529
3 changed files with 1041 additions and 1136 deletions

165
.gitignore vendored
View File

@@ -1,137 +1,50 @@
# Byte-compiled / optimized / DLL files
# ── Python ──────────────────────────────────────────────────────────────────
__pycache__/
*.py[cod]
*$py.class
*.pyo
*.pyd
*.pyc
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
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
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/
# Celery stuff
celerybeat-schedule
celerybeat.pid
# SageMath parsed files
*.sage.py
# Environments
.env
.venv
env/
# ── Environnements virtuels ──────────────────────────────────────────────────
venv/
.venv/
env/
ENV/
env.bak/
venv.bak/
Pipfile.lock
# Spyder project settings
.spyderproject
.spyproject
# ── Secrets ───────────────────────────────────────────────────────────────────
.env
.env.*
secret.env
secrets.py
*.secret
credentials.json
token.json
# Rope project settings
.ropeproject
# ── Logs ─────────────────────────────────────────────────────────────────────
*.log
logs/
# mkdocs documentation
/site
# ── IDE ───────────────────────────────────────────────────────────────────────
.vscode/
.idea/
*.swp
.DS_Store
Thumbs.db
# mypy
.mypy_cache/
.dmypy.json
dmypy.json
# ── Tests / Coverage ─────────────────────────────────────────────────────────
.coverage
htmlcov/
.pytest_cache/
# Pyre type checker
.pyre/
# ── Build ─────────────────────────────────────────────────────────────────────
dist/
build/
*.egg-info/
# pytype static type analyzer
.pytype/
# Cython debug symbols
cython_debug/
# ── Modèles IA (trop lourds pour git) ───────────────────────────────────────
*.gguf
*.bin
*.safetensors
models/
weights/

View File

@@ -1,27 +1,5 @@
#!/usr/bin/env python
# Primadiag SAS - Paris
# Author: Gino D.
# Copyright (c) 2023 Primadiag
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE
import os
import sys
import time
@@ -43,9 +21,10 @@ from dotenv import dotenv_values
from typing import List, Optional, Tuple, Union
BUFFER_SIZE: int = 256
BUFFER_SIZE: int = 512
LISTENING_TO: str = os.getcwd()
class Tab():
bordered: bool = False
colsize: List = []
@@ -330,6 +309,7 @@ class Pyboard(object):
self.transfer_status()
self.serial.write(command[i: min(i + BUFFER_SIZE, len(command))])
# time.sleep(0.0001)
if not self.read_until(self.send_ok()):
raise Exception('Terminal: could not execute command')
@@ -337,11 +317,13 @@ class Pyboard(object):
data = self.read_until(b'\x04', stream_output=stream_output, show_status=not stream_output)
if not data:
self.send_ctrl_d()
raise Exception('Terminal: timeout waiting for first EOF reception')
exception = self.read_until(b'\x04')
if not exception:
self.send_ctrl_d()
raise Exception('Terminal: timeout waiting for second EOF reception')
data, exception = (data[:-1].decode('utf-8'), exception[:-1].decode('utf-8'))
@@ -644,6 +626,13 @@ class Picowatch(object):
""")
self.interrupt()
def flash(self):
self.terminal("""
import machine
machine.bootloader()
""")
self.interrupt()
def interrupt(self):
self.filesystem.pyboard.send_ctrl_c()
self.filesystem.pyboard.until_nothing_in_waiting()
@@ -949,6 +938,7 @@ while True:
tab.line('ctrl + Z', 'exit', '', 'Same as ctrl + D, Exit Picowatch Terminal.')
tab.line('system', 'os', '', 'Pyboard name and version.')
tab.line('reset', 'rs', '', 'Perform a soft reset from the REPL.')
tab.line('flash', 'fl', '', 'Perform a flash disk from the REPL.')
tab.line('scan', 'ls', '[<path>] (default: /)', 'List information about the file(s) on the Pyboard.')
tab.line('edit', 'vim', '<file> [<use vim>]', 'Edit specified file from the PC (vim or vscode is required).')
tab.line('source', 'cat', '<file>', 'Concatenate source code to standard output.')
@@ -997,6 +987,8 @@ while True:
picowatch.boot()
case ['rs' | 'reset']:
picowatch.reset()
case ['fl' | 'flash']:
picowatch.flash()
case ['exit']:
sys.exit('Picowatch Terminal disconnected!')
case _: