Implement advanced text API call
This commit is contained in:
parent
2f39df176c
commit
b68c4a60e0
6 changed files with 1658 additions and 4 deletions
1630
src/fonts/antonio-semibold40.h
Normal file
1630
src/fonts/antonio-semibold40.h
Normal file
File diff suppressed because it is too large
Load diff
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
#include "antonio-semibold20.h"
|
#include "antonio-semibold20.h"
|
||||||
#include "antonio-semibold30.h"
|
#include "antonio-semibold30.h"
|
||||||
|
#include "antonio-semibold40.h"
|
||||||
#include "antonio-semibold90.h"
|
#include "antonio-semibold90.h"
|
||||||
// #include "oswald-20.h"
|
// #include "oswald-20.h"
|
||||||
// #include "oswald-30.h"
|
// #include "oswald-30.h"
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#define USER_AGENT "BTClock/2.0"
|
#define USER_AGENT "BTClock/2.0"
|
||||||
#define MCP_DEV_ADDR 0x20
|
#define MCP_DEV_ADDR 0x20
|
||||||
#define DEFAULT_SECONDS_BETWEEN_PRICE_UPDATE 30
|
#define DEFAULT_SECONDS_BETWEEN_PRICE_UPDATE 30
|
||||||
|
#define DEFAULT_MINUTES_FULL_REFRESH 60
|
||||||
|
|
||||||
#define DEFAULT_FG_COLOR GxEPD_WHITE
|
#define DEFAULT_FG_COLOR GxEPD_WHITE
|
||||||
#define DEFAULT_BG_COLOR GxEPD_BLACK
|
#define DEFAULT_BG_COLOR GxEPD_BLACK
|
||||||
|
|
|
@ -65,7 +65,7 @@ int bgColor = GxEPD_BLACK;
|
||||||
|
|
||||||
#define FONT_SMALL Antonio_SemiBold20pt7b
|
#define FONT_SMALL Antonio_SemiBold20pt7b
|
||||||
#define FONT_BIG Antonio_SemiBold90pt7b
|
#define FONT_BIG Antonio_SemiBold90pt7b
|
||||||
|
#define FONT_MEDIUM Antonio_SemiBold40pt7b
|
||||||
std::mutex epdUpdateMutex;
|
std::mutex epdUpdateMutex;
|
||||||
std::mutex epdMutex[NUM_SCREENS];
|
std::mutex epdMutex[NUM_SCREENS];
|
||||||
|
|
||||||
|
@ -187,7 +187,7 @@ void prepareDisplayUpdateTask(void *pvParameters)
|
||||||
|
|
||||||
if (epdContent[epdIndex].length() > 1)
|
if (epdContent[epdIndex].length() > 1)
|
||||||
{
|
{
|
||||||
showChars(epdIndex, epdContent[epdIndex], updatePartial, &Antonio_SemiBold30pt7b);
|
showChars(epdIndex, epdContent[epdIndex], updatePartial, &FONT_MEDIUM);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -227,7 +227,7 @@ extern "C" void updateDisplay(void *pvParameters) noexcept
|
||||||
bool updatePartial = true;
|
bool updatePartial = true;
|
||||||
|
|
||||||
// Full Refresh every x minutes
|
// Full Refresh every x minutes
|
||||||
if (!lastFullRefresh[epdIndex] || (millis() - lastFullRefresh[epdIndex]) > (preferences.getUInt("fullRefreshMin", 30) * 60 * 1000))
|
if (!lastFullRefresh[epdIndex] || (millis() - lastFullRefresh[epdIndex]) > (preferences.getUInt("fullRefreshMin", DEFAULT_MINUTES_FULL_REFRESH) * 60 * 1000))
|
||||||
{
|
{
|
||||||
updatePartial = false;
|
updatePartial = false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,6 +35,8 @@ void setupWebserver()
|
||||||
|
|
||||||
server.on("/api/show/screen", HTTP_GET, onApiShowScreen);
|
server.on("/api/show/screen", HTTP_GET, onApiShowScreen);
|
||||||
server.on("/api/show/text", HTTP_GET, onApiShowText);
|
server.on("/api/show/text", HTTP_GET, onApiShowText);
|
||||||
|
AsyncCallbackJsonWebHandler *handler = new AsyncCallbackJsonWebHandler("/api/show/custom", onApiShowTextAdvanced);
|
||||||
|
server.addHandler(handler);
|
||||||
|
|
||||||
server.on("/api/lights/off", HTTP_GET, onApiLightsOff);
|
server.on("/api/lights/off", HTTP_GET, onApiLightsOff);
|
||||||
server.on("/api/lights/color", HTTP_GET, onApiLightsSetColor);
|
server.on("/api/lights/color", HTTP_GET, onApiLightsSetColor);
|
||||||
|
@ -206,6 +208,24 @@ void onApiShowText(AsyncWebServerRequest *request)
|
||||||
request->send(200);
|
request->send(200);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void onApiShowTextAdvanced(AsyncWebServerRequest *request, JsonVariant &json)
|
||||||
|
{
|
||||||
|
JsonArray screens = json.as<JsonArray>();
|
||||||
|
|
||||||
|
std::array<String, NUM_SCREENS> epdContent;
|
||||||
|
int i = 0;
|
||||||
|
for (JsonVariant s : screens)
|
||||||
|
{
|
||||||
|
epdContent[i] = s.as<String>();
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
setEpdContent(epdContent);
|
||||||
|
|
||||||
|
setCurrentScreen(SCREEN_CUSTOM);
|
||||||
|
request->send(200);
|
||||||
|
}
|
||||||
|
|
||||||
void onApiRestart(AsyncWebServerRequest *request)
|
void onApiRestart(AsyncWebServerRequest *request)
|
||||||
{
|
{
|
||||||
request->send(200);
|
request->send(200);
|
||||||
|
@ -232,7 +252,7 @@ void onApiSettingsGet(AsyncWebServerRequest *request)
|
||||||
root["timerSeconds"] = getTimerSeconds();
|
root["timerSeconds"] = getTimerSeconds();
|
||||||
root["timerRunning"] = isTimerActive();
|
root["timerRunning"] = isTimerActive();
|
||||||
root["minSecPriceUpd"] = preferences.getUInt("minSecPriceUpd", DEFAULT_SECONDS_BETWEEN_PRICE_UPDATE);
|
root["minSecPriceUpd"] = preferences.getUInt("minSecPriceUpd", DEFAULT_SECONDS_BETWEEN_PRICE_UPDATE);
|
||||||
root["fullRefreshMin"] = preferences.getUInt("fullRefreshMin", 30);
|
root["fullRefreshMin"] = preferences.getUInt("fullRefreshMin", DEFAULT_MINUTES_FULL_REFRESH);
|
||||||
root["wpTimeout"] = preferences.getUInt("wpTimeout", 600);
|
root["wpTimeout"] = preferences.getUInt("wpTimeout", 600);
|
||||||
root["tzOffset"] = preferences.getInt("gmtOffset", TIME_OFFSET_SECONDS) / 60;
|
root["tzOffset"] = preferences.getInt("gmtOffset", TIME_OFFSET_SECONDS) / 60;
|
||||||
root["useBitcoinNode"] = preferences.getBool("useNode", false);
|
root["useBitcoinNode"] = preferences.getBool("useNode", false);
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include <ArduinoJson.h>
|
#include <ArduinoJson.h>
|
||||||
#include <LittleFS.h>
|
#include <LittleFS.h>
|
||||||
#include <ESPmDNS.h>
|
#include <ESPmDNS.h>
|
||||||
|
#include "AsyncJson.h"
|
||||||
|
|
||||||
#include "lib/block_notify.hpp"
|
#include "lib/block_notify.hpp"
|
||||||
#include "lib/price_notify.hpp"
|
#include "lib/price_notify.hpp"
|
||||||
|
@ -23,6 +24,7 @@ void onApiSystemStatus(AsyncWebServerRequest *request);
|
||||||
|
|
||||||
void onApiShowScreen(AsyncWebServerRequest *request);
|
void onApiShowScreen(AsyncWebServerRequest *request);
|
||||||
void onApiShowText(AsyncWebServerRequest *request);
|
void onApiShowText(AsyncWebServerRequest *request);
|
||||||
|
void onApiShowTextAdvanced(AsyncWebServerRequest *request, JsonVariant &json);
|
||||||
|
|
||||||
void onApiActionPause(AsyncWebServerRequest *request);
|
void onApiActionPause(AsyncWebServerRequest *request);
|
||||||
void onApiActionTimerRestart(AsyncWebServerRequest *request);
|
void onApiActionTimerRestart(AsyncWebServerRequest *request);
|
||||||
|
|
Loading…
Reference in a new issue