From 67e4490e6f099b029339fbf05d6bae3dfbe377d3 Mon Sep 17 00:00:00 2001 From: chrismcna Date: Sun, 23 Aug 2020 18:10:08 +0100 Subject: [PATCH] Minor corrections --- src/app/crypto_ticker/crypto_ticker.cpp | 9 ++++++-- src/app/crypto_ticker/crypto_ticker.h | 10 ++++----- src/app/crypto_ticker/crypto_ticker_fetch.h | 6 ++--- src/app/crypto_ticker/crypto_ticker_main.cpp | 22 ++++++++++++++----- src/app/crypto_ticker/crypto_ticker_main.h | 8 +++---- src/app/crypto_ticker/crypto_ticker_setup.cpp | 2 +- src/app/crypto_ticker/crypto_ticker_setup.h | 6 ++--- .../crypto_ticker/crypto_ticker_widget.cpp | 8 +++---- src/app/crypto_ticker/crypto_ticker_widget.h | 8 +++---- 9 files changed, 48 insertions(+), 31 deletions(-) diff --git a/src/app/crypto_ticker/crypto_ticker.cpp b/src/app/crypto_ticker/crypto_ticker.cpp index e366ee8..3b92822 100644 --- a/src/app/crypto_ticker/crypto_ticker.cpp +++ b/src/app/crypto_ticker/crypto_ticker.cpp @@ -26,8 +26,13 @@ #include "crypto_ticker_fetch.h" #include "crypto_ticker_main.h" #include "crypto_ticker_setup.h" + +#ifdef CRYPTO_TICKER_WIDGET + #include "crypto_ticker_widget.h" +#endif // CRYPTO_TICKER_WIDGET + #include "gui/mainbar/app_tile/app_tile.h" #include "gui/mainbar/main_tile/main_tile.h" #include "gui/mainbar/mainbar.h" @@ -112,7 +117,7 @@ uint32_t crypto_ticker_get_app_setup_tile_num( void ) { return( crypto_ticker_setup_tile_num ); } -void crypto_ticker_jump_to_forecast( void ) { +void crypto_ticker_jump_to_main( void ) { statusbar_hide( true ); mainbar_jump_to_tilenumber( crypto_ticker_main_tile_num, LV_ANIM_ON ); } @@ -127,7 +132,7 @@ void crypto_ticker_jump_to_setup( void ) { */ static void enter_crypto_ticker_event_cb( lv_obj_t * obj, lv_event_t event ) { switch( event ) { - case( LV_EVENT_CLICKED ): crypto_ticker_jump_to_forecast(); + case( LV_EVENT_CLICKED ): crypto_ticker_jump_to_main(); break; } } diff --git a/src/app/crypto_ticker/crypto_ticker.h b/src/app/crypto_ticker/crypto_ticker.h index a8fb500..6709dec 100644 --- a/src/app/crypto_ticker/crypto_ticker.h +++ b/src/app/crypto_ticker/crypto_ticker.h @@ -19,12 +19,12 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#ifndef _crypto_ticker_H - #define _crypto_ticker_H +#ifndef _CRYPTO_TICKER_H + #define _CRYPTO_TICKER_H #include - #define CRYPTO_TICKER_WIDGET // uncomment if an widget need + //#define CRYPTO_TICKER_WIDGET // uncomment if an widget need, comment to hide #define crypto_ticker_JSON_CONFIG_FILE "/crypto-ticker.json" @@ -42,9 +42,9 @@ void crypto_ticker_hide_widget_icon_info( bool show ); uint32_t crypto_ticker_get_app_setup_tile_num( void ); uint32_t crypto_ticker_get_app_main_tile_num( void ); - void crypto_ticker_jump_to_forecast( void ) ; + void crypto_ticker_jump_to_main( void ) ; void crypto_ticker_jump_to_setup( void ); void crypto_ticker_save_config( void ); -#endif // _crypto_ticker_H \ No newline at end of file +#endif // _CRYPTO_TICKER_H \ No newline at end of file diff --git a/src/app/crypto_ticker/crypto_ticker_fetch.h b/src/app/crypto_ticker/crypto_ticker_fetch.h index 7f14776..b57229f 100644 --- a/src/app/crypto_ticker/crypto_ticker_fetch.h +++ b/src/app/crypto_ticker/crypto_ticker_fetch.h @@ -23,12 +23,12 @@ #include "crypto_ticker_widget.h" //TODO: why is this needed #include "crypto_ticker_main.h" //TODO: why is this needed -#ifndef _crypto_ticker_FETCH_H - #define _crypto_ticker_FETCH_H +#ifndef _CRYPTO_TICKER_FETCH_H + #define _CRYPTO_TICKER_FETCH_H #define MY_TTGO_WATCH_HOST "my-ttgo-watch.co.uk" int crypto_ticker_fetch_price( crypto_ticker_config_t * crypto_ticker_config, crypto_ticker_widget_data_t * crypto_ticker_today ); int crypto_ticker_fetch_statistics( crypto_ticker_config_t *crypto_ticker_config, crypto_ticker_main_data_t *crypto_ticker_main_data ); -#endif // _crypto_ticker_FETCH_H \ No newline at end of file +#endif // _CRYPTO_TICKER_FETCH_H \ No newline at end of file diff --git a/src/app/crypto_ticker/crypto_ticker_main.cpp b/src/app/crypto_ticker/crypto_ticker_main.cpp index 85ed1ed..81f306b 100644 --- a/src/app/crypto_ticker/crypto_ticker_main.cpp +++ b/src/app/crypto_ticker/crypto_ticker_main.cpp @@ -23,8 +23,14 @@ #include #include "crypto_ticker.h" -#include "crypto_ticker_main.h" #include "crypto_ticker_fetch.h" +#include "crypto_ticker_main.h" + +#ifdef CRYPTO_TICKER_WIDGET + +#include "crypto_ticker_widget.h" + +#endif // CRYPTO_TICKER_WIDGET #include "gui/mainbar/app_tile/app_tile.h" #include "gui/mainbar/main_tile/main_tile.h" @@ -173,17 +179,23 @@ static void exit_crypto_ticker_main_event_cb( lv_obj_t * obj, lv_event_t event ) static void refresh_crypto_ticker_main_event_cb( lv_obj_t * obj, lv_event_t event ) { switch( event ) { case( LV_EVENT_CLICKED ): crypto_ticker_main_sync_request(); + +#ifdef CRYPTO_TICKER_WIDGET + + crypto_ticker_widget_sync_request(); + +#endif // CRYPTO_TICKER_WIDGET break; } } void crypto_ticker_main_sync_request( void ) { - if ( xEventGroupGetBits( crypto_ticker_main_event_handle ) & crypto_ticker_main_SYNC_REQUEST ) { + if ( xEventGroupGetBits( crypto_ticker_main_event_handle ) & CRYPTO_TICKER_MAIN_SYNC_REQUEST ) { return; } else { - xEventGroupSetBits( crypto_ticker_main_event_handle, crypto_ticker_main_SYNC_REQUEST ); + xEventGroupSetBits( crypto_ticker_main_event_handle, CRYPTO_TICKER_MAIN_SYNC_REQUEST ); xTaskCreate( crypto_ticker_main_sync_Task, /* Function to implement the task */ "crypto ticker main sync Task", /* Name of the task */ 5000, /* Stack size in words */ @@ -201,7 +213,7 @@ void crypto_ticker_main_sync_Task( void * pvParameters ) { vTaskDelay( 250 ); - if ( xEventGroupGetBits( crypto_ticker_main_event_handle ) & crypto_ticker_main_SYNC_REQUEST ) { + if ( xEventGroupGetBits( crypto_ticker_main_event_handle ) & CRYPTO_TICKER_MAIN_SYNC_REQUEST ) { if ( crypto_ticker_config->autosync ) { retval = crypto_ticker_fetch_statistics( crypto_ticker_config , &crypto_ticker_main_data ); if ( retval == 200 ) { @@ -228,6 +240,6 @@ void crypto_ticker_main_sync_Task( void * pvParameters ) { } } } - xEventGroupClearBits( crypto_ticker_main_event_handle, crypto_ticker_main_SYNC_REQUEST ); + xEventGroupClearBits( crypto_ticker_main_event_handle, CRYPTO_TICKER_MAIN_SYNC_REQUEST ); vTaskDelete( NULL ); } \ No newline at end of file diff --git a/src/app/crypto_ticker/crypto_ticker_main.h b/src/app/crypto_ticker/crypto_ticker_main.h index 40b6047..5521532 100644 --- a/src/app/crypto_ticker/crypto_ticker_main.h +++ b/src/app/crypto_ticker/crypto_ticker_main.h @@ -19,12 +19,12 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#ifndef _crypto_ticker_MAIN_H - #define _crypto_ticker_MAIN_H +#ifndef _CRYPTO_TICKER_MAIN_H + #define _CRYPTO_TICKER_MAIN_H #include - #define crypto_ticker_main_SYNC_REQUEST _BV(0) + #define CRYPTO_TICKER_MAIN_SYNC_REQUEST _BV(0) typedef struct { bool valide = false; @@ -37,4 +37,4 @@ void crypto_ticker_main_setup( uint32_t tile_num ); void crypto_ticker_main_sync_request( void ); -#endif // _crypto_ticker_MAIN_H \ No newline at end of file +#endif // _CRYPTO_TICKER_MAIN_H \ No newline at end of file diff --git a/src/app/crypto_ticker/crypto_ticker_setup.cpp b/src/app/crypto_ticker/crypto_ticker_setup.cpp index 72501ff..e89fcfc 100644 --- a/src/app/crypto_ticker/crypto_ticker_setup.cpp +++ b/src/app/crypto_ticker/crypto_ticker_setup.cpp @@ -133,7 +133,7 @@ static void exit_crypto_ticker_setup_event_cb( lv_obj_t * obj, lv_event_t event crypto_ticker_config_t *crypto_ticker_config = crypto_ticker_get_config(); strlcpy( crypto_ticker_config->symbol, lv_textarea_get_text( crypto_ticker_symbol_textfield ), sizeof( crypto_ticker_config->symbol ) ); crypto_ticker_save_config(); - crypto_ticker_jump_to_forecast(); + crypto_ticker_jump_to_main(); break; } } diff --git a/src/app/crypto_ticker/crypto_ticker_setup.h b/src/app/crypto_ticker/crypto_ticker_setup.h index 43e7caa..f8c0203 100644 --- a/src/app/crypto_ticker/crypto_ticker_setup.h +++ b/src/app/crypto_ticker/crypto_ticker_setup.h @@ -19,11 +19,11 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#ifndef _crypto_ticker_SETUP_H - #define _crypto_ticker_SETUP_H +#ifndef _CRYPTO_TICKER_SETUP_H + #define _CRYPTO_TICKER_SETUP_H #include void crypto_ticker_setup_setup( uint32_t tile_num ); -#endif // _crypto_ticker_SETUP_H \ No newline at end of file +#endif // _CRYPTO_TICKER_SETUP_H \ No newline at end of file diff --git a/src/app/crypto_ticker/crypto_ticker_widget.cpp b/src/app/crypto_ticker/crypto_ticker_widget.cpp index 9c202f0..b8789a1 100644 --- a/src/app/crypto_ticker/crypto_ticker_widget.cpp +++ b/src/app/crypto_ticker/crypto_ticker_widget.cpp @@ -141,11 +141,11 @@ static void enter_crypto_ticker_widget_event_cb( lv_obj_t * obj, lv_event_t even void crypto_ticker_widget_sync_request( void ) { - if ( xEventGroupGetBits( crypto_ticker_widget_event_handle ) & crypto_ticker_widget_SYNC_REQUEST ) { + if ( xEventGroupGetBits( crypto_ticker_widget_event_handle ) & CRYPTO_TICKER_WIDGET_SYNC_REQUEST ) { return; } else { - xEventGroupSetBits( crypto_ticker_widget_event_handle, crypto_ticker_widget_SYNC_REQUEST ); + xEventGroupSetBits( crypto_ticker_widget_event_handle, CRYPTO_TICKER_WIDGET_SYNC_REQUEST ); lv_obj_set_hidden( crypto_ticker_widget_icon_info, true ); xTaskCreate( crypto_ticker_widget_sync_Task, /* Function to implement the task */ "crypto_ticker widget sync Task", /* Name of the task */ @@ -164,7 +164,7 @@ void crypto_ticker_widget_sync_Task( void * pvParameters ) { vTaskDelay( 250 ); - if ( xEventGroupGetBits( crypto_ticker_widget_event_handle ) & crypto_ticker_widget_SYNC_REQUEST ) { + if ( xEventGroupGetBits( crypto_ticker_widget_event_handle ) & CRYPTO_TICKER_WIDGET_SYNC_REQUEST ) { uint32_t retval = crypto_ticker_fetch_price(crypto_ticker_get_config() , &crypto_ticker_widget_data ); if ( retval == 200 ) { @@ -179,7 +179,7 @@ void crypto_ticker_widget_sync_Task( void * pvParameters ) { } lv_obj_invalidate( lv_scr_act() ); } - xEventGroupClearBits( crypto_ticker_widget_event_handle, crypto_ticker_widget_SYNC_REQUEST ); + xEventGroupClearBits( crypto_ticker_widget_event_handle, CRYPTO_TICKER_WIDGET_SYNC_REQUEST ); vTaskDelete( NULL ); } diff --git a/src/app/crypto_ticker/crypto_ticker_widget.h b/src/app/crypto_ticker/crypto_ticker_widget.h index bf89d1e..5f513c2 100644 --- a/src/app/crypto_ticker/crypto_ticker_widget.h +++ b/src/app/crypto_ticker/crypto_ticker_widget.h @@ -19,12 +19,12 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#ifndef crypto_ticker_widget_H - #define crypto_ticker_widget_H +#ifndef CRYPTO_TICKER_WIDGET_H + #define CRYPTO_TICKER_WIDGET_H #include - #define crypto_ticker_widget_SYNC_REQUEST _BV(0) + #define CRYPTO_TICKER_WIDGET_SYNC_REQUEST _BV(0) typedef struct { @@ -38,4 +38,4 @@ void crypto_ticker_widget_sync_request( void ); -#endif // crypto_ticker_widget_H \ No newline at end of file +#endif // CRYPTO_TICKER_WIDGET_H \ No newline at end of file