Thanks to visit codestin.com
Credit goes to github.com

Skip to content

_stage: use 16 bit for coordinates to support larger screens #667

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 12, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions shared-bindings/_stage/__init__.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion shared-module/_stage/Layer.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion shared-module/_stage/Layer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion shared-module/_stage/Text.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion shared-module/_stage/Text.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
9 changes: 3 additions & 6 deletions shared-module/_stage/__init__.c
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down
2 changes: 1 addition & 1 deletion shared-module/_stage/__init__.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down