v0.40
- fixes a bug in text lengths calculations with spaces - adds the onscreen menu option to disable or enable internal apps Many options are moved from webinterface to onscreen menu the last few versions. if you running awtrix light for some versions now, it could be necessary to delete your config.json and restart in order to cleanup your webinterface. closes #14
This commit is contained in:
Binary file not shown.
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "AWTRIX Light",
|
||||
"version": "0.39",
|
||||
"version": "0.40",
|
||||
"home_assistant_domain": "AwtrixLight",
|
||||
"funding_url": "https://blueforcer.de",
|
||||
"new_install_prompt_erase": true,
|
||||
|
||||
@@ -17,5 +17,6 @@ Hold down the middle button for 2s to exit the current menu and to save your set
|
||||
| `DATE` | Allows selection of date format. |
|
||||
| `WEEKDAY` | Allows selection of start of week. |
|
||||
| `TEMP` | Allows selection of temperature system (°C or °F). |
|
||||
| `APPS` | Allows to enable or disable internal apps |
|
||||
| `UPDATE` | Check and download new firmware if available. |
|
||||
|
||||
|
||||
@@ -185,6 +185,9 @@ int8_t MatrixDisplayUi::update()
|
||||
void MatrixDisplayUi::tick()
|
||||
{
|
||||
this->state.ticksSinceLastStateSwitch++;
|
||||
|
||||
if (this->AppCount > 0)
|
||||
{
|
||||
switch (this->state.frameState)
|
||||
{
|
||||
case IN_TRANSITION:
|
||||
@@ -207,15 +210,16 @@ void MatrixDisplayUi::tick()
|
||||
{
|
||||
if (this->setAutoTransition)
|
||||
{
|
||||
|
||||
this->state.frameState = IN_TRANSITION;
|
||||
}
|
||||
this->state.ticksSinceLastStateSwitch = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
this->matrix->clear();
|
||||
if (this->AppCount > 0)
|
||||
this->drawApp();
|
||||
this->drawOverlays();
|
||||
this->matrix->show();
|
||||
|
||||
@@ -91,6 +91,11 @@ void DisplayManager_::drawJPG(uint16_t x, uint16_t y, fs::File jpgFile)
|
||||
TJpgDec.drawFsJpg(x, y, jpgFile);
|
||||
}
|
||||
|
||||
void DisplayManager_::drawBMP(int16_t x, int16_t y, const uint16_t bitmap[], int16_t w, int16_t h)
|
||||
{
|
||||
matrix.drawRGBBitmap(y, x, bitmap, w, h);
|
||||
}
|
||||
|
||||
void DisplayManager_::applyAllSettings()
|
||||
{
|
||||
ui.setTargetFPS(MATRIX_FPS);
|
||||
@@ -219,21 +224,18 @@ void pushCustomFrame(String name, int position)
|
||||
|
||||
void removeCustomFrame(const String &name)
|
||||
{
|
||||
// Suchen Sie nach dem Element, das dem Namen entspricht
|
||||
auto it = std::find_if(Apps.begin(), Apps.end(), [&name](const std::pair<String, AppCallback> &appPair)
|
||||
{ return appPair.first == name; });
|
||||
|
||||
// Wenn das Element gefunden wurde, entfernen Sie es aus dem Vektor
|
||||
if (it != Apps.end())
|
||||
{
|
||||
Apps.erase(it);
|
||||
ui.setApps(Apps); // Aktualisieren Sie die Frames
|
||||
ui.setApps(Apps);
|
||||
}
|
||||
}
|
||||
|
||||
void DisplayManager_::generateCustomPage(String name, String payload)
|
||||
{
|
||||
|
||||
if (payload == "" && customFrames.count(name))
|
||||
{
|
||||
customFrames.erase(customFrames.find(name));
|
||||
@@ -261,7 +263,6 @@ void DisplayManager_::generateCustomPage(String name, String payload)
|
||||
customFrame.pushIcon = doc.containsKey("pushIcon") ? doc["pushIcon"] : 0;
|
||||
customFrame.name = name;
|
||||
customFrame.text = utf8ascii(doc["text"].as<String>());
|
||||
|
||||
customFrame.color = doc.containsKey("color") ? doc["color"].is<String>() ? hexToRgb565(doc["color"]) : doc["color"].is<JsonArray>() ? hexToRgb565(doc["color"].as<String>())
|
||||
: TEXTCOLOR_565
|
||||
: TEXTCOLOR_565;
|
||||
@@ -342,25 +343,49 @@ void DisplayManager_::generateNotification(String payload)
|
||||
}
|
||||
}
|
||||
|
||||
void DisplayManager_::loadApps()
|
||||
void DisplayManager_::loadNativeApps()
|
||||
{
|
||||
Apps.clear();
|
||||
Apps.push_back(std::make_pair("time", TimeFrame));
|
||||
if (SHOW_DATE)
|
||||
Apps.push_back(std::make_pair("date", DateFrame));
|
||||
if (SHOW_TEMP)
|
||||
Apps.push_back(std::make_pair("temp", TempFrame));
|
||||
if (SHOW_HUM)
|
||||
Apps.push_back(std::make_pair("hum", HumFrame));
|
||||
if (SHOW_BATTERY)
|
||||
Apps.push_back(std::make_pair("bat", BatFrame));
|
||||
// if (SHOW_WEATHER)
|
||||
// Apps.push_back(std::make_pair(5, WeatherFrame));
|
||||
nativeAppsCount = Apps.size();
|
||||
ui.setApps(Apps); // Add frames
|
||||
if (AUTO_TRANSITION && nativeAppsCount == 1)
|
||||
// Define a helper function to check and update an app
|
||||
auto updateApp = [&](const String &name, AppCallback callback, bool show, size_t position)
|
||||
{
|
||||
auto it = std::find_if(Apps.begin(), Apps.end(), [&](const std::pair<String, AppCallback> &app)
|
||||
{ return app.first == name; });
|
||||
if (it != Apps.end())
|
||||
{
|
||||
if (!show)
|
||||
{
|
||||
Apps.erase(it);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (show)
|
||||
{
|
||||
Apps.insert(Apps.begin() + position, std::make_pair(name, callback));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Update the "time" app at position 0
|
||||
updateApp("time", TimeFrame, SHOW_TIME, 0);
|
||||
|
||||
// Update the "date" app at position 1
|
||||
updateApp("date", DateFrame, SHOW_DATE, 1);
|
||||
|
||||
// Update the "temp" app at position 2
|
||||
updateApp("temp", TempFrame, SHOW_TEMP, 2);
|
||||
|
||||
// Update the "hum" app at position 3
|
||||
updateApp("hum", HumFrame, SHOW_HUM, 3);
|
||||
|
||||
// Update the "bat" app at position 4
|
||||
updateApp("bat", BatFrame, SHOW_BAT, 4);
|
||||
|
||||
ui.setApps(Apps);
|
||||
if (AUTO_TRANSITION && Apps.size() == 1)
|
||||
{
|
||||
setAutoTransition(false);
|
||||
StartAppUpdater();
|
||||
}
|
||||
}
|
||||
|
||||
void DisplayManager_::setup()
|
||||
@@ -545,8 +570,8 @@ void DisplayManager_::drawProgressBar(int cur, int total)
|
||||
|
||||
void DisplayManager_::drawMenuIndicator(int cur, int total)
|
||||
{
|
||||
int menuItemWidth = 2;
|
||||
int totalWidth = total * menuItemWidth + (total - 2);
|
||||
int menuItemWidth = 1;
|
||||
int totalWidth = total * menuItemWidth + (total - 1);
|
||||
int leftMargin = (MATRIX_WIDTH - totalWidth) / 2;
|
||||
int pixelSpacing = 1;
|
||||
for (int i = 0; i < total; i++)
|
||||
|
||||
@@ -32,7 +32,7 @@ public:
|
||||
void rightButton();
|
||||
void dismissNotify();
|
||||
void HSVtext(int16_t, int16_t, const char *, bool);
|
||||
void loadApps();
|
||||
void loadNativeApps();
|
||||
void nextApp();
|
||||
void previousApp();
|
||||
void leftButton();
|
||||
@@ -55,6 +55,7 @@ public:
|
||||
void drawJPG(uint16_t x, uint16_t y, fs::File jpgFile);
|
||||
void drawProgressBar(int cur, int total);
|
||||
void drawMenuIndicator(int cur, int total);
|
||||
void drawBMP(int16_t x, int16_t y, const uint16_t bitmap[], int16_t w, int16_t h);
|
||||
};
|
||||
|
||||
extern DisplayManager_ &DisplayManager;
|
||||
|
||||
@@ -111,7 +111,7 @@ void TimeFrame(FastLED_NeoMatrix *matrix, MatrixDisplayUiState *state, int16_t x
|
||||
timeInfo = localtime(&now);
|
||||
char t[20];
|
||||
strftime(t, sizeof(t), TIME_FORMAT.c_str(), localtime(&now));
|
||||
DisplayManager.printText(0 + x, 6 + y, t, true, true);
|
||||
DisplayManager.printText(0 + x, 6 + y, t, true, false);
|
||||
|
||||
if (!SHOW_WEEKDAY)
|
||||
return;
|
||||
@@ -184,7 +184,7 @@ void HumFrame(FastLED_NeoMatrix *matrix, MatrixDisplayUiState *state, int16_t x,
|
||||
return;
|
||||
CURRENT_APP = "Humidity";
|
||||
DisplayManager.getInstance().resetTextColor();
|
||||
matrix->drawRGBBitmap(x, y + 1, get_icon(2075), 8, 8);
|
||||
matrix->drawRGBBitmap(x, y + 1, get_icon(2075), 8,8);
|
||||
matrix->setCursor(14 + x, 6 + y);
|
||||
int humidity = CURRENT_HUM; // Temperatur ohne Nachkommastellen
|
||||
matrix->print(humidity); // Ausgabe der Temperatur
|
||||
@@ -214,7 +214,6 @@ void MenuFrame(FastLED_NeoMatrix *matrix, MatrixDisplayUiState *state)
|
||||
void AlarmFrame(FastLED_NeoMatrix *matrix, MatrixDisplayUiState *state)
|
||||
{
|
||||
if (ALARM_ACTIVE)
|
||||
|
||||
{
|
||||
matrix->fillScreen(matrix->Color(255, 0, 0));
|
||||
CURRENT_APP = "Alarm";
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include <Globals.h>
|
||||
|
||||
std::map<char, uint16_t> CharMap = {
|
||||
{32, 3}, {33, 2}, {34, 4}, {35, 4}, {36, 4}, {37, 4}, {38, 4}, {39, 2}, {40, 3}, {41, 3}, {42, 4}, {43, 4}, {44, 3}, {45, 4}, {46, 2}, {47, 4}, {48, 4}, {49, 4}, {50, 4}, {51, 4}, {52, 4}, {53, 4}, {54, 4}, {55, 4}, {56, 4}, {57, 4}, {58, 2}, {59, 3}, {60, 4}, {61, 4}, {62, 4}, {63, 4}, {64, 4}, {65, 4}, {66, 4}, {67, 4}, {68, 4}, {69, 4}, {70, 4}, {71, 4}, {72, 4}, {73, 2}, {74, 4}, {75, 4}, {76, 4}, {77, 6}, {78, 5}, {79, 4}, {80, 4}, {81, 5}, {82, 4}, {83, 4}, {84, 4}, {85, 4}, {86, 4}, {87, 6}, {88, 4}, {89, 4}, {90, 4}, {91, 4}, {92, 4}, {93, 4}, {94, 4}, {95, 4}, {96, 3}, {97, 4}, {98, 4}, {99, 4}, {100, 4}, {101, 4}, {102, 4}, {103, 4}, {104, 4}, {105, 2}, {106, 4}, {107, 4}, {108, 4}, {109, 4}, {110, 4}, {111, 4}, {112, 4}, {113, 4}, {114, 4}, {115, 4}, {116, 4}, {117, 4}, {118, 4}, {119, 4}, {120, 4}, {121, 4}, {122, 4}, {123, 4}, {124, 2}, {125, 4}, {126, 4}, {161, 2}, {162, 4}, {163, 4}, {164, 4}, {165, 4}, {166, 2}, {167, 4}, {168, 4}, {169, 4}, {170, 4}, {171, 3}, {172, 4}, {173, 3}, {174, 4}, {175, 4}, {176, 4}, {177, 4}, {178, 4}, {179, 4}, {180, 3}, {181, 4}, {182, 4}, {183, 4}, {184, 4}, {185, 2}, {186, 4}, {187, 3}, {188, 4}, {189, 4}, {190, 4}, {191, 4}, {192, 4}, {193, 4}, {194, 4}, {195, 4}, {196, 4}, {197, 4}, {198, 4}, {199, 4}, {200, 4}, {201, 4}, {202, 4}, {203, 4}, {204, 4}, {205, 4}, {206, 4}, {207, 4}, {208, 4}, {209, 4}, {210, 4}, {211, 4}, {212, 4}, {213, 4}, {214, 4}, {215, 4}, {216, 4}, {217, 4}, {218, 4}, {219, 4}, {220, 4}, {221, 4}, {222, 4}, {223, 4}, {224, 4}, {225, 4}, {226, 4}, {227, 4}, {228, 4}, {229, 4}, {230, 4}, {231, 4}, {232, 4}, {233, 4}, {234, 4}, {235, 4}, {236, 3}, {237, 3}, {238, 4}, {239, 4}, {240, 4}, {241, 4}, {242, 4}, {243, 4}, {244, 4}, {245, 4}, {246, 4}, {247, 4}, {248, 4}, {249, 4}, {250, 4}, {251, 4}, {252, 4}, {253, 4}, {254, 4}, {255, 4}, {285, 2}, {338, 4}, {339, 4}, {352, 4}, {353, 4}, {376, 4}, {381, 4}, {382, 4}, {3748, 2}, {5024, 2}, {8226, 2}, {8230, 4}, {8364, 4}, {65533, 4}};
|
||||
{32, 2}, {33, 2}, {34, 4}, {35, 4}, {36, 4}, {37, 4}, {38, 4}, {39, 2}, {40, 3}, {41, 3}, {42, 4}, {43, 4}, {44, 3}, {45, 4}, {46, 2}, {47, 4}, {48, 4}, {49, 4}, {50, 4}, {51, 4}, {52, 4}, {53, 4}, {54, 4}, {55, 4}, {56, 4}, {57, 4}, {58, 2}, {59, 3}, {60, 4}, {61, 4}, {62, 4}, {63, 4}, {64, 4}, {65, 4}, {66, 4}, {67, 4}, {68, 4}, {69, 4}, {70, 4}, {71, 4}, {72, 4}, {73, 2}, {74, 4}, {75, 4}, {76, 4}, {77, 6}, {78, 5}, {79, 4}, {80, 4}, {81, 5}, {82, 4}, {83, 4}, {84, 4}, {85, 4}, {86, 4}, {87, 6}, {88, 4}, {89, 4}, {90, 4}, {91, 4}, {92, 4}, {93, 4}, {94, 4}, {95, 4}, {96, 3}, {97, 4}, {98, 4}, {99, 4}, {100, 4}, {101, 4}, {102, 4}, {103, 4}, {104, 4}, {105, 2}, {106, 4}, {107, 4}, {108, 4}, {109, 4}, {110, 4}, {111, 4}, {112, 4}, {113, 4}, {114, 4}, {115, 4}, {116, 4}, {117, 4}, {118, 4}, {119, 4}, {120, 4}, {121, 4}, {122, 4}, {123, 4}, {124, 2}, {125, 4}, {126, 4}, {161, 2}, {162, 4}, {163, 4}, {164, 4}, {165, 4}, {166, 2}, {167, 4}, {168, 4}, {169, 4}, {170, 4}, {171, 3}, {172, 4}, {173, 3}, {174, 4}, {175, 4}, {176, 4}, {177, 4}, {178, 4}, {179, 4}, {180, 3}, {181, 4}, {182, 4}, {183, 4}, {184, 4}, {185, 2}, {186, 4}, {187, 3}, {188, 4}, {189, 4}, {190, 4}, {191, 4}, {192, 4}, {193, 4}, {194, 4}, {195, 4}, {196, 4}, {197, 4}, {198, 4}, {199, 4}, {200, 4}, {201, 4}, {202, 4}, {203, 4}, {204, 4}, {205, 4}, {206, 4}, {207, 4}, {208, 4}, {209, 4}, {210, 4}, {211, 4}, {212, 4}, {213, 4}, {214, 4}, {215, 4}, {216, 4}, {217, 4}, {218, 4}, {219, 4}, {220, 4}, {221, 4}, {222, 4}, {223, 4}, {224, 4}, {225, 4}, {226, 4}, {227, 4}, {228, 4}, {229, 4}, {230, 4}, {231, 4}, {232, 4}, {233, 4}, {234, 4}, {235, 4}, {236, 3}, {237, 3}, {238, 4}, {239, 4}, {240, 4}, {241, 4}, {242, 4}, {243, 4}, {244, 4}, {245, 4}, {246, 4}, {247, 4}, {248, 4}, {249, 4}, {250, 4}, {251, 4}, {252, 4}, {253, 4}, {254, 4}, {255, 4}, {285, 2}, {338, 4}, {339, 4}, {352, 4}, {353, 4}, {376, 4}, {381, 4}, {382, 4}, {3748, 2}, {5024, 2}, {8226, 2}, {8230, 4}, {8364, 4}, {65533, 4}};
|
||||
|
||||
uint32_t hsvToRgb(uint8_t h, uint8_t s, uint8_t v)
|
||||
{
|
||||
@@ -24,7 +24,8 @@ uint16_t hexToRgb565(String hexValue)
|
||||
uint8_t r = strtol(hexValue.substring(0, 2).c_str(), NULL, 16);
|
||||
uint8_t g = strtol(hexValue.substring(2, 4).c_str(), NULL, 16);
|
||||
uint8_t b = strtol(hexValue.substring(4, 6).c_str(), NULL, 16);
|
||||
if ((errno == ERANGE) || (r > 255) || (g > 255) || (b > 255)) {
|
||||
if ((errno == ERANGE) || (r > 255) || (g > 255) || (b > 255))
|
||||
{
|
||||
return 0xFFFF;
|
||||
}
|
||||
uint16_t color = ((r >> 3) << 11) | ((g >> 2) << 5) | (b >> 3);
|
||||
|
||||
@@ -528,6 +528,7 @@ public:
|
||||
}
|
||||
}
|
||||
needNewFrame = false;
|
||||
lastFrameTime = millis();
|
||||
}
|
||||
|
||||
public:
|
||||
@@ -595,15 +596,12 @@ public:
|
||||
if (!file)
|
||||
return 0;
|
||||
|
||||
unsigned long now = millis();
|
||||
|
||||
if (now - lastFrameTime < newframeDelay)
|
||||
if (millis() - lastFrameTime < newframeDelay)
|
||||
{
|
||||
redrawLastFrame();
|
||||
return 0;
|
||||
}
|
||||
|
||||
lastFrameTime = now;
|
||||
lastFrameDrawn = false;
|
||||
|
||||
offsetX = x;
|
||||
@@ -614,8 +612,9 @@ public:
|
||||
byte b = readByte();
|
||||
if (b == 0x2c)
|
||||
{
|
||||
unsigned int fdelay = parseTableBasedImage();
|
||||
return fdelay;
|
||||
Serial.println("Parse");
|
||||
parseTableBasedImage();
|
||||
return 0;
|
||||
}
|
||||
else if (b == 0x21)
|
||||
{
|
||||
@@ -641,12 +640,12 @@ public:
|
||||
else
|
||||
{
|
||||
done = true;
|
||||
backUpStream(1);
|
||||
file.seek(0);
|
||||
Serial.println("Finished");
|
||||
parseGifHeader();
|
||||
parseLogicalScreenDescriptor();
|
||||
parseGlobalColorTable();
|
||||
drawFrame(offsetX, offsetY);
|
||||
drawFrame(offsetX,offsetY);
|
||||
return ERROR_FINISHED;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,11 @@ void loadSettings()
|
||||
DATE_FORMAT = Settings.getString("DFORMAT", "%d.%m.%y");
|
||||
START_ON_MONDAY = Settings.getBool("SOM", true);
|
||||
IS_CELSIUS = Settings.getBool("CEL", true);
|
||||
SHOW_TIME = Settings.getBool("TIM", true);
|
||||
SHOW_DATE = Settings.getBool("DAT", true);
|
||||
SHOW_TEMP = Settings.getBool("TEMP", true);
|
||||
SHOW_HUM = Settings.getBool("HUM", true);
|
||||
SHOW_BAT = Settings.getBool("BAT", true);
|
||||
Settings.end();
|
||||
}
|
||||
|
||||
@@ -34,6 +39,12 @@ void saveSettings()
|
||||
Settings.putString("DFORMAT", DATE_FORMAT);
|
||||
Settings.putBool("SOM", START_ON_MONDAY);
|
||||
Settings.putBool("CEL", IS_CELSIUS);
|
||||
|
||||
Settings.putBool("TIM", SHOW_TIME);
|
||||
Settings.putBool("DAT", SHOW_DATE);
|
||||
Settings.putBool("TEMP", SHOW_TEMP);
|
||||
Settings.putBool("HUM", SHOW_HUM);
|
||||
Settings.putBool("BAT", SHOW_BAT);
|
||||
Settings.end();
|
||||
}
|
||||
|
||||
@@ -42,7 +53,7 @@ IPAddress gateway;
|
||||
IPAddress subnet;
|
||||
IPAddress primaryDNS;
|
||||
IPAddress secondaryDNS;
|
||||
const char *VERSION = "0.39";
|
||||
const char *VERSION = "0.40";
|
||||
String MQTT_HOST = "";
|
||||
uint16_t MQTT_PORT = 1883;
|
||||
String MQTT_USER;
|
||||
@@ -51,9 +62,10 @@ String MQTT_PREFIX = "AwtrixLight";
|
||||
String CITY = "Berlin,de";
|
||||
bool IO_BROKER = false;
|
||||
bool NET_STATIC = false;
|
||||
bool SHOW_TIME = true;
|
||||
bool SHOW_DATE = true;
|
||||
bool SHOW_WEATHER = true;
|
||||
bool SHOW_BATTERY = true;
|
||||
bool SHOW_BAT = true;
|
||||
bool SHOW_TEMP = true;
|
||||
bool SHOW_HUM = true;
|
||||
bool SHOW_SECONDS = true;
|
||||
|
||||
@@ -16,9 +16,10 @@ extern String MQTT_PREFIX;
|
||||
extern String CITY;
|
||||
extern bool IO_BROKER;
|
||||
extern bool NET_STATIC;
|
||||
extern bool SHOW_TIME;
|
||||
extern bool SHOW_DATE;
|
||||
extern bool SHOW_WEATHER;
|
||||
extern bool SHOW_BATTERY;
|
||||
extern bool SHOW_BAT;
|
||||
extern bool SHOW_TEMP;
|
||||
extern bool SHOW_HUM;
|
||||
extern bool SHOW_SECONDS;
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <ServerManager.h>
|
||||
#include <DisplayManager.h>
|
||||
#include <updater.h>
|
||||
#include <icons.h>
|
||||
|
||||
String menuText;
|
||||
int menuSelection;
|
||||
@@ -23,7 +24,8 @@ enum MenuState
|
||||
TimeFormatMenu,
|
||||
DateFormatMenu,
|
||||
WeekdayMenu,
|
||||
TempMenu
|
||||
TempMenu,
|
||||
Appmenu,
|
||||
};
|
||||
|
||||
const char *menuItems[] PROGMEM = {
|
||||
@@ -37,10 +39,11 @@ const char *menuItems[] PROGMEM = {
|
||||
"DATE",
|
||||
"WEEKDAY",
|
||||
"TEMP",
|
||||
"APPS",
|
||||
"UPDATE"};
|
||||
|
||||
int8_t menuIndex = 0;
|
||||
uint8_t menuItemCount = 11;
|
||||
uint8_t menuItemCount = 12;
|
||||
|
||||
const char *timeFormat[] PROGMEM = {
|
||||
"%H:%M:%S",
|
||||
@@ -65,6 +68,16 @@ const char *dateFormat[] PROGMEM = {
|
||||
int8_t dateFormatIndex;
|
||||
uint8_t dateFormatCount = 9;
|
||||
|
||||
const char *appsItems[][2] PROGMEM = {
|
||||
{"13", "time"},
|
||||
{"1158", "date"},
|
||||
{"234", "temp"},
|
||||
{"2075", "hum"},
|
||||
{"1486", "bat"}};
|
||||
|
||||
int8_t appsIndex;
|
||||
uint8_t appsCount = 5;
|
||||
|
||||
MenuState currentState = MainMenu;
|
||||
|
||||
uint16_t textColors[] PROGMEM = {
|
||||
@@ -95,71 +108,60 @@ MenuManager_ &MenuManager = MenuManager.getInstance();
|
||||
|
||||
String MenuManager_::menutext()
|
||||
{
|
||||
if (currentState == MainMenu)
|
||||
{
|
||||
DisplayManager.drawMenuIndicator(menuIndex, menuItemCount);
|
||||
return (menuItems[menuIndex]);
|
||||
}
|
||||
else if (currentState == BrightnessMenu)
|
||||
{
|
||||
if (AUTO_BRIGHTNESS)
|
||||
{
|
||||
return ("AUTO");
|
||||
}
|
||||
else
|
||||
{
|
||||
return (String(BRIGHTNESS_PERCENT) + "%");
|
||||
}
|
||||
}
|
||||
else if (currentState == FPSMenu)
|
||||
{
|
||||
return String(MATRIX_FPS) + " FPS";
|
||||
}
|
||||
else if (currentState == ColorMenu)
|
||||
{
|
||||
DisplayManager.setTextColor(textColors[currentColor]);
|
||||
String colorStr = String(textColors[currentColor], HEX);
|
||||
while (colorStr.length() < 4)
|
||||
{
|
||||
colorStr = "0" + colorStr;
|
||||
}
|
||||
return colorStr;
|
||||
}
|
||||
else if (currentState == SwitchMenu)
|
||||
{
|
||||
return AUTO_TRANSITION ? "ON" : "OFF";
|
||||
}
|
||||
else if (currentState == TspeedMenu)
|
||||
{
|
||||
float seconds = (float)TIME_PER_TRANSITION / 1000.0;
|
||||
return String(seconds, 1) + "s";
|
||||
}
|
||||
else if (currentState == AppTimeMenu)
|
||||
{
|
||||
float seconds = (float)TIME_PER_APP / 1000.0;
|
||||
return String(seconds, 0) + "s";
|
||||
}
|
||||
else if (currentState == TimeFormatMenu)
|
||||
{
|
||||
time_t now = time(nullptr);
|
||||
char t[20];
|
||||
switch (currentState)
|
||||
{
|
||||
case MainMenu:
|
||||
DisplayManager.drawMenuIndicator(menuIndex, menuItemCount);
|
||||
return menuItems[menuIndex];
|
||||
case BrightnessMenu:
|
||||
return AUTO_BRIGHTNESS ? "AUTO" : String(BRIGHTNESS_PERCENT) + "%";
|
||||
case FPSMenu:
|
||||
return String(MATRIX_FPS) + " FPS";
|
||||
case ColorMenu:
|
||||
DisplayManager.setTextColor(textColors[currentColor]);
|
||||
return "0x" + String(textColors[currentColor], HEX);
|
||||
case SwitchMenu:
|
||||
return AUTO_TRANSITION ? "ON" : "OFF";
|
||||
case TspeedMenu:
|
||||
return String(TIME_PER_TRANSITION / 1000.0, 1) + "s";
|
||||
case AppTimeMenu:
|
||||
return String(TIME_PER_APP / 1000.0, 0) + "s";
|
||||
case TimeFormatMenu:
|
||||
strftime(t, sizeof(t), timeFormat[timeFormatIndex], localtime(&now));
|
||||
return t;
|
||||
}
|
||||
else if (currentState == DateFormatMenu)
|
||||
{
|
||||
time_t now = time(nullptr);
|
||||
char t[20];
|
||||
case DateFormatMenu:
|
||||
strftime(t, sizeof(t), dateFormat[dateFormatIndex], localtime(&now));
|
||||
return t;
|
||||
}
|
||||
else if (currentState == WeekdayMenu)
|
||||
{
|
||||
case WeekdayMenu:
|
||||
return START_ON_MONDAY ? "MON" : "SUN";
|
||||
}
|
||||
else if (currentState == TempMenu)
|
||||
{
|
||||
case TempMenu:
|
||||
return IS_CELSIUS ? "°C" : "°F";
|
||||
case Appmenu:
|
||||
switch (appsIndex)
|
||||
{
|
||||
case 0:
|
||||
DisplayManager.drawBMP(0, 0, get_icon(13), 8, 8);
|
||||
return SHOW_TIME ? "ON" : "OFF";
|
||||
case 1:
|
||||
DisplayManager.drawBMP(0, 0, get_icon(1158), 8, 8);
|
||||
return SHOW_DATE ? "ON" : "OFF";
|
||||
case 2:
|
||||
DisplayManager.drawBMP(0, 0, get_icon(234), 8, 8);
|
||||
return SHOW_TEMP ? "ON" : "OFF";
|
||||
case 3:
|
||||
DisplayManager.drawBMP(0, 0, get_icon(2075), 8, 8);
|
||||
return SHOW_HUM ? "ON" : "OFF";
|
||||
case 4:
|
||||
DisplayManager.drawBMP(0, 0, get_icon(1486), 8, 8);
|
||||
return SHOW_BAT ? "ON" : "OFF";
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
@@ -168,205 +170,199 @@ void MenuManager_::rightButton()
|
||||
{
|
||||
if (!inMenu)
|
||||
return;
|
||||
if (currentState == MainMenu)
|
||||
{
|
||||
menuIndex++;
|
||||
if (menuIndex > menuItemCount - 1)
|
||||
{
|
||||
menuIndex = 0; // Wrap around to the first menu item
|
||||
}
|
||||
}
|
||||
else if (currentState == BrightnessMenu)
|
||||
switch (currentState)
|
||||
{
|
||||
case MainMenu:
|
||||
menuIndex = (menuIndex + 1) % menuItemCount;
|
||||
break;
|
||||
case BrightnessMenu:
|
||||
if (!AUTO_BRIGHTNESS)
|
||||
{
|
||||
++BRIGHTNESS_PERCENT;
|
||||
if (BRIGHTNESS_PERCENT > 100)
|
||||
BRIGHTNESS_PERCENT = 1;
|
||||
BRIGHTNESS_PERCENT = (BRIGHTNESS_PERCENT % 100) + 1;
|
||||
BRIGHTNESS = map(BRIGHTNESS_PERCENT, 0, 100, 0, 255);
|
||||
DisplayManager.setBrightness(BRIGHTNESS);
|
||||
}
|
||||
}
|
||||
else if (currentState == FPSMenu)
|
||||
{
|
||||
break;
|
||||
case FPSMenu:
|
||||
if (MATRIX_FPS < 30)
|
||||
++MATRIX_FPS;
|
||||
}
|
||||
else if (currentState == ColorMenu)
|
||||
{
|
||||
int arraySize = sizeof(textColors) / sizeof(textColors[0]);
|
||||
currentColor = (currentColor + 1) % arraySize;
|
||||
}
|
||||
else if (currentState == SwitchMenu)
|
||||
{
|
||||
break;
|
||||
case ColorMenu:
|
||||
currentColor = (currentColor + 1) % (sizeof(textColors) / sizeof(textColors[0]));
|
||||
break;
|
||||
case SwitchMenu:
|
||||
AUTO_TRANSITION = !AUTO_TRANSITION;
|
||||
}
|
||||
else if (currentState == TspeedMenu)
|
||||
{
|
||||
break;
|
||||
case TspeedMenu:
|
||||
TIME_PER_TRANSITION = min(1200, TIME_PER_TRANSITION + 100);
|
||||
}
|
||||
else if (currentState == AppTimeMenu)
|
||||
{
|
||||
break;
|
||||
case AppTimeMenu:
|
||||
TIME_PER_APP = min(30000, TIME_PER_APP + 1000);
|
||||
}
|
||||
else if (currentState == TimeFormatMenu)
|
||||
{
|
||||
timeFormatIndex++;
|
||||
if (timeFormatIndex > timeFormatCount - 1)
|
||||
{
|
||||
timeFormatIndex = 0; // Wrap around to the first menu item
|
||||
}
|
||||
}
|
||||
else if (currentState == DateFormatMenu)
|
||||
{
|
||||
dateFormatIndex++;
|
||||
if (dateFormatIndex > dateFormatCount - 1)
|
||||
{
|
||||
dateFormatIndex = 0; // Wrap around to the first menu item
|
||||
}
|
||||
}
|
||||
else if (currentState == WeekdayMenu)
|
||||
{
|
||||
break;
|
||||
case TimeFormatMenu:
|
||||
timeFormatIndex = (timeFormatIndex + 1) % timeFormatCount;
|
||||
break;
|
||||
case DateFormatMenu:
|
||||
dateFormatIndex = (dateFormatIndex + 1) % dateFormatCount;
|
||||
break;
|
||||
case Appmenu:
|
||||
appsIndex = (appsIndex + 1) % appsCount;
|
||||
break;
|
||||
case WeekdayMenu:
|
||||
START_ON_MONDAY = !START_ON_MONDAY;
|
||||
}
|
||||
else if (currentState == TempMenu)
|
||||
{
|
||||
break;
|
||||
case TempMenu:
|
||||
IS_CELSIUS = !IS_CELSIUS;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void MenuManager_::leftButton()
|
||||
{
|
||||
if (!inMenu)
|
||||
{
|
||||
return;
|
||||
if (currentState == MainMenu)
|
||||
{
|
||||
menuIndex--;
|
||||
if (menuIndex < 0)
|
||||
{
|
||||
menuIndex = menuItemCount - 1; // Wrap around to the last menu item
|
||||
}
|
||||
}
|
||||
else if (currentState == BrightnessMenu)
|
||||
switch (currentState)
|
||||
{
|
||||
case MainMenu:
|
||||
menuIndex = (menuIndex == 0) ? menuItemCount - 1 : menuIndex - 1;
|
||||
break;
|
||||
case BrightnessMenu:
|
||||
if (!AUTO_BRIGHTNESS)
|
||||
{
|
||||
--BRIGHTNESS_PERCENT;
|
||||
if (BRIGHTNESS_PERCENT < 1)
|
||||
BRIGHTNESS_PERCENT = 100;
|
||||
BRIGHTNESS_PERCENT = (BRIGHTNESS_PERCENT == 1) ? 100 : BRIGHTNESS_PERCENT - 1;
|
||||
BRIGHTNESS = map(BRIGHTNESS_PERCENT, 0, 100, 0, 255);
|
||||
DisplayManager.setBrightness(BRIGHTNESS);
|
||||
}
|
||||
}
|
||||
else if (currentState == FPSMenu)
|
||||
{
|
||||
break;
|
||||
case FPSMenu:
|
||||
if (MATRIX_FPS > 15)
|
||||
--MATRIX_FPS;
|
||||
}
|
||||
else if (currentState == ColorMenu)
|
||||
{
|
||||
int arraySize = sizeof(textColors) / sizeof(textColors[0]);
|
||||
currentColor = (currentColor - 1 + arraySize) % arraySize;
|
||||
MATRIX_FPS--;
|
||||
}
|
||||
else if (currentState == SwitchMenu)
|
||||
{
|
||||
break;
|
||||
case ColorMenu:
|
||||
currentColor = (currentColor + sizeof(textColors) / sizeof(textColors[0]) - 1) % (sizeof(textColors) / sizeof(textColors[0]));
|
||||
break;
|
||||
case SwitchMenu:
|
||||
AUTO_TRANSITION = !AUTO_TRANSITION;
|
||||
}
|
||||
else if (currentState == TspeedMenu)
|
||||
{
|
||||
break;
|
||||
case TspeedMenu:
|
||||
TIME_PER_TRANSITION = max(200, TIME_PER_TRANSITION - 100);
|
||||
}
|
||||
else if (currentState == AppTimeMenu)
|
||||
{
|
||||
break;
|
||||
case AppTimeMenu:
|
||||
TIME_PER_APP = max(1000, TIME_PER_APP - 1000);
|
||||
}
|
||||
else if (currentState == TimeFormatMenu)
|
||||
{
|
||||
timeFormatIndex--;
|
||||
if (timeFormatIndex < 0)
|
||||
{
|
||||
timeFormatIndex = timeFormatCount - 1;
|
||||
}
|
||||
}
|
||||
else if (currentState == DateFormatMenu)
|
||||
{
|
||||
dateFormatIndex--;
|
||||
if (dateFormatIndex < 0)
|
||||
{
|
||||
dateFormatIndex = dateFormatCount - 1;
|
||||
}
|
||||
}
|
||||
else if (currentState == WeekdayMenu)
|
||||
{
|
||||
break;
|
||||
case TimeFormatMenu:
|
||||
timeFormatIndex = (timeFormatIndex == 0) ? timeFormatCount - 1 : timeFormatIndex - 1;
|
||||
break;
|
||||
case DateFormatMenu:
|
||||
dateFormatIndex = (dateFormatIndex == 0) ? dateFormatCount - 1 : dateFormatIndex - 1;
|
||||
break;
|
||||
case Appmenu:
|
||||
appsIndex = (appsIndex == 0) ? appsCount - 1 : appsIndex - 1;
|
||||
break;
|
||||
case WeekdayMenu:
|
||||
START_ON_MONDAY = !START_ON_MONDAY;
|
||||
}
|
||||
else if (currentState == TempMenu)
|
||||
{
|
||||
break;
|
||||
case TempMenu:
|
||||
IS_CELSIUS = !IS_CELSIUS;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void MenuManager_::selectButton()
|
||||
{
|
||||
if (!inMenu)
|
||||
{
|
||||
return;
|
||||
if (currentState == MainMenu)
|
||||
}
|
||||
switch (currentState)
|
||||
{
|
||||
if (menuIndex == 0) // BRIGHT
|
||||
case MainMenu:
|
||||
switch (menuIndex)
|
||||
{
|
||||
case 0:
|
||||
BRIGHTNESS_PERCENT = map(BRIGHTNESS, 0, 255, 0, 100);
|
||||
currentState = BrightnessMenu;
|
||||
}
|
||||
else if (menuIndex == 1) // RESET
|
||||
{
|
||||
break;
|
||||
case 1:
|
||||
currentState = FPSMenu;
|
||||
}
|
||||
else if (menuIndex == 2) // COLOR
|
||||
{
|
||||
break;
|
||||
case 2:
|
||||
currentState = ColorMenu;
|
||||
}
|
||||
else if (menuIndex == 3) // COLOR
|
||||
{
|
||||
break;
|
||||
case 3:
|
||||
currentState = SwitchMenu;
|
||||
}
|
||||
else if (menuIndex == 4) // TSPEED
|
||||
{
|
||||
break;
|
||||
case 4:
|
||||
currentState = TspeedMenu;
|
||||
}
|
||||
else if (menuIndex == 5) // AppTIme
|
||||
{
|
||||
break;
|
||||
case 5:
|
||||
currentState = AppTimeMenu;
|
||||
}
|
||||
else if (menuIndex == 6) // Time
|
||||
{
|
||||
break;
|
||||
case 6:
|
||||
currentState = TimeFormatMenu;
|
||||
}
|
||||
else if (menuIndex == 7) // date
|
||||
{
|
||||
break;
|
||||
case 7:
|
||||
currentState = DateFormatMenu;
|
||||
}
|
||||
else if (menuIndex == 8) // weekday
|
||||
{
|
||||
break;
|
||||
case 8:
|
||||
currentState = WeekdayMenu;
|
||||
}
|
||||
else if (menuIndex == 9) // temp
|
||||
{
|
||||
break;
|
||||
case 9:
|
||||
currentState = TempMenu;
|
||||
}
|
||||
else if (menuIndex == 10) // Updater
|
||||
{
|
||||
break;
|
||||
case 10:
|
||||
currentState = Appmenu;
|
||||
break;
|
||||
case 11:
|
||||
if (FirmwareVersionCheck())
|
||||
{
|
||||
updateFirmware();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
else if (currentState == BrightnessMenu)
|
||||
{
|
||||
break;
|
||||
case BrightnessMenu:
|
||||
AUTO_BRIGHTNESS = !AUTO_BRIGHTNESS;
|
||||
if (!AUTO_BRIGHTNESS)
|
||||
{
|
||||
BRIGHTNESS = map(BRIGHTNESS_PERCENT, 0, 100, 0, 255);
|
||||
DisplayManager.setBrightness(BRIGHTNESS);
|
||||
}
|
||||
break;
|
||||
case Appmenu:
|
||||
switch (appsIndex)
|
||||
{
|
||||
case 0:
|
||||
SHOW_TIME = !SHOW_TIME;
|
||||
break;
|
||||
case 1:
|
||||
SHOW_DATE = !SHOW_DATE;
|
||||
break;
|
||||
case 2:
|
||||
SHOW_TEMP = !SHOW_TEMP;
|
||||
break;
|
||||
case 3:
|
||||
SHOW_HUM = !SHOW_HUM;
|
||||
break;
|
||||
case 4:
|
||||
SHOW_BAT = !SHOW_BAT;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -374,57 +370,47 @@ void MenuManager_::selectButtonLong()
|
||||
{
|
||||
if (inMenu)
|
||||
{
|
||||
if (currentState == BrightnessMenu)
|
||||
switch (currentState)
|
||||
{
|
||||
case BrightnessMenu:
|
||||
BRIGHTNESS = map(BRIGHTNESS_PERCENT, 0, 100, 0, 255);
|
||||
saveSettings();
|
||||
}
|
||||
else if (currentState == FPSMenu)
|
||||
{
|
||||
break;
|
||||
case FPSMenu:
|
||||
DisplayManager.setFPS(MATRIX_FPS);
|
||||
saveSettings();
|
||||
}
|
||||
else if (currentState == ColorMenu)
|
||||
{
|
||||
break;
|
||||
case ColorMenu:
|
||||
TEXTCOLOR_565 = textColors[currentColor];
|
||||
saveSettings();
|
||||
}
|
||||
else if (currentState == MainMenu)
|
||||
{
|
||||
break;
|
||||
case MainMenu:
|
||||
inMenu = false;
|
||||
}
|
||||
else if (currentState == SwitchMenu)
|
||||
{
|
||||
break;
|
||||
case SwitchMenu:
|
||||
DisplayManager.setAutoTransition(AUTO_TRANSITION);
|
||||
saveSettings();
|
||||
}
|
||||
else if (currentState == TspeedMenu)
|
||||
{
|
||||
break;
|
||||
case TspeedMenu:
|
||||
case AppTimeMenu:
|
||||
DisplayManager.applyAllSettings();
|
||||
saveSettings();
|
||||
}
|
||||
else if (currentState == AppTimeMenu)
|
||||
{
|
||||
DisplayManager.applyAllSettings();
|
||||
saveSettings();
|
||||
}
|
||||
else if (currentState == TimeFormatMenu)
|
||||
{
|
||||
break;
|
||||
case TimeFormatMenu:
|
||||
TIME_FORMAT = timeFormat[timeFormatIndex];
|
||||
saveSettings();
|
||||
}
|
||||
else if (currentState == DateFormatMenu)
|
||||
{
|
||||
DATE_FORMAT = dateFormat[dateFormatIndex];
|
||||
break;
|
||||
case DateFormatMenu:
|
||||
case WeekdayMenu:
|
||||
case TempMenu:
|
||||
saveSettings();
|
||||
}
|
||||
else if (currentState == WeekdayMenu)
|
||||
{
|
||||
saveSettings();
|
||||
}
|
||||
else if (currentState == TempMenu)
|
||||
{
|
||||
break;
|
||||
case Appmenu:
|
||||
DisplayManager.loadNativeApps();
|
||||
saveSettings();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
currentState = MainMenu;
|
||||
}
|
||||
|
||||
@@ -84,8 +84,6 @@ void ServerManager_::setup()
|
||||
mws.addOption("Prefix", MQTT_PREFIX);
|
||||
mws.addOption("Homeassistant Discovery", HA_DISCOVERY);
|
||||
mws.addOptionBox("Time");
|
||||
mws.addOption("Show seconds", SHOW_SECONDS);
|
||||
mws.addOption("Show weekday", SHOW_WEEKDAY);
|
||||
mws.addOption("NTP Server", NTP_SERVER);
|
||||
mws.addOption("Timezone", NTP_TZ);
|
||||
mws.addHTML("<p>Find your timezone at <a href='https://github.com/nayarsystems/posix_tz_db/blob/master/zones.csv' target='_blank' rel='noopener noreferrer'>posix_tz_db</a>.</p>", "tz_link");
|
||||
@@ -95,10 +93,6 @@ void ServerManager_::setup()
|
||||
mws.addJavascript(custom_script);
|
||||
mws.addOptionBox("General");
|
||||
mws.addOption("Uppercase letters", UPPERCASE_LETTERS);
|
||||
mws.addOption("Show date", SHOW_DATE);
|
||||
mws.addOption("Show temperature", SHOW_TEMP);
|
||||
mws.addOption("Show humidity", SHOW_HUM);
|
||||
mws.addOption("Show battery", SHOW_BATTERY);
|
||||
mws.addHandler("/save", HTTP_GET, saveHandler);
|
||||
}
|
||||
|
||||
@@ -199,12 +193,6 @@ void ServerManager_::loadSettings()
|
||||
NET_PDNS = doc["Primary DNS"].as<String>();
|
||||
NET_SDNS = doc["Secondary DNS"].as<String>();
|
||||
UPPERCASE_LETTERS = doc["Uppercase letters"];
|
||||
SHOW_SECONDS = doc["Show seconds"];
|
||||
SHOW_WEEKDAY = doc["Show weekday"];
|
||||
SHOW_DATE = doc["Show date"];
|
||||
SHOW_TEMP = doc["Show temperature"];
|
||||
SHOW_HUM = doc["Show humidity"];
|
||||
SHOW_BATTERY = doc["Show battery"];
|
||||
file.close();
|
||||
DisplayManager.applyAllSettings();
|
||||
Serial.println(F("Configuration loaded"));
|
||||
|
||||
2392
src/icons.cpp
Normal file
2392
src/icons.cpp
Normal file
File diff suppressed because it is too large
Load Diff
2391
src/icons.h
2391
src/icons.h
File diff suppressed because it is too large
Load Diff
@@ -72,7 +72,7 @@ void setup()
|
||||
if (ServerManager.isConnected)
|
||||
{
|
||||
MQTTManager.setup();
|
||||
DisplayManager.loadApps();
|
||||
DisplayManager.loadNativeApps();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user