reordering the directory structure
This commit is contained in:
@@ -23,8 +23,10 @@
|
||||
#include "../mainbar.h"
|
||||
#include "app_tile.h"
|
||||
|
||||
static lv_obj_t *applabel = NULL;
|
||||
lv_app_entry_t app_entry[ MAX_APPS_ICON ];
|
||||
|
||||
static lv_obj_t *app_cont = NULL;
|
||||
static lv_obj_t *applabel = NULL;
|
||||
static lv_style_t appstyle;
|
||||
|
||||
LV_FONT_DECLARE(Ubuntu_72px);
|
||||
@@ -32,6 +34,8 @@ LV_FONT_DECLARE(Ubuntu_16px);
|
||||
|
||||
void app_tile_setup( lv_obj_t *tile, lv_style_t *style, lv_coord_t hres, lv_coord_t vres ) {
|
||||
|
||||
app_cont = tile;
|
||||
|
||||
lv_style_copy( &appstyle, style);
|
||||
lv_style_set_text_font( &appstyle, LV_STATE_DEFAULT, &Ubuntu_72px);
|
||||
|
||||
@@ -40,4 +44,39 @@ void app_tile_setup( lv_obj_t *tile, lv_style_t *style, lv_coord_t hres, lv_coor
|
||||
lv_obj_reset_style_list( applabel, LV_OBJ_PART_MAIN );
|
||||
lv_obj_add_style( applabel, LV_OBJ_PART_MAIN, &appstyle );
|
||||
lv_obj_align(applabel, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
|
||||
for ( int app = 0 ; app < MAX_APPS_ICON ; app++ ) {
|
||||
// set x, y and mark it as inactive
|
||||
app_entry[ app ].x = APP_FIRST_X_POS + ( ( app % MAX_APPS_ICON_HORZ ) * ( APP_ICON_X_SIZE + APP_ICON_X_CLEARENCE ) );
|
||||
app_entry[ app ].y = APP_FIRST_Y_POS + ( ( app % MAX_APPS_ICON_VERT ) * ( APP_ICON_Y_SIZE + APP_ICON_Y_CLEARENCE ) );
|
||||
app_entry[ app ].active = false;
|
||||
// create app icon container
|
||||
app_entry[ app ].app = lv_obj_create( app_cont, NULL );
|
||||
lv_obj_reset_style_list( app_entry[ app ].app, LV_OBJ_PART_MAIN );
|
||||
lv_obj_add_style( app_entry[ app ].app, LV_OBJ_PART_MAIN, style );
|
||||
lv_obj_set_size( app_entry[ app ].app, APP_ICON_X_SIZE, APP_ICON_Y_SIZE );
|
||||
lv_obj_align( app_entry[ app ].app , app_cont, LV_ALIGN_IN_TOP_LEFT, app_entry[ app ].x, app_entry[ app ].y );
|
||||
// create app label
|
||||
app_entry[ app ].label = lv_label_create( app_cont, NULL );
|
||||
lv_obj_reset_style_list( app_entry[ app ].label, LV_OBJ_PART_MAIN );
|
||||
lv_obj_add_style( app_entry[ app ].label, LV_OBJ_PART_MAIN, style );
|
||||
lv_obj_set_size( app_entry[ app ].label, APP_LABEL_X_SIZE, APP_LABEL_Y_SIZE );
|
||||
lv_obj_align( app_entry[ app ].app , app_entry[ app ].app, LV_ALIGN_OUT_BOTTOM_MID, 0, 0 );
|
||||
|
||||
lv_obj_set_hidden( app_entry[ app ].app, true );
|
||||
lv_obj_set_hidden( app_entry[ app ].label, true );
|
||||
}
|
||||
}
|
||||
|
||||
lv_obj_t *app_tile_register_app( const char* appname ) {
|
||||
for( int app = 0 ; app < MAX_APPS_ICON ; app++ ) {
|
||||
if ( app_entry[ app ].active == false ) {
|
||||
app_entry[ app ].active = true;
|
||||
|
||||
|
||||
lv_obj_set_hidden( app_entry[ app ].app, false );
|
||||
return( app_entry[ app ].app );
|
||||
}
|
||||
}
|
||||
return( NULL );
|
||||
}
|
||||
|
||||
@@ -24,6 +24,28 @@
|
||||
|
||||
#include <TTGO.h>
|
||||
|
||||
#define MAX_APPS_ICON_HORZ 3
|
||||
#define MAX_APPS_ICON_VERT 2
|
||||
#define MAX_APPS_ICON ( MAX_APPS_ICON_HORZ * MAX_APPS_ICON_VERT )
|
||||
|
||||
#define APP_ICON_X_SIZE 48
|
||||
#define APP_ICON_Y_SIZE 48
|
||||
#define APP_ICON_X_CLEARENCE 32
|
||||
#define APP_ICON_Y_CLEARENCE 32
|
||||
#define APP_LABEL_X_SIZE APP_ICON_X_SIZE + APP_ICON_X_CLEARENCE
|
||||
#define APP_LABEL_Y_SIZE APP_ICON_Y_CLEARENCE / 2
|
||||
|
||||
#define APP_FIRST_X_POS ( 240 - ( APP_ICON_X_SIZE * MAX_APPS_ICON_HORZ + APP_ICON_X_CLEARENCE * ( MAX_APPS_ICON_HORZ - 1 ) ) ) / 2
|
||||
#define APP_FIRST_Y_POS ( 240 - ( APP_ICON_Y_SIZE * MAX_APPS_ICON_VERT + APP_ICON_Y_CLEARENCE * ( MAX_APPS_ICON_VERT - 1 ) ) ) / 2
|
||||
|
||||
typedef struct {
|
||||
lv_obj_t *app;
|
||||
lv_obj_t *label;
|
||||
lv_coord_t x;
|
||||
lv_coord_t y;
|
||||
bool active;
|
||||
} lv_app_entry_t;
|
||||
|
||||
void app_tile_setup( lv_obj_t *tile, lv_style_t *style, lv_coord_t hres, lv_coord_t vres );
|
||||
|
||||
#endif // _APP_TILE_H
|
||||
@@ -33,7 +33,7 @@ uint64_t update_check_new_version( void ) {
|
||||
uint64_t retval = -1;
|
||||
|
||||
if ( !check_version_client.connect( FIRMWARE_HOST, FIRMWARE_HOST_PORT ) ) {
|
||||
Serial.printf("connection failed\r\n");
|
||||
Serial.printf( __FILE__ "connection failed\r\n");
|
||||
return( -1 );
|
||||
}
|
||||
|
||||
@@ -48,15 +48,15 @@ uint64_t update_check_new_version( void ) {
|
||||
uint64_t startMillis = millis();
|
||||
while ( check_version_client.available() == 0 ) {
|
||||
if ( millis() - startMillis > 5000 ) {
|
||||
Serial.printf("connection timeout\r\n");
|
||||
Serial.printf( __FILE__ "connection timeout\r\n");
|
||||
check_version_client.stop();
|
||||
return( retval );
|
||||
}
|
||||
}
|
||||
|
||||
char *json = (char *)ps_malloc( 100 );
|
||||
char *json = (char *)ps_malloc( 200 );
|
||||
if ( json == NULL ) {
|
||||
Serial.printf("memory alloc failed\r\n");
|
||||
Serial.printf( __FILE__ "memory alloc failed\r\n");
|
||||
check_version_client.stop();
|
||||
return( retval );
|
||||
}
|
||||
@@ -82,11 +82,11 @@ uint64_t update_check_new_version( void ) {
|
||||
}
|
||||
check_version_client.stop();
|
||||
|
||||
DynamicJsonDocument doc(200);
|
||||
DynamicJsonDocument doc( 400 );
|
||||
|
||||
DeserializationError error = deserializeJson( doc, json);
|
||||
if (error) {
|
||||
Serial.print(F("deserializeJson() failed: "));
|
||||
Serial.print(F( __FILE__ "update version deserializeJson() failed: "));
|
||||
Serial.println(error.c_str());
|
||||
doc.clear();
|
||||
free( json );
|
||||
|
||||
Reference in New Issue
Block a user