summaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp167
1 files changed, 167 insertions, 0 deletions
diff --git a/src/main.cpp b/src/main.cpp
new file mode 100644
index 0000000..a29cd8d
--- /dev/null
+++ b/src/main.cpp
@@ -0,0 +1,167 @@
+
+// Example sketch which shows how to display some patterns
+// on a 64x64 LED matrix
+//
+
+#include <ESP32-HUB75-MatrixPanel-I2S-DMA.h>
+#include <Fonts/Picopixel.h>
+
+#define PANEL_RES_X 64 // Number of pixels wide of each INDIVIDUAL panel module.
+#define PANEL_RES_Y 64 // Number of pixels tall of each INDIVIDUAL panel module.
+#define PANEL_CHAIN 1 // Total number of panels chained one to another
+
+#include <ESP32-HUB75-MatrixPanel-I2S-DMA.h>
+/*--------------------- HUB75 MATRIX GPIO CONFIG ---------------------*/
+
+#define R1 1
+#define G1 40
+#define BL1 2
+#define R2 4
+#define G2 36
+#define BL2 6
+#define CH_A 8
+#define CH_B 21
+#define CH_C 10
+#define CH_D 17
+#define CH_E 34 // required for 1/32 scan panels, like 64x64px. Any available pin would do, i.e. IO32
+#define LAT 15
+#define OE 14
+#define CLK 13
+
+
+//MatrixPanel_I2S_DMA dma_display;
+MatrixPanel_I2S_DMA *dma_display = nullptr;
+
+uint16_t myBLACK = dma_display->color565(0, 0, 0);
+uint16_t myWHITE = dma_display->color565(255, 255, 255);
+uint16_t myRED = dma_display->color565(255, 0, 0);
+uint16_t myGREEN = dma_display->color565(0, 255, 0);
+uint16_t myBLUE = dma_display->color565(0, 0, 255);
+
+uint16_t get_color(char name[4]) {
+ if (name == "1A") {
+ return dma_display->color565(255, 0, 0); // Red
+ } else if (name == "A") {
+ return dma_display->color565(75, 75, 255); // Light blue
+ } else if (name == "B") {
+ return dma_display->color565(50, 150, 16); // Green
+ } else if (name == "350S" or name == "150S") {
+ return dma_display->color565(0, 101, 170); // Dark blue
+ }else {
+ return dma_display->color565(200, 100, 0); // Yellow
+ }
+}
+
+void draw_line(int index, char* name, char* direction, int time, int time_offset) {
+ const int vertical_offset = 9 * index;
+ const uint16_t color = get_color(name);
+ dma_display->fillRect(0, vertical_offset, 19, 9, color);
+
+ if(strlen(name) == 4){
+ // The name is 4 characters wide, use a condensed font
+ dma_display->setFont(&Picopixel);
+ dma_display->setCursor(2, 6 + vertical_offset); // start at top left, with 8 pixel of spacing
+ }else{
+ dma_display->setCursor(8 + (4 - (strlen(name) * 6)) / 2, 1 + vertical_offset); // start at top left, with 8 pixel of spacing
+ }
+
+ dma_display->setTextColor(dma_display->color565(255, 255, 255));
+ dma_display->println(name);
+ dma_display->setFont();
+ dma_display->setCursor(21, 1 + vertical_offset); // start at top left, with 8 pixel of spacing
+ dma_display->print(direction);
+ dma_display->print(" ");
+
+ if (time < 10) {
+ dma_display->print(" ");
+ }
+
+ if(time_offset > 0){
+ dma_display->setTextColor(dma_display->color565(255, 0, 0));
+ } else if(time_offset < 0){
+ dma_display->setTextColor(dma_display->color565(0, 255, 0));
+ }
+
+ dma_display->print(time);
+ dma_display->setFont(&Picopixel);
+
+ dma_display->setCursor(52, 6 + vertical_offset); // start at top left, with 8 pixel of spacing
+
+ if(time_offset == 0){
+ dma_display->print("min");
+ } else {
+ if(time_offset > 0){
+ dma_display->print("+");
+ }
+ dma_display->print(time_offset);
+ }
+
+ dma_display->setFont();
+}
+
+void setup() {
+
+ // Module configuration
+ 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_RES_X, // module width
+ PANEL_RES_Y, // module height
+ PANEL_CHAIN, // Chain length
+ _pins // pin mapping
+ );
+
+ mxconfig.gpio.e = 34;
+ mxconfig.clkphase = false;
+ mxconfig.driver = HUB75_I2S_CFG::MBI5124;
+ mxconfig.latch_blanking = 4;
+ mxconfig.i2sspeed = HUB75_I2S_CFG::HZ_8M;
+
+ // Display Setup
+ dma_display = new MatrixPanel_I2S_DMA(mxconfig);
+ dma_display->begin();
+ dma_display->setBrightness8(28); //0-255
+ dma_display->clearScreen();
+
+ dma_display->setTextSize(1); // size 1 == 8 pixels high
+ dma_display->setTextWrap(false); // Don't wrap at end of line - will do ourselves
+
+ draw_line(0, "1A", "Av", 0, 0);
+ draw_line(1, "C", "Kl", 6, 7);
+ draw_line(2, "B", "Fa", 7, 0);
+ draw_line(3, "A", "Av", 9, 0);
+ draw_line(4, "A", "Vi", 10, 0);
+ draw_line(5, "350S", "Ba", 16, -2);
+ draw_line(6, "184", "Av", 19, 0);
+
+ /*
+ // draw a box
+ dma_display->fillRect(0, 12, 13, 11, dma_display->color565(200, 100, 0));
+ dma_display->setCursor(4, 14); // start at top left, with 8 pixel of spacing
+ dma_display->setTextColor(dma_display->color565(255,255,255));
+ dma_display->print("C FR 15min");
+
+ // draw a box
+ dma_display->fillRect(0, 24, 13, 11, dma_display->color565(0, 125, 190));
+ dma_display->setCursor(4, 26); // start at top left, with 8 pixel of spacing
+ dma_display->setTextColor(dma_display->color565(255,255,255));
+ dma_display->print("A HI 22min");
+
+ // draw a box
+ dma_display->fillRect(0, 36, 13, 11, dma_display->color565(0, 175, 0));
+ dma_display->setCursor(4, 38); // start at top left, with 8 pixel of spacing
+ dma_display->setTextColor(dma_display->color565(255,255,255));
+ dma_display->print("B FA 25min");
+
+ // draw a box
+ dma_display->fillRect(0, 48, 13, 11, dma_display->color565(0, 125, 190));
+ dma_display->setCursor(4, 50); // start at top left, with 8 pixel of spacing
+ dma_display->setTextColor(dma_display->color565(255,255,255));
+ dma_display->print("A KO 29min");
+*/
+ delay(500);
+}
+
+void loop() {
+ delay(1000);
+}
+