struct-rain #2

Merged
panki merged 8 commits from struct-rain into master 2024-12-08 15:16:40 +01:00
Showing only changes of commit 722be35737 - Show all commits

View File

@ -33,6 +33,8 @@
#define NUM_LEDS PANE_WIDTH*PANE_HEIGHT
#define ONBOARD_LED 13
#define BACK_BUTTON 6
MatrixPanel_I2S_DMA *matrix = nullptr;
@ -51,9 +53,12 @@ typedef struct {
Raindrop raindrops[PANEL_WIDTH];
bool stealth_mode = false;
void setup(){
Serial.begin(BAUD_RATE);
pinMode(ONBOARD_LED, OUTPUT);
pinMode(BACK_BUTTON, INPUT_PULLUP);
for (int i = 0; i<PANEL_WIDTH; i++) {
raindrops[i].y = 0 - random(24);
@ -86,6 +91,12 @@ void loop() {
matrix ->flipDMABuffer();
matrix->clearScreen();
delay(25);
if(!digitalRead(BACK_BUTTON)) {
stealth_mode = !stealth_mode;
while(!digitalRead(BACK_BUTTON)); // Wait for release
}
//matrix ->drawBitmap(0, 0, overlay, 64, 32, matrix->color565(64, 0, 0));
unsigned long timestamp = millis();
for (int x = 0; x < PANEL_WIDTH; x++) {
@ -106,7 +117,7 @@ void loop() {
int trail_y = raindrops[x].y - trail_offset;
if (trail_y >= 0) {
int pixel_num = (trail_y * PANEL_WIDTH) + x;
if (overlay[ pixel_num / 8 ] & (1 << (7 - (pixel_num % 8)) )) {
if (overlay[ pixel_num / 8 ] & (1 << (7 - (pixel_num % 8)) ) and !stealth_mode) {
matrix->drawPixel(x, trail_y, matrix->color565(128, 255, 128));
} else {
matrix->drawPixel(x, trail_y, matrix->color565(0, (255 / raindrops[x].length) * (raindrops[x].length - trail_offset), 0));
@ -114,7 +125,7 @@ void loop() {
} else if (raindrops[x].reached_bottom) {
int pixel_num = ((PANEL_HEIGHT + trail_y) * PANEL_WIDTH) + x;
if (line_pos[x] >= 0) {
if (overlay[ pixel_num / 8 ] & (1 << (7 - (pixel_num % 8)) )) {
if (overlay[ pixel_num / 8 ] & (1 << (7 - (pixel_num % 8)) ) and !stealth_mode) {
matrix->drawPixel(x, PANEL_HEIGHT + trail_y, matrix->color565(128, 255, 128));
} else {
matrix->drawPixel(x, PANEL_HEIGHT + trail_y, matrix->color565(0,(255 / raindrops[x].length) * (raindrops[x].length - trail_offset), 0));