Improved multi-currency support, improved WebUI checks

This commit is contained in:
Djuri 2024-08-31 23:11:48 +02:00
parent 9c67f769d3
commit 478c951ffb
9 changed files with 249 additions and 31 deletions

View file

@ -16,6 +16,9 @@
#define DEFAULT_SUFFIX_PRICE false
#define DEFAULT_DISABLE_LEDS false
#define DEFAULT_OWN_DATA_SOURCE true
#define DEFAULT_STAGING_SOURCE false
#define DEFAULT_V2_SOURCE_CURRENCY CURRENCY_USD
#define DEFAULT_TIME_OFFSET_SECONDS 3600

View file

@ -252,7 +252,7 @@ void prepareDisplayUpdateTask(void *pvParameters)
bool updatePartial = true;
if (strstr(epdContent[epdIndex].c_str(), "/") != NULL)
if (epdContent[epdIndex].length() > 1 && strstr(epdContent[epdIndex].c_str(), "/") != NULL)
{
String top = epdContent[epdIndex].substring(
0, epdContent[epdIndex].indexOf("/"));

View file

@ -1,6 +1,8 @@
#include "price_notify.hpp"
const char *wsOwnServerPrice = "wss://ws.btclock.dev/ws?assets=bitcoin";
const char *wsOwnServerV2 = "wss://ws-staging.btclock.dev/api/v2/ws";
const char *wsServerPrice = "wss://ws.coincap.io/prices?assets=bitcoin";
// const char* coinCapWsCert = R"(-----BEGIN CERTIFICATE-----

View file

@ -48,20 +48,6 @@ const PROGMEM int screens[SCREEN_COUNT] = {
const int usPerSecond = 1000000;
const int usPerMinute = 60 * usPerSecond;
struct SpiRamAllocator : ArduinoJson::Allocator {
void* allocate(size_t size) override {
return heap_caps_malloc(size, MALLOC_CAP_SPIRAM);
}
void deallocate(void* pointer) override {
heap_caps_free(pointer);
}
void* reallocate(void* ptr, size_t new_size) override {
return heap_caps_realloc(ptr, new_size, MALLOC_CAP_SPIRAM);
}
};
struct ScreenMapping {
int value;
const char* name;

View file

@ -455,7 +455,7 @@ void onApiSettingsPatch(AsyncWebServerRequest *request, JsonVariant &json)
}
}
String uintSettings[] = {"minSecPriceUpd", "fullRefreshMin", "ledBrightness", "flMaxBrightness", "flEffectDelay", "luxLightToggle", "wpTimeout"};
String uintSettings[] = {"minSecPriceUpd", "fullRefreshMin", "ledBrightness", "flMaxBrightness", "flEffectDelay", "luxLightToggle", "wpTimeout", "srcV2Currency"};
for (String setting : uintSettings)
{
@ -478,7 +478,7 @@ void onApiSettingsPatch(AsyncWebServerRequest *request, JsonVariant &json)
String boolSettings[] = {"fetchEurPrice", "ledTestOnPower", "ledFlashOnUpd",
"mdnsEnabled", "otaEnabled", "stealFocus",
"mcapBigChar", "useSatsSymbol", "useBlkCountdown",
"suffixPrice", "disableLeds", "ownDataSource", "flAlwaysOn", "flFlashOnUpd", "mempoolSecure", "useNostr", "bitaxeEnabled", "nostrZapNotify"};
"suffixPrice", "disableLeds", "ownDataSource", "flAlwaysOn", "flFlashOnUpd", "mempoolSecure", "useNostr", "bitaxeEnabled", "nostrZapNotify", "stagingSource"};
for (String setting : boolSettings)
{
@ -597,6 +597,8 @@ void onApiSettingsGet(AsyncWebServerRequest *request)
root["ip"] = WiFi.localIP();
root["txPower"] = WiFi.getTxPower();
root["ownDataSource"] = preferences.getBool("ownDataSource", DEFAULT_OWN_DATA_SOURCE);
root["stagingSource"] = preferences.getBool("stagingSource", DEFAULT_STAGING_SOURCE);
root["srcV2Currency"] = preferences.getChar("srcV2Currency", DEFAULT_V2_SOURCE_CURRENCY);
root["nostrPubKey"] = preferences.getString("nostrPubKey", DEFAULT_NOSTR_NPUB);
root["nostrRelay"] = preferences.getString("nostrRelay", DEFAULT_NOSTR_RELAY);