Fahrplan initial commit
This commit is contained in:
parent
cd8f565e3e
commit
55d26d4949
21
fahrplan/Makefile
Normal file
21
fahrplan/Makefile
Normal file
@ -0,0 +1,21 @@
|
||||
# Uncomment lines below if you have problems with $PATH
|
||||
#SHELL := /bin/bash
|
||||
#PATH := /usr/local/bin:$(PATH)
|
||||
|
||||
all:
|
||||
pio.exe -f -c vim run
|
||||
|
||||
upload:
|
||||
pio.exe -f -c vim run --target upload
|
||||
|
||||
clean:
|
||||
pio.exe -f -c vim run --target clean
|
||||
|
||||
program:
|
||||
pio.exe -f -c vim run --target program
|
||||
|
||||
uploadfs:
|
||||
pio.exe -f -c vim run --target uploadfs
|
||||
|
||||
update:
|
||||
pio.exe -f -c vim update
|
||||
22
fahrplan/platformio.ini
Normal file
22
fahrplan/platformio.ini
Normal file
@ -0,0 +1,22 @@
|
||||
; PlatformIO Project Configuration File
|
||||
;
|
||||
; Build options: build flags, source filter
|
||||
; Upload options: custom upload port, speed and extra flags
|
||||
; Library options: dependencies, extra library storages
|
||||
; Advanced options: extra scripting
|
||||
;
|
||||
; Please visit documentation for the other options and examples
|
||||
; https://docs.platformio.org/page/projectconf.html
|
||||
|
||||
[env:adafruit_matrixportal_esp32s3]
|
||||
platform = espressif32
|
||||
board = adafruit_matrixportal_esp32s3
|
||||
framework = arduino
|
||||
monitor_speed = 115200
|
||||
|
||||
lib_deps =
|
||||
adafruit/Adafruit GFX Library
|
||||
adafruit/Adafruit BusIO
|
||||
Wire
|
||||
fastled/FastLED
|
||||
https://github.com/mrfaptastic/ESP32-HUB75-MatrixPanel-I2S-DMA.git
|
||||
4
fahrplan/src/config.h
Normal file
4
fahrplan/src/config.h
Normal file
@ -0,0 +1,4 @@
|
||||
// config.h
|
||||
|
||||
#define WIFI_SSID PankiNet
|
||||
#define WIFI_PSK foo
|
||||
26
fahrplan/src/constants.h
Normal file
26
fahrplan/src/constants.h
Normal file
@ -0,0 +1,26 @@
|
||||
#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
|
||||
110
fahrplan/src/main.cpp
Normal file
110
fahrplan/src/main.cpp
Normal file
@ -0,0 +1,110 @@
|
||||
#include <Arduino.h>
|
||||
#include "xtensa/core-macros.h"
|
||||
#include <ESP32-HUB75-MatrixPanel-I2S-DMA.h>
|
||||
|
||||
#include "main.h"
|
||||
#include "constants.h"
|
||||
#include "config.h"
|
||||
#include "util.h"
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
MatrixPanel_I2S_DMA *matrix = nullptr;
|
||||
|
||||
void setup(){
|
||||
Serial.begin(BAUD_RATE);
|
||||
//while (!Serial) {
|
||||
// ; // wait for serial port to connect. Needed for native USB
|
||||
//}
|
||||
pinMode(ONBOARD_LED, OUTPUT);
|
||||
|
||||
// redefine pins 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);
|
||||
|
||||
mxconfig.gpio.e = PIN_E;
|
||||
mxconfig.driver = HUB75_I2S_CFG::FM6126A; // for panels using FM6126A chips
|
||||
|
||||
mxconfig.latch_blanking = 4;
|
||||
mxconfig.i2sspeed = HUB75_I2S_CFG::HZ_10M;
|
||||
mxconfig.clkphase = false;
|
||||
|
||||
// mxconfig.double_buff = true;
|
||||
|
||||
matrix = new MatrixPanel_I2S_DMA(mxconfig);
|
||||
matrix->begin();
|
||||
matrix->setBrightness8(64);
|
||||
matrix->fillScreenRGB888(0, 0, 0);
|
||||
}
|
||||
|
||||
void draw_title(const std::string& title, uint16_t color) {
|
||||
int y_pos = 0;
|
||||
int x_pos = 0;
|
||||
//matrix->setCursor(x_pos, y_pos);
|
||||
for (size_t idx = 0; idx < title.size(); idx++) {
|
||||
char current = title[idx];
|
||||
if (current != ' ') {
|
||||
if (current == 'I') {
|
||||
x_pos -=1;
|
||||
}
|
||||
matrix->drawChar(x_pos, y_pos, current, color, matrix->color444(0,0,0), 1);
|
||||
if (current == 'I') {
|
||||
x_pos += 5;
|
||||
} else {
|
||||
x_pos += 6; // char width + 1px gap
|
||||
}
|
||||
} else {
|
||||
x_pos += 2; // small space
|
||||
}
|
||||
|
||||
if (x_pos > (63 - 5)) { // new line
|
||||
if (current != ' ') {
|
||||
matrix->drawChar(x_pos, y_pos, '-', color, matrix->color444(0,0,0), 1);
|
||||
}
|
||||
x_pos = 0;
|
||||
y_pos = y_pos + 8; //char height + 1px
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void draw_time(const std::string &time) {
|
||||
int x_pos = 0;
|
||||
int y_pos = 32 - 8;
|
||||
|
||||
for (size_t idx = 0; idx < time.size(); idx++) {
|
||||
char current = time[idx];
|
||||
int offset = 0;
|
||||
switch (current) {
|
||||
case '1':
|
||||
offset = 1;
|
||||
break;
|
||||
}
|
||||
if (current == ':') {
|
||||
matrix->drawPixel(x_pos, y_pos + 2, matrix->color444(1,1,1));
|
||||
matrix->drawPixel(x_pos, y_pos + 4, matrix->color444(1,1,1));
|
||||
x_pos = x_pos + 2;
|
||||
} else {
|
||||
x_pos = x_pos - offset;
|
||||
matrix->drawChar(x_pos, y_pos, current, matrix->color444(1,1,1), matrix->color444(0,0,0), 1);
|
||||
x_pos = x_pos + (6 - offset);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void draw_location(const std::string &location) {
|
||||
int pixel_size = (location.size() * 6) - 1;
|
||||
matrix->setCursor(63 - pixel_size, 32 - 8);
|
||||
matrix->print(location.c_str());
|
||||
}
|
||||
|
||||
void loop() {
|
||||
std::string title = "THE ART OF TEXT RENDERING";
|
||||
std::string time = "11:00";
|
||||
std::string loc = "GRND";
|
||||
draw_title(title, matrix->color565(249, 176, 0));
|
||||
draw_time(time);
|
||||
draw_location(loc);
|
||||
|
||||
delay(100);
|
||||
}
|
||||
10
fahrplan/src/main.h
Normal file
10
fahrplan/src/main.h
Normal file
@ -0,0 +1,10 @@
|
||||
#include <FastLED.h>
|
||||
|
||||
#define BAUD_RATE 115200 // serial debug port baud rate
|
||||
|
||||
void buffclear(CRGB *buf);
|
||||
uint16_t XY16( uint16_t x, uint16_t y);
|
||||
void mxfill(CRGB *leds);
|
||||
uint16_t colorWheel(uint8_t pos);
|
||||
void drawText(int colorWheelOffset);
|
||||
|
||||
5
fahrplan/src/util.cpp
Normal file
5
fahrplan/src/util.cpp
Normal file
@ -0,0 +1,5 @@
|
||||
#include "constants.h"
|
||||
|
||||
bool is_in_bounds(int x, int y) {
|
||||
return (x < PANEL_WIDTH) and (y < PANEL_HEIGHT) and (x >= 0) and (y >= 0);
|
||||
}
|
||||
2
fahrplan/src/util.h
Normal file
2
fahrplan/src/util.h
Normal file
@ -0,0 +1,2 @@
|
||||
bool is_in_bounds(int x, int y);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user