Merge pull request #536 from WantClue/master

update BTC price API
This commit is contained in:
BitMaker 2024-12-16 15:58:46 +01:00 committed by GitHub
commit c5f1e2d295
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 6 additions and 4 deletions

View File

@ -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);

View File

@ -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<unsigned int>();
}
doc.clear();
@ -168,7 +170,7 @@ String getBTCprice(void){
} catch(...) {
http.end();
}
}
}
return (String(bitcoin_price) + "$");
}

View File

@ -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