struct-rain #2
@ -53,8 +53,13 @@ typedef struct {
|
||||
|
||||
Raindrop raindrops[PANEL_WIDTH];
|
||||
|
||||
bool stealth_mode = false;
|
||||
enum Mode {
|
||||
Stealth,
|
||||
LowVis,
|
||||
HighVis
|
||||
};
|
||||
|
||||
Mode mode = Stealth;
|
||||
void setup(){
|
||||
Serial.begin(BAUD_RATE);
|
||||
pinMode(ONBOARD_LED, OUTPUT);
|
||||
@ -93,7 +98,17 @@ void loop() {
|
||||
delay(25);
|
||||
|
||||
if(!digitalRead(BACK_BUTTON)) {
|
||||
stealth_mode = !stealth_mode;
|
||||
switch(mode) {
|
||||
case Stealth:
|
||||
mode = LowVis;
|
||||
break;
|
||||
case LowVis:
|
||||
mode = HighVis;
|
||||
break;
|
||||
case HighVis:
|
||||
mode = Stealth;
|
||||
break;
|
||||
}
|
||||
while(!digitalRead(BACK_BUTTON)); // Wait for release
|
||||
}
|
||||
|
||||
@ -117,16 +132,33 @@ 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)) ) and !stealth_mode) {
|
||||
if (overlay[ pixel_num / 8 ] & (1 << (7 - (pixel_num % 8)) ) and mode != Stealth) {
|
||||
if (mode == HighVis) {
|
||||
matrix->drawPixel(x, trail_y, matrix->color565(128, 255, 128));
|
||||
} else {
|
||||
matrix->drawPixel(x, trail_y, matrix->color565(
|
||||
(128 / raindrops[x].length) * (raindrops[x].length - trail_offset),
|
||||
(255 / raindrops[x].length) * (raindrops[x].length - trail_offset),
|
||||
(128 / raindrops[x].length) * (raindrops[x].length - trail_offset))
|
||||
);
|
||||
}
|
||||
} else {
|
||||
matrix->drawPixel(x, trail_y, matrix->color565(0, (255 / raindrops[x].length) * (raindrops[x].length - trail_offset), 0));
|
||||
}
|
||||
} 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)) ) and !stealth_mode) {
|
||||
|
||||
if (overlay[ pixel_num / 8 ] & (1 << (7 - (pixel_num % 8)) ) and mode != Stealth) {
|
||||
if (mode == HighVis) {
|
||||
matrix->drawPixel(x, PANEL_HEIGHT + trail_y, matrix->color565(128, 255, 128));
|
||||
} else {
|
||||
matrix->drawPixel(x, PANEL_HEIGHT + trail_y, matrix->color565(
|
||||
(128 / raindrops[x].length) * (raindrops[x].length - trail_offset),
|
||||
(255 / raindrops[x].length) * (raindrops[x].length - trail_offset),
|
||||
(128 / raindrops[x].length) * (raindrops[x].length - trail_offset))
|
||||
);
|
||||
}
|
||||
} else {
|
||||
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