8000 Rework based on Dan's review · tannewt/circuitpython@7324b70 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7324b70

Browse files
committed
Rework based on Dan's review
1 parent b992ca8 commit 7324b70

File tree

26 files changed

+137
-132
lines changed

26 files changed

+137
-132
lines changed

ports/atmel-samd/boards/monster_m4sk/mpconfigboard.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,3 @@
2727
// USB is always used internally so skip the pin objects for it.
2828
#define IGNORE_PIN_PA24 1
2929
#define IGNORE_PIN_PA25 1
30-
31-
#define CIRCUITPY_FS_NAME "MONSTERM4SK"

ports/atmel-samd/common-hal/displayio/ParallelBus.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,9 @@ bool common_hal_displayio_parallelbus_begin_transaction(mp_obj_t obj) {
131131
return true;
132132
}
133133

134-
void common_hal_displayio_parallelbus_send(mp_obj_t obj, bool command, bool toggle_every_byte, uint8_t *data, uint32_t data_length) {
134+
void common_hal_displayio_parallelbus_send(mp_obj_t obj, display_byte_type_t byte_type, display_chip_select_behavior_t chip_select, uint8_t *data, uint32_t data_length) {
135135
displayio_parallelbus_obj_t* self = MP_OBJ_TO_PTR(obj);
136-
common_hal_digitalio_digitalinout_set_value(&self->command, !command);
136+
common_hal_digitalio_digitalinout_set_value(&self->command, byte_type == DISPLAY_DATA);
137137
uint32_t* clear_write = (uint32_t*) &self->write_group->OUTCLR.reg;
138138
uint32_t* set_write = (uint32_t*) &self->write_group->OUTSET.reg;
139139
uint32_t mask = self->write_mask;

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,10 @@ bool common_hal_displayio_parallelbus_begin_transaction(mp_obj_t obj) {
142142
return true;
143143
}
144144

145-
void common_hal_displayio_parallelbus_send(mp_obj_t obj, bool command, bool toggle_every_byte, uint8_t *data, uint32_t data_length) {
145+
// This ignores chip_select behaviour because data is clocked in by the write line toggling.
146+
void common_hal_displayio_parallelbus_send(mp_obj_t obj, display_byte_type_t byte_type, display_chip_select_behavior_t chip_select, uint8_t *data, uint32_t data_length) {
146147
displayio_parallelbus_obj_t* self = MP_OBJ_TO_PTR(obj);
147-
common_hal_digitalio_digitalinout_set_value(&self->command, !command);
148+
common_hal_digitalio_digitalinout_set_value(&self->command, byte_type == DISPLAY_DATA);
148149
uint32_t* clear_write = (uint32_t*) &self->write_group->OUTCLR;
149150
uint32_t* set_write = (uint32_t*) &self->write_group->OUTSET;
150151
uint32_t mask = self->write_mask;

py/circuitpy_mpconfig.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -657,8 +657,4 @@ void run_background_tasks(void);
657657
#define CIRCUITPY_FILESYSTEM_FLUSH_INTERVAL_MS 1000
658658
#define CIRCUITPY_BOOT_OUTPUT_FILE "/boot_out.txt"
659659

660-
#ifndef CIRCUITPY_FS_NAME
661-
#define CIRCUITPY_FS_NAME "CIRCUITPY"
662-
#endif
663-
664660
#endif // __INCLUDED_MPCONFIG_CIRCUITPY_H

shared-bindings/_stage/__init__.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ STATIC mp_obj_t stage_render(size_t n_args, const mp_obj_t *args) {
107107
area.y2 = y1;
108108
displayio_display_core_set_region_to_update(&display->core, display->set_column_command, display->set_row_command, NO_COMMAND, NO_COMMAND, display->data_as_commands, false, &area);
109109

110-
display->core.send(display->core.bus, true, true, &display->write_ram_command, 1);
110+
display->core.send(display->core.bus, DISPLAY_COMMAND, CHIP_SELECT_TOGGLE_EVERY_BYTE, &display->write_ram_command, 1);
111111
render_stage(x0, y0, x1, y1, layers, layers_size, buffer, buffer_size,
112112
display, scale);
113113
displayio_display_core_end_transaction(&display->core);

shared-bindings/displayio/Display.c

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -218,16 +218,22 @@ STATIC mp_obj_t displayio_display_obj_show(mp_obj_t self_in, mp_obj_t group_in)
218218
}
219219
MP_DEFINE_CONST_FUN_OBJ_2(displayio_display_show_obj, displayio_display_obj_show);
220220

221-
//| .. method:: refresh(*, target_frames_per_second=None, minimum_frames_per_second=1)
221+
//| .. method:: refresh(*, target_frames_per_second=60, minimum_frames_per_second=1)
222222
//|
223-
//| When auto refresh is off, waits for the target frame rate and then refreshes the display. If
224-
//| the call is too late for the given target frame rate, then the refresh returns immediately
225-
//| without updating the screen to hopefully help getting caught up. If the current frame rate
226-
//| is below the minimum frame rate, then an exception will be raised.
223+
//| When auto refresh is off, waits for the target frame rate and then refreshes the display,
224+
//| returning True. If the call has taken too long since the last refresh call for the given
225+
//| target frame rate, then the refresh returns False immediately without updating the screen to
226+
//| hopefully help getting caught up.
227+
//|
228+
//| If the time since the last successful refresh is below the minimum frame rate, then an
229+
//| exception will be raised. Set minimum_frames_per_second to 0 to disable.
227230
//|
228231
//| When auto refresh is on, updates the display immediately. (The display will also update
229232
//| without calls to this.)
230233
//|
234+
//| :param int target_frames_per_second: How many times a second `refresh` should be called and the screen updated.
235+
//| :param int minimum_frames_per_second: The minimum number of times the screen should be updated per second.
236+
//|
231237
STATIC mp_obj_t displayio_display_obj_refresh(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
232238
enum { ARG_target_frames_per_second, ARG_minimum_frames_per_second };
233239
static const mp_arg_t allowed_args[] = {
@@ -238,8 +244,12 @@ STATIC mp_obj_t displayio_display_obj_refresh(size_t n_args, const mp_obj_t *pos
238244
mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
239245

240246
displayio_display_obj_t *self = native_display(pos_args[0]);
241-
common_hal_displayio_display_refresh(self, 1000 / args[ARG_target_frames_per_second].u_int, 1000 / args[ARG_minimum_frames_per_second].u_int);
242-
return mp_const_none;
247+
uint32_t maximum_ms_per_real_frame = 0xffffffff;
248+
mp_int_t minimum_frames_per_second = args[ARG_minimum_frames_per_second].u_int;
249+
if (minimum_frames_per_second > 0) {
250+
maximum_ms_per_real_frame = 1000 / minimum_frames_per_second;
251+
}
252+
return mp_obj_new_bool(common_hal_displayio_display_refresh(self, 1000 / args[ARG_target_frames_per_second].u_int, maximum_ms_per_real_frame));
243253
}
244254
MP_DEFINE_CONST_FUN_OBJ_KW(displayio_display_refresh_obj, 1, displayio_display_obj_refresh);
245255

shared-bindings/displayio/Display.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ bool common_hal_displayio_display_show(displayio_display_obj_t* self,
5151
displayio_group_t* root_group);
5252

5353
// Times in ms.
54-
void common_hal_displayio_display_refresh(displayio_display_obj_t* self, uint32_t target_frame_time, uint32_t maximum_frame_time);
54+
bool common_hal_displayio_display_refresh(displayio_display_obj_t* self, uint32_t target_ms_per_frame, uint32_t maximum_ms_per_real_frame);
5555

5656
bool common_hal_displayio_display_get_auto_refresh(displayio_display_obj_t* self);
5757
void common_hal_displayio_display_set_auto_refresh(displayio_display_obj_t* self, bool auto_refresh);

shared-bindings/displayio/EPaperDisplay.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
//|
5656
//| Create a EPaperDisplay object on the given display bus (`displayio.FourWire` or `displayio.ParallelBus`).
5757
//|
58-
//| The ``start_sequence`` and ``stop_sequence`` bitpacked to minimize the ram impact. Every
58+
//| The ``start_sequence`` and ``stop_sequence`` are bitpacked to minimize the ram impact. Every
5959
//| command begins with a command byte followed by a byte to determine the parameter count and if
6060
//| a delay is need after. When the top bit of the second byte is 1, the next byte will be the
6161
//| delay time in milliseconds. The remaining 7 bits are the parameter count excluding any delay

shared-bindings/displayio/FourWire.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,12 @@ STATIC mp_obj_t displayio_fourwire_obj_send(size_t n_args, const mp_obj_t *pos_a
146146
while (!common_hal_displayio_fourwire_begin_transaction(self)) {
147147
RUN_BACKGROUND_TASKS;
148148
}
149-
common_hal_displayio_fourwire_send(self, true, args[ARG_toggle_every_byte].u_bool, &command, 1);
150-
common_hal_displayio_fourwire_send(self, false, args[ARG_toggle_every_byte].u_bool, ((uint8_t*) bufinfo.buf), bufinfo.len);
149+
display_chip_select_behavior_t chip_select = CHIP_SELECT_UNTOUCHED;
150+
if (args[ARG_toggle_every_byte].u_bool) {
151+
chip_select = CHIP_SELECT_TOGGLE_EVERY_BYTE;
152+
}
153+
common_hal_displayio_fourwire_send(self, DISPLAY_COMMAND, chip_select, &command, 1);
154+
common_hal_displayio_fourwire_send(self, DISPLAY_DATA, chip_select, ((uint8_t*) bufinfo.buf), bufinfo.len);
151155
common_hal_displayio_fourwire_end_transaction(self);
152156

153157
return mp_const_none;

shared-bindings/displayio/FourWire.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
#define MICROPY_INCLUDED_SHARED_BINDINGS_DISPLAYBUSIO_FOURWIRE_H
2929

3030
#include "shared-module/displayio/FourWire.h"
31+
32+
#include "shared-bindings/displayio/__init__.h"
3133
#include "common-hal/microcontroller/Pin.h"
3234

3335
#include "shared-module/displayio/Group.h"
@@ -45,7 +47,7 @@ bool common_hal_displayio_fourwire_bus_free(mp_obj_t self);
4547

4648
bool common_hal_displayio_fourwire_begin_transaction(mp_obj_t self);
4749

48-
void common_hal_displayio_fourwire_send(mp_obj_t self, bool command, bool toggle_every_byte, uint8_t *data, uint32_t data_length);
50+
void common_hal_displayio_fourwire_send(mp_obj_t self, display_byte_type_t byte_type, display_chip_select_behavior_t chip_select, uint8_t *data, uint32_t data_length);
4951

5052
void common_hal_displayio_fourwire_end_transaction(mp_obj_t self);
5153

0 commit comments

Comments
 (0)
0