V0.38
adds new options in onscreen menu. - Option to choose between 5 timeformats - Option to choose between 9 dateformats - Option to choose the start of the week (monday or sunday) - Option to switch between °C and °F https://blueforcer.github.io/awtrix-light/#/onscreen closes #10
This commit is contained in:
@@ -1,2 +1,6 @@
|
||||
|
||||
[filename](/flasher/index.html ':include :type=iframe')
|
||||
# Online flasher
|
||||
|
||||
is available in Google Chrome and Microsoft Edge browsers.
|
||||
|
||||
[filename](../flasher/index.html ':include :type=iframe')
|
||||
|
||||
Binary file not shown.
@@ -32,5 +32,17 @@ In this menu you can change the transisiton speed between apps.
|
||||
#### T_SPEED
|
||||
In this menu, you can adjust the duration for which an app is displayed before switching to the next one.
|
||||
|
||||
#### TIME
|
||||
In this menu, you can change the time format. To change the format, use the left and right buttons to navigate through the available options. When you have found the format you want, press and hold the middle button for 2 seconds to save your setting. This will exit the menu and store your selected format.
|
||||
|
||||
#### DATE
|
||||
In this menu, you can change the date format. To change the format, use the left and right buttons to navigate through the available options. When you have found the format you want, press and hold the middle button for 2 seconds to save your setting. This will exit the menu and store your selected format.
|
||||
|
||||
#### WEEKDAY
|
||||
In this menu, you can change the start of your week. To change the start from Monday to Sunday, use the left and right buttons. Press and hold the middle button for 2 seconds to save your setting. This will exit the menu and store your selected start of the week.
|
||||
|
||||
#### TEMP
|
||||
In this menu, you can change the temperature from °C to °F. Use the left and right buttons to change the system. Press and hold the middle button for 2 seconds to save your setting.
|
||||
|
||||
#### UPDATE
|
||||
Here you can check and download a new firmware if available.
|
||||
|
||||
@@ -21,4 +21,3 @@ lib_deps =
|
||||
fastled/FastLED@^3.5.0
|
||||
marcmerlin/FastLED NeoMatrix@^1.2
|
||||
knolleary/PubSubClient@^2.8
|
||||
https://github.com/schreibfaul1/ESP32-audioI2S
|
||||
@@ -1,222 +0,0 @@
|
||||
#include <AudioManager.h>
|
||||
#include <ArduinoJson.h>
|
||||
#include <Preferences.h>
|
||||
#include <LittleFS.h>
|
||||
#include "Audio.h"
|
||||
|
||||
Preferences sender;
|
||||
|
||||
#define LRCLK 18
|
||||
#define BCLK 17
|
||||
#define DOUT 16
|
||||
|
||||
const char *StreamTitle;
|
||||
|
||||
Audio audio;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char url[150];
|
||||
char name[32];
|
||||
uint8_t enabled;
|
||||
} Station;
|
||||
|
||||
#define STATIONS 30
|
||||
|
||||
Station stationlist[STATIONS];
|
||||
#define DEFAULTSTATIONS 24
|
||||
|
||||
AudioManager_ &AudioManager_::getInstance()
|
||||
{
|
||||
static AudioManager_ instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
AudioManager_ &AudioManager = AudioManager.getInstance();
|
||||
|
||||
void loadStations()
|
||||
{
|
||||
// Open the JSON file
|
||||
File file = LittleFS.open("/stations.json", "r");
|
||||
|
||||
if (!file)
|
||||
{
|
||||
Serial.println("Failed to open stations.json file");
|
||||
return;
|
||||
}
|
||||
|
||||
// Read the JSON data from the file
|
||||
DynamicJsonDocument doc(2048);
|
||||
DeserializationError error = deserializeJson(doc, file);
|
||||
|
||||
if (error)
|
||||
{
|
||||
Serial.println("Failed to parse stations.json file");
|
||||
file.close();
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the array of stations from the JSON data
|
||||
JsonArray stations = doc["stations"];
|
||||
|
||||
// Save each station in the array to the stationlist array
|
||||
int i = 0;
|
||||
for (JsonObject station : stations)
|
||||
{
|
||||
const char *url = station["url"];
|
||||
const char *name = station["name"];
|
||||
uint8_t enabled = station["enabled"];
|
||||
strncpy(stationlist[i].url, url, sizeof(stationlist[i].url) - 1);
|
||||
strncpy(stationlist[i].name, name, sizeof(stationlist[i].name) - 1);
|
||||
stationlist[i].enabled = enabled;
|
||||
i++;
|
||||
if (i >= STATIONS)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
file.close();
|
||||
}
|
||||
|
||||
void AudioManager_::setup()
|
||||
{
|
||||
audio.setPinout(BCLK, LRCLK, DOUT); // 0...21
|
||||
// audio.connecttohost("http://mp3.ffh.de/radioffh/hqlivestream.mp3"); // 128k mp3
|
||||
audio.setVolume(14);
|
||||
loadStations();
|
||||
}
|
||||
|
||||
void AudioManager_::tick()
|
||||
{
|
||||
audio.loop();
|
||||
isRunning = audio.isRunning();
|
||||
}
|
||||
|
||||
void AudioManager_::increaseVol()
|
||||
{
|
||||
if (curGain < 21)
|
||||
{
|
||||
curGain++;
|
||||
}
|
||||
audio.setVolume(curGain);
|
||||
}
|
||||
|
||||
void AudioManager_::decreaseVol()
|
||||
{
|
||||
if (curGain > 0)
|
||||
{
|
||||
curGain--;
|
||||
}
|
||||
audio.setVolume(curGain);
|
||||
}
|
||||
|
||||
void AudioManager_::playText(String text)
|
||||
{
|
||||
audio.connecttospeech(text.c_str(), "de");
|
||||
}
|
||||
|
||||
void audio_showstation(const char *info)
|
||||
{
|
||||
Serial.print("station ");
|
||||
Serial.println(info);
|
||||
}
|
||||
|
||||
void audio_showstreamtitle(const char *info)
|
||||
{
|
||||
Serial.print("Streamtitle ");
|
||||
Serial.println(info);
|
||||
AudioManager_::getInstance().StreamInfo = String(info);
|
||||
}
|
||||
|
||||
String AudioManager_::getNextRadioStation(bool playPrevious)
|
||||
{
|
||||
static int currentStation = 0; // Speichere die Indexnummer der letzten gespielten Station
|
||||
int startStation = currentStation + 1; // Starte mit der nächsten Station
|
||||
|
||||
if (playPrevious)
|
||||
{
|
||||
// Wenn die vorherige Station aktiviert ist, aktualisiere die Indexnummer
|
||||
int prevStation = currentStation - 1;
|
||||
if (prevStation >= 0 && stationlist[prevStation].enabled)
|
||||
{
|
||||
currentStation = prevStation;
|
||||
return String(stationlist[currentStation].name);
|
||||
}
|
||||
}
|
||||
|
||||
// Durchlaufe die Liste von Stationen, beginnend mit der nächsten Station
|
||||
for (int i = startStation; i < STATIONS; i++)
|
||||
{
|
||||
// Wenn die Station aktiviert ist, aktualisiere die Indexnummer und gib den Namen zurück
|
||||
if (stationlist[i].enabled)
|
||||
{
|
||||
currentStation = i;
|
||||
return String(stationlist[currentStation].name);
|
||||
}
|
||||
}
|
||||
|
||||
// Wenn keine Station aktiviert ist, beginne wieder von vorne
|
||||
for (int i = 0; i <= currentStation; i++)
|
||||
{
|
||||
// Wenn die Station aktiviert ist, aktualisiere die Indexnummer und gib den Namen zurück
|
||||
if (stationlist[i].enabled)
|
||||
{
|
||||
currentStation = i;
|
||||
return String(stationlist[currentStation].name);
|
||||
}
|
||||
}
|
||||
|
||||
// Wenn keine Station aktiviert ist, gebe einen leeren String zurück
|
||||
return "";
|
||||
}
|
||||
|
||||
void AudioManager_::startRadioStation(String stationName)
|
||||
{
|
||||
// Durchlaufe die Liste von Stationen, um die URL der Station mit dem gegebenen Namen zu finden
|
||||
for (int i = 0; i < STATIONS; i++)
|
||||
{
|
||||
if (stationlist[i].enabled && String(stationlist[i].name) == stationName)
|
||||
{
|
||||
audio.connecttohost(stationlist[i].url);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String AudioManager_::getCurrentRadioStation()
|
||||
{
|
||||
int currentStation = stationIndex;
|
||||
if (currentStation >= 0 && currentStation < STATIONS && stationlist[currentStation].enabled)
|
||||
{
|
||||
return String(stationlist[currentStation].name);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
void AudioManager_::prevStation()
|
||||
{
|
||||
do
|
||||
{
|
||||
stationIndex--;
|
||||
if (stationIndex < 0)
|
||||
{
|
||||
stationIndex = STATIONS - 1; // Wrap around to the last station
|
||||
}
|
||||
} while (!stationlist[stationIndex].enabled);
|
||||
}
|
||||
|
||||
void AudioManager_::nextStation()
|
||||
{
|
||||
do
|
||||
{
|
||||
stationIndex++;
|
||||
if (stationIndex >= STATIONS)
|
||||
{
|
||||
stationIndex = 0; // Wrap around to the first station
|
||||
}
|
||||
} while (!stationlist[stationIndex].enabled);
|
||||
}
|
||||
|
||||
void AudioManager_::stopPlay(){
|
||||
audio.stopSong();
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
#ifndef AudioManager_h
|
||||
#define AudioManager_h
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
class AudioManager_
|
||||
{
|
||||
private:
|
||||
AudioManager_() = default;
|
||||
|
||||
public:
|
||||
static AudioManager_ &getInstance();
|
||||
void setup();
|
||||
void tick();
|
||||
uint8_t curGain = 15;
|
||||
String StreamInfo = "";
|
||||
bool isRunning;
|
||||
void increaseVol();
|
||||
void decreaseVol();
|
||||
void setGain(uint8_t);
|
||||
void playText(String text);
|
||||
String getNextRadioStation(bool playPrevious);
|
||||
void startRadioStation(String stationName);
|
||||
String getCurrentRadioStation();
|
||||
void prevStation();
|
||||
void nextStation();
|
||||
void stopPlay();
|
||||
int stationIndex;
|
||||
};
|
||||
|
||||
extern AudioManager_ &AudioManager;
|
||||
|
||||
#endif
|
||||
@@ -8,7 +8,6 @@
|
||||
#include "PeripheryManager.h"
|
||||
#include "MQTTManager.h"
|
||||
#include "GifPlayer.h"
|
||||
#include "AudioManager.h"
|
||||
#include <Ticker.h>
|
||||
#include "Functions.h"
|
||||
#include "ServerManager.h"
|
||||
@@ -155,11 +154,11 @@ void DisplayManager_::printText(int16_t x, int16_t y, const char *text, bool cen
|
||||
}
|
||||
|
||||
upperText[length] = '\0'; // Null terminator
|
||||
matrix.print(upperText);
|
||||
matrix.print(utf8ascii(upperText));
|
||||
}
|
||||
else
|
||||
{
|
||||
matrix.print(text);
|
||||
matrix.print(utf8ascii(text));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -400,7 +399,6 @@ void DisplayManager_::show()
|
||||
matrix.show();
|
||||
}
|
||||
|
||||
|
||||
void DisplayManager_::leftButton()
|
||||
{
|
||||
if (!MenuManager.inMenu)
|
||||
@@ -537,3 +535,23 @@ void DisplayManager_::drawProgressBar(int cur, int total)
|
||||
matrix.drawFastHLine(0, 7, leds_for_progress / MATRIX_HEIGHT, matrix.Color(0, 255, 0));
|
||||
matrix.show();
|
||||
}
|
||||
|
||||
void DisplayManager_::drawMenuIndicator(int cur, int total)
|
||||
{
|
||||
int menuItemWidth = 2;
|
||||
int totalWidth = total * menuItemWidth + (total - 2);
|
||||
int leftMargin = (MATRIX_WIDTH - totalWidth) / 2;
|
||||
int pixelSpacing = 1;
|
||||
for (int i = 0; i < total; i++)
|
||||
{
|
||||
int x = leftMargin + i * (menuItemWidth + pixelSpacing);
|
||||
if (i == cur)
|
||||
{
|
||||
matrix.drawLine(x, 7, x + menuItemWidth - 1, 7, matrix.Color(255, 0, 0));
|
||||
}
|
||||
else
|
||||
{
|
||||
matrix.drawLine(x, 7, x + menuItemWidth - 1, 7, matrix.Color(100, 100, 100));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -54,6 +54,7 @@ public:
|
||||
void drawGIF(uint16_t x, uint16_t y, fs::File gifFile);
|
||||
void drawJPG(uint16_t x, uint16_t y, fs::File jpgFile);
|
||||
void drawProgressBar(int cur, int total);
|
||||
void drawMenuIndicator(int cur, int total);
|
||||
};
|
||||
|
||||
extern DisplayManager_ &DisplayManager;
|
||||
|
||||
68
src/Frames.h
68
src/Frames.h
@@ -106,28 +106,19 @@ void TimeFrame(FastLED_NeoMatrix *matrix, MatrixDisplayUiState *state, int16_t x
|
||||
return;
|
||||
CURRENT_APP = "Time";
|
||||
DisplayManager.getInstance().resetTextColor();
|
||||
time_t now1 = time(nullptr);
|
||||
time_t now = time(nullptr);
|
||||
struct tm *timeInfo;
|
||||
timeInfo = localtime(&now1);
|
||||
char t[14];
|
||||
if (SHOW_SECONDS)
|
||||
{
|
||||
sprintf_P(t, PSTR("%02d:%02d:%02d"), timeInfo->tm_hour, timeInfo->tm_min, timeInfo->tm_sec);
|
||||
matrix->setCursor(2 + x, 6 + y);
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf_P(t, PSTR("%02d:%02d"), timeInfo->tm_hour, timeInfo->tm_min);
|
||||
matrix->setCursor(7 + x, 6 + y);
|
||||
}
|
||||
|
||||
matrix->println(t);
|
||||
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);
|
||||
|
||||
if (!SHOW_WEEKDAY)
|
||||
return;
|
||||
int dayOffset = START_ON_MONDAY ? 0 : 1;
|
||||
for (int i = 0; i <= 6; i++)
|
||||
{
|
||||
if (i == (timeInfo->tm_wday + 6) % 7)
|
||||
if (i == (timeInfo->tm_wday + 6 + dayOffset) % 7)
|
||||
{
|
||||
matrix->drawLine((2 + i * 4) + x, y + 7, (i * 4 + 4) + x, y + 7, matrix->Color(200, 200, 200));
|
||||
}
|
||||
@@ -144,18 +135,18 @@ void DateFrame(FastLED_NeoMatrix *matrix, MatrixDisplayUiState *state, int16_t x
|
||||
return;
|
||||
CURRENT_APP = "Date";
|
||||
DisplayManager.getInstance().resetTextColor();
|
||||
time_t now1 = time(nullptr);
|
||||
time_t now = time(nullptr);
|
||||
struct tm *timeInfo;
|
||||
timeInfo = localtime(&now1);
|
||||
char d[11];
|
||||
sprintf_P(d, PSTR("%02d.%02d.%02d"), timeInfo->tm_mday, timeInfo->tm_mon + 1, timeInfo->tm_year % 100);
|
||||
matrix->setCursor(2 + x, 6 + y);
|
||||
matrix->println(d);
|
||||
timeInfo = localtime(&now);
|
||||
char d[20];
|
||||
strftime(d, sizeof(d), DATE_FORMAT.c_str(), localtime(&now));
|
||||
DisplayManager.printText(0 + x, 6 + y, d, true, true);
|
||||
if (!SHOW_WEEKDAY)
|
||||
return;
|
||||
int dayOffset = START_ON_MONDAY ? 0 : 1;
|
||||
for (int i = 0; i <= 6; i++)
|
||||
{
|
||||
if (i == (timeInfo->tm_wday + 6) % 7)
|
||||
if (i == (timeInfo->tm_wday + 6 + dayOffset) % 7)
|
||||
{
|
||||
matrix->drawLine((2 + i * 4) + x, y + 7, (i * 4 + 4) + x, y + 7, matrix->Color(200, 200, 200));
|
||||
}
|
||||
@@ -173,9 +164,18 @@ void TempFrame(FastLED_NeoMatrix *matrix, MatrixDisplayUiState *state, int16_t x
|
||||
CURRENT_APP = "Temperature";
|
||||
DisplayManager.getInstance().resetTextColor();
|
||||
matrix->drawRGBBitmap(x, y, get_icon(234), 8, 8);
|
||||
matrix->setCursor(14 + x, 6 + y);
|
||||
matrix->print((int)CURRENT_TEMP); // Ausgabe der Temperatur
|
||||
matrix->print(utf8ascii("°"));
|
||||
matrix->setCursor(12 + x, 6 + y);
|
||||
if (IS_CELSIUS)
|
||||
{
|
||||
matrix->print((int)CURRENT_TEMP);
|
||||
matrix->print(utf8ascii("°C"));
|
||||
}
|
||||
else
|
||||
{
|
||||
int tempF = (CURRENT_TEMP * 9 / 5) + 32;
|
||||
matrix->print(tempF);
|
||||
matrix->print(utf8ascii("°F"));
|
||||
}
|
||||
}
|
||||
|
||||
void HumFrame(FastLED_NeoMatrix *matrix, MatrixDisplayUiState *state, int16_t x, int16_t y, bool firstFrame, bool lastFrame)
|
||||
@@ -218,7 +218,7 @@ void AlarmFrame(FastLED_NeoMatrix *matrix, MatrixDisplayUiState *state)
|
||||
{
|
||||
matrix->fillScreen(matrix->Color(255, 0, 0));
|
||||
CURRENT_APP = "Alarm";
|
||||
uint16_t textWidth = getTextWidth("ALARM",false);
|
||||
uint16_t textWidth = getTextWidth("ALARM", false);
|
||||
int16_t textX = ((32 - textWidth) / 2);
|
||||
matrix->setTextColor(0);
|
||||
matrix->setCursor(textX, 6);
|
||||
@@ -238,7 +238,7 @@ void TimerFrame(FastLED_NeoMatrix *matrix, MatrixDisplayUiState *state)
|
||||
matrix->fillScreen(matrix->Color(0, 255, 0));
|
||||
CURRENT_APP = "Timer";
|
||||
String menuText = "TIMER";
|
||||
uint16_t textWidth = getTextWidth(menuText.c_str(),false);
|
||||
uint16_t textWidth = getTextWidth(menuText.c_str(), false);
|
||||
int16_t textX = ((32 - textWidth) / 2);
|
||||
matrix->setTextColor(0);
|
||||
matrix->setCursor(textX, 6);
|
||||
@@ -283,9 +283,9 @@ void ShowCustomFrame(String name, FastLED_NeoMatrix *matrix, MatrixDisplayUiStat
|
||||
bool hasIcon = cf->icon;
|
||||
uint16_t availableWidth = (hasIcon) ? 24 : 32;
|
||||
|
||||
bool noScrolling = getTextWidth(cf->text.c_str(),false) <= availableWidth;
|
||||
bool noScrolling = getTextWidth(cf->text.c_str(), false) <= availableWidth;
|
||||
|
||||
if ((cf->repeat > 0) && (getTextWidth(cf->text.c_str(),false) > availableWidth) && (state->frameState == FIXED))
|
||||
if ((cf->repeat > 0) && (getTextWidth(cf->text.c_str(), false) > availableWidth) && (state->frameState == FIXED))
|
||||
{
|
||||
DisplayManager.setAutoTransition(false);
|
||||
}
|
||||
@@ -294,9 +294,9 @@ void ShowCustomFrame(String name, FastLED_NeoMatrix *matrix, MatrixDisplayUiStat
|
||||
DisplayManager.setAutoTransition(true);
|
||||
}
|
||||
|
||||
if (getTextWidth(cf->text.c_str(),false) > availableWidth && !(state->frameState == IN_TRANSITION))
|
||||
if (getTextWidth(cf->text.c_str(), false) > availableWidth && !(state->frameState == IN_TRANSITION))
|
||||
{
|
||||
if (cf->scrollposition <= -getTextWidth(cf->text.c_str(),false))
|
||||
if (cf->scrollposition <= -getTextWidth(cf->text.c_str(), false))
|
||||
{
|
||||
cf->scrollDelay = 0;
|
||||
cf->scrollposition = 9;
|
||||
@@ -344,7 +344,7 @@ void ShowCustomFrame(String name, FastLED_NeoMatrix *matrix, MatrixDisplayUiStat
|
||||
}
|
||||
}
|
||||
}
|
||||
int16_t textX = (hasIcon) ? ((24 - getTextWidth(cf->text.c_str(),false)) / 2) + 9 : ((32 - getTextWidth(cf->text.c_str(),false)) / 2);
|
||||
int16_t textX = (hasIcon) ? ((24 - getTextWidth(cf->text.c_str(), false)) / 2) + 9 : ((32 - getTextWidth(cf->text.c_str(), false)) / 2);
|
||||
matrix->setTextColor(cf->color);
|
||||
if (noScrolling)
|
||||
{
|
||||
@@ -451,7 +451,7 @@ void NotifyFrame(FastLED_NeoMatrix *matrix, MatrixDisplayUiState *state)
|
||||
matrix->fillRect(0, 0, 32, 8, 0);
|
||||
|
||||
// Calculate text and available width
|
||||
uint16_t textWidth = getTextWidth(notify.text.c_str(),false);
|
||||
uint16_t textWidth = getTextWidth(notify.text.c_str(), false);
|
||||
uint16_t availableWidth = hasIcon ? 24 : 32;
|
||||
|
||||
// Check if text is scrolling
|
||||
|
||||
@@ -13,6 +13,10 @@ void loadSettings()
|
||||
AUTO_TRANSITION = Settings.getBool("TRANS", true);
|
||||
TIME_PER_TRANSITION = Settings.getUInt("TSPEED", 500);
|
||||
TIME_PER_APP = Settings.getUInt("ADUR", 5000);
|
||||
TIME_FORMAT = Settings.getString("TFORMAT", "%H:%M:%S");
|
||||
DATE_FORMAT = Settings.getString("DFORMAT", "%d.%m.%y");
|
||||
START_ON_MONDAY = Settings.getBool("SOM", true);
|
||||
IS_CELSIUS = Settings.getBool("CEL", true);
|
||||
Settings.end();
|
||||
}
|
||||
|
||||
@@ -26,6 +30,10 @@ void saveSettings()
|
||||
Settings.putUInt("COL", TEXTCOLOR_565);
|
||||
Settings.putUInt("TSPEED", TIME_PER_TRANSITION);
|
||||
Settings.putUInt("ADUR", TIME_PER_APP);
|
||||
Settings.putString("TFORMAT", TIME_FORMAT);
|
||||
Settings.putString("DFORMAT", DATE_FORMAT);
|
||||
Settings.putBool("SOM", START_ON_MONDAY);
|
||||
Settings.putBool("CEL", IS_CELSIUS);
|
||||
Settings.end();
|
||||
}
|
||||
|
||||
@@ -34,7 +42,7 @@ IPAddress gateway;
|
||||
IPAddress subnet;
|
||||
IPAddress primaryDNS;
|
||||
IPAddress secondaryDNS;
|
||||
const char *VERSION = "0.37";
|
||||
const char *VERSION = "0.38";
|
||||
String MQTT_HOST = "";
|
||||
uint16_t MQTT_PORT = 1883;
|
||||
String MQTT_USER;
|
||||
@@ -65,12 +73,17 @@ bool HA_DISCOVERY = false;
|
||||
// Periphery
|
||||
String CURRENT_APP;
|
||||
float CURRENT_TEMP;
|
||||
bool IS_CELSIUS;
|
||||
float CURRENT_HUM;
|
||||
float CURRENT_LUX;
|
||||
uint8_t BRIGHTNESS = 120;
|
||||
uint8_t BRIGHTNESS_PERCENT;
|
||||
uint8_t BATTERY_PERCENT;
|
||||
|
||||
String TIME_FORMAT = "%H:%M:%S";
|
||||
String DATE_FORMAT = "%d.%m.%y";
|
||||
bool START_ON_MONDAY;
|
||||
|
||||
String ALARM_SOUND;
|
||||
uint8_t SNOOZE_TIME;
|
||||
|
||||
|
||||
@@ -43,6 +43,7 @@ extern uint8_t BATTERY_PERCENT;
|
||||
extern uint8_t BRIGHTNESS;
|
||||
extern uint8_t BRIGHTNESS_PERCENT;
|
||||
extern String TEXTCOLOR;
|
||||
extern String TIME_FORMAT;
|
||||
extern bool AUTO_BRIGHTNESS;
|
||||
extern bool AP_MODE;
|
||||
extern bool ALARM_ACTIVE;
|
||||
@@ -53,6 +54,10 @@ extern String TIMER_SOUND;
|
||||
extern uint16_t TEXTCOLOR_565;
|
||||
extern uint8_t SNOOZE_TIME;
|
||||
extern bool AUTO_TRANSITION;
|
||||
extern String TIME_FORMAT;
|
||||
extern String DATE_FORMAT;
|
||||
extern bool START_ON_MONDAY;
|
||||
extern bool IS_CELSIUS;
|
||||
|
||||
void loadSettings();
|
||||
void saveSettings();
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#include <MenuManager.h>
|
||||
#include <Arduino.h>
|
||||
#include <AudioManager.h>
|
||||
#include <Globals.h>
|
||||
#include <ServerManager.h>
|
||||
#include <DisplayManager.h>
|
||||
@@ -9,39 +8,66 @@
|
||||
String menuText;
|
||||
int menuSelection;
|
||||
|
||||
int8_t menuIndex = 0;
|
||||
int8_t stationIndex = 0;
|
||||
bool isPlayingRadio = false;
|
||||
|
||||
enum MenuState
|
||||
{
|
||||
MainMenu,
|
||||
RadioMenu,
|
||||
StationSelection,
|
||||
PlayingStation,
|
||||
VolumeMenu,
|
||||
BrightnessMenu,
|
||||
FPSMenu,
|
||||
ColorMenu,
|
||||
SwitchMenu,
|
||||
TspeedMenu,
|
||||
AppTimeMenu
|
||||
AppTimeMenu,
|
||||
TimeFormatMenu,
|
||||
DateFormatMenu,
|
||||
WeekdayMenu,
|
||||
TempMenu
|
||||
};
|
||||
|
||||
const char *menuItems[] = {
|
||||
const char *menuItems[] PROGMEM = {
|
||||
"BRIGHT",
|
||||
"FPS",
|
||||
"COLOR",
|
||||
"SWITCH",
|
||||
"T-SPEED",
|
||||
"APPTIME",
|
||||
"TIME",
|
||||
"DATE",
|
||||
"WEEKDAY",
|
||||
"TEMP",
|
||||
"UPDATE"};
|
||||
|
||||
byte menuItemCount = 7;
|
||||
int8_t menuIndex = 0;
|
||||
uint8_t menuItemCount = 11;
|
||||
|
||||
const char *timeFormat[] PROGMEM = {
|
||||
"%H:%M:%S",
|
||||
"%l:%M:%S",
|
||||
"%H:%M",
|
||||
"%l:%M",
|
||||
"%l:%M %p"};
|
||||
int8_t timeFormatIndex;
|
||||
uint8_t timeFormatCount = 5;
|
||||
|
||||
const char *dateFormat[] PROGMEM = {
|
||||
"%d.%m.%y", // 01.04.22
|
||||
"%d.%m", // 01.04
|
||||
"%y-%m-%d", // 22-04-01
|
||||
"%m-%d", // 04-01
|
||||
"%m/%d/%y", // 04/01/22
|
||||
"%m/%d", // 04/01
|
||||
"%d/%m/%y", // 01/04/22
|
||||
"%d/%m", // 01/04
|
||||
"%m-%d-%y", // 04-01-22
|
||||
};
|
||||
int8_t dateFormatIndex;
|
||||
uint8_t dateFormatCount = 9;
|
||||
|
||||
MenuState currentState = MainMenu;
|
||||
|
||||
uint16_t textColors[] = {
|
||||
uint16_t textColors[] PROGMEM = {
|
||||
0xFFFF, // White
|
||||
0xF800, // Red
|
||||
0xF812, // Dark orange
|
||||
@@ -71,6 +97,7 @@ String MenuManager_::menutext()
|
||||
{
|
||||
if (currentState == MainMenu)
|
||||
{
|
||||
DisplayManager.drawMenuIndicator(menuIndex, menuItemCount);
|
||||
return (menuItems[menuIndex]);
|
||||
}
|
||||
else if (currentState == BrightnessMenu)
|
||||
@@ -106,13 +133,33 @@ String MenuManager_::menutext()
|
||||
{
|
||||
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];
|
||||
strftime(t, sizeof(t), timeFormat[timeFormatIndex], localtime(&now));
|
||||
return t;
|
||||
}
|
||||
else if (currentState == DateFormatMenu)
|
||||
{
|
||||
time_t now = time(nullptr);
|
||||
char t[20];
|
||||
strftime(t, sizeof(t), dateFormat[dateFormatIndex], localtime(&now));
|
||||
return t;
|
||||
}
|
||||
else if (currentState == WeekdayMenu)
|
||||
{
|
||||
return START_ON_MONDAY ? "MON" : "SUN";
|
||||
}
|
||||
else if (currentState == TempMenu)
|
||||
{
|
||||
return IS_CELSIUS ? "°C" : "°F";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
@@ -129,10 +176,6 @@ void MenuManager_::rightButton()
|
||||
menuIndex = 0; // Wrap around to the first menu item
|
||||
}
|
||||
}
|
||||
else if (currentState == RadioMenu || currentState == StationSelection)
|
||||
{
|
||||
AudioManager.nextStation();
|
||||
}
|
||||
else if (currentState == BrightnessMenu)
|
||||
{
|
||||
if (!AUTO_BRIGHTNESS)
|
||||
@@ -166,6 +209,30 @@ void MenuManager_::rightButton()
|
||||
{
|
||||
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)
|
||||
{
|
||||
START_ON_MONDAY = !START_ON_MONDAY;
|
||||
}
|
||||
else if (currentState == TempMenu)
|
||||
{
|
||||
IS_CELSIUS = !IS_CELSIUS;
|
||||
}
|
||||
}
|
||||
|
||||
void MenuManager_::leftButton()
|
||||
@@ -180,10 +247,6 @@ void MenuManager_::leftButton()
|
||||
menuIndex = menuItemCount - 1; // Wrap around to the last menu item
|
||||
}
|
||||
}
|
||||
else if (currentState == RadioMenu || currentState == StationSelection)
|
||||
{
|
||||
AudioManager.prevStation();
|
||||
}
|
||||
else if (currentState == BrightnessMenu)
|
||||
{
|
||||
if (!AUTO_BRIGHTNESS)
|
||||
@@ -217,6 +280,30 @@ void MenuManager_::leftButton()
|
||||
{
|
||||
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)
|
||||
{
|
||||
START_ON_MONDAY = !START_ON_MONDAY;
|
||||
}
|
||||
else if (currentState == TempMenu)
|
||||
{
|
||||
IS_CELSIUS = !IS_CELSIUS;
|
||||
}
|
||||
}
|
||||
|
||||
void MenuManager_::selectButton()
|
||||
@@ -250,18 +337,36 @@ void MenuManager_::selectButton()
|
||||
{
|
||||
currentState = AppTimeMenu;
|
||||
}
|
||||
else if (menuIndex == 6) // Updater
|
||||
else if (menuIndex == 6) // Time
|
||||
{
|
||||
FirmwareVersionCheck();
|
||||
currentState = TimeFormatMenu;
|
||||
}
|
||||
}
|
||||
else if (currentState == StationSelection)
|
||||
else if (menuIndex == 7) // date
|
||||
{
|
||||
AudioManager.startRadioStation(AudioManager.getCurrentRadioStation());
|
||||
currentState = DateFormatMenu;
|
||||
}
|
||||
else if (menuIndex == 8) // weekday
|
||||
{
|
||||
currentState = WeekdayMenu;
|
||||
}
|
||||
else if (menuIndex == 9) // temp
|
||||
{
|
||||
currentState = TempMenu;
|
||||
}
|
||||
else if (menuIndex == 10) // Updater
|
||||
{
|
||||
if (FirmwareVersionCheck())
|
||||
updateFirmware();
|
||||
}
|
||||
}
|
||||
else if (currentState == BrightnessMenu)
|
||||
{
|
||||
AUTO_BRIGHTNESS = !AUTO_BRIGHTNESS;
|
||||
if (!AUTO_BRIGHTNESS)
|
||||
{
|
||||
BRIGHTNESS = map(BRIGHTNESS_PERCENT, 0, 100, 0, 255);
|
||||
DisplayManager.setBrightness(BRIGHTNESS);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -303,6 +408,24 @@ void MenuManager_::selectButtonLong()
|
||||
DisplayManager.applyAllSettings();
|
||||
saveSettings();
|
||||
}
|
||||
else if (currentState == TimeFormatMenu)
|
||||
{
|
||||
TIME_FORMAT = timeFormat[timeFormatIndex];
|
||||
saveSettings();
|
||||
}
|
||||
else if (currentState == DateFormatMenu)
|
||||
{
|
||||
DATE_FORMAT = dateFormat[dateFormatIndex];
|
||||
saveSettings();
|
||||
}
|
||||
else if (currentState == WeekdayMenu)
|
||||
{
|
||||
saveSettings();
|
||||
}
|
||||
else if (currentState == TempMenu)
|
||||
{
|
||||
saveSettings();
|
||||
}
|
||||
currentState = MainMenu;
|
||||
}
|
||||
else
|
||||
|
||||
@@ -162,7 +162,7 @@ void PeripheryManager_::tick()
|
||||
button_right.read();
|
||||
button_select.read();
|
||||
|
||||
// Auslesen von Batterie-, Temperatur- und Luftfeuchtigkeitswerten alle 10 Sekunden
|
||||
|
||||
unsigned long currentMillis_BatTempHum = millis();
|
||||
if (currentMillis_BatTempHum - previousMillis_BatTempHum >= interval_BatTempHum)
|
||||
{
|
||||
@@ -174,11 +174,13 @@ void PeripheryManager_::tick()
|
||||
CURRENT_TEMP -= 9.0;
|
||||
checkAlarms();
|
||||
MQTTManager.sendStats();
|
||||
uint32_t freeHeap = esp_get_free_heap_size(); // Freien Heap-Speicher in Bytes erhalten
|
||||
float freeHeapKB = freeHeap / 1024.0; // Freien Heap-Speicher in Kilobytes umrechnen
|
||||
uint32_t freeHeap = esp_get_free_heap_size();
|
||||
float freeHeapKB = freeHeap / 1024.0;
|
||||
Serial.print(ESP.getFreeHeap() / 1024);
|
||||
Serial.println(" KB");
|
||||
}
|
||||
|
||||
// Auslesen des LDR-Werts alle 500 ms
|
||||
|
||||
unsigned long currentMillis_LDR = millis();
|
||||
if (currentMillis_LDR - previousMillis_LDR >= interval_LDR && AUTO_BRIGHTNESS)
|
||||
{
|
||||
|
||||
@@ -36,7 +36,6 @@
|
||||
#include "MQTTManager.h"
|
||||
#include "ServerManager.h"
|
||||
#include "Globals.h"
|
||||
#include "AudioManager.h"
|
||||
|
||||
TaskHandle_t taskHandle;
|
||||
volatile bool StopTask = false;
|
||||
@@ -73,7 +72,6 @@ void setup()
|
||||
if (ServerManager.isConnected)
|
||||
{
|
||||
MQTTManager.setup();
|
||||
AudioManager.setup();
|
||||
DisplayManager.loadApps();
|
||||
}
|
||||
else
|
||||
@@ -92,7 +90,6 @@ void loop()
|
||||
DisplayManager.tick();
|
||||
if (ServerManager.isConnected)
|
||||
{
|
||||
AudioManager.tick();
|
||||
PeripheryManager.tick();
|
||||
MQTTManager.tick();
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ void update_started()
|
||||
|
||||
void update_finished()
|
||||
{
|
||||
Serial.println("CALLBACK: HTTP update process finished");
|
||||
|
||||
}
|
||||
|
||||
void update_progress(int cur, int total)
|
||||
@@ -29,7 +29,7 @@ void update_error(int err)
|
||||
DisplayManager.show();
|
||||
}
|
||||
|
||||
void firmwareUpdate(void)
|
||||
void updateFirmware()
|
||||
{
|
||||
WiFiClientSecure client;
|
||||
client.setCACert(rootCACertificate);
|
||||
@@ -55,7 +55,9 @@ void firmwareUpdate(void)
|
||||
break;
|
||||
}
|
||||
}
|
||||
int FirmwareVersionCheck(void)
|
||||
|
||||
|
||||
bool FirmwareVersionCheck()
|
||||
{
|
||||
|
||||
DisplayManager.clear();
|
||||
@@ -73,8 +75,6 @@ int FirmwareVersionCheck(void)
|
||||
if (client)
|
||||
{
|
||||
client->setCACert(rootCACertificate);
|
||||
|
||||
// Add a scoping block for HTTPClient https to make sure it is destroyed before WiFiClientSecure *client is
|
||||
HTTPClient https;
|
||||
|
||||
if (https.begin(*client, fwurl))
|
||||
@@ -115,7 +115,6 @@ int FirmwareVersionCheck(void)
|
||||
Serial.println(payload);
|
||||
Serial.println("New firmware detected");
|
||||
DisplayManager.printText(0, 6, payload.c_str(), true, true);
|
||||
firmwareUpdate();
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user