|
41 | 41 | //| self,
|
42 | 42 | //| *,
|
43 | 43 | //| clock: microcontroller.Pin,
|
44 |
| -//| data: microcontroller.Pin, |
| 44 | +//| data: Union[microcontroller.Pin, List[microcontroller.Pin]], |
45 | 45 | //| latch: microcontroller.Pin,
|
46 | 46 | //| value_to_latch: bool = True,
|
47 |
| -//| key_count: int, |
| 47 | +//| key_count: Union[int, List[int]] |
48 | 48 | //| value_when_pressed: bool,
|
49 | 49 | //| interval: float = 0.020,
|
50 | 50 | //| max_events: int = 64
|
|
56 | 56 | //|
|
57 | 57 | //| Key number 0 is the first (or more properly, the zero-th) bit read. In the
|
58 | 58 | //| 74HC165, this bit is labeled ``Q7``. Key number 1 will be the value of ``Q6``, etc.
|
| 59 | +//| When specifying multiple data pins, the key numbers are sequential. |
| 60 | +//| So with two data Pins in parallel and key_count[0] = 32, the keys of data[1] will start with 32. |
59 | 61 | //|
|
60 | 62 | //| An `EventQueue` is created when this object is created and is available in the `events` attribute.
|
61 | 63 | //|
|
62 | 64 | //| :param microcontroller.Pin clock: The shift register clock pin.
|
63 | 65 | //| The shift register should clock on a low-to-high transition.
|
64 |
| -//| :param microcontroller.Pin data: the incoming shift register data pin |
65 |
| -//| :param Sequence[microcontroller.Pin] data: a list of incoming shift register data pins |
| 66 | +//| :param Union[microcontroller.Pin, List[microcontroller.Pin]] data: the incoming shift register data pin(s) |
66 | 67 | //| :param microcontroller.Pin latch:
|
67 | 68 | //| Pin used to latch parallel data going into the shift register.
|
68 | 69 | //| :param bool value_to_latch: Pin state to latch data being read.
|
69 | 70 | //| ``True`` if the data is latched when ``latch`` goes high
|
70 | 71 | //| ``False`` if the data is latched when ``latch`` goes low.
|
71 | 72 | //| The default is ``True``, which is how the 74HC165 operates. The CD4021 latch is the opposite.
|
72 | 73 | //| Once the data is latched, it will be shifted out by toggling the clock pin.
|
73 |
| -//| :param int key_count: number of data lines to clock in |
74 |
| -//| :param Sequence[int] key_count: a list of key_counts equal sized to data pins |
| 74 | +//| :param Union[int, List[int]] key_count: number of data lines to clock in (per data pin) |
75 | 75 | //| :param bool value_when_pressed: ``True`` if the pin reads high when the key is pressed.
|
76 | 76 | //| ``False`` if the pin reads low (is grounded) when the key is pressed.
|
77 | 77 | //| :param float interval: Scan keys no more often than ``interval`` to allow for debouncing.
|
|
84 | 84 | //| ...
|
85 | 85 |
|
86 | 86 | STATIC mp_obj_t keypad_shiftregisterkeys_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) {
|
87 |
| - #if CIRCUITPY_KEYPAD_SHIFTREGISTERKEYS |
| 87 | +#if CIRCUITPY_KEYPAD_SHIFTREGISTERKEYS |
88 | 88 | keypad_shiftregisterkeys_obj_t *self = m_new_obj(keypad_shiftregisterkeys_obj_t);
|
89 | 89 | self->base.type = &keypad_shiftregisterkeys_type;
|
90 | 90 | enum { ARG_clock, ARG_data, ARG_latch, ARG_value_to_latch, ARG_key_count, ARG_value_when_pressed, ARG_interval, ARG_max_events };
|
@@ -159,9 +159,9 @@ STATIC mp_obj_t keypad_shiftregisterkeys_make_new(const mp_obj_type_t *type, siz
|
159 | 159 |
|
160 | 160 | return MP_OBJ_FROM_PTR(self);
|
161 | 161 |
|
162 |
| - #else |
| 162 | +#else |
163 | 163 | mp_raise_NotImplementedError_varg(translate("%q"), MP_QSTR_ShiftRegisterKeys);
|
164 |
| - #endif |
| 164 | +#endif |
165 | 165 | }
|
166 | 166 |
|
167 | 167 | #if CIRCUITPY_KEYPAD_SHIFTREGISTERKEYS
|
@@ -225,7 +225,7 @@ const mp_obj_type_t keypad_shiftregisterkeys_type = {
|
225 | 225 | { &mp_type_type },
|
226 | 226 | .name = MP_QSTR_ShiftRegisterKeys,
|
227 | 227 | .make_new = keypad_shiftregisterkeys_make_new,
|
228 |
| - #if CIRCUITPY_KEYPAD_SHIFTREGISTERKEYS |
| 228 | +#if CIRCUITPY_KEYPAD_SHIFTREGISTERKEYS |
229 | 229 | .locals_dict = (mp_obj_t)&keypad_shiftregisterkeys_locals_dict,
|
230 |
| - #endif |
| 230 | +#endif |
231 | 231 | };
|
0 commit comments