Skip to content

Commit 34aa01c

Browse files
committed
Remove redundant clear_write, add make translate
1 parent 811a34f commit 34aa01c

File tree

2 files changed

+34
-4
lines changed

2 files changed

+34
-4
lines changed

locale/circuitpython.pot

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,7 @@ msgid "Buffer too short by %d bytes"
527527
msgstr ""
528528

529529
#: ports/atmel-samd/common-hal/displayio/ParallelBus.c
530+
#: ports/esp32s2/common-hal/displayio/ParallelBus.c
530531
#: ports/nrf/common-hal/displayio/ParallelBus.c
531532
#, c-format
532533
msgid "Bus pin %d is already in use"
@@ -796,6 +797,10 @@ msgstr ""
796797
msgid "Data 0 pin must be byte aligned"
797798
msgstr ""
798799

800+
#: ports/esp32s2/common-hal/displayio/ParallelBus.c
801+
msgid "Data 0 pin must be byte aligned and < 32"
802+
msgstr ""
803+
799804
#: shared-module/audiocore/WaveFile.c
800805
msgid "Data chunk must follow fmt chunk"
801806
msgstr ""
@@ -1564,7 +1569,6 @@ msgid ""
15641569
"PWM frequency not writable when variable_frequency is False on construction."
15651570
msgstr ""
15661571

1567-
#: ports/esp32s2/common-hal/displayio/ParallelBus.c
15681572
#: ports/mimxrt10xx/common-hal/displayio/ParallelBus.c
15691573
#: ports/stm/common-hal/displayio/ParallelBus.c
15701574
msgid "ParallelBus not yet supported"
@@ -2136,6 +2140,10 @@ msgstr ""
21362140
msgid "Woken up by alarm.\n"
21372141
msgstr ""
21382142

2143+
#: ports/esp32s2/common-hal/displayio/ParallelBus.c
2144+
msgid "Write pin must be < 32"
2145+
msgstr ""
2146+
21392147
#: ports/nrf/common-hal/_bleio/PacketBuffer.c
21402148
msgid "Writes not supported on Characteristic"
21412149
msgstr ""

ports/esp32s2/common-hal/displayio/ParallelBus.c

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,19 +177,33 @@ void common_hal_displayio_parallelbus_send(mp_obj_t obj, display_byte_type_t byt
177177
Future: To accommodate write pin numbers >= 32, will need to update to choose a different register
178178
for set/reset (out1_w1tc and out1_w1ts) */
179179

180+
// **** Bit shifting trial
181+
// uint32_t* output_register = self->bus;
182+
// const uint8_t bit_shift=self->data0_pin;
183+
180184
uint32_t* clear_write = (uint32_t*) &self->write_group->out_w1tc;
181185
uint32_t* set_write = (uint32_t*) &self->write_group->out_w1ts;
182-
uint32_t mask = self->write_mask;
186+
187+
const uint32_t mask = self->write_mask;
188+
183189

184190
/* Setup structures for data writing. The ESP32-S2 port differs from the SAMD and NRF ports
185191
because I have not found a way to write a single byte into the ESP32-S2 registers.
186192
For the ESP32-S2, I create a 32-bit data_buffer that is used to transfer the data bytes. */
187193

188194
*clear_write = mask; // Clear the write pin to prepare the registers before storing register settings into data_buffer
189-
uint32_t data_buffer = *self->bus; // store the initial output register values into the data output buffer
195+
196+
const uint32_t data_buffer = *self->bus; // store the initial output register values into the data output buffer
190197
uint8_t* data_address = ((uint8_t*) &data_buffer) + (self->data0_pin / 8); /* address inside data_buffer where
191198
each data byte will be written (as offset by (data0_pin/8) number of bytes) */
192199

200+
// *** Bit shifting trial
201+
// *data_address = 0; //clear the 8 data bits
202+
203+
//mp_printf(&mp_plat_print, "\n\ndata_buffer: %x\n", data_buffer);
204+
//mp_printf(&mp_plat_print, "data[0]: %x\n", data[0]);
205+
//mp_printf(&mp_plat_print, "data_buffer[0]: %x\n\n", (data_buffer | (((uint32_t) data[0]) << self->data0_pin)));
206+
193207
for (uint32_t i = 0; i < data_length; i++) {
194208

195209
/* Question: Is there a faster way of stuffing the data byte into the data_buffer, is bit arithmetic
@@ -200,9 +214,17 @@ void common_hal_displayio_parallelbus_send(mp_obj_t obj, display_byte_type_t byt
200214
latches the data on the rising or falling edge of the write pin. Remember: This method
201215
will require the write pin to be controlled by the same GPIO register as the data pins. */
202216

203-
*clear_write = mask; // clear the write pin (See comment above, this may not be necessary).
217+
// Can ignore this line if the write pin is in the same register as the data pins
218+
// *clear_write = mask; // clear the write pin (See comment above, this may not be necessary).
219+
220+
// *** Original code
204221
*(data_address) = data[i]; // stuff the data byte into the data_buffer at the correct offset byte location
205222
*self->bus = data_buffer; // write the data to the output register
223+
224+
// *** Bit shifting trial - didn't have much improvement in performance
225+
// *output_register = (data_buffer | (((uint32_t) data[i]) << bit_shift));
226+
227+
206228
*set_write = mask; // set the write pin
207229
}
208230

0 commit comments

Comments
 (0)