|
46 | 46 | //| Manage updating a display over SPI four wire protocol in the background while Python code runs. |
47 | 47 | //| It doesn't handle display initialization. |
48 | 48 | //| |
49 | | -//| .. class:: FourWire(spi_bus, *, command, chip_select, reset=None) |
| 49 | +//| .. class:: FourWire(spi_bus, *, command, chip_select, reset=None, baudrate=24000000) |
50 | 50 | //| |
51 | 51 | //| Create a FourWire object associated with the given pins. |
52 | 52 | //| |
|
59 | 59 | //| :param microcontroller.Pin command: Data or command pin |
60 | 60 | //| :param microcontroller.Pin chip_select: Chip select pin |
61 | 61 | //| :param microcontroller.Pin reset: Reset pin. When None only software reset can be used |
| 62 | +//| :param int baudrate: Maximum baudrate in Hz for the display on the bus |
62 | 63 | //| |
63 | 64 | STATIC mp_obj_t displayio_fourwire_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { |
64 | | - enum { ARG_spi_bus, ARG_command, ARG_chip_select, ARG_reset }; |
| 65 | + enum { ARG_spi_bus, ARG_command, ARG_chip_select, ARG_reset, ARG_baudrate }; |
65 | 66 | static const mp_arg_t allowed_args[] = { |
66 | 67 | { MP_QSTR_spi_bus, MP_ARG_REQUIRED | MP_ARG_OBJ }, |
67 | 68 | { MP_QSTR_command, MP_ARG_OBJ | MP_ARG_KW_ONLY | MP_ARG_REQUIRED }, |
68 | 69 | { MP_QSTR_chip_select, MP_ARG_OBJ | MP_ARG_KW_ONLY | MP_ARG_REQUIRED }, |
69 | 70 | { MP_QSTR_reset, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_obj = mp_const_none} }, |
| 71 | + { MP_QSTR_baudrate, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 24000000} }, |
70 | 72 | }; |
71 | 73 | mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; |
72 | 74 | mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); |
@@ -97,7 +99,7 @@ STATIC mp_obj_t displayio_fourwire_make_new(const mp_obj_type_t *type, size_t n_ |
97 | 99 | } |
98 | 100 |
|
99 | 101 | common_hal_displayio_fourwire_construct(self, |
100 | | - MP_OBJ_TO_PTR(spi), command, chip_select, reset); |
| 102 | + MP_OBJ_TO_PTR(spi), command, chip_select, reset, args[ARG_baudrate].u_int); |
101 | 103 | return self; |
102 | 104 | } |
103 | 105 |
|
|
0 commit comments