From f19eab36a921f45f708c970f195a4fb96832ef80 Mon Sep 17 00:00:00 2001 From: WantClue Date: Fri, 6 Dec 2024 15:51:53 +0100 Subject: [PATCH 1/2] update BTC price API --- src/monitor.cpp | 6 ++++-- src/monitor.h | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/monitor.cpp b/src/monitor.cpp index 9cd3e206..eb977f69 100644 --- a/src/monitor.cpp +++ b/src/monitor.cpp @@ -157,7 +157,9 @@ String getBTCprice(void){ DynamicJsonDocument doc(1024); deserializeJson(doc, payload); - if (doc.containsKey("last_trade_price")) bitcoin_price = doc["last_trade_price"]; + if (doc.containsKey("bpi") && doc["bpi"].containsKey("USD")) { + bitcoin_price = doc["bpi"]["USD"]["rate_float"].as(); + } doc.clear(); @@ -168,7 +170,7 @@ String getBTCprice(void){ } catch(...) { http.end(); } - } + } return (String(bitcoin_price) + "$"); } diff --git a/src/monitor.h b/src/monitor.h index dfe3791b..8d45ab1b 100644 --- a/src/monitor.h +++ b/src/monitor.h @@ -13,7 +13,7 @@ #define UPDATE_PERIOD_h 5 //API BTC price (Update to USDT cus it's more liquidity and flow price updade) -#define getBTCAPI "https://api.blockchain.com/v3/exchange/tickers/BTC-USDT" +#define getBTCAPI "https://api.coindesk.com/v1/bpi/currentprice.json" #define UPDATE_BTC_min 1 //API Block height From 26d8827f8bf7e2f72bb209248e98490e1adaed4b Mon Sep 17 00:00:00 2001 From: WantClue Date: Mon, 16 Dec 2024 15:41:41 +0100 Subject: [PATCH 2/2] update 2.8inch display to fit 6 figure price --- src/drivers/displays/esp23_2432s028r.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/drivers/displays/esp23_2432s028r.cpp b/src/drivers/displays/esp23_2432s028r.cpp index fe2545db..c2bd365b 100644 --- a/src/drivers/displays/esp23_2432s028r.cpp +++ b/src/drivers/displays/esp23_2432s028r.cpp @@ -462,7 +462,7 @@ void esp32_2432S028R_BTCprice(unsigned long mElapsed) // Delete sprite to free the memory heap background.deleteSprite(); - createBackgroundSprite(169,105); + createBackgroundSprite(180,105); // Print background screen background.pushImage(-130, -3, priceScreenWidth, priceScreenHeight, priceScreen);