struct-rain #2
@ -33,6 +33,8 @@
|
|||||||
#define NUM_LEDS PANE_WIDTH*PANE_HEIGHT
|
#define NUM_LEDS PANE_WIDTH*PANE_HEIGHT
|
||||||
|
|
||||||
#define ONBOARD_LED 13
|
#define ONBOARD_LED 13
|
||||||
|
#define BACK_BUTTON 6
|
||||||
|
|
||||||
|
|
||||||
MatrixPanel_I2S_DMA *matrix = nullptr;
|
MatrixPanel_I2S_DMA *matrix = nullptr;
|
||||||
|
|
||||||
@ -51,9 +53,12 @@ typedef struct {
|
|||||||
|
|
||||||
Raindrop raindrops[PANEL_WIDTH];
|
Raindrop raindrops[PANEL_WIDTH];
|
||||||
|
|
||||||
|
bool stealth_mode = false;
|
||||||
|
|
||||||
void setup(){
|
void setup(){
|
||||||
Serial.begin(BAUD_RATE);
|
Serial.begin(BAUD_RATE);
|
||||||
pinMode(ONBOARD_LED, OUTPUT);
|
pinMode(ONBOARD_LED, OUTPUT);
|
||||||
|
pinMode(BACK_BUTTON, INPUT_PULLUP);
|
||||||
|
|
||||||
for (int i = 0; i<PANEL_WIDTH; i++) {
|
for (int i = 0; i<PANEL_WIDTH; i++) {
|
||||||
raindrops[i].y = 0 - random(24);
|
raindrops[i].y = 0 - random(24);
|
||||||
@ -86,6 +91,12 @@ void loop() {
|
|||||||
matrix ->flipDMABuffer();
|
matrix ->flipDMABuffer();
|
||||||
matrix->clearScreen();
|
matrix->clearScreen();
|
||||||
delay(25);
|
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));
|
//matrix ->drawBitmap(0, 0, overlay, 64, 32, matrix->color565(64, 0, 0));
|
||||||
unsigned long timestamp = millis();
|
unsigned long timestamp = millis();
|
||||||
for (int x = 0; x < PANEL_WIDTH; x++) {
|
for (int x = 0; x < PANEL_WIDTH; x++) {
|
||||||
@ -106,7 +117,7 @@ void loop() {
|
|||||||
int trail_y = raindrops[x].y - trail_offset;
|
int trail_y = raindrops[x].y - trail_offset;
|
||||||
if (trail_y >= 0) {
|
if (trail_y >= 0) {
|
||||||
int pixel_num = (trail_y * PANEL_WIDTH) + x;
|
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));
|
matrix->drawPixel(x, trail_y, matrix->color565(128, 255, 128));
|
||||||
} else {
|
} else {
|
||||||
matrix->drawPixel(x, trail_y, matrix->color565(0, (255 / raindrops[x].length) * (raindrops[x].length - trail_offset), 0));
|
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) {
|
} else if (raindrops[x].reached_bottom) {
|
||||||
int pixel_num = ((PANEL_HEIGHT + trail_y) * PANEL_WIDTH) + x;
|
int pixel_num = ((PANEL_HEIGHT + trail_y) * PANEL_WIDTH) + x;
|
||||||
if (line_pos[x] >= 0) {
|
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));
|
matrix->drawPixel(x, PANEL_HEIGHT + trail_y, matrix->color565(128, 255, 128));
|
||||||
} else {
|
} else {
|
||||||
matrix->drawPixel(x, PANEL_HEIGHT + trail_y, matrix->color565(0,(255 / raindrops[x].length) * (raindrops[x].length - trail_offset), 0));
|
matrix->drawPixel(x, PANEL_HEIGHT + trail_y, matrix->color565(0,(255 / raindrops[x].length) * (raindrops[x].length - trail_offset), 0));
|
||||||
|
Loading…
Reference in New Issue
Block a user