actual fahrplan
This commit is contained in:
parent
6a313c1cc9
commit
73c6f13b0e
@ -21,3 +21,7 @@ lib_deps =
|
||||
fastled/FastLED
|
||||
https://github.com/mrfaptastic/ESP32-HUB75-MatrixPanel-I2S-DMA.git
|
||||
bitbank2/AnimatedGIF
|
||||
bblanchon/ArduinoJson
|
||||
|
||||
build_flags =
|
||||
-DS3_LCD_DIV_NUM=20
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
// config.h
|
||||
|
||||
#define WIFI_SSID PankiNet
|
||||
#define WIFI_PSK foo
|
||||
#define DISPLAY_DURATION 10000
|
||||
|
||||
@ -1,4 +1,7 @@
|
||||
#include <Arduino.h>
|
||||
#include <ArduinoJson.h>
|
||||
#include <WiFi.h>
|
||||
#include <HTTPClient.h>
|
||||
#include "xtensa/core-macros.h"
|
||||
#include <ESP32-HUB75-MatrixPanel-I2S-DMA.h>
|
||||
|
||||
@ -15,12 +18,22 @@
|
||||
|
||||
MatrixPanel_I2S_DMA *matrix = nullptr;
|
||||
AnimatedGIF gif;
|
||||
WiFiClientSecure client;
|
||||
HTTPClient http;
|
||||
DynamicJsonDocument doc(32768);
|
||||
|
||||
long lastrefresh = 0;
|
||||
bool firstRequest = true;
|
||||
|
||||
int current_index = 0;
|
||||
long last_index_change = 0;
|
||||
|
||||
|
||||
void setup(){
|
||||
Serial.begin(BAUD_RATE);
|
||||
//while (!Serial) {
|
||||
// while (!Serial) {
|
||||
// ; // wait for serial port to connect. Needed for native USB
|
||||
//}
|
||||
// }
|
||||
pinMode(ONBOARD_LED, OUTPUT);
|
||||
|
||||
// redefine pins if required
|
||||
@ -42,6 +55,26 @@ void setup(){
|
||||
matrix->fillScreenRGB888(0, 0, 0);
|
||||
|
||||
gif.begin(LITTLE_ENDIAN_PIXELS);
|
||||
|
||||
matrix->setCursor(0, 0);
|
||||
char ssid[] = "YOUR_SSID";
|
||||
char pw[] = "YOUR_PSK";
|
||||
matrix->print(ssid);
|
||||
//Serial.print("Connecting");
|
||||
WiFi.begin(ssid, pw);
|
||||
// WiFi.begin(ssid, NULL);
|
||||
while (WiFi.status() != WL_CONNECTED) {
|
||||
delay(500);
|
||||
matrix->fillScreenRGB888(0, 0, 0);
|
||||
matrix->setCursor(0, 0);
|
||||
matrix->print(WiFi.status());
|
||||
//Serial.print(".");
|
||||
}
|
||||
matrix->fillScreenRGB888(0, 0, 0);
|
||||
|
||||
client.setInsecure();
|
||||
http.useHTTP10(true);
|
||||
http.begin(client, "https://www.theresno.cloud/schedhelp");
|
||||
}
|
||||
|
||||
void draw_title(const std::string& title, uint16_t color) {
|
||||
@ -60,10 +93,17 @@ void draw_title(const std::string& title, uint16_t color) {
|
||||
} else {
|
||||
x_pos += 6; // char width + 1px gap
|
||||
}
|
||||
} else {
|
||||
} else if (x_pos != 0) {
|
||||
x_pos += 2; // small space
|
||||
}
|
||||
|
||||
if (y_pos >= 16 && x_pos >= (63 - 6)) {
|
||||
// ellipsis
|
||||
matrix->drawPixel(x_pos, y_pos + 6, color);
|
||||
matrix->drawPixel(x_pos + 2, y_pos + 6, color);
|
||||
matrix->drawPixel(x_pos + 4, y_pos + 6, color);
|
||||
break;
|
||||
}
|
||||
if (x_pos > (63 - 5)) { // new line
|
||||
if (current != ' ') {
|
||||
matrix->drawChar(x_pos, y_pos, '-', color, matrix->color444(0,0,0), 1);
|
||||
@ -76,7 +116,7 @@ void draw_title(const std::string& title, uint16_t color) {
|
||||
|
||||
void draw_time(const std::string &time) {
|
||||
int x_pos = 0;
|
||||
int y_pos = 32 - 8;
|
||||
int y_pos = 32 - 7;
|
||||
|
||||
for (size_t idx = 0; idx < time.size(); idx++) {
|
||||
char current = time[idx];
|
||||
@ -87,12 +127,12 @@ void draw_time(const std::string &time) {
|
||||
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));
|
||||
matrix->drawPixel(x_pos, y_pos + 2, matrix->color565(255,255,255));
|
||||
matrix->drawPixel(x_pos, y_pos + 4, matrix->color565(255,255,255));
|
||||
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);
|
||||
matrix->drawChar(x_pos, y_pos, current, matrix->color565(255,255,255), matrix->color444(0,0,0), 1);
|
||||
x_pos = x_pos + (6 - offset);
|
||||
}
|
||||
}
|
||||
@ -100,7 +140,7 @@ void draw_time(const std::string &time) {
|
||||
|
||||
void draw_location(const std::string &location) {
|
||||
int pixel_size = (location.size() * 6) - 1;
|
||||
matrix->setCursor(63 - pixel_size, 32 - 8);
|
||||
matrix->setCursor(63 - pixel_size, 32 - 7);
|
||||
matrix->print(location.c_str());
|
||||
}
|
||||
|
||||
@ -125,7 +165,7 @@ void GIFDraw(GIFDRAW *pDraw) {
|
||||
// Apply the new pixels to the main image
|
||||
if (pDraw->ucHasTransparency) // if transparency used
|
||||
{
|
||||
Serial.println("Transparency!");
|
||||
// Serial.println("Transparency!");
|
||||
uint8_t *pEnd, c, ucTransparent = pDraw->ucTransparent;
|
||||
int x, iCount;
|
||||
pEnd = s + pDraw->iWidth;
|
||||
@ -153,7 +193,7 @@ void GIFDraw(GIFDRAW *pDraw) {
|
||||
{
|
||||
for (int xOffset = 0; xOffset < iCount; xOffset++)
|
||||
{
|
||||
matrix->drawPixel(28 + x + xOffset, 25 + y, usTemp[xOffset]);
|
||||
matrix->drawPixel(28 + x + xOffset, 27 + y, usTemp[xOffset]);
|
||||
}
|
||||
x += iCount;
|
||||
iCount = 0;
|
||||
@ -181,23 +221,49 @@ void GIFDraw(GIFDRAW *pDraw) {
|
||||
// Translate the 8-bit pixels through the RGB565 palette (already byte reversed)
|
||||
for (x = 0; x < pDraw->iWidth; x++)
|
||||
{
|
||||
matrix->drawPixel(28 + x, 25 + y, usPalette[*s++]);
|
||||
matrix->drawPixel(28 + x, 27 + y, usPalette[*s++]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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));
|
||||
if(firstRequest || (millis() - lastrefresh > 120000)) {
|
||||
http.GET();
|
||||
|
||||
DeserializationError error = deserializeJson(doc, http.getStream());
|
||||
if (error) {
|
||||
//Serial.print(F("deserializeJson() failed: "));
|
||||
//Serial.println(error.f_str());
|
||||
return;
|
||||
}
|
||||
lastrefresh = millis();
|
||||
firstRequest = false;
|
||||
}
|
||||
const char *j_title = doc[current_index]["title"];
|
||||
const char *j_time = doc[current_index]["start"];
|
||||
const char *j_room = doc[current_index]["room"];
|
||||
|
||||
std::string title(j_title); //= "THE ART OF TEXT RE:NDERING";
|
||||
std::string time(j_time); // = "11:00";
|
||||
std::string loc(j_room); //= "GRND";
|
||||
//draw_title(title, matrix->color565(249, 176, 0));
|
||||
draw_title(title, matrix->color565(doc[current_index]["r"], doc[current_index]["g"], doc[current_index]["b"]));
|
||||
draw_time(time);
|
||||
draw_location(loc);
|
||||
|
||||
|
||||
if (gif.open((uint8_t *)reallytinypp, sizeof(reallytinypp), GIFDraw)) {
|
||||
while (gif.playFrame(true, NULL)) {
|
||||
;
|
||||
}
|
||||
gif.close();
|
||||
}
|
||||
if (millis() - last_index_change > DISPLAY_DURATION ) {
|
||||
current_index++;
|
||||
if (current_index > 4) {
|
||||
current_index = 0;
|
||||
}
|
||||
last_index_change = millis();
|
||||
matrix->fillScreenRGB888(0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user