more tweaks
This commit is contained in:
@@ -31,6 +31,6 @@
|
|||||||
/*
|
/*
|
||||||
* firmeware version string
|
* firmeware version string
|
||||||
*/
|
*/
|
||||||
#define __FIRMWARE__ "2020072403"
|
#define __FIRMWARE__ "2020072408"
|
||||||
|
|
||||||
#endif // _CONFIG_H
|
#endif // _CONFIG_H
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ void battery_settings_tile_setup( lv_obj_t *tile, lv_style_t *style, lv_coord_t
|
|||||||
lv_obj_align( battery_design_cap_label, battery_design_cont, LV_ALIGN_IN_LEFT_MID, 5, 0 );
|
lv_obj_align( battery_design_cap_label, battery_design_cont, LV_ALIGN_IN_LEFT_MID, 5, 0 );
|
||||||
battery_design_cap = lv_label_create( battery_design_cont, NULL);
|
battery_design_cap = lv_label_create( battery_design_cont, NULL);
|
||||||
lv_obj_add_style( battery_design_cap, LV_OBJ_PART_MAIN, style );
|
lv_obj_add_style( battery_design_cap, LV_OBJ_PART_MAIN, style );
|
||||||
lv_label_set_text( battery_design_cap, "350mAh");
|
lv_label_set_text( battery_design_cap, "300mAh");
|
||||||
lv_obj_align( battery_design_cap, battery_design_cont, LV_ALIGN_IN_RIGHT_MID, -5, 0 );
|
lv_obj_align( battery_design_cap, battery_design_cont, LV_ALIGN_IN_RIGHT_MID, -5, 0 );
|
||||||
|
|
||||||
lv_obj_t *battery_current_cont = lv_obj_create( battery_settings_tile, NULL );
|
lv_obj_t *battery_current_cont = lv_obj_create( battery_settings_tile, NULL );
|
||||||
@@ -94,7 +94,7 @@ void battery_settings_tile_setup( lv_obj_t *tile, lv_style_t *style, lv_coord_t
|
|||||||
lv_obj_align( battery_current_cap_label, battery_current_cont, LV_ALIGN_IN_LEFT_MID, 5, 0 );
|
lv_obj_align( battery_current_cap_label, battery_current_cont, LV_ALIGN_IN_LEFT_MID, 5, 0 );
|
||||||
battery_current_cap = lv_label_create( battery_current_cont, NULL);
|
battery_current_cap = lv_label_create( battery_current_cont, NULL);
|
||||||
lv_obj_add_style( battery_current_cap, LV_OBJ_PART_MAIN, style );
|
lv_obj_add_style( battery_current_cap, LV_OBJ_PART_MAIN, style );
|
||||||
lv_label_set_text( battery_current_cap, "380mAh");
|
lv_label_set_text( battery_current_cap, "300mAh");
|
||||||
lv_obj_align( battery_current_cap, battery_current_cont, LV_ALIGN_IN_RIGHT_MID, -5, 0 );
|
lv_obj_align( battery_current_cap, battery_current_cont, LV_ALIGN_IN_RIGHT_MID, -5, 0 );
|
||||||
|
|
||||||
lv_obj_t *battery_voltage_cont = lv_obj_create( battery_settings_tile, NULL );
|
lv_obj_t *battery_voltage_cont = lv_obj_create( battery_settings_tile, NULL );
|
||||||
|
|||||||
@@ -31,6 +31,8 @@
|
|||||||
#include "gui/keyboard.h"
|
#include "gui/keyboard.h"
|
||||||
#include "images/resolve_owm_icon.h"
|
#include "images/resolve_owm_icon.h"
|
||||||
|
|
||||||
|
#include "hardware/motor.h"
|
||||||
|
|
||||||
EventGroupHandle_t weather_widget_event_handle = NULL;
|
EventGroupHandle_t weather_widget_event_handle = NULL;
|
||||||
TaskHandle_t _weather_widget_sync_Task;
|
TaskHandle_t _weather_widget_sync_Task;
|
||||||
void weather_widget_sync_Task( void * pvParameters );
|
void weather_widget_sync_Task( void * pvParameters );
|
||||||
@@ -97,7 +99,8 @@ void weather_widget_setup( void ) {
|
|||||||
|
|
||||||
static void enter_weather_widget_event_cb( lv_obj_t * obj, lv_event_t event ) {
|
static void enter_weather_widget_event_cb( lv_obj_t * obj, lv_event_t event ) {
|
||||||
switch( event ) {
|
switch( event ) {
|
||||||
case( LV_EVENT_CLICKED ): mainbar_jump_to_tilenumber( weather_widget_tile_num, LV_ANIM_OFF );
|
case( LV_EVENT_CLICKED ): motor_vibe( 1 );
|
||||||
|
mainbar_jump_to_tilenumber( weather_widget_tile_num, LV_ANIM_OFF );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ void weather_fetch_today( weather_config_t *weather_config, weather_forcast_t *w
|
|||||||
|
|
||||||
uint64_t startMillis = millis();
|
uint64_t startMillis = millis();
|
||||||
while ( today_client.available() == 0 ) {
|
while ( today_client.available() == 0 ) {
|
||||||
|
yield();
|
||||||
if ( millis() - startMillis > 5000 ) {
|
if ( millis() - startMillis > 5000 ) {
|
||||||
today_client.stop();
|
today_client.stop();
|
||||||
return;
|
return;
|
||||||
@@ -61,6 +62,7 @@ void weather_fetch_today( weather_config_t *weather_config, weather_forcast_t *w
|
|||||||
|
|
||||||
bool data_begin = false;
|
bool data_begin = false;
|
||||||
while( today_client.available() ) {
|
while( today_client.available() ) {
|
||||||
|
yield();
|
||||||
if ( data_begin ) {
|
if ( data_begin ) {
|
||||||
*ptr = today_client.read();
|
*ptr = today_client.read();
|
||||||
ptr++;
|
ptr++;
|
||||||
@@ -76,6 +78,7 @@ void weather_fetch_today( weather_config_t *weather_config, weather_forcast_t *w
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
yield();
|
||||||
today_client.stop();
|
today_client.stop();
|
||||||
|
|
||||||
DynamicJsonDocument doc(20000);
|
DynamicJsonDocument doc(20000);
|
||||||
@@ -89,6 +92,7 @@ void weather_fetch_today( weather_config_t *weather_config, weather_forcast_t *w
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
yield();
|
||||||
weather_today->valide = true;
|
weather_today->valide = true;
|
||||||
snprintf( weather_today->temp, sizeof( weather_today->temp ),"%0.1f°C", doc["main"]["temp"].as<float>() - 273.15 );
|
snprintf( weather_today->temp, sizeof( weather_today->temp ),"%0.1f°C", doc["main"]["temp"].as<float>() - 273.15 );
|
||||||
snprintf( weather_today->humidity, sizeof( weather_today->humidity ),"%f%%", doc["main"]["humidity"].as<float>() );
|
snprintf( weather_today->humidity, sizeof( weather_today->humidity ),"%f%%", doc["main"]["humidity"].as<float>() );
|
||||||
@@ -121,6 +125,7 @@ void weather_fetch_forecast( weather_config_t *weather_config, weather_forcast_t
|
|||||||
|
|
||||||
uint64_t startMillis = millis();
|
uint64_t startMillis = millis();
|
||||||
while ( forecast_client.available() == 0 ) {
|
while ( forecast_client.available() == 0 ) {
|
||||||
|
yield();
|
||||||
if ( millis() - startMillis > 5000 ) {
|
if ( millis() - startMillis > 5000 ) {
|
||||||
forecast_client.stop();
|
forecast_client.stop();
|
||||||
return;
|
return;
|
||||||
@@ -132,6 +137,7 @@ void weather_fetch_forecast( weather_config_t *weather_config, weather_forcast_t
|
|||||||
|
|
||||||
bool data_begin = false;
|
bool data_begin = false;
|
||||||
while( forecast_client.available() ) {
|
while( forecast_client.available() ) {
|
||||||
|
yield();
|
||||||
if ( data_begin ) {
|
if ( data_begin ) {
|
||||||
ptr[ forecast_client.readBytes( ptr, 40000 ) ] = '\0';
|
ptr[ forecast_client.readBytes( ptr, 40000 ) ] = '\0';
|
||||||
}
|
}
|
||||||
@@ -149,6 +155,7 @@ void weather_fetch_forecast( weather_config_t *weather_config, weather_forcast_t
|
|||||||
free( json );
|
free( json );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
yield();
|
||||||
|
|
||||||
DynamicJsonDocument doc(20000);
|
DynamicJsonDocument doc(20000);
|
||||||
DeserializationError error = deserializeJson( doc, json );
|
DeserializationError error = deserializeJson( doc, json );
|
||||||
@@ -160,6 +167,7 @@ void weather_fetch_forecast( weather_config_t *weather_config, weather_forcast_t
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
yield();
|
||||||
weather_forecast[0].valide = true;
|
weather_forecast[0].valide = true;
|
||||||
for ( int i = 0 ; i < WEATHER_MAX_FORECAST ; i++ ) {
|
for ( int i = 0 ; i < WEATHER_MAX_FORECAST ; i++ ) {
|
||||||
snprintf( weather_forecast[ i ].temp, sizeof( weather_forecast[ i ].temp ),"%0.1f°C", doc["list"][i]["main"]["temp"].as<float>() - 273.15 );
|
snprintf( weather_forecast[ i ].temp, sizeof( weather_forecast[ i ].temp ),"%0.1f°C", doc["list"][i]["main"]["temp"].as<float>() - 273.15 );
|
||||||
|
|||||||
@@ -32,12 +32,15 @@
|
|||||||
#include "gui/statusbar.h"
|
#include "gui/statusbar.h"
|
||||||
#include "gui/keyboard.h"
|
#include "gui/keyboard.h"
|
||||||
|
|
||||||
|
#include "hardware/motor.h"
|
||||||
|
|
||||||
EventGroupHandle_t weather_forecast_event_handle = NULL;
|
EventGroupHandle_t weather_forecast_event_handle = NULL;
|
||||||
TaskHandle_t _weather_forecast_sync_Task;
|
TaskHandle_t _weather_forecast_sync_Task;
|
||||||
void weather_forecast_sync_Task( void * pvParameters );
|
void weather_forecast_sync_Task( void * pvParameters );
|
||||||
|
|
||||||
lv_obj_t *weather_widget_tile = NULL;
|
lv_obj_t *weather_widget_tile = NULL;
|
||||||
lv_obj_t *weather_forecast_location_label = NULL;
|
lv_obj_t *weather_forecast_location_label = NULL;
|
||||||
|
lv_obj_t *weather_forecast_update_label = NULL;
|
||||||
lv_obj_t *weather_forecast_icon_imgbtn[ WEATHER_MAX_FORECAST ];
|
lv_obj_t *weather_forecast_icon_imgbtn[ WEATHER_MAX_FORECAST ];
|
||||||
lv_obj_t *weather_forecast_temperature_label[ WEATHER_MAX_FORECAST ];
|
lv_obj_t *weather_forecast_temperature_label[ WEATHER_MAX_FORECAST ];
|
||||||
lv_style_t weather_widget_style;
|
lv_style_t weather_widget_style;
|
||||||
@@ -86,10 +89,15 @@ void weather_widget_tile_setup( lv_obj_t *tile, lv_style_t *style, lv_coord_t hr
|
|||||||
lv_obj_reset_style_list( weather_forecast_location_label, LV_OBJ_PART_MAIN );
|
lv_obj_reset_style_list( weather_forecast_location_label, LV_OBJ_PART_MAIN );
|
||||||
lv_obj_align( weather_forecast_location_label, tile, LV_ALIGN_IN_TOP_LEFT, 15, STATUSBAR_HEIGHT + 15 );
|
lv_obj_align( weather_forecast_location_label, tile, LV_ALIGN_IN_TOP_LEFT, 15, STATUSBAR_HEIGHT + 15 );
|
||||||
|
|
||||||
|
weather_forecast_update_label = lv_label_create( tile , NULL);
|
||||||
|
lv_label_set_text( weather_forecast_update_label, "");
|
||||||
|
lv_obj_reset_style_list( weather_forecast_update_label, LV_OBJ_PART_MAIN );
|
||||||
|
lv_obj_align( weather_forecast_update_label, weather_forecast_location_label, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 0 );
|
||||||
|
|
||||||
lv_obj_t * weater_forecast_cont = lv_obj_create( tile, NULL );
|
lv_obj_t * weater_forecast_cont = lv_obj_create( tile, NULL );
|
||||||
lv_obj_set_size( weater_forecast_cont, hres , 80 );
|
lv_obj_set_size( weater_forecast_cont, hres , 80 );
|
||||||
lv_obj_add_style( weater_forecast_cont, LV_OBJ_PART_MAIN, style );
|
lv_obj_add_style( weater_forecast_cont, LV_OBJ_PART_MAIN, style );
|
||||||
lv_obj_align( weater_forecast_cont, tile, LV_ALIGN_CENTER, 0, 0 );
|
lv_obj_align( weater_forecast_cont, tile, LV_ALIGN_CENTER, 0, 10 );
|
||||||
|
|
||||||
for ( int i = 0 ; i < WEATHER_MAX_FORECAST / 4 ; i++ ) {
|
for ( int i = 0 ; i < WEATHER_MAX_FORECAST / 4 ; i++ ) {
|
||||||
weather_forecast_icon_imgbtn[ i ] = lv_imgbtn_create( weater_forecast_cont, NULL);
|
weather_forecast_icon_imgbtn[ i ] = lv_imgbtn_create( weater_forecast_cont, NULL);
|
||||||
@@ -127,28 +135,36 @@ void weather_widget_tile_setup( lv_obj_t *tile, lv_style_t *style, lv_coord_t hr
|
|||||||
|
|
||||||
static void exit_weather_widget_event_cb( lv_obj_t * obj, lv_event_t event ) {
|
static void exit_weather_widget_event_cb( lv_obj_t * obj, lv_event_t event ) {
|
||||||
switch( event ) {
|
switch( event ) {
|
||||||
case( LV_EVENT_CLICKED ): mainbar_jump_to_tilenumber( MAIN_TILE, LV_ANIM_OFF );
|
case( LV_EVENT_CLICKED ): motor_vibe( 1 );
|
||||||
|
mainbar_jump_to_tilenumber( MAIN_TILE, LV_ANIM_OFF );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setup_weather_widget_event_cb( lv_obj_t * obj, lv_event_t event ) {
|
static void setup_weather_widget_event_cb( lv_obj_t * obj, lv_event_t event ) {
|
||||||
switch( event ) {
|
switch( event ) {
|
||||||
case( LV_EVENT_CLICKED ): weather_jump_to_setup();
|
case( LV_EVENT_CLICKED ): motor_vibe( 1 );
|
||||||
|
weather_jump_to_setup();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void refresh_weather_widget_event_cb( lv_obj_t * obj, lv_event_t event ) {
|
static void refresh_weather_widget_event_cb( lv_obj_t * obj, lv_event_t event ) {
|
||||||
switch( event ) {
|
switch( event ) {
|
||||||
case( LV_EVENT_CLICKED ): weather_forecast_sync_request();
|
case( LV_EVENT_CLICKED ): motor_vibe( 1 );
|
||||||
|
weather_forecast_sync_request();
|
||||||
weather_widget_sync_request();
|
weather_widget_sync_request();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void weather_forecast_sync_request( void ) {
|
void weather_forecast_sync_request( void ) {
|
||||||
xEventGroupSetBits( weather_forecast_event_handle, WEATHER_FORECAST_SYNC_REQUEST );
|
if ( xEventGroupGetBits( weather_forecast_event_handle ) & WEATHER_FORECAST_SYNC_REQUEST ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
xEventGroupSetBits( weather_forecast_event_handle, WEATHER_FORECAST_SYNC_REQUEST );
|
||||||
|
}
|
||||||
vTaskResume( _weather_forecast_sync_Task );
|
vTaskResume( _weather_forecast_sync_Task );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -163,7 +179,6 @@ void weather_forecast_sync_Task( void * pvParameters ) {
|
|||||||
if ( !weather_forecast[ 0 ].valide )
|
if ( !weather_forecast[ 0 ].valide )
|
||||||
weather_fetch_forecast( weather_get_config() , &weather_forecast[ 0 ] );
|
weather_fetch_forecast( weather_get_config() , &weather_forecast[ 0 ] );
|
||||||
if ( weather_forecast[ 0 ].valide ) {
|
if ( weather_forecast[ 0 ].valide ) {
|
||||||
Serial.printf("weather forecast fetch ok\r\n");
|
|
||||||
for( int i = 0 ; i < WEATHER_MAX_FORECAST / 4 ; i++ ) {
|
for( int i = 0 ; i < WEATHER_MAX_FORECAST / 4 ; i++ ) {
|
||||||
lv_label_set_text( weather_forecast_location_label, weather_forecast[ i * 4 ].name );
|
lv_label_set_text( weather_forecast_location_label, weather_forecast[ i * 4 ].name );
|
||||||
lv_label_set_text( weather_forecast_temperature_label[ i ], weather_forecast[ i * 4 ].temp );
|
lv_label_set_text( weather_forecast_temperature_label[ i ], weather_forecast[ i * 4 ].temp );
|
||||||
@@ -172,6 +187,14 @@ void weather_forecast_sync_Task( void * pvParameters ) {
|
|||||||
lv_imgbtn_set_src( weather_forecast_icon_imgbtn[ i ], LV_BTN_STATE_PRESSED, resolve_owm_icon( weather_forecast[ i * 4 ].icon ) );
|
lv_imgbtn_set_src( weather_forecast_icon_imgbtn[ i ], LV_BTN_STATE_PRESSED, resolve_owm_icon( weather_forecast[ i * 4 ].icon ) );
|
||||||
lv_imgbtn_set_src( weather_forecast_icon_imgbtn[ i ], LV_BTN_STATE_CHECKED_RELEASED, resolve_owm_icon( weather_forecast[ i * 4 ].icon ) );
|
lv_imgbtn_set_src( weather_forecast_icon_imgbtn[ i ], LV_BTN_STATE_CHECKED_RELEASED, resolve_owm_icon( weather_forecast[ i * 4 ].icon ) );
|
||||||
lv_imgbtn_set_src( weather_forecast_icon_imgbtn[ i ], LV_BTN_STATE_CHECKED_PRESSED, resolve_owm_icon( weather_forecast[ i * 4 ].icon ) );
|
lv_imgbtn_set_src( weather_forecast_icon_imgbtn[ i ], LV_BTN_STATE_CHECKED_PRESSED, resolve_owm_icon( weather_forecast[ i * 4 ].icon ) );
|
||||||
|
|
||||||
|
time_t now;
|
||||||
|
struct tm info;
|
||||||
|
char buf[64];
|
||||||
|
time( &now );
|
||||||
|
localtime_r( &now, &info );
|
||||||
|
strftime( buf, sizeof(buf), "updated: %d.%b %H:%M", &info );
|
||||||
|
lv_label_set_text( weather_forecast_update_label, buf );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
#define PMU_EVENT_AXP_INT _BV(0)
|
#define PMU_EVENT_AXP_INT _BV(0)
|
||||||
|
|
||||||
#define PMU_BATTERY_CAP 350
|
#define PMU_BATTERY_CAP 300
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @brief setup pmu: axp202
|
* @brief setup pmu: axp202
|
||||||
|
|||||||
@@ -39,7 +39,8 @@ static bool touch_getXY( int16_t &x, int16_t &y ) {
|
|||||||
|
|
||||||
if ( !ttgo->touch->touched() ) {
|
if ( !ttgo->touch->touched() ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
p = ttgo->touch->getPoint();
|
p = ttgo->touch->getPoint();
|
||||||
|
|
||||||
uint8_t rotation = ttgo->tft->getRotation();
|
uint8_t rotation = ttgo->tft->getRotation();
|
||||||
|
|||||||
@@ -247,7 +247,7 @@ void wifictl_Task( void * pvParameters ) {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
while( true ) {
|
while( true ) {
|
||||||
vTaskDelay( 500 );
|
vTaskDelay( 125 );
|
||||||
if ( powermgm_get_event( POWERMGM_WIFI_ON_REQUEST ) ) {
|
if ( powermgm_get_event( POWERMGM_WIFI_ON_REQUEST ) ) {
|
||||||
statusbar_wifi_set_state( true, "activate" );
|
statusbar_wifi_set_state( true, "activate" );
|
||||||
WiFi.mode( WIFI_STA );
|
WiFi.mode( WIFI_STA );
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user