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) {
|
||||
if (x >= width || y >= height) {
|
||||
Serial.printf("ERROR: Cannot set pixel (%d/%d) in matrix (%d/%d).\n", x, y, width, height);
|
||||
return;
|
||||
}
|
||||
leds.setPixelColor(y * width + x, color);
|
||||
setPixelColor(x, y, color);
|
||||
}
|
||||
|
||||
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) {
|
||||
Serial.printf("ERROR: Cannot set pixel (%d/%d) in matrix (%d/%d).\n", x, y, width, height);
|
||||
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() {
|
||||
|
||||
@ -155,22 +155,21 @@ private:
|
||||
for (int y = 0; y < display->height; y++) {
|
||||
for (int x = 0; x < display->width; x++) {
|
||||
cell->animate(dt);
|
||||
int xx = (y % 2) == 0 ? display->width - x - 1 : x;
|
||||
uint8_t brightness;
|
||||
switch (colorMode) {
|
||||
case BLACK_WHITE:
|
||||
brightness = cell->alive ? 255 : 0;
|
||||
display->set(xx, y, brightness, brightness, brightness);
|
||||
display->set(x, y, brightness, brightness, brightness);
|
||||
break;
|
||||
case GRAYSCALE:
|
||||
brightness = (uint8_t) cell->fade;
|
||||
display->set(xx, y, brightness, brightness, brightness);
|
||||
display->set(x, y, brightness, brightness, brightness);
|
||||
break;
|
||||
case COLOR_FADE:
|
||||
display->set(xx, y, cell->getR(), cell->getG(), cell->getB());
|
||||
display->set(x, y, cell->getR(), cell->getG(), cell->getB());
|
||||
break;
|
||||
case RANDOM_COLOR:
|
||||
display->set(xx, y, cell->alive ? cell->color : 0);
|
||||
display->set(x, y, cell->alive ? cell->color : 0);
|
||||
break;
|
||||
}
|
||||
cell++;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user