Skip to content

Commit

Permalink
Merge pull request #536 from WantClue/master
Browse files Browse the repository at this point in the history
update BTC price API
  • Loading branch information
BitMaker-hub authored Dec 16, 2024
2 parents f174d62 + 26d8827 commit c5f1e2d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/drivers/displays/esp23_2432s028r.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
6 changes: 4 additions & 2 deletions src/monitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -168,7 +170,7 @@ String getBTCprice(void){
} catch(...) {
http.end();
}
}
}

return (String(bitcoin_price) + "$");
}
Expand Down
2 changes: 1 addition & 1 deletion src/monitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c5f1e2d

Please sign in to comment.