Skip to content

Commit 2e0268c

Browse files
author
Melissa LeBlanc-Williams
committed
Simplified cs toggling into fourwire only
2 parents f4cede4 + f3ec051 commit 2e0268c

File tree

4 files changed

+6
-16
lines changed

4 files changed

+6
-16
lines changed

shared-bindings/displayio/FourWire.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,4 @@ void common_hal_displayio_fourwire_send(mp_obj_t self, bool command, uint8_t *da
4747

4848
void common_hal_displayio_fourwire_end_transaction(mp_obj_t self);
4949

50-
void common_hal_displayio_fourwire_set_cs(mp_obj_t self, bool high);
51-
5250
#endif // MICROPY_INCLUDED_SHARED_BINDINGS_DISPLAYBUSIO_FOURWIRE_H

shared-module/displayio/Display.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,10 @@ void common_hal_displayio_display_construct(displayio_display_obj_t* self,
6060
self->begin_transaction = common_hal_displayio_parallelbus_begin_transaction;
6161
self->send = common_hal_displayio_parallelbus_send;
6262
self->end_transaction = common_hal_displayio_parallelbus_end_transaction;
63-
self->set_cs = NULL;
6463
} else if (MP_OBJ_IS_TYPE(bus, &displayio_fourwire_type)) {
6564
self->begin_transaction = common_hal_displayio_fourwire_begin_transaction;
6665
self->send = common_hal_displayio_fourwire_send;
6766
self->end_transaction = common_hal_displayio_fourwire_end_transaction;
68-
self->set_cs = common_hal_displayio_fourwire_set_cs;
6967
} else {
7068
mp_raise_ValueError(translate("Unsupported display bus type"));
7169
}
@@ -83,11 +81,6 @@ void common_hal_displayio_display_construct(displayio_display_obj_t* self,
8381
bool delay = (data_size & DELAY) != 0;
8482
data_size &= ~DELAY;
8583
uint8_t *data = cmd + 2;
86-
if (self->set_cs != NULL) {
87-
self->set_cs(self->bus, true);
88-
common_hal_time_delay_ms(1);
89-
self->set_cs(self->bus, false);
90-
}
9184
self->send(self->bus, true, cmd, 1);
9285
self->send(self->bus, false, data, data_size);
9386
uint16_t delay_length_ms = 10;

shared-module/displayio/Display.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
typedef bool (*display_bus_begin_transaction)(mp_obj_t bus);
3535
typedef void (*display_bus_send)(mp_obj_t bus, bool command, uint8_t *data, uint32_t data_length);
3636
typedef void (*display_bus_end_transaction)(mp_obj_t bus);
37-
typedef void (*display_bus_set_cs)(mp_obj_t bus, bool high);
3837

3938
typedef struct {
4039
mp_obj_base_t base;
@@ -54,7 +53,6 @@ typedef struct {
5453
display_bus_begin_transaction begin_transaction;
5554
display_bus_send send;
5655
display_bus_end_transaction end_transaction;
57-
display_bus_set_cs set_cs;
5856
union {
5957
digitalio_digitalinout_obj_t backlight_inout;
6058
pulseio_pwmout_obj_t backlight_pwm;

shared-module/displayio/FourWire.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030

3131
#include "shared-bindings/busio/SPI.h"
3232
#include "shared-bindings/digitalio/DigitalInOut.h"
33+
#include "shared-bindings/time/__init__.h"
3334

3435
#include "tick.h"
3536

@@ -78,6 +79,11 @@ bool common_hal_displayio_fourwire_begin_transaction(mp_obj_t obj) {
7879

7980
void common_hal_displayio_fourwire_send(mp_obj_t obj, bool command, uint8_t *data, uint32_t data_length) {
8081
displayio_fourwire_obj_t* self = MP_OBJ_TO_PTR(obj);
82+
if (command) {
83+
common_hal_digitalio_digitalinout_set_value(&self->chip_select, true);
84+
common_hal_time_delay_ms(1);
85+
common_hal_digitalio_digitalinout_set_value(&self->chip_select, false);
86+
}
8187
common_hal_digitalio_digitalinout_set_value(&self->command, !command);
8288
common_hal_busio_spi_write(self->bus, data, data_length);
8389
}
@@ -87,8 +93,3 @@ void common_hal_displayio_fourwire_end_transaction(mp_obj_t obj) {
8793
common_hal_digitalio_digitalinout_set_value(&self->chip_select, true);
8894
common_hal_busio_spi_unlock(self->bus);
8995
}
90-
91-
void common_hal_displayio_fourwire_set_cs(mp_obj_t obj, bool high) {
92-
displayio_fourwire_obj_t* self = MP_OBJ_TO_PTR(obj);
93-
common_hal_digitalio_digitalinout_set_value(&self->chip_select, high);
94-
}

0 commit comments

Comments
 (0)