This commit is contained in:
chrismcna
2020-08-23 11:19:13 +01:00
parent 280ca88944
commit ea837c809e
4 changed files with 13 additions and 6 deletions

View File

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

View File

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

View File

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

View File

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