Skip to content

Commit 57dee64

Browse files
committed
_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.
1 parent a3aeefd commit 57dee64

File tree

6 files changed

+11
-10
lines changed

6 files changed

+11
-10
lines changed

shared-module/_stage/Layer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030

3131
// Get the color of the pixel on the layer.
32-
uint16_t get_layer_pixel(layer_obj_t *layer, uint16_t x, uint16_t y) {
32+
uint16_t get_layer_pixel(layer_obj_t *layer, int16_t x, int16_t y) {
3333

3434
// Shift by the layer's position offset.
3535
x -= layer->x;

shared-module/_stage/Layer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,6 @@ typedef struct {
4343
uint8_t rotation;
4444
} layer_obj_t;
4545

46-
uint16_t get_layer_pixel(layer_obj_t *layer, uint16_t x, uint16_t y);
46+
uint16_t get_layer_pixel(layer_obj_t *layer, int16_t x, int16_t y);
4747

4848
#endif // MICROPY_INCLUDED_SHARED_MODULE__STAGE_LAYER

shared-module/_stage/Text.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030

3131
// Get the color of the pixel on the text.
32-
uint16_t get_text_pixel(text_obj_t *text, uint16_t x, uint16_t y) {
32+
uint16_t get_text_pixel(text_obj_t *text, int16_t x, int16_t y) {
3333

3434
// Shift by the text's position offset.
3535
x -= text->x;

shared-module/_stage/Text.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,6 @@ typedef struct {
4141
uint8_t width, height;
4242
} text_obj_t;
4343

44-
uint16_t get_text_pixel(text_obj_t *text, uint16_t x, uint16_t y);
44+
uint16_t get_text_pixel(text_obj_t *text, int16_t x, int16_t y);
4545

4646
#endif // MICROPY_INCLUDED_SHARED_MODULE__STAGE_TEXT

shared-module/_stage/__init__.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,14 @@ void render_stage(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1,
3939

4040

4141
displayio_area_t area;
42-
area.x1 = x0;
43-
area.y1 = y0;
44-
area.x2 = x1;
45-
area.y2 = y1;
42+
area.x1 = x0 * scale;
43+
area.y1 = y0 * scale;
44+
area.x2 = x1 * scale;
45+
area.y2 = y1 * scale;
4646
displayio_display_core_set_region_to_update(
4747
&display->core, display->set_column_command, display->set_row_command,
48-
NO_COMMAND, NO_COMMAND, display->data_as_commands, false, &area, display->SH1107_addressing);
48+
NO_COMMAND, NO_COMMAND, display->data_as_commands, false, &area,
49+
display->SH1107_addressing);
4950

5051
while (!displayio_display_core_begin_transaction(&display->core)) {
5152
RUN_BACKGROUND_TASKS;

0 commit comments

Comments
 (0)