summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRadomir Dopieralski <openstack@sheep.art.pl>2018-03-11 12:01:48 +0100
committerRadomir Dopieralski <openstack@sheep.art.pl>2018-03-11 12:05:20 +0100
commitf10be555928dd8a59b7f6348ee08df66efe44cb3 (patch)
treeef7f0270e5c0db5df04a7f32f6c71e3d1d0fbb8d
parent544b9e4ba01acf1252d63444266e91bf17600b04 (diff)
_stage: use 16 bit for coordinates to support larger screens
-rw-r--r--shared-bindings/_stage/__init__.c8
-rw-r--r--shared-module/_stage/Layer.c2
-rw-r--r--shared-module/_stage/Layer.h2
-rw-r--r--shared-module/_stage/Text.c2
-rw-r--r--shared-module/_stage/Text.h2
-rw-r--r--shared-module/_stage/__init__.c9
-rw-r--r--shared-module/_stage/__init__.h2
7 files changed, 12 insertions, 15 deletions
diff --git a/shared-bindings/_stage/__init__.c b/shared-bindings/_stage/__init__.c
index 16e0b58d9..a0c66cca5 100644
--- a/shared-bindings/_stage/__init__.c
+++ b/shared-bindings/_stage/__init__.c
@@ -56,10 +56,10 @@
//| This function is intended for internal use in the ``stage`` library
//| and all the necessary checks are performed there.
STATIC mp_obj_t stage_render(size_t n_args, const mp_obj_t *args) {
- uint8_t x0 = mp_obj_get_int(args[0]);
- uint8_t y0 = mp_obj_get_int(args[1]);
- uint8_t x1 = mp_obj_get_int(args[2]);
- uint8_t y1 = mp_obj_get_int(args[3]);
+ uint16_t x0 = mp_obj_get_int(args[0]);
+ uint16_t y0 = mp_obj_get_int(args[1]);
+ uint16_t x1 = mp_obj_get_int(args[2]);
+ uint16_t y1 = mp_obj_get_int(args[3]);
size_t layers_size = 0;
mp_obj_t *layers;
diff --git a/shared-module/_stage/Layer.c b/shared-module/_stage/Layer.c
index 4c9c46d7c..d958f0d19 100644
--- a/shared-module/_stage/Layer.c
+++ b/shared-module/_stage/Layer.c
@@ -29,7 +29,7 @@
// Get the color of the pixel on the layer.
-uint16_t get_layer_pixel(layer_obj_t *layer, int16_t x, uint16_t y) {
+uint16_t get_layer_pixel(layer_obj_t *layer, uint16_t x, uint16_t y) {
// Shift by the layer's position offset.
x -= layer->x;
diff --git a/shared-module/_stage/Layer.h b/shared-module/_stage/Layer.h
index c46f71349..17d101263 100644
--- a/shared-module/_stage/Layer.h
+++ b/shared-module/_stage/Layer.h
@@ -43,6 +43,6 @@ typedef struct {
uint8_t rotation;
} layer_obj_t;
-uint16_t get_layer_pixel(layer_obj_t *layer, int16_t x, uint16_t y);
+uint16_t get_layer_pixel(layer_obj_t *layer, uint16_t x, uint16_t y);
#endif // MICROPY_INCLUDED_SHARED_MODULE__STAGE_LAYER
diff --git a/shared-module/_stage/Text.c b/shared-module/_stage/Text.c
index 307f9bbfa..df5bf8008 100644
--- a/shared-module/_stage/Text.c
+++ b/shared-module/_stage/Text.c
@@ -29,7 +29,7 @@
// Get the color of the pixel on the text.
-uint16_t get_text_pixel(text_obj_t *text, int16_t x, uint16_t y) {
+uint16_t get_text_pixel(text_obj_t *text, uint16_t x, uint16_t y) {
// Shift by the text's position offset.
x -= text->x;
diff --git a/shared-module/_stage/Text.h b/shared-module/_stage/Text.h
index bc111e49c..b263fc710 100644
--- a/shared-module/_stage/Text.h
+++ b/shared-module/_stage/Text.h
@@ -41,6 +41,6 @@ typedef struct {
uint8_t width, height;
} text_obj_t;
-uint16_t get_text_pixel(text_obj_t *text, int16_t x, uint16_t y);
+uint16_t get_text_pixel(text_obj_t *text, uint16_t x, uint16_t y);
#endif // MICROPY_INCLUDED_SHARED_MODULE__STAGE_TEXT
diff --git a/shared-module/_stage/__init__.c b/shared-module/_stage/__init__.c
index 1931b8940..86f5ee795 100644
--- a/shared-module/_stage/__init__.c
+++ b/shared-module/_stage/__init__.c
@@ -31,17 +31,14 @@
#include "shared-bindings/_stage/Text.h"
-bool render_stage(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1,
+bool render_stage(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1,
mp_obj_t *layers, size_t layers_size,
uint16_t *buffer, size_t buffer_size,
busio_spi_obj_t *spi) {
- // TODO(deshipu): Do a collision check of each layer with the
- // rectangle, and only process the layers that overlap with it.
-
size_t index = 0;
- for (uint8_t y = y0; y < y1; ++y) {
- for (uint8_t x = x0; x < x1; ++x) {
+ for (uint16_t y = y0; y < y1; ++y) {
+ for (uint16_t x = x0; x < x1; ++x) {
for (size_t layer = 0; layer < layers_size; ++layer) {
uint16_t c = TRANSPARENT;
layer_obj_t *obj = MP_OBJ_TO_PTR(layers[layer]);
diff --git a/shared-module/_stage/__init__.h b/shared-module/_stage/__init__.h
index 326c72559..d56a26940 100644
--- a/shared-module/_stage/__init__.h
+++ b/shared-module/_stage/__init__.h
@@ -34,7 +34,7 @@
#define TRANSPARENT (0x1ff8)
-bool render_stage(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1,
+bool render_stage(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1,
mp_obj_t *layers, size_t layers_size,
uint16_t *buffer, size_t buffer_size,
busio_spi_obj_t *spi);