Simplified cs toggling into fourwire only
This commit is contained in:
commit
2e0268cb09
|
@ -47,6 +47,4 @@ void common_hal_displayio_fourwire_send(mp_obj_t self, bool command, uint8_t *da
|
|||
|
||||
void common_hal_displayio_fourwire_end_transaction(mp_obj_t self);
|
||||
|
||||
void common_hal_displayio_fourwire_set_cs(mp_obj_t self, bool high);
|
||||
|
||||
#endif // MICROPY_INCLUDED_SHARED_BINDINGS_DISPLAYBUSIO_FOURWIRE_H
|
||||
|
|
|
@ -60,12 +60,10 @@ void common_hal_displayio_display_construct(displayio_display_obj_t* self,
|
|||
self->begin_transaction = common_hal_displayio_parallelbus_begin_transaction;
|
||||
self->send = common_hal_displayio_parallelbus_send;
|
||||
self->end_transaction = common_hal_displayio_parallelbus_end_transaction;
|
||||
self->set_cs = NULL;
|
||||
} else if (MP_OBJ_IS_TYPE(bus, &displayio_fourwire_type)) {
|
||||
self->begin_transaction = common_hal_displayio_fourwire_begin_transaction;
|
||||
self->send = common_hal_displayio_fourwire_send;
|
||||
self->end_transaction = common_hal_displayio_fourwire_end_transaction;
|
||||
self->set_cs = common_hal_displayio_fourwire_set_cs;
|
||||
} else {
|
||||
mp_raise_ValueError(translate("Unsupported display bus type"));
|
||||
}
|
||||
|
@ -83,11 +81,6 @@ void common_hal_displayio_display_construct(displayio_display_obj_t* self,
|
|||
bool delay = (data_size & DELAY) != 0;
|
||||
data_size &= ~DELAY;
|
||||
uint8_t *data = cmd + 2;
|
||||
if (self->set_cs != NULL) {
|
||||
self->set_cs(self->bus, true);
|
||||
common_hal_time_delay_ms(1);
|
||||
self->set_cs(self->bus, false);
|
||||
}
|
||||
self->send(self->bus, true, cmd, 1);
|
||||
self->send(self->bus, false, data, data_size);
|
||||
uint16_t delay_length_ms = 10;
|
||||
|
|
|
@ -34,7 +34,6 @@
|
|||
typedef bool (*display_bus_begin_transaction)(mp_obj_t bus);
|
||||
typedef void (*display_bus_send)(mp_obj_t bus, bool command, uint8_t *data, uint32_t data_length);
|
||||
typedef void (*display_bus_end_transaction)(mp_obj_t bus);
|
||||
typedef void (*display_bus_set_cs)(mp_obj_t bus, bool high);
|
||||
|
||||
typedef struct {
|
||||
mp_obj_base_t base;
|
||||
|
@ -54,7 +53,6 @@ typedef struct {
|
|||
display_bus_begin_transaction begin_transaction;
|
||||
display_bus_send send;
|
||||
display_bus_end_transaction end_transaction;
|
||||
display_bus_set_cs set_cs;
|
||||
union {
|
||||
digitalio_digitalinout_obj_t backlight_inout;
|
||||
pulseio_pwmout_obj_t backlight_pwm;
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
|
||||
#include "shared-bindings/busio/SPI.h"
|
||||
#include "shared-bindings/digitalio/DigitalInOut.h"
|
||||
#include "shared-bindings/time/__init__.h"
|
||||
|
||||
#include "tick.h"
|
||||
|
||||
|
@ -78,6 +79,11 @@ bool common_hal_displayio_fourwire_begin_transaction(mp_obj_t obj) {
|
|||
|
||||
void common_hal_displayio_fourwire_send(mp_obj_t obj, bool command, uint8_t *data, uint32_t data_length) {
|
||||
displayio_fourwire_obj_t* self = MP_OBJ_TO_PTR(obj);
|
||||
if (command) {
|
||||
common_hal_digitalio_digitalinout_set_value(&self->chip_select, true);
|
||||
common_hal_time_delay_ms(1);
|
||||
common_hal_digitalio_digitalinout_set_value(&self->chip_select, false);
|
||||
}
|
||||
common_hal_digitalio_digitalinout_set_value(&self->command, !command);
|
||||
common_hal_busio_spi_write(self->bus, data, data_length);
|
||||
}
|
||||
|
@ -87,8 +93,3 @@ void common_hal_displayio_fourwire_end_transaction(mp_obj_t obj) {
|
|||
common_hal_digitalio_digitalinout_set_value(&self->chip_select, true);
|
||||
common_hal_busio_spi_unlock(self->bus);
|
||||
}
|
||||
|
||||
void common_hal_displayio_fourwire_set_cs(mp_obj_t obj, bool high) {
|
||||
displayio_fourwire_obj_t* self = MP_OBJ_TO_PTR(obj);
|
||||
common_hal_digitalio_digitalinout_set_value(&self->chip_select, high);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue