diff --git a/nametag/src/main.cpp b/nametag/src/main.cpp index b913ab4..2cb5e3b 100644 --- a/nametag/src/main.cpp +++ b/nametag/src/main.cpp @@ -36,21 +36,10 @@ MatrixPanel_I2S_DMA *matrix = nullptr; -uint16_t colorWheel(uint8_t pos) { - if(pos < 85) { - return matrix->color565(pos * 3, 255 - pos * 3, 0); - } else if(pos < 170) { - pos -= 85; - return matrix->color565(255 - pos * 3, 0, pos * 3); - } else { - pos -= 170; - return matrix->color565(0, pos * 3, 255 - pos * 3); - } -} - int line_pos[PANEL_WIDTH]; // where a rain marker is (y coordinate) int line_length[PANEL_WIDTH]; // how long a line is for a given x coord int line_speed[PANEL_WIDTH]; // how fast each line moves +unsigned long line_last_moved[PANEL_WIDTH]; void setup(){ Serial.begin(BAUD_RATE); @@ -58,8 +47,9 @@ void setup(){ for (int i = 0; ibegin(); matrix->setBrightness8(64); @@ -79,15 +71,19 @@ void setup(){ matrix->setFont(&CaveatBrush_Regular9pt7b); } -uint8_t color = 0; -const char *str = "Panki"; void loop() { - matrix->fillScreenRGB888(0, 0, 0); + matrix ->flipDMABuffer(); + matrix->clearScreen(); + delay(25); //matrix ->drawBitmap(0, 0, overlay, 64, 32, matrix->color565(64, 0, 0)); + unsigned long timestamp = millis(); for (int x = 0; x < PANEL_WIDTH; x++) { - // step down a pixel - line_pos[x]++; + if ((timestamp - line_last_moved[x]) > line_speed[x]) { + // step down a pixel + line_pos[x]++; + line_last_moved[x] = timestamp; + } if (line_pos[x] > PANEL_HEIGHT) { line_pos[x] = 0; } @@ -101,7 +97,6 @@ void loop() { //} int trail_y = line_pos[x] - trail_offset; if (trail_y >= 0) { - //if (overlay[ (trail_y * PANEL_WIDTH) + x ]) { int pixel_num = (trail_y * PANEL_WIDTH) + x; if (overlay[ pixel_num / 8 ] & (1 << (7 - (pixel_num % 8)) )) { matrix->drawPixel(x, trail_y, matrix->color565(128, 255, 128)); @@ -123,20 +118,6 @@ void loop() { } } } - delay(100); - //for (color=0; color<256; color++) { - // // create a border - // matrix->drawRect(0, 0, matrix->width(), matrix->height(), colorWheel(color)); - // matrix->drawRect(1, 1, matrix->width()-2, matrix->height()-2, colorWheel(color)); - - // matrix->setTextSize(1); - // matrix->setTextWrap(false); - // matrix->setCursor(8, 22); - - // //const char *str = "Panki"; - // matrix->setTextColor(colorWheel(color+128)); - // matrix->print(str); - // delay(100); - //} + //delay(25); }