update
This commit is contained in:
8
.vscode/settings.json
vendored
8
.vscode/settings.json
vendored
@@ -48,6 +48,12 @@
|
||||
"streambuf": "cpp",
|
||||
"cinttypes": "cpp",
|
||||
"typeinfo": "cpp",
|
||||
"tjpgd.h": "c"
|
||||
"tjpgd.h": "c",
|
||||
"chrono": "cpp",
|
||||
"condition_variable": "cpp",
|
||||
"list": "cpp",
|
||||
"ratio": "cpp",
|
||||
"mutex": "cpp",
|
||||
"thread": "cpp"
|
||||
}
|
||||
}
|
||||
@@ -150,19 +150,12 @@ IPAddress FSWebServer::startWiFi(uint32_t timeout, const char *apSSID, const cha
|
||||
|
||||
const char *_ssid;
|
||||
const char *_pass;
|
||||
#if defined(ESP8266)
|
||||
struct station_config conf;
|
||||
wifi_station_get_config_default(&conf);
|
||||
_ssid = reinterpret_cast<const char *>(conf.ssid);
|
||||
_pass = reinterpret_cast<const char *>(conf.password);
|
||||
|
||||
#elif defined(ESP32)
|
||||
wifi_config_t conf;
|
||||
esp_wifi_get_config(WIFI_IF_STA, &conf);
|
||||
|
||||
_ssid = reinterpret_cast<const char *>(conf.sta.ssid);
|
||||
_pass = reinterpret_cast<const char *>(conf.sta.password);
|
||||
#endif
|
||||
|
||||
if (strlen(_ssid) && strlen(_pass))
|
||||
{
|
||||
|
||||
@@ -493,6 +493,7 @@ void NotifyApp(FastLED_NeoMatrix *matrix, MatrixDisplayUiState *state)
|
||||
notify.iconWasPushed = false;
|
||||
notify.iconPosition = 0;
|
||||
notify.scrollDelay = 0;
|
||||
DisplayManager.showGif=false;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,8 @@ Ticker TimerTicker;
|
||||
#define MATRIX_HEIGHT 8
|
||||
fs::File gifFile;
|
||||
GifPlayer gif;
|
||||
bool showGif;
|
||||
|
||||
uint16_t gifX, gifY;
|
||||
CRGB leds[MATRIX_WIDTH * MATRIX_HEIGHT];
|
||||
// Awtrix Big / Ulanzi
|
||||
|
||||
@@ -93,9 +94,13 @@ bool DisplayManager_::setAutoTransition(bool active)
|
||||
|
||||
void DisplayManager_::drawGIF(uint16_t x, uint16_t y, fs::File gFile)
|
||||
{
|
||||
gif.setFile(gFile);
|
||||
gifX = x;
|
||||
gifY = y;
|
||||
if (!showGif)
|
||||
{
|
||||
gif.setFile(gFile);
|
||||
showGif = true;
|
||||
}
|
||||
}
|
||||
|
||||
void DisplayManager_::drawJPG(uint16_t x, uint16_t y, fs::File jpgFile)
|
||||
@@ -245,7 +250,7 @@ void removeCustomApp(const String &name)
|
||||
ui->setApps(Apps);
|
||||
}
|
||||
|
||||
void DisplayManager_::generateCustomPage(String name, const char *json)
|
||||
void DisplayManager_::generateCustomPage(const String &name, const char *json)
|
||||
{
|
||||
|
||||
if (strcmp(json, "") == 0 && customApps.count(name))
|
||||
@@ -256,12 +261,14 @@ void DisplayManager_::generateCustomPage(String name, const char *json)
|
||||
return;
|
||||
}
|
||||
|
||||
Serial.printf("Appname %s", name);
|
||||
|
||||
DynamicJsonDocument doc(1024);
|
||||
DeserializationError error = deserializeJson(doc, json);
|
||||
if (error)
|
||||
{
|
||||
doc.clear();
|
||||
return;
|
||||
}
|
||||
|
||||
CustomApp customApp;
|
||||
|
||||
@@ -349,6 +356,10 @@ void DisplayManager_::generateCustomPage(String name, const char *json)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (customApp.icon)
|
||||
{
|
||||
customApp.icon.close();
|
||||
}
|
||||
if (LittleFS.exists("/ICONS/" + iconFileName + ".jpg"))
|
||||
{
|
||||
customApp.isGif = false;
|
||||
@@ -374,6 +385,7 @@ void DisplayManager_::generateCustomPage(String name, const char *json)
|
||||
|
||||
pushCustomApp(name, pos - 1);
|
||||
customApps[name] = customApp;
|
||||
doc.clear();
|
||||
}
|
||||
|
||||
void DisplayManager_::generateNotification(const char *json)
|
||||
@@ -387,7 +399,7 @@ void DisplayManager_::generateNotification(const char *json)
|
||||
notify.rainbow = doc.containsKey("rainbow") ? doc["rainbow"].as<bool>() : false;
|
||||
notify.hold = doc.containsKey("hold") ? doc["hold"].as<bool>() : false;
|
||||
notify.pushIcon = doc.containsKey("pushIcon") ? doc["pushIcon"] : 0;
|
||||
notify.flag = true;
|
||||
|
||||
notify.startime = millis();
|
||||
notify.scrollposition = 9;
|
||||
notify.iconWasPushed = false;
|
||||
@@ -446,6 +458,9 @@ void DisplayManager_::generateNotification(const char *json)
|
||||
notify.color = TEXTCOLOR_565;
|
||||
}
|
||||
|
||||
notify.flag = true;
|
||||
showGif = false;
|
||||
|
||||
if (doc.containsKey("icon"))
|
||||
{
|
||||
String iconFileName = doc["icon"].as<String>();
|
||||
@@ -472,6 +487,7 @@ void DisplayManager_::generateNotification(const char *json)
|
||||
fs::File nullPointer;
|
||||
notify.icon = nullPointer;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void DisplayManager_::loadNativeApps()
|
||||
@@ -534,6 +550,9 @@ void DisplayManager_::setup()
|
||||
setMatrixLayout(MATRIX_LAYOUT);
|
||||
gif.setMatrix(matrix);
|
||||
ui->setAppAnimation(SLIDE_DOWN);
|
||||
ui->setTimePerApp(TIME_PER_APP);
|
||||
ui->setTimePerTransition(TIME_PER_TRANSITION);
|
||||
ui->setTargetFPS(MATRIX_FPS);
|
||||
ui->setOverlays(overlays, 4);
|
||||
setAutoTransition(AUTO_TRANSITION);
|
||||
ui->init();
|
||||
@@ -551,7 +570,6 @@ void DisplayManager_::tick()
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
if (ui->getUiState()->appState == IN_TRANSITION && !appIsSwitching)
|
||||
{
|
||||
appIsSwitching = true;
|
||||
@@ -565,8 +583,8 @@ void DisplayManager_::tick()
|
||||
}
|
||||
int remainingTimeBudget = ui->update();
|
||||
|
||||
if (showGif)
|
||||
gif.drawFrame(0, 0);
|
||||
if (showGif && !MenuManager.inMenu)
|
||||
gif.drawFrame(gifX, gifY);
|
||||
matrix->show();
|
||||
}
|
||||
}
|
||||
@@ -645,8 +663,10 @@ void DisplayManager_::selectButtonLong()
|
||||
|
||||
void DisplayManager_::dismissNotify()
|
||||
{
|
||||
|
||||
notify.hold = false;
|
||||
notify.flag = false;
|
||||
showGif = false;
|
||||
}
|
||||
|
||||
void timerCallback()
|
||||
@@ -672,7 +692,7 @@ void DisplayManager_::gererateTimer(String Payload)
|
||||
futureTimeinfo.tm_sec += seconds;
|
||||
time_t futureTime = mktime(&futureTimeinfo);
|
||||
int interval = difftime(futureTime, now) * 1000;
|
||||
TimerTicker.attach_ms(interval, timerCallback);
|
||||
TimerTicker.once_ms(interval, timerCallback);
|
||||
}
|
||||
|
||||
void DisplayManager_::switchToApp(const char *json)
|
||||
@@ -701,6 +721,7 @@ void DisplayManager_::setNewSettings(const char *json)
|
||||
BRIGHTNESS = doc.containsKey("brightness") ? doc["brightness"] : BRIGHTNESS;
|
||||
AUTO_BRIGHTNESS = doc.containsKey("autobrightness") ? doc["autobrightness"] : AUTO_BRIGHTNESS;
|
||||
AUTO_TRANSITION = doc.containsKey("autotransition") ? doc["autotransition"] : AUTO_TRANSITION;
|
||||
UPPERCASE_LETTERS = doc.containsKey("uppercase") ? doc["uppercase"] : UPPERCASE_LETTERS;
|
||||
applyAllSettings();
|
||||
saveSettings();
|
||||
}
|
||||
@@ -910,7 +931,7 @@ void DisplayManager_::updateAppVector(const char *json)
|
||||
|
||||
String DisplayManager_::getStat()
|
||||
{
|
||||
StaticJsonDocument<200> doc;
|
||||
StaticJsonDocument<256> doc;
|
||||
char buffer[5];
|
||||
#ifdef ULANZI
|
||||
doc[BatKey] = BATTERY_PERCENT;
|
||||
@@ -928,9 +949,9 @@ String DisplayManager_::getStat()
|
||||
doc[UpTimeKey] = PeripheryManager.readUptime();
|
||||
doc[SignalStrengthKey] = WiFi.RSSI();
|
||||
doc[UpdateKey] = UPDATE_AVAILABLE;
|
||||
doc["messages"] = RECEIVED_MESSAGES;
|
||||
String jsonString;
|
||||
serializeJson(doc, jsonString);
|
||||
return jsonString;
|
||||
return serializeJson(doc, jsonString), jsonString;
|
||||
}
|
||||
|
||||
void DisplayManager_::setAppTime(uint16_t duration)
|
||||
|
||||
@@ -27,6 +27,7 @@ private:
|
||||
public:
|
||||
static DisplayManager_ &getInstance();
|
||||
bool appIsSwitching;
|
||||
bool showGif;
|
||||
void setup();
|
||||
void tick();
|
||||
void clear();
|
||||
@@ -49,7 +50,7 @@ public:
|
||||
void setFPS(uint8_t);
|
||||
void MatrixState(bool);
|
||||
void generateNotification(const char *json);
|
||||
void generateCustomPage(String name, const char *json);
|
||||
void generateCustomPage(const String &name, const char *json);
|
||||
void printText(int16_t x, int16_t y, const char *text, bool centered, bool ignoreUppercase);
|
||||
bool setAutoTransition(bool active);
|
||||
void switchToApp(const char *json);
|
||||
|
||||
@@ -509,25 +509,26 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
// Zeichne das Bild auf die Matrix
|
||||
int yOffset, pixel;
|
||||
int pixel, yOffset;
|
||||
for (int y = tbiImageY; y < tbiHeight + tbiImageY; y++)
|
||||
{
|
||||
yOffset = y * WIDTH;
|
||||
for (int x = tbiImageX; x < tbiWidth + tbiImageX; x++)
|
||||
{
|
||||
pixel = imageData[yOffset + x];
|
||||
if (pixel == -99)
|
||||
if (pixel == transparentColorIndex) // Check if the pixel index is the transparent index
|
||||
{
|
||||
mtx->drawPixel(x + offsetX, y + offsetY, mtx->Color(0, 0, 0));
|
||||
continue;
|
||||
mtx->drawPixel(x + offsetX, y + offsetY, mtx->Color(0, 0, 0)); // Draw a black pixel
|
||||
lastFrame[yOffset + x] = -99; // Save it as a special value
|
||||
}
|
||||
|
||||
lastFrame[yOffset + x] = pixel;
|
||||
else
|
||||
{
|
||||
color.red = gifPalette[pixel].Red;
|
||||
color.green = gifPalette[pixel].Green;
|
||||
color.blue = gifPalette[pixel].Blue;
|
||||
mtx->drawPixel(x + offsetX, y + offsetY, color);
|
||||
lastFrame[yOffset + x] = pixel;
|
||||
}
|
||||
}
|
||||
}
|
||||
needNewFrame = false;
|
||||
@@ -596,6 +597,8 @@ public:
|
||||
|
||||
unsigned long drawFrame(int x, int y)
|
||||
{
|
||||
offsetX = x;
|
||||
offsetY = y;
|
||||
if (!file)
|
||||
return 0;
|
||||
|
||||
@@ -607,8 +610,6 @@ public:
|
||||
|
||||
lastFrameDrawn = false;
|
||||
|
||||
offsetX = x;
|
||||
offsetY = y;
|
||||
boolean done = false;
|
||||
while (!done)
|
||||
{
|
||||
|
||||
@@ -74,7 +74,7 @@ void loadSettings()
|
||||
AUTO_BRIGHTNESS = Settings.getBool("ABRI", true);
|
||||
TEXTCOLOR_565 = Settings.getUInt("COL", 0xFFFF);
|
||||
AUTO_TRANSITION = Settings.getBool("TRANS", true);
|
||||
TIME_PER_TRANSITION = Settings.getUInt("TSPEED", 500);
|
||||
TIME_PER_TRANSITION = Settings.getUInt("TSPEED", 400);
|
||||
TIME_PER_APP = Settings.getUInt("ADUR", 5000);
|
||||
TIME_FORMAT = Settings.getString("TFORMAT", "%H:%M:%S");
|
||||
DATE_FORMAT = Settings.getString("DFORMAT", "%d.%m.%y");
|
||||
@@ -135,7 +135,7 @@ IPAddress gateway;
|
||||
IPAddress subnet;
|
||||
IPAddress primaryDNS;
|
||||
IPAddress secondaryDNS;
|
||||
const char *VERSION = "0.47";
|
||||
const char *VERSION = "0.48";
|
||||
String MQTT_HOST = "";
|
||||
uint16_t MQTT_PORT = 1883;
|
||||
String MQTT_USER;
|
||||
@@ -203,3 +203,4 @@ uint8_t VOLUME_PERCENT;
|
||||
uint8_t VOLUME;
|
||||
int MATRIX_LAYOUT;
|
||||
bool UPDATE_AVAILABLE = false;
|
||||
long RECEIVED_MESSAGES;
|
||||
@@ -72,6 +72,7 @@ extern uint8_t VOLUME_PERCENT;
|
||||
extern uint8_t VOLUME;
|
||||
extern int MATRIX_LAYOUT;
|
||||
extern bool UPDATE_AVAILABLE;
|
||||
extern long RECEIVED_MESSAGES;
|
||||
void loadSettings();
|
||||
void saveSettings();
|
||||
#endif // Globals_H
|
||||
@@ -140,61 +140,72 @@ void onMqttMessage(const char *topic, const uint8_t *payload, uint16_t length)
|
||||
char *payloadCopy = new char[length + 1];
|
||||
memcpy(payloadCopy, payload, length);
|
||||
payloadCopy[length] = '\0';
|
||||
if (strTopic == MQTT_PREFIX + "/notify")
|
||||
++RECEIVED_MESSAGES;
|
||||
if (strTopic.equals(MQTT_PREFIX + "/notify"))
|
||||
{
|
||||
if (payload[0] != '{' || payload[length - 1] != '}')
|
||||
{
|
||||
delete[] payloadCopy;
|
||||
return;
|
||||
}
|
||||
DisplayManager.generateNotification(payloadCopy);
|
||||
delete[] payloadCopy;
|
||||
return;
|
||||
}
|
||||
|
||||
if (strTopic == MQTT_PREFIX + "/timer")
|
||||
if (strTopic.equals(MQTT_PREFIX + "/timer"))
|
||||
{
|
||||
DisplayManager.gererateTimer(payloadCopy);
|
||||
delete[] payloadCopy;
|
||||
return;
|
||||
}
|
||||
|
||||
if (strTopic == MQTT_PREFIX + "/notify/dismiss")
|
||||
if (strTopic.equals(MQTT_PREFIX + "/notify/dismiss"))
|
||||
{
|
||||
DisplayManager.dismissNotify();
|
||||
delete[] payloadCopy;
|
||||
return;
|
||||
}
|
||||
|
||||
if (strTopic == MQTT_PREFIX + "/apps")
|
||||
if (strTopic.equals(MQTT_PREFIX + "/apps"))
|
||||
{
|
||||
DisplayManager.updateAppVector(payloadCopy);
|
||||
delete[] payloadCopy;
|
||||
return;
|
||||
}
|
||||
|
||||
if (strTopic == MQTT_PREFIX + "/switch")
|
||||
if (strTopic.equals(MQTT_PREFIX + "/switch"))
|
||||
{
|
||||
DisplayManager.switchToApp(payloadCopy);
|
||||
delete[] payloadCopy;
|
||||
return;
|
||||
}
|
||||
|
||||
if (strTopic == MQTT_PREFIX + "/settings")
|
||||
if (strTopic.equals(MQTT_PREFIX + "/settings"))
|
||||
{
|
||||
DisplayManager.setNewSettings(payloadCopy);
|
||||
delete[] payloadCopy;
|
||||
return;
|
||||
}
|
||||
|
||||
if (strTopic == MQTT_PREFIX + "/nextapp")
|
||||
if (strTopic.equals(MQTT_PREFIX + "/nextapp"))
|
||||
{
|
||||
DisplayManager.nextApp();
|
||||
delete[] payloadCopy;
|
||||
return;
|
||||
}
|
||||
|
||||
if (strTopic == MQTT_PREFIX + "/previousapp")
|
||||
if (strTopic.equals(MQTT_PREFIX + "/previousapp"))
|
||||
{
|
||||
DisplayManager.previousApp();
|
||||
delete[] payloadCopy;
|
||||
return;
|
||||
}
|
||||
if (strTopic == MQTT_PREFIX + "/doupdate")
|
||||
if (strTopic.equals(MQTT_PREFIX + "/doupdate"))
|
||||
{
|
||||
if (UPDATE_AVAILABLE)
|
||||
UpdateManager.updateFirmware();
|
||||
delete[] payloadCopy;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -208,9 +219,9 @@ void onMqttMessage(const char *topic, const uint8_t *payload, uint16_t length)
|
||||
}
|
||||
|
||||
DisplayManager.generateCustomPage(topic_str, payloadCopy);
|
||||
delete[] payloadCopy;
|
||||
return;
|
||||
}
|
||||
delete[] payloadCopy;
|
||||
}
|
||||
|
||||
void onMqttConnected()
|
||||
|
||||
@@ -60,7 +60,7 @@ void BootAnimation(void *parameter)
|
||||
void setup()
|
||||
{
|
||||
loadSettings();
|
||||
Serial.begin(9600);
|
||||
Serial.begin(115200);
|
||||
PeripheryManager.setup();
|
||||
delay(500);
|
||||
ServerManager.loadSettings();
|
||||
|
||||
Reference in New Issue
Block a user