_stage: Fix handling of scaled display in the stage library

The "scale" parameter wasn't exposed in the library, and there
were some problems in how it was handled.

This also fixes some types in the pixel-drawing functions.
This commit is contained in:
Radomir Dopieralski 2021-10-07 12:58:43 +02:00
parent a3aeefd92c
commit 57dee6406d
6 changed files with 11 additions and 10 deletions

@ -1 +1 @@
Subproject commit d0f1c46d7f879cd60562ee69900d619499d4d206
Subproject commit ab28481acaac4a38b3066bd90249ae6fcf4aeda5

View File

@ -29,7 +29,7 @@
// Get the color of the pixel on the layer.
uint16_t get_layer_pixel(layer_obj_t *layer, uint16_t x, uint16_t y) {
uint16_t get_layer_pixel(layer_obj_t *layer, int16_t x, int16_t y) {
// Shift by the layer's position offset.
x -= layer->x;

View File

@ -43,6 +43,6 @@ typedef struct {
uint8_t rotation;
} layer_obj_t;
uint16_t get_layer_pixel(layer_obj_t *layer, uint16_t x, uint16_t y);
uint16_t get_layer_pixel(layer_obj_t *layer, int16_t x, int16_t y);
#endif // MICROPY_INCLUDED_SHARED_MODULE__STAGE_LAYER

View File

@ -29,7 +29,7 @@
// Get the color of the pixel on the text.
uint16_t get_text_pixel(text_obj_t *text, uint16_t x, uint16_t y) {
uint16_t get_text_pixel(text_obj_t *text, int16_t x, int16_t y) {
// Shift by the text's position offset.
x -= text->x;

View File

@ -41,6 +41,6 @@ typedef struct {
uint8_t width, height;
} text_obj_t;
uint16_t get_text_pixel(text_obj_t *text, uint16_t x, uint16_t y);
uint16_t get_text_pixel(text_obj_t *text, int16_t x, int16_t y);
#endif // MICROPY_INCLUDED_SHARED_MODULE__STAGE_TEXT

View File

@ -39,13 +39,14 @@ void render_stage(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1,
displayio_area_t area;
area.x1 = x0;
area.y1 = y0;
area.x2 = x1;
area.y2 = y1;
area.x1 = x0 * scale;
area.y1 = y0 * scale;
area.x2 = x1 * scale;
area.y2 = y1 * scale;
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, display->SH1107_addressing);
NO_COMMAND, NO_COMMAND, display->data_as_commands, false, &area,
display->SH1107_addressing);
while (!displayio_display_core_begin_transaction(&display->core)) {
RUN_BACKGROUND_TASKS;