V0.36
adds new MQTT commands. See https://blueforcer.github.io/awtrix-light/#/mqtt
This commit is contained in:
Binary file not shown.
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "AWTRIX Light",
|
"name": "AWTRIX Light",
|
||||||
"version": "0.35",
|
"version": "0.36",
|
||||||
"home_assistant_domain": "AwtrixLight",
|
"home_assistant_domain": "AwtrixLight",
|
||||||
"funding_url": "https://blueforcer.de",
|
"funding_url": "https://blueforcer.de",
|
||||||
"new_install_prompt_erase": true,
|
"new_install_prompt_erase": true,
|
||||||
|
|||||||
26
docs/mqtt.md
26
docs/mqtt.md
@@ -1,9 +1,14 @@
|
|||||||
# MQTT Commands
|
# MQTT Commands
|
||||||
|
|
||||||
### Switch to app
|
### Switch apps
|
||||||
**Topic**
|
##### Topic
|
||||||
|
`[PREFIX]/nextapp`
|
||||||
|
`[PREFIX]/previousapp`
|
||||||
|
|
||||||
|
### Switch to specific app
|
||||||
|
##### Topic
|
||||||
`[PREFIX]/switch`
|
`[PREFIX]/switch`
|
||||||
**Payload**
|
##### Payload
|
||||||
`{"name":"time"}`
|
`{"name":"time"}`
|
||||||
|
|
||||||
Build-in app names are
|
Build-in app names are
|
||||||
@@ -16,3 +21,18 @@ Build-in app names are
|
|||||||
For custompages you need to call the name you set in the topic:
|
For custompages you need to call the name you set in the topic:
|
||||||
If `[PREFIX]/custom/test` is your topic,
|
If `[PREFIX]/custom/test` is your topic,
|
||||||
then `test` is the name.
|
then `test` is the name.
|
||||||
|
|
||||||
|
## Change Settings
|
||||||
|
##### Topic
|
||||||
|
`[PREFIX]/settings`
|
||||||
|
|
||||||
|
##### JSON Properties
|
||||||
|
| Key | Type | Description | Value Range |
|
||||||
|
| ----------- | ------- | --------------------------------------------------------------------------- | ------------------------------------------ |
|
||||||
|
| `apptime` | number | Determines the duration an app is displayed in milliseconds. | Any positive integer value. Default 7000 |
|
||||||
|
| `transition`| number | The time the transition to the next app takes in milliseconds. | Any positive integer value. Default 500 |
|
||||||
|
| `textcolor` | string | A color in hexadecimal format. | Any valid 6-digit hexadecimal color value, e.g. "#FF0000" for red |
|
||||||
|
| `fps` | number | Determines the frame rate at which the matrix is updated. | Any positive integer value. Default 23 |
|
||||||
|
| `brightness`| number | Determines the brightness of the matrix. | An integer between 0 and 255 |
|
||||||
|
| `autobrightness`| boolean | Determines if automatic brightness control is active. | `true` or `false` |
|
||||||
|
| `autotransition`| boolean | Determines if automatic switching to the next app is active. | `true` or `false` |
|
||||||
|
|||||||
@@ -92,11 +92,14 @@ void DisplayManager_::drawJPG(uint16_t x, uint16_t y, fs::File jpgFile)
|
|||||||
TJpgDec.drawFsJpg(x, y, jpgFile);
|
TJpgDec.drawFsJpg(x, y, jpgFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DisplayManager_::setSettings()
|
void DisplayManager_::applyAllSettings()
|
||||||
{
|
{
|
||||||
ui.setTargetFPS(MATRIX_FPS);
|
ui.setTargetFPS(MATRIX_FPS);
|
||||||
ui.setTimePerApp(TIME_PER_APP);
|
ui.setTimePerApp(TIME_PER_APP);
|
||||||
ui.setTimePerTransition(TIME_PER_TRANSITION);
|
ui.setTimePerTransition(TIME_PER_TRANSITION);
|
||||||
|
setBrightness(BRIGHTNESS);
|
||||||
|
setTextColor(TEXTCOLOR_565);
|
||||||
|
setAutoTransition(AUTO_TRANSITION);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DisplayManager_::resetTextColor()
|
void DisplayManager_::resetTextColor()
|
||||||
@@ -493,3 +496,20 @@ void DisplayManager_::switchToApp(String Payload)
|
|||||||
if (index > -1)
|
if (index > -1)
|
||||||
ui.transitionToApp(index);
|
ui.transitionToApp(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DisplayManager_::setNewSettings(String Payload)
|
||||||
|
{
|
||||||
|
DynamicJsonDocument doc(512);
|
||||||
|
DeserializationError error = deserializeJson(doc, Payload);
|
||||||
|
if (error)
|
||||||
|
return;
|
||||||
|
TIME_PER_APP = doc.containsKey("apptime") ? doc["apptime"] : TIME_PER_APP;
|
||||||
|
TIME_PER_TRANSITION = doc.containsKey("transition") ? doc["transition"] : TIME_PER_TRANSITION;
|
||||||
|
TEXTCOLOR_565 = doc.containsKey("textcolor") ? hexToRgb565(doc["textcolor"]) : TEXTCOLOR_565;
|
||||||
|
MATRIX_FPS = doc.containsKey("fps") ? doc["fps"] : MATRIX_FPS;
|
||||||
|
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;
|
||||||
|
applyAllSettings();
|
||||||
|
saveSettings();
|
||||||
|
}
|
||||||
@@ -26,7 +26,7 @@ public:
|
|||||||
static DisplayManager_ &getInstance();
|
static DisplayManager_ &getInstance();
|
||||||
void setup();
|
void setup();
|
||||||
void tick();
|
void tick();
|
||||||
void setSettings();
|
void applyAllSettings();
|
||||||
void rightButton();
|
void rightButton();
|
||||||
void dismissNotify();
|
void dismissNotify();
|
||||||
void HSVtext(int16_t, int16_t, const char *, bool);
|
void HSVtext(int16_t, int16_t, const char *, bool);
|
||||||
@@ -48,6 +48,7 @@ public:
|
|||||||
void printText(int16_t x, int16_t y, const char *text, bool centered, bool ignoreUppercase);
|
void printText(int16_t x, int16_t y, const char *text, bool centered, bool ignoreUppercase);
|
||||||
bool setAutoTransition(bool active);
|
bool setAutoTransition(bool active);
|
||||||
void switchToApp(String Payload);
|
void switchToApp(String Payload);
|
||||||
|
void setNewSettings(String Payload);
|
||||||
void drawGIF(uint16_t x, uint16_t y, fs::File gifFile);
|
void drawGIF(uint16_t x, uint16_t y, fs::File gifFile);
|
||||||
void drawJPG(uint16_t x, uint16_t y, fs::File jpgFile);
|
void drawJPG(uint16_t x, uint16_t y, fs::File jpgFile);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -24,6 +24,9 @@ uint16_t hexToRgb565(String hexValue)
|
|||||||
uint8_t r = strtol(hexValue.substring(0, 2).c_str(), NULL, 16);
|
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 g = strtol(hexValue.substring(2, 4).c_str(), NULL, 16);
|
||||||
uint8_t b = strtol(hexValue.substring(4, 6).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)) {
|
||||||
|
return 0xFFFF;
|
||||||
|
}
|
||||||
uint16_t color = ((r >> 3) << 11) | ((g >> 2) << 5) | (b >> 3);
|
uint16_t color = ((r >> 3) << 11) | ((g >> 2) << 5) | (b >> 3);
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ IPAddress gateway;
|
|||||||
IPAddress subnet;
|
IPAddress subnet;
|
||||||
IPAddress primaryDNS;
|
IPAddress primaryDNS;
|
||||||
IPAddress secondaryDNS;
|
IPAddress secondaryDNS;
|
||||||
const char *VERSION = "0.35";
|
const char *VERSION = "0.36";
|
||||||
String MQTT_HOST = "";
|
String MQTT_HOST = "";
|
||||||
uint16_t MQTT_PORT = 1883;
|
uint16_t MQTT_PORT = 1883;
|
||||||
String MQTT_USER;
|
String MQTT_USER;
|
||||||
|
|||||||
@@ -138,6 +138,24 @@ void onMqttMessage(const char *topic, const uint8_t *payload, uint16_t length)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (strTopic == MQTT_PREFIX + "/settings")
|
||||||
|
{
|
||||||
|
DisplayManager.setNewSettings(strPayload);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strTopic == MQTT_PREFIX + "/nextapp")
|
||||||
|
{
|
||||||
|
DisplayManager.nextApp();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strTopic == MQTT_PREFIX + "/previousapp")
|
||||||
|
{
|
||||||
|
DisplayManager.previousApp();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
else if (strTopic.startsWith(MQTT_PREFIX + "/custom"))
|
else if (strTopic.startsWith(MQTT_PREFIX + "/custom"))
|
||||||
{
|
{
|
||||||
String topic_str = topic;
|
String topic_str = topic;
|
||||||
@@ -161,6 +179,9 @@ void onMqttConnected()
|
|||||||
mqtt.subscribe((prefix + String("/timer")).c_str());
|
mqtt.subscribe((prefix + String("/timer")).c_str());
|
||||||
mqtt.subscribe((prefix + String("/custom/#")).c_str());
|
mqtt.subscribe((prefix + String("/custom/#")).c_str());
|
||||||
mqtt.subscribe((prefix + String("/switch")).c_str());
|
mqtt.subscribe((prefix + String("/switch")).c_str());
|
||||||
|
mqtt.subscribe((prefix + String("/settings")).c_str());
|
||||||
|
mqtt.subscribe((prefix + String("/previousapp")).c_str());
|
||||||
|
mqtt.subscribe((prefix + String("/nextapp")).c_str());
|
||||||
Serial.println("MQTT Connected");
|
Serial.println("MQTT Connected");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -289,12 +289,12 @@ void MenuManager_::selectButtonLong()
|
|||||||
}
|
}
|
||||||
else if (currentState == TspeedMenu)
|
else if (currentState == TspeedMenu)
|
||||||
{
|
{
|
||||||
DisplayManager.setSettings();
|
DisplayManager.applyAllSettings();
|
||||||
saveSettings();
|
saveSettings();
|
||||||
}
|
}
|
||||||
else if (currentState == AppTimeMenu)
|
else if (currentState == AppTimeMenu)
|
||||||
{
|
{
|
||||||
DisplayManager.setSettings();
|
DisplayManager.applyAllSettings();
|
||||||
saveSettings();
|
saveSettings();
|
||||||
}
|
}
|
||||||
currentState = MainMenu;
|
currentState = MainMenu;
|
||||||
|
|||||||
@@ -206,7 +206,7 @@ void ServerManager_::loadSettings()
|
|||||||
SHOW_HUM = doc["Show humidity"];
|
SHOW_HUM = doc["Show humidity"];
|
||||||
SHOW_BATTERY = doc["Show battery"];
|
SHOW_BATTERY = doc["Show battery"];
|
||||||
file.close();
|
file.close();
|
||||||
DisplayManager.setSettings();
|
DisplayManager.applyAllSettings();
|
||||||
Serial.println(F("Configuration loaded"));
|
Serial.println(F("Configuration loaded"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user