Regular display fixes including refresh tweaks
This commit is contained in:
parent
9993a99906
commit
8d836fa248
@ -64,21 +64,23 @@ void common_hal_displayio_display_construct(displayio_display_obj_t* self,
|
||||
self->write_ram_command = write_ram_command;
|
||||
self->brightness_command = brightness_command;
|
||||
self->auto_brightness = auto_brightness;
|
||||
self->auto_refresh = auto_refresh;
|
||||
self->first_manual_refresh = !auto_refresh;
|
||||
self->data_as_commands = data_as_commands;
|
||||
|
||||
self->native_frames_per_second = native_frames_per_second;
|
||||
self->native_frame_time = 1000 / native_frames_per_second;
|
||||
|
||||
uint32_t i = 0;
|
||||
while (!displayio_display_core_begin_transaction(&self->core)) {
|
||||
RUN_BACKGROUND_TASKS;
|
||||
}
|
||||
while (i < init_sequence_len) {
|
||||
uint8_t *cmd = init_sequence + i;
|
||||
uint8_t data_size = *(cmd + 1);
|
||||
bool delay = (data_size & DELAY) != 0;
|
||||
data_size &= ~DELAY;
|
||||
uint8_t *data = cmd + 2;
|
||||
while (!displayio_display_core_begin_transaction(&self->core)) {
|
||||
RUN_BACKGROUND_TASKS;
|
||||
}
|
||||
if (self->data_as_commands) {
|
||||
uint8_t full_command[data_size + 1];
|
||||
full_command[0] = cmd[0];
|
||||
@ -88,6 +90,7 @@ void common_hal_displayio_display_construct(displayio_display_obj_t* self,
|
||||
self->core.send(self->core.bus, true, true, cmd, 1);
|
||||
self->core.send(self->core.bus, false, false, data, data_size);
|
||||
}
|
||||
self->core.end_transaction(self->core.bus);
|
||||
uint16_t delay_length_ms = 10;
|
||||
if (delay) {
|
||||
data_size++;
|
||||
@ -99,7 +102,6 @@ void common_hal_displayio_display_construct(displayio_display_obj_t* self,
|
||||
common_hal_time_delay_ms(delay_length_ms);
|
||||
i += 2 + data_size;
|
||||
}
|
||||
self->core.end_transaction(self->core.bus);
|
||||
|
||||
supervisor_start_terminal(width, height);
|
||||
|
||||
@ -192,9 +194,10 @@ STATIC const displayio_area_t* _get_refresh_areas(displayio_display_obj_t *self)
|
||||
if (self->core.full_refresh) {
|
||||
self->core.area.next = NULL;
|
||||
return &self->core.area;
|
||||
} else {
|
||||
} else if (self->core.current_group != NULL) {
|
||||
return displayio_group_get_refresh_areas(self->core.current_group, NULL);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
STATIC void _send_pixels(displayio_display_obj_t* self, uint8_t* pixels, uint32_t length) {
|
||||
@ -242,7 +245,7 @@ STATIC bool _refresh_area(displayio_display_obj_t* self, const displayio_area_t*
|
||||
// Allocated and shared as a uint32_t array so the compiler knows the
|
||||
// alignment everywhere.
|
||||
uint32_t buffer[buffer_size];
|
||||
volatile uint32_t mask_length = (pixels_per_buffer / 32) + 1;
|
||||
uint32_t mask_length = (pixels_per_buffer / 32) + 1;
|
||||
uint32_t mask[mask_length];
|
||||
uint16_t remaining_rows = displayio_area_height(&clipped);
|
||||
|
||||
@ -311,7 +314,7 @@ uint16_t common_hal_displayio_display_get_rotation(displayio_display_obj_t* self
|
||||
}
|
||||
|
||||
void common_hal_displayio_display_refresh(displayio_display_obj_t* self, uint32_t target_frame_time, uint32_t maximum_frame_time) {
|
||||
if (!self->auto_refresh) {
|
||||
if (!self->auto_refresh && !self->first_manual_refresh) {
|
||||
uint64_t current_time = ticks_ms;
|
||||
uint32_t current_frame_time = current_time - self->core.last_refresh;
|
||||
// Test to see if the real frame time is below our minimum.
|
||||
@ -332,6 +335,7 @@ void common_hal_displayio_display_refresh(displayio_display_obj_t* self, uint32_
|
||||
#endif
|
||||
}
|
||||
}
|
||||
self->first_manual_refresh = false;
|
||||
_refresh_display(self);
|
||||
}
|
||||
|
||||
@ -341,6 +345,7 @@ bool common_hal_displayio_display_get_auto_refresh(displayio_display_obj_t* self
|
||||
|
||||
void common_hal_displayio_display_set_auto_refresh(displayio_display_obj_t* self,
|
||||
bool auto_refresh) {
|
||||
self->first_manual_refresh = !auto_refresh;
|
||||
self->auto_refresh = auto_refresh;
|
||||
}
|
||||
|
||||
@ -376,6 +381,12 @@ void release_display(displayio_display_obj_t* self) {
|
||||
}
|
||||
}
|
||||
|
||||
void reset_display(displayio_display_obj_t* self) {
|
||||
self->auto_refresh = true;
|
||||
self->auto_brightness = true;
|
||||
common_hal_displayio_display_show(self, NULL);
|
||||
}
|
||||
|
||||
void displayio_display_collect_ptrs(displayio_display_obj_t* self) {
|
||||
displayio_display_core_collect_ptrs(&self->core);
|
||||
}
|
||||
|
@ -51,6 +51,7 @@ typedef struct {
|
||||
uint8_t set_row_command;
|
||||
uint8_t write_ram_command;
|
||||
bool auto_refresh;
|
||||
bool first_manual_refresh;
|
||||
bool data_as_commands;
|
||||
bool auto_brightness;
|
||||
bool updating_backlight;
|
||||
@ -58,6 +59,7 @@ typedef struct {
|
||||
|
||||
void displayio_display_background(displayio_display_obj_t* self);
|
||||
void release_display(displayio_display_obj_t* self);
|
||||
void reset_display(displayio_display_obj_t* self);
|
||||
|
||||
void displayio_display_collect_ptrs(displayio_display_obj_t* self);
|
||||
|
||||
|
@ -102,10 +102,12 @@ bool common_hal_displayio_epaperdisplay_show(displayio_epaperdisplay_obj_t* self
|
||||
}
|
||||
|
||||
const displayio_area_t* displayio_epaperdisplay_get_refresh_areas(displayio_epaperdisplay_obj_t *self) {
|
||||
const displayio_area_t* first_area;
|
||||
if (self->core.full_refresh) {
|
||||
first_area = &self->core.area;
|
||||
} else {
|
||||
self->core.area.next = NULL;
|
||||
return &self->core.area;
|
||||
}
|
||||
const displayio_area_t* first_area = NULL;
|
||||
if (self->core.current_group != NULL) {
|
||||
first_area = displayio_group_get_refresh_areas(self->core.current_group, NULL);
|
||||
}
|
||||
if (first_area != NULL && self->set_row_window_command == NO_COMMAND) {
|
||||
|
@ -207,7 +207,7 @@ uint8_t common_hal_displayio_tilegrid_get_tile(displayio_tilegrid_t *self, uint1
|
||||
|
||||
void common_hal_displayio_tilegrid_set_tile(displayio_tilegrid_t *self, uint16_t x, uint16_t y, uint8_t tile_index) {
|
||||
if (tile_index >= self->tiles_in_bitmap) {
|
||||
mp_raise_ValueError(translate("Tile value out of bounds"));
|
||||
mp_raise_ValueError(translate("Tile index out of bounds"));
|
||||
}
|
||||
uint8_t* tiles = self->tiles;
|
||||
if (self->inline_tiles) {
|
||||
|
@ -43,7 +43,7 @@ typedef struct {
|
||||
uint16_t pixel_width;
|
||||
uint16_t pixel_height;
|
||||
uint16_t bitmap_width_in_tiles;;
|
||||
uint8_t tiles_in_bitmap;
|
||||
uint16_t tiles_in_bitmap;
|
||||
uint16_t width_in_tiles;
|
||||
uint16_t height_in_tiles;
|
||||
uint16_t tile_width;
|
||||
|
@ -143,9 +143,7 @@ void reset_displays(void) {
|
||||
// Reset the displayed group. Only the first will get the terminal but
|
||||
// that's ok.
|
||||
if (displays[i].display.base.type == &displayio_display_type) {
|
||||
displayio_display_obj_t* display = &displays[i].display;
|
||||
display->auto_brightness = true;
|
||||
common_hal_displayio_display_show(display, NULL);
|
||||
reset_display(&displays[i].display);
|
||||
} else if (displays[i].epaper_display.base.type == &displayio_epaperdisplay_type) {
|
||||
displayio_epaperdisplay_obj_t* display = &displays[i].epaper_display;
|
||||
common_hal_displayio_epaperdisplay_show(display, NULL);
|
||||
|
@ -82,8 +82,8 @@ void displayio_display_core_construct(displayio_display_core_t* self,
|
||||
|
||||
self->width = width;
|
||||
self->height = height;
|
||||
self->ram_width = width;
|
||||
self->ram_height = height;
|
||||
self->ram_width = ram_width;
|
||||
self->ram_height = ram_height;
|
||||
rotation = rotation % 360;
|
||||
self->transform.x = 0;
|
||||
self->transform.y = 0;
|
||||
@ -206,7 +206,7 @@ void displayio_display_core_set_region_to_update(displayio_display_core_t* self,
|
||||
data[0] = column_command;
|
||||
uint8_t data_length = 1;
|
||||
if (!data_as_commands) {
|
||||
self->send(self->bus, true, true, data, 1);
|
||||
self->send(self->bus, true, false, data, 1);
|
||||
data_length = 0;
|
||||
}
|
||||
if (self->ram_width < 0x100) {
|
||||
@ -227,11 +227,14 @@ void displayio_display_core_set_region_to_update(displayio_display_core_t* self,
|
||||
self->send(self->bus, false, always_toggle_chip_select, data, data_length / 2);
|
||||
}
|
||||
|
||||
displayio_display_core_end_transaction(self);
|
||||
displayio_display_core_begin_transaction(self);
|
||||
|
||||
// Set row.
|
||||
data[0] = row_command;
|
||||
data_length = 1;
|
||||
if (!data_as_commands) {
|
||||
self->send(self->bus, true, true, data, 1);
|
||||
self->send(self->bus, true, false, data, 1);
|
||||
data_length = 0;
|
||||
}
|
||||
if (self->ram_height < 0x100) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user