diff --git a/src/app/crypto_ticker/crypto_ticker.cpp b/src/app/crypto_ticker/crypto_ticker.cpp index 7d84872..e366ee8 100644 --- a/src/app/crypto_ticker/crypto_ticker.cpp +++ b/src/app/crypto_ticker/crypto_ticker.cpp @@ -53,11 +53,17 @@ lv_obj_t *crypto_ticker_icon_info = NULL; LV_IMG_DECLARE(bitcoin_64px); LV_IMG_DECLARE(bitcoin_48px); LV_IMG_DECLARE(info_1_16px); + // declare callback functions static void enter_crypto_ticker_event_cb( lv_obj_t * obj, lv_event_t event ); +void crypto_ticker_load_config( void ); + // setup routine for example app void crypto_ticker_setup( void ) { + + crypto_ticker_load_config(); + // register 2 vertical tiles and get the first tile number and save it for later use crypto_ticker_main_tile_num = mainbar_add_app_tile( 1, 2 ); crypto_ticker_setup_tile_num = crypto_ticker_main_tile_num + 1; diff --git a/src/app/crypto_ticker/crypto_ticker_fetch.cpp b/src/app/crypto_ticker/crypto_ticker_fetch.cpp index 5411ba9..aac7985 100644 --- a/src/app/crypto_ticker/crypto_ticker_fetch.cpp +++ b/src/app/crypto_ticker/crypto_ticker_fetch.cpp @@ -35,12 +35,13 @@ int crypto_ticker_fetch_today( crypto_ticker_config_t *crypto_ticker_config, cry int httpcode = -1; - snprintf( url, sizeof( url ), "https://%s/api/v3/ticker/price?symbol=%s", OWM_HOST, crypto_ticker_config->symbol); + snprintf( url, sizeof( url ), "http://%s/api/CryptoTicker/Price/%s", MY_TTGO_WATCH_HOST, crypto_ticker_config->symbol); HTTPClient today_client; today_client.useHTTP10( true ); today_client.begin( url ); + today_client.addHeader("force-unsecure","true"); httpcode = today_client.GET(); if ( httpcode != 200 ) { @@ -49,7 +50,9 @@ int crypto_ticker_fetch_today( crypto_ticker_config_t *crypto_ticker_config, cry return( -1 ); } - SpiRamJsonDocument doc( today_client.getSize() * 2 ); + Serial.println(ESP.getFreeHeap()); + + SpiRamJsonDocument doc( 1000 ); DeserializationError error = deserializeJson( doc, today_client.getStream() ); if (error) { diff --git a/src/app/crypto_ticker/crypto_ticker_fetch.h b/src/app/crypto_ticker/crypto_ticker_fetch.h index 0a2d581..142b0c1 100644 --- a/src/app/crypto_ticker/crypto_ticker_fetch.h +++ b/src/app/crypto_ticker/crypto_ticker_fetch.h @@ -25,10 +25,7 @@ #ifndef _crypto_ticker_FETCH_H #define _crypto_ticker_FETCH_H - #define OWM_HOST "api.binance.com" - #define OWM_PORT 443 - - #define crypto_ticker_PRICE_BUFFER_SIZE 10000 + #define MY_TTGO_WATCH_HOST "my-ttgo-watch.co.uk" int crypto_ticker_fetch_today( crypto_ticker_config_t * crypto_ticker_config, crypto_ticker_widget_data_t * crypto_ticker_today ); diff --git a/src/app/crypto_ticker/crypto_ticker_widget.cpp b/src/app/crypto_ticker/crypto_ticker_widget.cpp index 7fad370..8b8b8f6 100644 --- a/src/app/crypto_ticker/crypto_ticker_widget.cpp +++ b/src/app/crypto_ticker/crypto_ticker_widget.cpp @@ -170,6 +170,7 @@ void crypto_ticker_widget_sync_Task( void * pvParameters ) { lv_img_set_src( crypto_ticker_widget_icon_info, &info_ok_16px ); lv_obj_set_hidden( crypto_ticker_widget_icon_info, false ); + lv_label_set_text( crypto_ticker_widget_label, crypto_ticker_widget_data.price); } else { lv_img_set_src( crypto_ticker_widget_icon_info, &info_fail_16px );