Display odd/even lines fix
This commit is contained in:
parent
ac676e4dcb
commit
a8d7392619
@ -34,19 +34,22 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void set(uint8_t x, uint8_t y, uint32_t color) {
|
void set(uint8_t x, uint8_t y, uint32_t color) {
|
||||||
if (x >= width || y >= height) {
|
setPixelColor(x, y, color);
|
||||||
Serial.printf("ERROR: Cannot set pixel (%d/%d) in matrix (%d/%d).\n", x, y, width, height);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
leds.setPixelColor(y * width + x, color);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void set(uint8_t x, uint8_t y, uint8_t r, uint8_t g, uint8_t b) {
|
void set(uint8_t x, uint8_t y, uint8_t r, uint8_t g, uint8_t b) {
|
||||||
|
setPixelColor(x, y, (((r << 8) | g) << 8) | b);
|
||||||
|
}
|
||||||
|
|
||||||
|
void setPixelColor(uint8_t x, uint8_t y, uint32_t color) {
|
||||||
if (x >= width || y >= height) {
|
if (x >= width || y >= height) {
|
||||||
Serial.printf("ERROR: Cannot set pixel (%d/%d) in matrix (%d/%d).\n", x, y, width, height);
|
Serial.printf("ERROR: Cannot set pixel (%d/%d) in matrix (%d/%d).\n", x, y, width, height);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
leds.setPixelColor(y * width + x, r, g, b);
|
if ((y % 2) != 0) {
|
||||||
|
x = width - x - 1;
|
||||||
|
}
|
||||||
|
leds.setPixelColor(y * width + x, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
void clear() {
|
void clear() {
|
||||||
|
|||||||
@ -155,22 +155,21 @@ private:
|
|||||||
for (int y = 0; y < display->height; y++) {
|
for (int y = 0; y < display->height; y++) {
|
||||||
for (int x = 0; x < display->width; x++) {
|
for (int x = 0; x < display->width; x++) {
|
||||||
cell->animate(dt);
|
cell->animate(dt);
|
||||||
int xx = (y % 2) == 0 ? display->width - x - 1 : x;
|
|
||||||
uint8_t brightness;
|
uint8_t brightness;
|
||||||
switch (colorMode) {
|
switch (colorMode) {
|
||||||
case BLACK_WHITE:
|
case BLACK_WHITE:
|
||||||
brightness = cell->alive ? 255 : 0;
|
brightness = cell->alive ? 255 : 0;
|
||||||
display->set(xx, y, brightness, brightness, brightness);
|
display->set(x, y, brightness, brightness, brightness);
|
||||||
break;
|
break;
|
||||||
case GRAYSCALE:
|
case GRAYSCALE:
|
||||||
brightness = (uint8_t) cell->fade;
|
brightness = (uint8_t) cell->fade;
|
||||||
display->set(xx, y, brightness, brightness, brightness);
|
display->set(x, y, brightness, brightness, brightness);
|
||||||
break;
|
break;
|
||||||
case COLOR_FADE:
|
case COLOR_FADE:
|
||||||
display->set(xx, y, cell->getR(), cell->getG(), cell->getB());
|
display->set(x, y, cell->getR(), cell->getG(), cell->getB());
|
||||||
break;
|
break;
|
||||||
case RANDOM_COLOR:
|
case RANDOM_COLOR:
|
||||||
display->set(xx, y, cell->alive ? cell->color : 0);
|
display->set(x, y, cell->alive ? cell->color : 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
cell++;
|
cell++;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user