Commit graph

92 commits

Author SHA1 Message Date
Dan Halbert
cd92b3d2e8 fix keypad.EventQueue.__len__(); improve EventQueue doc 2025-03-26 09:35:19 -04:00
8aa1969c61 add, use a default exit object
This just delegates to .deinit().

Also, change default __enter__ to a macro that reuses the
identically-beving "identity_obj", and harmonize a few sites so that
the naming s consistent.

Saves about 800 bytes on metro rp2350.
2025-02-07 15:10:58 -06:00
Scott Shawcroft
e277540f7a
Switch to ruff like MicroPython 2025-02-05 11:09:15 -08:00
Dan Halbert
d08cecfeb8 keypad: add doc that reset() can be used to determine keys held down at startup 2024-11-19 17:45:25 -05:00
Dan Halbert
f517203ba6
Merge pull request #9717 from aseanwatson/fix_issue9714
Make edits suggested in #9714
2024-10-17 10:25:11 -04:00
Dan Halbert
697fba2da9 ShiftRegisterKeys key_count value was wrong 2024-10-14 20:41:34 -04:00
Sean Watson
d2367ea58b
Make edits suggested in issue 9714 2024-10-13 11:17:52 -07:00
Diamond Rivero
d5d40267bf
use 'mp_obj_property_getter_t' type 2024-10-04 14:56:36 +08:00
Diamond Rivero
d976f832f1
fix formatting 2024-10-04 11:14:46 +08:00
Diamond Rivero
7e72009ca6
remove 'mp_obj_property_t' usage remains 2024-10-04 11:01:14 +08:00
Dan Halbert
8b740373ed add warnings to keypad and rp2pio as well 2024-09-16 15:07:37 -04:00
Dan Halbert
3f4d9310ff CircuitPython files: replace STATIC with static 2024-05-20 11:02:17 -04:00
Dan Halbert
950b5d09d2 guard2once -s ... 2024-05-19 20:40:44 -04:00
Dan Halbert
747b7619ea update headers of most CircuitPython-only files 2024-05-17 14:56:28 -04:00
Joshua
e956f2994b Updated to use ringbuf and an event callback. 2024-04-06 12:53:08 +10:30
xs5871
3e184e994c
Add state integration based debouncing to the keypad module 2024-03-22 19:17:23 +00:00
Scott Shawcroft
d1e710fb4b
Merge remote-tracking branch 'adafruit/8.2.x' into merge_in_8.2.x 2024-02-13 11:18:56 -08:00
RetiredWizard
2490303a23 Add pre-commit changes (black 24.11) formattings changes 2024-02-12 16:56:21 -05:00
5aa203f13e
Restore CIRCUITPY-CHANGEs for stream protocols
We mark all protocols with their type using MP_PROTO_IMPLEMENT,
and checking in mp_get_stream{,_raise}.

This was not turning up as a problem in tests until a (new, not yet
commited) change to jpegio caused a segfault because a type implementing
a different protocol was passed in to mp_get_stream.

By using 0 (instead of MP_QSTR_protocol_stream) as the marker for
objects implementing the standard micropython stream protocol, the
number of CIRCUITPY-CHANGEs is minimized.
2023-12-24 10:41:54 -06:00
774f6ac6ab
Switch to using MP_ERROR_TEXT instead of translate, globally 2023-10-30 09:49:06 +01:00
Radomir Dopieralski
8123dc8bf7 Fix keypad classes to show the events property
It looks like we need the MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS flag on
the class for properties to work, and the Keys, KeyMatrix and
ShiftRegisterKeys classes were missing it, so the "events" property
didn't appear on the instances.
2023-10-28 19:33:37 +02:00
Scott Shawcroft
e62db5adcd
Fix native property setting from subclass 2023-10-24 16:20:51 -07:00
Dan Halbert
4b42a6f4a0 restore old uzlib; remove remaining U and u prefixes 2023-10-19 21:29:57 -04:00
Scott Shawcroft
9633c4e78f
Merge remote-tracking branch 'adafruit/main' into v1.20-merge 2023-10-11 11:21:57 -07:00
Dan Halbert
7e0e6fcdca Metro M4 now compiles 2023-10-03 15:03:59 -04:00
Dan Halbert
4d175ab41a convert to MP_DEFINED_CONST_OBJ_TYPE() 2023-09-19 21:09:29 -04:00
c029d6a165
Merge remote-tracking branch 'origin/8.2.x' into merge-82x 2023-08-22 08:49:16 -05:00
Dan Halbert
2171e67c1b merge latest adafruit/main 2023-08-13 19:43:54 -04:00
Dan Halbert
0d2c3c3f08 wip: continuing compilation fixes; mp_obj_alloc everywhere 2023-08-07 20:45:57 -04:00
f15eceb24c
Document more classes that can be separately enabled 2023-07-20 11:16:49 -05:00
Marco van der Kolk
bdf9336b80 Improved help text
Signed-off-by: Marco van der Kolk <marco.git@vdkolk.nl>
2023-07-11 12:09:51 +02:00
Marco van der Kolk
0c606c534c Documentation: Sequences are supported, not just Lists
Signed-off-by: Marco van der Kolk <marco.git@vdkolk.nl>
2023-07-11 11:18:29 +02:00
Marco van der Kolk
f8edecf473 corrected formatting 2023-07-10 22:16:22 +02:00
kolkmvd
2860593425
fixed missing comma 2023-07-10 12:28:36 +02:00
Marco van der Kolk
21d08646e1 updated documentation 2023-07-10 12:04:26 +02:00
Marco van der Kolk
5fcd90d8fb Extended to support multiple data pins
Signed-off-by: Marco van der Kolk <marco.git@vdkolk.nl>
2023-07-06 23:40:47 +02:00
9679aaa0be
Apply suggestions from code review
Co-authored-by: Scott Shawcroft <scott@tannewt.org>
2023-04-05 11:57:06 -05:00
3038b9a560
Update shared-bindings/keypad/ShiftRegisterKeys.c
Co-authored-by: Scott Shawcroft <scott@tannewt.org>
2023-04-05 11:56:21 -05:00
8b05d11538
save 4 bytes memory since qstr constants are smol 2023-04-01 19:25:30 -05:00
05cf5213e2
Allow disabling each class in keypad
.. for boards like pewpewm4 which need a specific kind. And need
some space.
2023-04-01 19:22:52 -05:00
hathach
fecc1bdedb
fix typos (partial) detected by codepell 2023-03-18 22:17:02 +07:00
MicroDev
d9d94eacca
run updated pre-commit 2023-02-01 13:38:41 +05:30
Dan Halbert
a974402542 Improve type validation errors messages, especially for pins 2023-01-10 15:02:55 -05:00
068b7c4af8
Use micropython #defines for stream polling operations
We adopted the file "py/ioctl.h" and the ioctl names beginning
with MP_IOCTL_POLL while micropython went with "py/stream.h" and
MP_STREAM_POLL.

Align with upstream.

Closes #6711
2022-10-14 12:15:30 -05:00
907c5d387f
Tweak black_bindings
Originally, black_bindings found each contiguous "//|" block and sent
it to black independently. This was slower than it needed to be.

Instead, swap the comment prefix: when running black, take off
"//|" prefixes and put "##|" prefixes on all un-prefixed lines.
Then, after black is run, do the opposite operation

This more than doubles the overall speed of "pre-commit run --all",
from 3m20s to 55s CPU time on my local machine (32.5s to under 10s
"elapsed" time)

It also causes a small amount of churn in the bindings, because
black now sees enough context to know whether one 'def' follows another
or ends the 'def's in a 'class'. In the latter case, it adds an extra
newline, which becomes a "//|" line.

I'm less sure why a trailing comma was omitted before down in
rp2pio/StateMachine.c but let's roll with it.
2022-09-30 11:18:13 -05:00
b2cc8d2aad
run black_bindings across all bindings 2022-09-27 15:21:42 -05:00
76f03a2bee
Make keypad select/poll'able for better async
This allows a small wrapper class to be written
```py
class AsyncEventQueue:
    def __init__(self, events):
        self._events = events

    async def __await__(self):
        yield asyncio.core._io_queue.queue_read(self._events)
        return self._events.get()

    def __enter__(self):
        return self

    def __exit__(self, exc_type, exc_value, traceback):
        pass

```
and used to just "await" the next event:
```py
async def key_task():
    print("waiting for keypresses")
    with keypad.KeyMatrix([board.D4], [board.D5]) as keys, AsyncEventQueue(keys.events) as ev:
        while True:
            print(await ev)
```

Because checking the empty status of the EventQueue does not enter
CircuitPython bytecode, it's assumed (but not measured) that this is
more efficient than an equivalent loop with an `await async.sleep(0)`
yield and introduces less latency than any non-zero sleep value.
2022-08-09 21:48:27 -05:00
foamyguy
e92ac0caf4 adding links in docs 2022-07-11 11:04:06 -05:00
78cf0a90af
Make MP_PROPERTY_GETTER / _GETSET fully declare the property
This will enable setting data attributes, namely, the section of the
symbol.
2022-05-03 08:48:53 -05:00
31da335cac
Introduce, use MP_PROPERTY_GETTER, _GETSET
Later, these can be changed in cunning ways to save flash storage.
2022-05-03 08:48:52 -05:00