Merge pull request 'struct-rain' (#2) from struct-rain into master

Reviewed-on: #2
This commit is contained in:
Felix Pankratz 2024-12-08 15:16:39 +01:00
commit 8e94cf28d5
9 changed files with 458 additions and 84 deletions

View File

@ -13,6 +13,7 @@ platform = espressif32
board = adafruit_matrixportal_esp32s3
framework = arduino
monitor_speed = 115200
build_flags = -Ilib -Isrc
lib_deps =
adafruit/Adafruit GFX Library

47
nametag/src/congress.cpp Normal file
View File

@ -0,0 +1,47 @@
#include "constants.h"
#include "congress.h"
int running_text_pos = 21;
void draw_congress(MatrixPanel_I2S_DMA *matrix, enum Mode mode) {
uint16_t grid_color = matrix->color565(25, 11, 47);
matrix->fillScreenRGB888(15, 0, 10);
matrix->drawFastHLine(0, 0, PANEL_WIDTH, grid_color);
matrix->drawFastHLine(0, 7, PANEL_WIDTH, grid_color);
matrix->drawFastHLine(0, 24, PANEL_WIDTH, grid_color);
matrix->drawFastHLine(0, 31, PANEL_WIDTH, grid_color);
matrix->drawFastVLine(0, 0, PANEL_HEIGHT, grid_color);
matrix->drawFastVLine(63, 0, PANEL_HEIGHT, grid_color);
int v_lines = PANEL_WIDTH / 7;
for(int v; v < v_lines; v++) {
matrix->drawFastVLine(v * 7, 0, 7, grid_color);
matrix->drawFastVLine(v * 7, 24, 7, grid_color);
}
matrix->setTextWrap(false);
matrix->setTextColor(matrix->color565(255, 80, 83));
if (mode == Stealth) {
matrix->setCursor(7, 21);
matrix->print("38C3");
} else if (mode == LowVis) {
matrix->setCursor(2, 21);
matrix->print("Panki");
} else if (mode == HighVis) {
matrix->setCursor(running_text_pos, 21);
String message = "38C3 - Panki - DECT - 3389 - 38C3";
matrix->print(message);
if ((running_text_pos == 7) or (running_text_pos == - 70) or (running_text_pos == -146 ) or (running_text_pos == -216) ) {
delay(2000);
}
running_text_pos -= 1;
if (running_text_pos < - 286 ) { // (0 - (13 * message.length()))) {
running_text_pos = 7;
};
matrix->drawFastVLine(0, 0, PANEL_HEIGHT, grid_color);
matrix->drawFastVLine(63, 0, PANEL_HEIGHT, grid_color);
delay(10);
}
}

4
nametag/src/congress.h Normal file
View File

@ -0,0 +1,4 @@
#include "xtensa/core-macros.h"
#include <ESP32-HUB75-MatrixPanel-I2S-DMA.h>
#include "enums.h"
void draw_congress(MatrixPanel_I2S_DMA *matrix, enum Mode mode);

29
nametag/src/constants.h Normal file
View File

@ -0,0 +1,29 @@
#define R1 42
#define G1 40
#define BL1 41
#define R2 38
#define G2 37
#define BL2 39
#define CH_A 45
#define CH_B 36
#define CH_C 48
#define CH_D 35
#define CH_E 21
#define CLK 2
#define LAT 47
#define OE 14
#define PIN_E 21
#define PANEL_WIDTH 64
#define PANEL_HEIGHT 32 // Panel height of 64 will required PIN_E to be defined.
#define PANELS_NUMBER 1
#define PANE_WIDTH PANEL_WIDTH * PANELS_NUMBER
#define PANE_HEIGHT PANEL_HEIGHT
#define NUM_LEDS PANE_WIDTH*PANE_HEIGHT
#define ONBOARD_LED 13
#define BACK_BUTTON 6
#define NEXT_BUTTON 7

13
nametag/src/enums.h Normal file
View File

@ -0,0 +1,13 @@
#ifndef INCLUDED_ENUMS
#define INCLUDED_ENUMS
enum Mode {
Stealth,
LowVis,
HighVis
};
enum DisplayStyle {
Rain,
Congress
};
#endif

View File

@ -3,55 +3,23 @@
#include <ESP32-HUB75-MatrixPanel-I2S-DMA.h>
#include "main.h"
#include "constants.h"
#include "congress.h"
#include "rain.h"
#include "caveatbrush9pt7b.h"
#include "overlay.h"
#define R1 42
#define G1 40
#define BL1 41
#define R2 38
#define G2 37
#define BL2 39
#define CH_A 45
#define CH_B 36
#define CH_C 48
#define CH_D 35
#define CH_E 21
#define CLK 2
#define LAT 47
#define OE 14
#define PIN_E 21
#define PANEL_WIDTH 64
#define PANEL_HEIGHT 32 // Panel height of 64 will required PIN_E to be defined.
#define PANELS_NUMBER 1
#define PANE_WIDTH PANEL_WIDTH * PANELS_NUMBER
#define PANE_HEIGHT PANEL_HEIGHT
#define NUM_LEDS PANE_WIDTH*PANE_HEIGHT
#define ONBOARD_LED 13
#include "pillowlava8pt7b.h"
MatrixPanel_I2S_DMA *matrix = nullptr;
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];
Mode mode = HighVis;
DisplayStyle style = Congress;
void setup(){
Serial.begin(BAUD_RATE);
pinMode(ONBOARD_LED, OUTPUT);
pinMode(BACK_BUTTON, INPUT_PULLUP);
pinMode(NEXT_BUTTON, INPUT_PULLUP);
for (int i = 0; i<PANEL_WIDTH; i++) {
line_pos[i] = 0 - random(24);
line_length[i] = random(20, 28);
line_speed[i] = random(25, 100);
line_last_moved[i] = millis();
}
// redefine pins if required
// redefine pins in constants.h if required
HUB75_I2S_CFG::i2s_pins _pins={R1, G1, BL1, R2, G2, BL2, CH_A, CH_B, CH_C, CH_D, CH_E, LAT, OE, CLK};
HUB75_I2S_CFG mxconfig(PANEL_WIDTH, PANEL_HEIGHT, PANELS_NUMBER, _pins);
@ -68,56 +36,48 @@ void setup(){
matrix->begin();
matrix->setBrightness8(64);
matrix->fillScreenRGB888(0, 0, 0);
matrix->setFont(&CaveatBrush_Regular9pt7b);
matrix->setFont(&Pilowlava_Regular8pt7b);
}
void loop() {
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++) {
if ((timestamp - line_last_moved[x]) > line_speed[x]) {
// step down a pixel
line_pos[x]++;
line_last_moved[x] = timestamp;
if(!digitalRead(BACK_BUTTON)) {
switch(mode) {
case Stealth:
mode = LowVis;
break;
case LowVis:
mode = HighVis;
break;
case HighVis:
mode = Stealth;
break;
}
if (line_pos[x] > PANEL_HEIGHT) {
line_pos[x] = 0;
while(!digitalRead(BACK_BUTTON)); // Wait for release
}
if (line_pos[x] >= 0) {
//draw our pixel
matrix->drawPixel(x, line_pos[x], matrix->color565(128, 255, 128));
// draw our trail
for (int trail_offset = 1; trail_offset < line_length[x]; trail_offset++) {
//if (random(10) > 8) {
// trail_offset++;
//}
int trail_y = line_pos[x] - trail_offset;
if (trail_y >= 0) {
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));
} else {
matrix->drawPixel(x, trail_y, matrix->color565(0, (255 / line_length[x]) * (line_length[x] - trail_offset), 0));
if(!digitalRead(NEXT_BUTTON)) {
switch(style) {
case Rain:
style = Congress;
break;
case Congress:
style = Rain;
break;
}
} else {
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)) )) {
matrix->drawPixel(x, PANEL_HEIGHT + trail_y, matrix->color565(128, 255, 128));
} else {
matrix->drawPixel(x, PANEL_HEIGHT + trail_y, matrix->color565(0,(255 / line_length[x]) * (line_length[x] - trail_offset), 0));
while(!digitalRead(NEXT_BUTTON)); // Wait for release
}
} else {
switch(style) {
case Rain:
draw_rain(matrix, mode);
break;
case Congress:
draw_congress(matrix, mode);
break;
}
}
}
}
}
//delay(25);
}

View File

@ -0,0 +1,229 @@
const uint8_t Pilowlava_Regular8pt7bBitmaps[] PROGMEM = {
0x00, 0x38, 0xE3, 0x8E, 0x30, 0xC2, 0x08, 0x00, 0x8F, 0x3C, 0x00, 0x77,
0x77, 0x66, 0xC4, 0x00, 0x00, 0x0D, 0x80, 0x34, 0x00, 0xD0, 0x1A, 0x80,
0x38, 0xE6, 0x0F, 0xBF, 0x00, 0x00, 0xC0, 0x15, 0xC0, 0x53, 0x03, 0x40,
0x09, 0x00, 0x06, 0x00, 0x60, 0x06, 0x07, 0x47, 0xFF, 0xFF, 0x0F, 0x7C,
0x01, 0xF0,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 0xCF, 0x1A, 0xCE, 0x84, 0x47,
0x62, 0x27, 0x31, 0x27, 0x39, 0x1F, 0x9F, 0x8F, 0x8F, 0x83, 0x87, 0x80,
0x70, 0x7B, 0x87, 0xBC, 0x7D, 0xC6, 0x4E, 0x40, 0x74, 0x07, 0x80, 0xB0,
0x3A, 0x07, 0x1F, 0x70, 0xF7, 0x07, 0x00, 0x07, 0x07, 0xB8, 0x7B, 0x87,
0xDC, 0x6C, 0xE6, 0x07, 0x40, 0x78, 0x03, 0x80, 0x10, 0x1F, 0x01, 0xE0,
0x1C, 0x00, 0xFF, 0xDF, 0x9F, 0xE7, 0xF1, 0xE0, 0x78, 0x1C, 0x06, 0x01,
0xC0, 0x67, 0x1C, 0x7F, 0x87, 0xF0, 0x70, 0x00, 0x00, 0x30, 0x60, 0x82,
0x04, 0x30, 0xC1, 0x81, 0x81, 0x01, 0x01, 0x03, 0x06, 0x0C, 0x00, 0x9B,
0xFE, 0xEF, 0xF0, 0x00, 0x3E, 0x76, 0x20, 0x03, 0x6C, 0xD4, 0xD5, 0x33,
0xDF, 0xD0, 0x3C, 0x00, 0x04, 0xA7, 0x80, 0x00, 0x2F, 0xFC, 0x3F, 0xF0,
0x00, 0x01, 0xC1, 0x83, 0x02, 0x02, 0x03, 0x06, 0x0C, 0x18, 0x41, 0x02,
0x0C, 0x38, 0x20, 0x00, 0x9B, 0xFE, 0xEF, 0xF0, 0x00, 0x3E, 0x76, 0x20,
0x03, 0x6C, 0xD4, 0xD5, 0x33, 0xDF, 0xD0, 0x3C, 0x00, 0x04, 0xA7, 0x80,
0x00, 0x2F, 0xFC, 0x3F, 0xF0 };
const GFXglyph Pilowlava_Regular8pt7bGlyphs[] PROGMEM = {
{ 0, 1, 1, 6, 0, 0 }, // 0x20 ' '
{ 1, 6, 13, 6, 0, -11 }, // 0x21 '!'
{ 11, 8, 4, 9, 0, -11 }, // 0x22 '"'
{ 15, 14, 13, 14, 0, -12 }, // 0x23 '#'
{ 38, 12, 17, 14, 1, -13 }, // 0x24 '$'
{ 64, 12, 12, 12, 0, -11 }, // 0x25 '%'
{ 82, 14, 12, 15, 1, -11 }, // 0x26 '&'
{ 103, 4, 4, 5, 0, -11 }, // 0x27 '''
{ 105, 5, 16, 6, 1, -13 }, // 0x28 '('
{ 115, 5, 16, 6, 0, -13 }, // 0x29 ')'
{ 125, 7, 7, 9, 1, -11 }, // 0x2A '*'
{ 132, 14, 14, 18, 2, -12 }, // 0x2B '+'
{ 157, 4, 5, 5, 0, -2 }, // 0x2C ','
{ 160, 6, 2, 7, 0, -6 }, // 0x2D '-'
{ 162, 4, 3, 4, 0, -2 }, // 0x2E '.'
{ 164, 7, 12, 7, 0, -11 }, // 0x2F '/'
{ 175, 11, 12, 13, 1, -11 }, // 0x30 '0'
{ 192, 6, 12, 7, 0, -11 }, // 0x31 '1'
{ 201, 11, 12, 13, 1, -11 }, // 0x32 '2'
{ 218, 11, 12, 13, 1, -11 }, // 0x33 '3'
{ 235, 12, 12, 13, 0, -11 }, // 0x34 '4'
{ 253, 10, 12, 12, 1, -11 }, // 0x35 '5'
{ 268, 12, 12, 13, 1, -11 }, // 0x36 '6'
{ 286, 11, 12, 11, 0, -11 }, // 0x37 '7'
{ 303, 11, 12, 13, 1, -11 }, // 0x38 '8'
{ 320, 11, 12, 13, 1, -11 }, // 0x39 '9'
{ 337, 3, 9, 5, 1, -9 }, // 0x3A ':'
{ 341, 4, 12, 5, 0, -9 }, // 0x3B ';'
{ 347, 14, 14, 18, 2, -12 }, // 0x3C '<'
{ 372, 9, 5, 10, 1, -7 }, // 0x3D '='
{ 378, 14, 14, 18, 2, -12 }, // 0x3E '>'
{ 403, 10, 12, 11, 0, -11 }, // 0x3F '?'
{ 418, 13, 12, 15, 1, -11 }, // 0x40 '@'
{ 438, 12, 12, 13, 0, -11 }, // 0x41 'A'
{ 456, 12, 12, 14, 1, -11 }, // 0x42 'B'
{ 474, 11, 13, 13, 1, -11 }, // 0x43 'C'
{ 492, 12, 12, 14, 1, -11 }, // 0x44 'D'
{ 510, 11, 12, 13, 1, -11 }, // 0x45 'E'
{ 527, 11, 12, 12, 1, -11 }, // 0x46 'F'
{ 544, 12, 12, 14, 1, -11 }, // 0x47 'G'
{ 562, 12, 12, 14, 1, -11 }, // 0x48 'H'
{ 580, 5, 12, 7, 1, -11 }, // 0x49 'I'
{ 588, 7, 12, 8, 0, -11 }, // 0x4A 'J'
{ 599, 12, 12, 14, 1, -11 }, // 0x4B 'K'
{ 617, 8, 12, 9, 1, -11 }, // 0x4C 'L'
{ 629, 16, 12, 18, 1, -11 }, // 0x4D 'M'
{ 653, 12, 12, 14, 1, -11 }, // 0x4E 'N'
{ 671, 11, 12, 13, 1, -11 }, // 0x4F 'O'
{ 688, 11, 12, 13, 1, -11 }, // 0x50 'P'
{ 705, 13, 15, 15, 1, -11 }, // 0x51 'Q'
{ 730, 12, 12, 14, 1, -11 }, // 0x52 'R'
{ 748, 11, 12, 13, 1, -11 }, // 0x53 'S'
{ 765, 12, 12, 12, 0, -11 }, // 0x54 'T'
{ 783, 10, 12, 12, 1, -11 }, // 0x55 'U'
{ 798, 12, 12, 12, 0, -11 }, // 0x56 'V'
{ 816, 17, 12, 18, 0, -11 }, // 0x57 'W'
{ 842, 12, 12, 13, 0, -11 }, // 0x58 'X'
{ 860, 12, 13, 12, 0, -12 }, // 0x59 'Y'
{ 880, 11, 12, 13, 1, -11 }, // 0x5A 'Z'
{ 897, 6, 16, 7, 1, -13 }, // 0x5B '['
{ 909, 7, 12, 7, 0, -11 }, // 0x5C '\'
{ 920, 6, 16, 7, 0, -13 }, // 0x5D ']'
{ 932, 7, 3, 9, 1, -11 }, // 0x5E '^'
{ 935, 12, 2, 13, 0, 1 }, // 0x5F '_'
{ 938, 5, 2, 9, 1, -14 }, // 0x60 '`'
{ 940, 12, 12, 13, 0, -11 }, // 0x61 'a'
{ 958, 12, 12, 14, 1, -11 }, // 0x62 'b'
{ 976, 11, 13, 13, 1, -11 }, // 0x63 'c'
{ 994, 12, 12, 14, 1, -11 }, // 0x64 'd'
{ 1012, 11, 12, 13, 1, -11 }, // 0x65 'e'
{ 1029, 11, 12, 12, 1, -11 }, // 0x66 'f'
{ 1046, 12, 12, 14, 1, -11 }, // 0x67 'g'
{ 1064, 12, 12, 14, 1, -11 }, // 0x68 'h'
{ 1082, 5, 12, 7, 1, -11 }, // 0x69 'i'
{ 1090, 7, 12, 8, 0, -11 }, // 0x6A 'j'
{ 1101, 12, 12, 14, 1, -11 }, // 0x6B 'k'
{ 1119, 8, 12, 9, 1, -11 }, // 0x6C 'l'
{ 1131, 16, 12, 18, 1, -11 }, // 0x6D 'm'
{ 1155, 12, 12, 14, 1, -11 }, // 0x6E 'n'
{ 1173, 11, 12, 13, 1, -11 }, // 0x6F 'o'
{ 1190, 11, 12, 13, 1, -11 }, // 0x70 'p'
{ 1207, 13, 15, 15, 1, -11 }, // 0x71 'q'
{ 1232, 12, 12, 14, 1, -11 }, // 0x72 'r'
{ 1250, 11, 12, 13, 1, -11 }, // 0x73 's'
{ 1267, 12, 12, 12, 0, -11 }, // 0x74 't'
{ 1285, 10, 12, 12, 1, -11 }, // 0x75 'u'
{ 1300, 12, 12, 12, 0, -11 }, // 0x76 'v'
{ 1318, 17, 12, 18, 0, -11 }, // 0x77 'w'
{ 1344, 12, 12, 13, 0, -11 }, // 0x78 'x'
{ 1362, 12, 13, 12, 0, -12 }, // 0x79 'y'
{ 1382, 11, 12, 13, 1, -11 }, // 0x7A 'z'
{ 1399, 7, 18, 7, 0, -14 }, // 0x7B '{'
{ 1415, 14, 14, 18, 2, -12 }, // 0x7C '|'
{ 1440, 7, 18, 7, -1, -14 }, // 0x7D '}'
{ 1456, 14, 14, 18, 2, -12 } }; // 0x7E '~'
const GFXfont Pilowlava_Regular8pt7b PROGMEM = {
(uint8_t *)Pilowlava_Regular8pt7bBitmaps,
(GFXglyph *)Pilowlava_Regular8pt7bGlyphs,
0x20, 0x7E, 19 };
// Approx. 2153 bytes

87
nametag/src/rain.cpp Normal file
View File

@ -0,0 +1,87 @@
#include "rain.h"
#include "constants.h"
#include "overlay.h"
typedef struct {
bool reached_bottom = false;
int y;
int length;
int speed;
unsigned long last_moved;
} Raindrop;
Raindrop raindrops[PANEL_WIDTH];
bool rain_initialized = false;
void setup_rain() {
for (int i = 0; i<PANEL_WIDTH; i++) {
raindrops[i].y = 0 - random(24);
raindrops[i].length = random(20, 28);
raindrops[i].speed = random(25, 100);
raindrops[i].last_moved = millis();
}
}
void draw_rain(MatrixPanel_I2S_DMA *matrix, Mode mode) {
//matrix ->drawBitmap(0, 0, overlay, 64, 32, matrix->color565(64, 0, 0));
if (!rain_initialized) {
setup_rain();
rain_initialized = true;
}
unsigned long timestamp = millis();
for (int x = 0; x < PANEL_WIDTH; x++) {
if ((timestamp - raindrops[x].last_moved) > raindrops[x].speed) {
// step down a pixel
raindrops[x].y++;
raindrops[x].last_moved = timestamp;
}
if (raindrops[x].y > PANEL_HEIGHT) {
raindrops[x].y = 0;
raindrops[x].reached_bottom = true;
}
if (raindrops[x].y >= 0) {
//draw our pixel
matrix->drawPixel(x, raindrops[x].y, matrix->color565(128, 255, 128));
// draw our trail
for (int trail_offset = 1; trail_offset < raindrops[x].length; trail_offset++) {
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 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 (raindrops[x].y >= 0) {
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));
}
} else {
break;
}
}
}
}
}
}

4
nametag/src/rain.h Normal file
View File

@ -0,0 +1,4 @@
#include "xtensa/core-macros.h"
#include <ESP32-HUB75-MatrixPanel-I2S-DMA.h>
#include "enums.h"
void draw_rain(MatrixPanel_I2S_DMA *matrix, enum Mode mode);