Skip to content

Commit 478c951

Browse files
committed
Improved multi-currency support, improved WebUI checks
1 parent 9c67f76 commit 478c951

File tree

9 files changed

+249
-31
lines changed

9 files changed

+249
-31
lines changed

data

Submodule data updated from 645c0f7 to e21b989

lib/btclock/data_handler.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ char getCurrencySymbol(char input)
1212
return '[';
1313
break;
1414
case CURRENCY_GBP:
15-
return '\\';
15+
return ']';
1616
break;
1717
case CURRENCY_JPY:
18-
return ']';
18+
return '^';
1919
break;
2020
case CURRENCY_AUD:
2121
case CURRENCY_CAD:
@@ -43,9 +43,6 @@ std::string getCurrencyCode(char input)
4343
case CURRENCY_AUD:
4444
return "AUD";
4545
break;
46-
case CURRENCY_CHF:
47-
return "CHF";
48-
break;
4946
case CURRENCY_CAD:
5047
return "CAD";
5148
break;

lib/btclock/data_handler.hpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@
77

88
const char CURRENCY_USD = '$';
99
const char CURRENCY_EUR = '[';
10-
const char CURRENCY_GBP = '\\';
11-
const char CURRENCY_JPY = ']';
12-
const char CURRENCY_AUD = '^';
13-
const char CURRENCY_CHF = '_';
10+
const char CURRENCY_GBP = ']';
11+
const char CURRENCY_JPY = '^';
12+
const char CURRENCY_AUD = '_';
1413
const char CURRENCY_CAD = '`';
1514

1615
std::array<std::string, NUM_SCREENS> parsePriceData(std::uint32_t price, char currency, bool useSuffixFormat = false);

src/fonts/antonio-semibold90.h

Lines changed: 233 additions & 4 deletions
Large diffs are not rendered by default.

src/lib/defaults.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
#define DEFAULT_SUFFIX_PRICE false
1717
#define DEFAULT_DISABLE_LEDS false
1818
#define DEFAULT_OWN_DATA_SOURCE true
19+
#define DEFAULT_STAGING_SOURCE false
20+
#define DEFAULT_V2_SOURCE_CURRENCY CURRENCY_USD
21+
1922

2023
#define DEFAULT_TIME_OFFSET_SECONDS 3600
2124

src/lib/epd.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ void prepareDisplayUpdateTask(void *pvParameters)
252252

253253
bool updatePartial = true;
254254

255-
if (strstr(epdContent[epdIndex].c_str(), "/") != NULL)
255+
if (epdContent[epdIndex].length() > 1 && strstr(epdContent[epdIndex].c_str(), "/") != NULL)
256256
{
257257
String top = epdContent[epdIndex].substring(
258258
0, epdContent[epdIndex].indexOf("/"));

src/lib/price_notify.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#include "price_notify.hpp"
22

33
const char *wsOwnServerPrice = "wss://ws.btclock.dev/ws?assets=bitcoin";
4+
const char *wsOwnServerV2 = "wss://ws-staging.btclock.dev/api/v2/ws";
5+
46
const char *wsServerPrice = "wss://ws.coincap.io/prices?assets=bitcoin";
57

68
// const char* coinCapWsCert = R"(-----BEGIN CERTIFICATE-----

src/lib/shared.hpp

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -48,20 +48,6 @@ const PROGMEM int screens[SCREEN_COUNT] = {
4848
const int usPerSecond = 1000000;
4949
const int usPerMinute = 60 * usPerSecond;
5050

51-
struct SpiRamAllocator : ArduinoJson::Allocator {
52-
void* allocate(size_t size) override {
53-
return heap_caps_malloc(size, MALLOC_CAP_SPIRAM);
54-
}
55-
56-
void deallocate(void* pointer) override {
57-
heap_caps_free(pointer);
58-
}
59-
60-
void* reallocate(void* ptr, size_t new_size) override {
61-
return heap_caps_realloc(ptr, new_size, MALLOC_CAP_SPIRAM);
62-
}
63-
};
64-
6551
struct ScreenMapping {
6652
int value;
6753
const char* name;

src/lib/webserver.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ void onApiSettingsPatch(AsyncWebServerRequest *request, JsonVariant &json)
455455
}
456456
}
457457

458-
String uintSettings[] = {"minSecPriceUpd", "fullRefreshMin", "ledBrightness", "flMaxBrightness", "flEffectDelay", "luxLightToggle", "wpTimeout"};
458+
String uintSettings[] = {"minSecPriceUpd", "fullRefreshMin", "ledBrightness", "flMaxBrightness", "flEffectDelay", "luxLightToggle", "wpTimeout", "srcV2Currency"};
459459

460460
for (String setting : uintSettings)
461461
{
@@ -478,7 +478,7 @@ void onApiSettingsPatch(AsyncWebServerRequest *request, JsonVariant &json)
478478
String boolSettings[] = {"fetchEurPrice", "ledTestOnPower", "ledFlashOnUpd",
479479
"mdnsEnabled", "otaEnabled", "stealFocus",
480480
"mcapBigChar", "useSatsSymbol", "useBlkCountdown",
481-
"suffixPrice", "disableLeds", "ownDataSource", "flAlwaysOn", "flFlashOnUpd", "mempoolSecure", "useNostr", "bitaxeEnabled", "nostrZapNotify"};
481+
"suffixPrice", "disableLeds", "ownDataSource", "flAlwaysOn", "flFlashOnUpd", "mempoolSecure", "useNostr", "bitaxeEnabled", "nostrZapNotify", "stagingSource"};
482482

483483
for (String setting : boolSettings)
484484
{
@@ -597,6 +597,8 @@ void onApiSettingsGet(AsyncWebServerRequest *request)
597597
root["ip"] = WiFi.localIP();
598598
root["txPower"] = WiFi.getTxPower();
599599
root["ownDataSource"] = preferences.getBool("ownDataSource", DEFAULT_OWN_DATA_SOURCE);
600+
root["stagingSource"] = preferences.getBool("stagingSource", DEFAULT_STAGING_SOURCE);
601+
root["srcV2Currency"] = preferences.getChar("srcV2Currency", DEFAULT_V2_SOURCE_CURRENCY);
600602

601603
root["nostrPubKey"] = preferences.getString("nostrPubKey", DEFAULT_NOSTR_NPUB);
602604
root["nostrRelay"] = preferences.getString("nostrRelay", DEFAULT_NOSTR_RELAY);

0 commit comments

Comments
 (0)