Minor corrections

This commit is contained in:
chrismcna
2020-08-23 18:10:08 +01:00
parent 06f248bcf5
commit 67e4490e6f
9 changed files with 48 additions and 31 deletions

View File

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

View File

@@ -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 <TTGO.h>
#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
#endif // _CRYPTO_TICKER_H

View File

@@ -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
#endif // _CRYPTO_TICKER_FETCH_H

View File

@@ -23,8 +23,14 @@
#include <TTGO.h>
#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 );
}

View File

@@ -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 <TTGO.h>
#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
#endif // _CRYPTO_TICKER_MAIN_H

View File

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

View File

@@ -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 <TTGO.h>
void crypto_ticker_setup_setup( uint32_t tile_num );
#endif // _crypto_ticker_SETUP_H
#endif // _CRYPTO_TICKER_SETUP_H

View File

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

View File

@@ -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 <TTGO.h>
#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
#endif // CRYPTO_TICKER_WIDGET_H