Skip to content

Adding the usage of the 3rd button as the Wheel in USB mouse.py #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 104 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
104 commits
Select commit Hold shift + click to select a range
78900af
aioble: Add short name support to scan results.
FlantasticDan Feb 16, 2023
52fcb8e
cbor2: Add cbor2 library.
iabdalkader Nov 29, 2022
9ee0257
senml: Add SenML library.
iabdalkader Sep 27, 2022
1eb282a
tools/ci.sh: Support publishing package and index files to GitHub Pages.
projectgus Feb 20, 2023
40dfc5f
github/workflows: Attach built packages to GitHub workflow artifacts.
projectgus Feb 24, 2023
b9741f6
cbor2: Remove u-module prefix from imports.
iabdalkader Mar 2, 2023
295a9e3
senml: Remove u-module prefix from imports.
iabdalkader Mar 2, 2023
c860319
senml: Fix data record encoding to use binascii instead of base64.
iabdalkader Mar 3, 2023
ea21cb3
iperf3: Support devices without os.urandom().
dpgeorge Mar 21, 2023
f672353
unittest-discover: Print results when no tests are found/run.
pi-anl Mar 16, 2023
386ab99
python-ecosys: Add pypi= to metadata.
jimmo Apr 6, 2023
afc9d0a
micropython: Add missing metadata for packages.
jimmo Apr 6, 2023
9b5f4d7
tools/makepyproject.py: Add tool to generate PyPI package.
jimmo Mar 31, 2023
01db3da
senml: Allow publishing to PyPI as micropython-senml.
jimmo Mar 31, 2023
c113611
aioble: Fix descriptor flag handling.
jimmo Apr 11, 2023
a1b9aa9
aioespnow: Add library providing asyncio support for espnow module.
glenn20 Apr 7, 2023
7128d42
utarfile: Support creating/appending tar files.
dpwe May 14, 2023
1957f24
lora: Add lora modem drivers for SX127x and SX126x.
projectgus Jun 28, 2022
2fba6b8
lora: Workaround SX1262 bug with GetStatus.
projectgus Jan 16, 2023
da5ddfc
hashlib: Refactor, split, and optimise.
jimmo Jun 1, 2023
0a5b635
utarfile: Fix read/write handling of nulls in tar header.
dpgeorge Jul 21, 2023
fe3e0a2
cmd: Remove comments about using the string module.
jimmo Jul 21, 2023
66924d9
xmltok: Change StopIteration to EOFError due to PEP-479.
ThunderEX Feb 3, 2021
c48b17d
aiorepl/README.md: More info about globals.
jimmo Jul 21, 2023
c2b44ea
types: Add manifest file.
pi-anl Apr 19, 2023
0f768c9
bisect: Add manifest file.
pi-anl Apr 20, 2023
b95deb3
json: Add manifest file.
pi-anl Apr 20, 2023
028a369
keyword: Add manifest file.
pi-anl Apr 20, 2023
5329ef5
logging: Add full support for logging exception tracebacks.
pi-anl May 18, 2023
0e68c7d
copy: Declare dependency on types.
pi-anl Jun 13, 2023
ff84231
aiorepl: Replace f-string with str.format.
jimmo Jun 20, 2023
6103823
all: Remove __version__ from .py files.
jimmo Jun 22, 2023
e45a7f6
fnmatch: Fix compatibility with ure -> re.
pi-anl Jul 6, 2023
5004436
tarfile: Rename from utarfile.
jimmo Jul 21, 2023
8513bfb
requests: Rename urequests to requests.
jimmo Jul 21, 2023
87b4cda
aiorepl: Bump patch version.
jimmo Jul 21, 2023
97b7a30
xmltok: Bump patch version.
jimmo Jul 21, 2023
a19d2a3
copy: Bump patch version.
jimmo Jul 21, 2023
ebbb78e
logging: Bump minor version.
jimmo Jul 21, 2023
8fc9eda
all: Standardise x.y.z versioning for all packages.
jimmo Jul 21, 2023
752ce66
github/workflows: Build all example .py files as part of CI.
dpgeorge Jul 24, 2023
4da6e6f
all: Lint Python code with ruff.
cclauss May 2, 2023
36e74c1
zlib: Add zlib module.
jimmo Jun 26, 2023
2328592
tools/codeformat.py: Remove git state detection.
jimmo Jul 25, 2023
5cdfe71
top: Add pre-commit config.
jimmo Jul 25, 2023
efa0402
tools/codeformat.py: Fix ruff warnings.
jimmo Jul 25, 2023
ce3f282
github/workflows: Split ruff into its own action.
jimmo Jul 25, 2023
01ab7ba
iperf3: Add compatibility for servers pre version 3.2.
graeme-winter May 21, 2023
674e734
drivers/display/lcd160cr: Use isinstance() for type checking.
projectgus Aug 9, 2023
86050c3
bmm150: Remove broken reset function.
projectgus Aug 9, 2023
2d16f21
lsm6dsox: Add missing time import.
projectgus Aug 9, 2023
1f3002b
wm8960: Add missing self reference for sample table.
projectgus Aug 9, 2023
786c0ea
all: Add missing const imports
projectgus Aug 9, 2023
c6a72c7
cbor2: Improve decoder to pass Ruff F821 undefined-name.
projectgus Aug 9, 2023
991ac98
iperf3: Pre-declare some variables set in the loop.
projectgus Aug 9, 2023
b46306c
uaiohttpclient: Fix missing name in unreachable example code.
projectgus Aug 9, 2023
5b6fb2b
top: Enable Ruff linter to check undefined-name (F821).
projectgus Aug 9, 2023
1b557ee
lsm6dsox: Bump patch version.
dpgeorge Aug 23, 2023
dc765ad
wm8960: Bump patch version.
dpgeorge Aug 23, 2023
93bf707
lora: Remove the pin parameter from IRQ callback.
projectgus Aug 8, 2023
ed688cf
lora: Add STM32WL55 subghz LoRa modem class.
projectgus Nov 10, 2022
0bdecbc
lora: Note known issue with STM32WL5 HP antenna.
projectgus Aug 9, 2023
7fcc728
lora/sx126x: Fix busy timeout handling.
projectgus Aug 23, 2023
e6b89ea
all: Remove unnecessary start argument in range.
dpgeorge Aug 31, 2023
55d1d23
__future__: Add "annotations".
smurfix Sep 24, 2023
e5ba864
aioble/server.py: Add data arg for indicate.
jimmo Sep 14, 2023
46748d2
aioble/server.py: Allow BufferedCharacteristic to support all ops.
jimmo Sep 14, 2023
e025c84
requests: Fix detection of iterators in chunked data requests.
bwhitman May 30, 2023
0620d02
.github/workflows/ruff.yml: Pin to 0.1.0.
jimmo Oct 17, 2023
d8e163b
unix-ffi/re: Convert to PCRE2.
Ansuel Sep 28, 2023
ad0a259
tools/verifygitlog.py: Add git commit message checking.
jimmo Oct 26, 2023
cee0945
all: Replace "black" with "ruff format".
jimmo Oct 17, 2023
83f3991
lcd160cr: Remove support for options in manifest.
jimmo Nov 10, 2023
340243e
time: Add README to explain the purpose of the time extension library.
mattytrentini Sep 30, 2023
41aa257
base64: Implement custom maketrans and translate methods.
magixyu Nov 12, 2023
e051a12
aiorepl: Update import of asyncio.
pi-anl Oct 24, 2023
d41851c
aiorepl: Add support for paste mode (ctrl-e).
pi-anl Oct 24, 2023
10c9281
aiorepl: Add cursor left/right support.
pi-anl Oct 24, 2023
f672baa
aiorepl: Add support for raw mode (ctrl-a).
pi-anl Oct 24, 2023
ae8ea8d
os-path: Implement os.path.isfile().
scivision Sep 14, 2023
149226d
uaiohttpclient: Fix hard coded port 80.
bulletmark Nov 7, 2023
9d09cdd
uaiohttpclient: Make flake8 inspired improvements.
bulletmark Nov 7, 2023
05efdd0
uaiohttpclient: Update "yield from" to "await".
bulletmark Nov 7, 2023
9ceda53
uaiohttpclient: Update example client code.
bulletmark Nov 7, 2023
57ce3ba
aioble: Fix advertising variable name to use us not ms.
bhavesh-k Nov 20, 2023
7cdf708
aiohttp: Add new aiohttp package.
Carglglz Sep 5, 2023
803452a
umqtt.simple: Simplify check for user being unused.
felixdoerre Feb 1, 2024
35d41db
ssl: Restructure micropython SSL interface to a new tls module.
felixdoerre Feb 1, 2024
ddb1a27
hmac: Fix passing in a string for digestmod argument.
Pharkie Jan 20, 2024
56f514f
aiohttp: Fix binary data treatment.
Carglglz Jan 3, 2024
8058b29
tarfile-write: Fix permissions when adding to archive.
ubidefeo Feb 5, 2024
4cc6706
tools/ci.sh: Add unix-ffi library when testing unix-ffi subdirectory.
projectgus Feb 13, 2024
b712103
lora-sx126x: Fix invalid default configuration after reset.
projectgus Feb 13, 2024
ad6ab5a
lora-sync: Fix race with fast or failed send().
projectgus Feb 13, 2024
5462848
lora-sx127x: Implement missing syncword support.
projectgus Feb 13, 2024
35bb795
lora-sx126x: Fix syncword setting.
projectgus Feb 13, 2024
2242465
lora-sx126x: Clean up some struct formatting.
projectgus Feb 13, 2024
ffb07db
gzip: Fix recursion error in open() function.
dpgeorge Feb 29, 2024
23df50d
unix-ffi: Remove "unix_ffi" argument from require().
dpgeorge Mar 17, 2024
5c7e3fc
json: Move to unix-ffi.
jimmo Feb 22, 2024
8ee876d
cbor2: Deprecate decoder and encoder modules.
iabdalkader Mar 6, 2024
661efa4
senml: Use the updated cbor2 API.
iabdalkader Mar 6, 2024
744f8c4
usb: Add USB device support packages.
projectgus Mar 27, 2024
dfdedeb
The new lines 105 and 106 were necessary to ensure the proper handlin…
wzab Jun 10, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions .github/workflows/build_packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,28 @@ name: Build all packages

on: [push, pull_request]

env:
PACKAGE_INDEX_PATH: /tmp/micropython-lib-deploy

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v1
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- name: Setup environment
run: source tools/ci.sh && ci_build_packages_setup
- name: Check manifest files
run: source tools/ci.sh && ci_build_packages_check_manifest
- name: Compile package index
run: source tools/ci.sh && ci_build_packages_compile_index
- name: Compile package examples
run: source tools/ci.sh && ci_build_packages_examples
- name: Publish packages for branch
if: vars.MICROPY_PUBLISH_MIP_INDEX && github.event_name == 'push' && ! github.event.deleted
run: source tools/ci.sh && ci_push_package_index
- name: Upload packages as artifact
uses: actions/upload-artifact@v3
with:
name: packages-${{ github.sha }}
path: ${{ env.PACKAGE_INDEX_PATH }}
12 changes: 12 additions & 0 deletions .github/workflows/cleanup_published_packages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Cleanup published packages

on: delete

jobs:
cleanup:
runs-on: ubuntu-latest
if: vars.MICROPY_PUBLISH_MIP_INDEX
steps:
- uses: actions/checkout@v3
- name: Clean up published files
run: source tools/ci.sh && ci_cleanup_package_index ${{ github.event.ref }}
16 changes: 0 additions & 16 deletions .github/workflows/code_formatting.yml

This file was deleted.

18 changes: 18 additions & 0 deletions .github/workflows/commit_formatting.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Check commit message formatting

on: [push, pull_request]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: '100'
- uses: actions/setup-python@v4
- name: Check commit message formatting
run: source tools/ci.sh && ci_commit_formatting_run
11 changes: 11 additions & 0 deletions .github/workflows/ruff.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
name: Python code lint and formatting with ruff
on: [push, pull_request]
jobs:
ruff:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: pip install --user ruff==0.1.2
- run: ruff check --output-format=github .
- run: ruff format --diff .
14 changes: 14 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
repos:
- repo: local
hooks:
- id: verifygitlog
name: MicroPython git commit message format checker
entry: tools/verifygitlog.py --check-file --ignore-rebase
language: python
verbose: true
stages: [commit-msg]
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.1.2
hooks:
- id: ruff
id: ruff-format
64 changes: 60 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,21 @@ or packages from micropython-lib, please post at the
### Pull requests

The same rules for commit messages, signing-off commits, and commit structure
apply as for the main MicroPython repository. All Python code is formatted
using `black`. See [`tools/codeformat.py`](tools/codeformat.py) to apply
`black` automatically before submitting a PR.
apply [as for the main MicroPython repository](https://github.com/micropython/micropython/blob/master/CODECONVENTIONS.md).

There are some specific conventions and guidelines for micropython-lib:
All Python code is formatted using the [black](https://github.com/psf/black)
tool. You can run [`tools/codeformat.py`](tools/codeformat.py) to apply
`black` automatically before submitting a PR. The GitHub CI will also run the
[ruff](https://github.com/astral-sh/ruff) tool to apply further "linting"
checks.

Similar to the main repository, a configuration is provided for the
[pre-commit](https://pre-commit.com/) tool to apply `black` code formatting
rules and run `ruff` automatically. See the documentation for using pre-commit
in [the code conventions document](https://github.com/micropython/micropython/blob/master/CODECONVENTIONS.md#automatic-pre-commit-hooks)

In addition to the conventions from the main repository, there are some
specific conventions and guidelines for micropython-lib:

* The first line of the commit message should start with the name of the
package, followed by a short description of the commit. Package names are
Expand Down Expand Up @@ -69,3 +79,49 @@ There are some specific conventions and guidelines for micropython-lib:

* When porting an existing third-party package, please ensure that the source
license is compatible.

* To make it easier for others to install packages directly from your PR before
it is merged, consider opting-in to automatic package publishing (see
[Publishing packages from forks](#publishing-packages-from-forks)). If you do
this, consider quoting the [commands to install
packages](README.md#installing-packages-from-forks) in your Pull Request
description.

### Publishing packages from forks

You can easily publish the packages from your micropython-lib
[fork](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/about-forks)
by opting in to a system based on [GitHub
Actions](https://docs.github.com/en/actions) and [GitHub
Pages](https://docs.github.com/en/pages):

1. Open your fork's repository in the GitHub web interface.
2. Navigate to "Settings" -> "Secrets and variables" -> "Actions" -> "Variables".
3. Click "New repository variable"
4. Create a variable named `MICROPY_PUBLISH_MIP_INDEX` with value `true` (or any
"truthy" value).
5. The settings for GitHub Actions and GitHub Pages features should not need to
be changed from the repository defaults, unless you've explicitly disabled
them.

The next time you push commits to a branch in your fork, GitHub Actions will run
an additional step in the "Build All Packages" workflow named "Publish Packages
for branch".

Anyone can then install these packages as described under [Installing packages
from forks](README.md#installing-packages-from-forks). The exact commands are also
quoted in the GitHub Actions log for the "Publish Packages for branch" step.

#### Opting Back Out

To opt-out again, delete the `MICROPY_PUBLISH_MIP_INDEX` variable and
(optionally) delete the `gh-pages` branch from your fork.

*Note*: While enabled, all micropython-lib packages will be published each time
a change is pushed to any branch in your fork. A commit is added to the
`gh-pages` branch each time. In a busy repository, the `gh-pages` branch may
become quite large. The actual `.git` directory size on disk should still be
quite small, as most of the content will be duplicated. If you're worried that
the `gh-pages` branch has become too large then you can always delete this
branch from GitHub. GitHub Actions will create a new `gh-pages` branch the next
time you push a change.
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,37 @@ Note that unlike the other three approaches based on `mip` or `manifest.py`,
you will need to manually resolve dependencies. You can inspect the relevant
`manifest.py` file to view the list of dependencies for a given package.

## Installing packages from forks

It is possible to use the `mpremote mip install` or `mip.install()` methods to
install packages built from a
[fork](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/about-forks)
of micropython-lib, if the fork's owner has opted in.

This can be useful to install packages from a pending Pull Request, for example.

First, the owner of the fork must opt-in as described under
[Publishing packages from forks](CONTRIBUTING.md#publishing-packages-from-forks).

After this has happened, each time someone pushes to a branch in that fork then
GitHub Actions will automatically publish the packages to a GitHub Pages site.

To install these packages, use commands such as:

```bash
$ mpremote connect /dev/ttyUSB0 mip install --index https://USERNAME.github.io/micropython-lib/mip/BRANCH_NAME PACKAGE_NAME
```

Or from a networked device:

```py
import mip
mip.install(PACKAGE_NAME, index="https://USERNAME.github.io/micropython-lib/mip/BRANCH_NAME")
```

(Where `USERNAME`, `BRANCH_NAME` and `PACKAGE_NAME` are replaced with the owner
of the fork, the branch the packages were built from, and the package name.)

## Contributing

We use [GitHub Discussions](https://github.com/micropython/micropython/discussions)
Expand Down
91 changes: 91 additions & 0 deletions micropython/aioespnow/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# `aioespnow`

A supplementary module which extends the micropython `espnow` module to provide
`asyncio` support.

- Asyncio support is available on all ESP32 targets as well as those ESP8266
boards which include the `uasyncio` module (ie. ESP8266 devices with at least
2MB flash storage).

## API reference

- class `AIOESPNow()`: inherits all the methods of the `ESPNow` class and
extends the interface with the following async methods:

- `async AIOESPNow.arecv()`

Asyncio support for ESPNow.recv(). Note that this method does not take a
timeout value as argument.

- `async AIOESPNow.airecv()`

Asyncio support for ESPNow.irecv(). Use this method to reduce memory
fragmentation, as it will reuse common storage for each new message
received, whereas the `arecv()` method will allocate new memory for every
message received.

- `async AIOESPNow.asend(mac, msg, sync=True)`
- `async AIOESPNow.asend(msg)`

Asyncio support for ESPNow.send().

- `__aiter__()/async __anext__()`

AIOESPNow also supports reading incoming messages by asynchronous
iteration using `async for`, eg:

```python
e = AIOESPNow()
e.active(True)
async def recv_till_halt(e):
async for mac, msg in e:
print(mac, msg)
if msg == b'halt':
break
asyncio.run(recv_till_halt(e))
```

## Example Usage

A small async server example::

```python
import network
import aioespnow
import uasyncio as asyncio

# A WLAN interface must be active to send()/recv()
network.WLAN(network.STA_IF).active(True)

e = aioespnow.AIOESPNow() # Returns AIOESPNow enhanced with async support
e.active(True)
peer = b'\xbb\xbb\xbb\xbb\xbb\xbb'
e.add_peer(peer)

# Send a periodic ping to a peer
async def heartbeat(e, peer, period=30):
while True:
if not await e.asend(peer, b'ping'):
print("Heartbeat: peer not responding:", peer)
else:
print("Heartbeat: ping", peer)
await asyncio.sleep(period)

# Echo any received messages back to the sender
async def echo_server(e):
async for mac, msg in e:
print("Echo:", msg)
try:
await e.asend(mac, msg)
except OSError as err:
if len(err.args) > 1 and err.args[1] == 'ESP_ERR_ESPNOW_NOT_FOUND':
e.add_peer(mac)
await e.asend(mac, msg)

async def main(e, peer, timeout, period):
asyncio.create_task(heartbeat(e, peer, period))
asyncio.create_task(echo_server(e))
await asyncio.sleep(timeout)

asyncio.run(main(e, peer, 120, 10))
```
31 changes: 31 additions & 0 deletions micropython/aioespnow/aioespnow.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# aioespnow module for MicroPython on ESP32 and ESP8266
# MIT license; Copyright (c) 2022 Glenn Moloney @glenn20

import uasyncio as asyncio
import espnow


# Modelled on the uasyncio.Stream class (extmod/stream/stream.py)
# NOTE: Relies on internal implementation of uasyncio.core (_io_queue)
class AIOESPNow(espnow.ESPNow):
# Read one ESPNow message
async def arecv(self):
yield asyncio.core._io_queue.queue_read(self)
return self.recv(0) # type: ignore[misc]

async def airecv(self):
yield asyncio.core._io_queue.queue_read(self)
return self.irecv(0) # type: ignore[misc]

async def asend(self, mac, msg=None, sync=None):
if msg is None:
msg, mac = mac, None # If msg is None: swap mac and msg
yield asyncio.core._io_queue.queue_write(self)
return self.send(mac, msg, sync) # type: ignore[misc]

# "async for" support
def __aiter__(self):
return self

async def __anext__(self):
return await self.airecv()
6 changes: 6 additions & 0 deletions micropython/aioespnow/manifest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
metadata(
description="Extends the micropython espnow module with methods to support asyncio.",
version="0.1.0",
)

module("aioespnow.py")
18 changes: 12 additions & 6 deletions micropython/aiorepl/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ To use this library, you need to import the library and then start the REPL task
For example, in main.py:

```py
import uasyncio as asyncio
import asyncio
import aiorepl

async def demo():
Expand Down Expand Up @@ -50,11 +50,17 @@ async def main():
asyncio.run(main())
```

The optional globals passed to `task([globals])` allows you to specify what
will be in scope for the REPL. By default it uses `__main__`, which is the
same scope as the regular REPL (and `main.py`). In the example above, the
REPL will be able to call the `demo()` function as well as get/set the
`state` variable.
An optional globals dictionary can be passed to `aiorepl.task()`, which allows
you to specify what will be in scope for the REPL. By default it uses the
globals dictionary from the `__main__` module, which is the same scope as the
regular REPL (and `main.py`). In the example above, the REPL will be able to
call the `demo()` function as well as get/set the `state` variable.

You can also provide your own dictionary, e.g. `aiorepl.task({"obj": obj })`,
or use the globals dict from the current module, e.g.
`aiorepl.task(globals())`. Note that you cannot use a class instance's members
dictionary, e.g. `aiorepl.task(obj.__dict__)`, as this is read-only in
MicroPython.

Instead of the regular `>>> ` prompt, the asyncio REPL will show `--> `.

Expand Down
Loading