some fixes

This commit is contained in:
sharandac
2020-08-13 01:17:42 +02:00
parent 4bb56c8b58
commit f5f6faa53f
11 changed files with 110 additions and 42 deletions

View File

@@ -32,6 +32,6 @@
/*
* firmeware version string
*/
#define __FIRMWARE__ "2020081207"
#define __FIRMWARE__ "2020081301"
#endif // _CONFIG_H

View File

@@ -42,6 +42,7 @@ lv_obj_t *display_timeout_slider = NULL;
lv_obj_t *display_timeout_slider_label = NULL;
lv_obj_t *display_rotation_list = NULL;
lv_obj_t *display_vibe_onoff = NULL;
lv_obj_t *display_block_return_maintile_onoff = NULL;
LV_IMG_DECLARE(brightness_64px);
LV_IMG_DECLARE(exit_32px);
@@ -59,6 +60,7 @@ static void display_brightness_setup_event_cb( lv_obj_t * obj, lv_event_t event
static void display_timeout_setup_event_cb( lv_obj_t * obj, lv_event_t event );
static void display_rotation_event_handler(lv_obj_t * obj, lv_event_t event);
static void display_vibe_setup_event_cb( lv_obj_t * obj, lv_event_t event );
static void display_block_return_maintile_setup_event_cb( lv_obj_t * obj, lv_event_t event );
void display_settings_tile_setup( void ) {
// get an app tile and copy mainstyle
@@ -114,15 +116,6 @@ void display_settings_tile_setup( void ) {
lv_label_set_text( exit_label_1, "display settings");
lv_obj_align( exit_label_1, exit_btn_1, LV_ALIGN_OUT_RIGHT_MID, 5, 0 );
lv_obj_t *exit_btn_2 = lv_imgbtn_create( display_settings_tile_2, NULL);
lv_imgbtn_set_src( exit_btn_2, LV_BTN_STATE_RELEASED, &exit_32px);
lv_imgbtn_set_src( exit_btn_2, LV_BTN_STATE_PRESSED, &exit_32px);
lv_imgbtn_set_src( exit_btn_2, LV_BTN_STATE_CHECKED_RELEASED, &exit_32px);
lv_imgbtn_set_src( exit_btn_2, LV_BTN_STATE_CHECKED_PRESSED, &exit_32px);
lv_obj_add_style( exit_btn_2, LV_IMGBTN_PART_MAIN, &display_settings_style );
lv_obj_align( exit_btn_2, display_settings_tile_2, LV_ALIGN_IN_TOP_LEFT, 10, STATUSBAR_HEIGHT + 10 );
lv_obj_set_event_cb( exit_btn_2, exit_display_setup_event_cb );
lv_obj_t *up_btn_1 = lv_imgbtn_create( display_settings_tile_2, NULL);
lv_imgbtn_set_src( up_btn_1, LV_BTN_STATE_RELEASED, &up_32px);
lv_imgbtn_set_src( up_btn_1, LV_BTN_STATE_PRESSED, &up_32px);
@@ -132,11 +125,6 @@ void display_settings_tile_setup( void ) {
lv_obj_align( up_btn_1, display_settings_tile_2, LV_ALIGN_IN_TOP_RIGHT, -10, STATUSBAR_HEIGHT + 10 );
lv_obj_set_event_cb( up_btn_1, up_display_setup_event_cb );
lv_obj_t *exit_label_2 = lv_label_create( display_settings_tile_2, NULL );
lv_obj_add_style( exit_label_2, LV_OBJ_PART_MAIN, &display_settings_style );
lv_label_set_text( exit_label_2, "display settings");
lv_obj_align( exit_label_2, exit_btn_2, LV_ALIGN_OUT_RIGHT_MID, 5, 0 );
lv_obj_t *brightness_cont = lv_obj_create( display_settings_tile_1, NULL );
lv_obj_set_size( brightness_cont, LV_HOR_RES_MAX , 48 );
lv_obj_add_style( brightness_cont, LV_OBJ_PART_MAIN, &display_settings_style );
@@ -202,6 +190,21 @@ void display_settings_tile_setup( void ) {
lv_label_set_text( display_vibe_label, "vibe feedback");
lv_obj_align( display_vibe_label, vibe_cont, LV_ALIGN_IN_LEFT_MID, 5, 0 );
lv_obj_t *block_return_maintile_cont = lv_obj_create( display_settings_tile_2, NULL );
lv_obj_set_size(block_return_maintile_cont, LV_HOR_RES_MAX , 40 );
lv_obj_add_style( block_return_maintile_cont, LV_OBJ_PART_MAIN, &display_settings_style );
lv_obj_align( block_return_maintile_cont, vibe_cont, LV_ALIGN_OUT_BOTTOM_MID, 0, 0 );
display_block_return_maintile_onoff = lv_switch_create( block_return_maintile_cont, NULL );
lv_obj_add_protect( display_block_return_maintile_onoff, LV_PROTECT_CLICK_FOCUS);
lv_obj_add_style( display_block_return_maintile_onoff, LV_SWITCH_PART_INDIC, mainbar_get_switch_style() );
lv_switch_off( display_block_return_maintile_onoff, LV_ANIM_ON );
lv_obj_align( display_block_return_maintile_onoff, block_return_maintile_cont, LV_ALIGN_IN_RIGHT_MID, -5, 0 );
lv_obj_set_event_cb( display_block_return_maintile_onoff, display_block_return_maintile_setup_event_cb );
lv_obj_t *display_block_return_maintile_label = lv_label_create( block_return_maintile_cont, NULL );
lv_obj_add_style( display_block_return_maintile_label, LV_OBJ_PART_MAIN, &display_settings_style );
lv_label_set_text( display_block_return_maintile_label, "block return maintile" );
lv_obj_align( display_block_return_maintile_label, block_return_maintile_cont, LV_ALIGN_IN_LEFT_MID, 5, 0 );
lv_slider_set_value( display_brightness_slider, display_get_brightness(), LV_ANIM_OFF );
lv_slider_set_value( display_timeout_slider, display_get_timeout(), LV_ANIM_OFF );
char temp[16]="";
@@ -221,10 +224,16 @@ void display_settings_tile_setup( void ) {
else
lv_switch_off( display_vibe_onoff, LV_ANIM_OFF );
if ( display_get_block_return_maintile() )
lv_switch_on( display_block_return_maintile_onoff, LV_ANIM_OFF );
else
lv_switch_off( display_block_return_maintile_onoff, LV_ANIM_OFF );
lv_tileview_add_element( display_settings_tile_1, brightness_cont );
lv_tileview_add_element( display_settings_tile_1, timeout_cont );
lv_tileview_add_element( display_settings_tile_1, rotation_cont );
lv_tileview_add_element( display_settings_tile_2, vibe_cont );
lv_tileview_add_element( display_settings_tile_2, block_return_maintile_cont );
}
static void enter_display_setup_event_cb( lv_obj_t * obj, lv_event_t event ) {
@@ -266,6 +275,13 @@ static void display_vibe_setup_event_cb( lv_obj_t * obj, lv_event_t event ) {
}
}
static void display_block_return_maintile_setup_event_cb( lv_obj_t * obj, lv_event_t event ) {
switch( event ) {
case( LV_EVENT_VALUE_CHANGED ): display_set_block_return_maintile( lv_slider_get_value( obj ) );
break;
}
}
static void display_brightness_setup_event_cb( lv_obj_t * obj, lv_event_t event ) {
switch( event ) {
case( LV_EVENT_VALUE_CHANGED ): display_set_brightness( lv_slider_get_value( obj ) );

View File

@@ -29,6 +29,7 @@
#include "hardware/wifictl.h"
#include "hardware/motor.h"
#include "webserver/webserver.h"
#include <WiFi.h>
@@ -401,6 +402,12 @@ static void wifi_autoon_onoff_event_handler( lv_obj_t * obj, lv_event_t event )
static void wifi_webserver_onoff_event_handler( lv_obj_t * obj, lv_event_t event ) {
switch (event) {
case (LV_EVENT_VALUE_CHANGED): wifictl_set_webserver( lv_switch_get_state( obj ) );
if ( lv_switch_get_state( obj ) ) {
asyncwebserver_start();
}
else {
asyncwebserver_end();
}
break;
}
}

View File

@@ -53,16 +53,16 @@ class BleCtlServerCallbacks: public BLEServerCallbacks {
void onConnect(BLEServer* pServer) {
blectl_set_event( BLECTL_CONNECT );
statusbar_style_icon( STATUSBAR_BLUETOOTH, STATUSBAR_STYLE_WHITE );
Serial.printf("BLE connected\r\n");
log_i("BLE connected");
};
void onDisconnect(BLEServer* pServer) {
blectl_clear_event( BLECTL_CONNECT );
statusbar_style_icon( STATUSBAR_BLUETOOTH, STATUSBAR_STYLE_GRAY );
Serial.printf("BLE disconnected\r\n");
log_i("BLE disconnected");
delay(500);
pServer->getAdvertising()->start();
Serial.printf("BLE advertising...\r\n");
log_i("BLE advertising...");
}
};
@@ -72,29 +72,29 @@ class BleCtlServerCallbacks: public BLEServerCallbacks {
class BtlCtlSecurity : public BLESecurityCallbacks {
uint32_t onPassKeyRequest(){
Serial.printf("BLE: PassKeyRequest\r\n");
log_i("BLE: PassKeyRequest");
// TODO: when is this used?
return 123456;
}
void onPassKeyNotify(uint32_t pass_key){
blectl_set_event( BLECTL_PAIRING );
Serial.printf("Bluetooth Pairing Request\r\nPIN: %06d\r\n", pass_key);
log_i("Bluetooth Pairing Request\r\nPIN: %06d", pass_key);
}
bool onConfirmPIN(uint32_t pass_key){
Serial.printf("BLE: The passkey YES/NO number :%06d\r\n", pass_key);
log_i("BLE: The passkey YES/NO number :%06d", pass_key);
// vTaskDelay(5000);
// return true;
// TODO: when is this used?
return false;
}
bool onSecurityRequest(){
Serial.printf("BLE: SecurityRequest\r\n");
log_i("BLE: SecurityRequest");
// TODO: when is this used?
return true;
}
void onAuthenticationComplete( esp_ble_auth_cmpl_t cmpl ){
Serial.printf("Bluetooth pairing %s\r\n", cmpl.success ? "successful" : "unsuccessful");
log_i("Bluetooth pairing %s", cmpl.success ? "successful" : "unsuccessful");
if( cmpl.success ){
uint16_t length;
@@ -122,7 +122,7 @@ class BleCtlCallbacks : public BLECharacteristicCallbacks
for (int i = 0; i < rxValue.length(); i++) {
if (rxValue[i] == 0x10) {
if ( message.length() ) {
log_i("BLE: Discarding %d bytes\n", message.length());
log_i("BLE: Discarding %d bytes", message.length());
}
message.clear();
} else if (rxValue[i] == '\n') {
@@ -157,6 +157,8 @@ void blectl_setup( void ) {
esp_bt_controller_enable( ESP_BT_MODE_BLE );
esp_bt_controller_mem_release( ESP_BT_MODE_CLASSIC_BT );
esp_bt_mem_release( ESP_BT_MODE_CLASSIC_BT );
esp_bt_controller_mem_release( ESP_BT_MODE_IDLE );
esp_bt_mem_release( ESP_BT_MODE_IDLE );
// Create the BLE Device
// Name needs to match filter in Gadgetbridge's banglejs getSupportedType() function.
@@ -204,33 +206,41 @@ void blectl_setup( void ) {
pServer->getAdvertising()->setMinInterval( 100 );
pServer->getAdvertising()->setMaxInterval( 200 );
pServer->getAdvertising()->start();
Serial.printf("BLE advertising...\r\n");
log_i("BLE advertising...");
}
/*
*
*/
void blectl_set_event( EventBits_t bits ) {
portENTER_CRITICAL_ISR(&blectlMux);
portENTER_CRITICAL(&blectlMux);
xEventGroupSetBits( blectl_status, bits );
portEXIT_CRITICAL_ISR(&blectlMux);
portEXIT_CRITICAL(&blectlMux);
}
/*
*
*/
void blectl_clear_event( EventBits_t bits ) {
portENTER_CRITICAL_ISR(&blectlMux);
portENTER_CRITICAL(&blectlMux);
xEventGroupClearBits( blectl_status, bits );
portEXIT_CRITICAL_ISR(&blectlMux);
portEXIT_CRITICAL(&blectlMux);
}
/*
*
*/
EventBits_t blectl_get_event( EventBits_t bits ) {
portENTER_CRITICAL_ISR(&blectlMux);
portENTER_CRITICAL(&blectlMux);
EventBits_t temp = xEventGroupGetBits( blectl_status ) & bits;
portEXIT_CRITICAL_ISR(&blectlMux);
portEXIT_CRITICAL(&blectlMux);
return( temp );
}
void blectl_standby( void ) {
statusbar_style_icon( STATUSBAR_BLUETOOTH, STATUSBAR_STYLE_GRAY );
}
void blectl_wakeup( void ) {
statusbar_style_icon( STATUSBAR_BLUETOOTH, STATUSBAR_STYLE_GRAY );
}

View File

@@ -58,5 +58,7 @@
* @param bits event state, example: POWERMGM_STANDBY to evaluate if the system in standby
*/
EventBits_t blectl_get_event( EventBits_t bits );
void blectl_standby( void );
void blectl_wakeup( void );
#endif // _BLECTL_H

View File

@@ -124,6 +124,7 @@ void display_save_config( void ) {
doc["brightness"] = display_config.brightness;
doc["rotation"] = display_config.rotation;
doc["timeout"] = display_config.timeout;
doc["block_return_maintile"] = display_config.block_return_maintile;
if ( serializeJsonPretty( doc, file ) == 0) {
log_e("Failed to write config file");
@@ -154,6 +155,7 @@ void display_read_config( void ) {
display_config.brightness = doc["brightness"].as<uint32_t>();
display_config.rotation = doc["rotation"].as<uint32_t>();
display_config.timeout = doc["timeout"].as<uint32_t>();
display_config.block_return_maintile = doc["block_return_maintile"].as<bool>();
}
doc.clear();
}
@@ -203,6 +205,14 @@ uint32_t display_get_rotation( void ) {
return( display_config.rotation );
}
bool display_get_block_return_maintile( void ) {
return( display_config.block_return_maintile );
}
void display_set_block_return_maintile( bool block_return_maintile ) {
display_config.block_return_maintile = block_return_maintile;
}
void display_set_rotation( uint32_t rotation ) {
TTGOClass *ttgo = TTGOClass::getWatch();
display_config.rotation = rotation;

View File

@@ -35,6 +35,7 @@
uint32_t brightness = DISPLAY_MAX_BRIGHTNESS;
uint32_t timeout = DISPLAY_MIN_TIMEOUT;
uint32_t rotation = 0;
bool block_return_maintile = false;
} display_config_t;
#define DISPLAY_CONFIG_FILE "/display.cfg"
@@ -96,6 +97,18 @@
* @param rotation from 0-270 in 90 degree steps
*/
void display_set_rotation( uint32_t rotation );
/*
* @brief read the block_return_maintile while wakeup
*
* @param rotation from 0-270 in 90 degree steps
*/
bool display_get_block_return_maintile( void );
/*
* @brief set the block_return_maintile while wakeup
*
* @param block_return_maintile true or false, true means no autoreturn zu maintile
*/
void display_set_block_return_maintile( bool block_return_maintile );
/*
* @brief set display into standby
*/

View File

@@ -31,6 +31,7 @@
#include "bma.h"
#include "powermgm.h"
#include "wifictl.h"
#include "blectl.h"
#include "timesync.h"
#include "motor.h"
#include "touch.h"
@@ -84,6 +85,8 @@ void powermgm_loop( TTGOClass *ttgo ) {
timesyncToSystem();
wifictl_wakeup();
blectl_wakeup();
Serial.printf("Total heap: %d\r\n", ESP.getHeapSize());
Serial.printf("Free heap: %d\r\n", ESP.getFreeHeap());
Serial.printf("Total PSRAM: %d\r\n", ESP.getPsramSize());
@@ -91,6 +94,10 @@ void powermgm_loop( TTGOClass *ttgo ) {
ttgo->startLvglTick();
lv_disp_trig_activity(NULL);
if ( !display_get_block_return_maintile() ) {
mainbar_jump_to_maintile( LV_ANIM_OFF );
}
}
else {
ttgo->stopLvglTick();
@@ -100,19 +107,22 @@ void powermgm_loop( TTGOClass *ttgo ) {
Serial.printf("Total PSRAM: %d\r\n", ESP.getPsramSize());
Serial.printf("Free PSRAM: %d\r\n", ESP.getFreePsram());
display_standby();
mainbar_jump_to_maintile( LV_ANIM_OFF );
timesyncToRTC();
bma_standby();
pmu_standby();
wifictl_standby();
blectl_standby();
powermgm_set_event( POWERMGM_STANDBY );
powermgm_clear_event( POWERMGM_SILENCE_WAKEUP );
adc_power_off();
motor_vibe(1);
delay(50);
log_i("go standby");
setCpuFrequencyMhz( 80 );
@@ -135,26 +145,26 @@ void powermgm_loop( TTGOClass *ttgo ) {
*
*/
void powermgm_set_event( EventBits_t bits ) {
portENTER_CRITICAL_ISR(&powermgmMux);
portENTER_CRITICAL(&powermgmMux);
xEventGroupSetBits( powermgm_status, bits );
portEXIT_CRITICAL_ISR(&powermgmMux);
portEXIT_CRITICAL(&powermgmMux);
}
/*
*
*/
void powermgm_clear_event( EventBits_t bits ) {
portENTER_CRITICAL_ISR(&powermgmMux);
portENTER_CRITICAL(&powermgmMux);
xEventGroupClearBits( powermgm_status, bits );
portEXIT_CRITICAL_ISR(&powermgmMux);
portEXIT_CRITICAL(&powermgmMux);
}
/*
*
*/
EventBits_t powermgm_get_event( EventBits_t bits ) {
portENTER_CRITICAL_ISR(&powermgmMux);
portENTER_CRITICAL(&powermgmMux);
EventBits_t temp = xEventGroupGetBits( powermgm_status ) & bits;
portEXIT_CRITICAL_ISR(&powermgmMux);
portEXIT_CRITICAL(&powermgmMux);
return( temp );
}

View File

@@ -91,12 +91,12 @@ void setup()
splash_screen_stage_finish( ttgo );
display_set_brightness( display_get_brightness() );
blectl_setup();
Serial.printf("Total heap: %d\r\n", ESP.getHeapSize());
Serial.printf("Free heap: %d\r\n", ESP.getFreeHeap());
Serial.printf("Total PSRAM: %d\r\n", ESP.getPsramSize());
Serial.printf("Free PSRAM: %d\r\n", ESP.getFreePsram());
blectl_setup();
}
void loop()

Binary file not shown.

View File

@@ -1 +1 @@
{"version":"2020081207","host":"http://www.neo-guerillaz.de","file":"ttgo-t-watch2020_v1.ino.bin"}
{"version":"2020081301","host":"http://www.neo-guerillaz.de","file":"ttgo-t-watch2020_v1.ino.bin"}