highly experimental bluetooth, try gadgetbridge
This commit is contained in:
@@ -32,6 +32,6 @@
|
||||
/*
|
||||
* firmeware version string
|
||||
*/
|
||||
#define __FIRMWARE__ "2020081202"
|
||||
#define __FIRMWARE__ "2020081207"
|
||||
|
||||
#endif // _CONFIG_H
|
||||
|
||||
@@ -27,30 +27,34 @@
|
||||
|
||||
lv_setup_entry_t setup_entry[ MAX_SETUP_ICON ];
|
||||
|
||||
lv_obj_t *setup_cont = NULL;
|
||||
lv_obj_t *setup_cont[ MAX_SETUP_TILES ];
|
||||
uint32_t setup_tile_num[ MAX_SETUP_TILES ];
|
||||
lv_style_t setup_style;
|
||||
uint32_t setup_tile_num;
|
||||
|
||||
void setup_tile_setup( void ) {
|
||||
setup_tile_num = mainbar_add_tile( 1, 1 );
|
||||
setup_cont = mainbar_get_tile_obj( setup_tile_num );
|
||||
|
||||
for ( int tiles = 0 ; tiles < MAX_SETUP_TILES ; tiles++ ) {
|
||||
setup_tile_num[ tiles ] = mainbar_add_tile( 1 + tiles , 1 );
|
||||
setup_cont[ tiles ] = mainbar_get_tile_obj( setup_tile_num[ tiles ] );
|
||||
}
|
||||
|
||||
lv_style_copy( &setup_style, mainbar_get_style() );
|
||||
|
||||
for ( int setup = 0 ; setup < MAX_SETUP_ICON ; setup++ ) {
|
||||
// set x, y and mark it as inactive
|
||||
setup_entry[ setup ].x = SETUP_FIRST_X_POS + ( ( setup % MAX_SETUP_ICON_HORZ ) * ( SETUP_ICON_X_SIZE + SETUP_ICON_X_CLEARENCE ) );
|
||||
setup_entry[ setup ].y = SETUP_FIRST_Y_POS + ( ( setup / MAX_SETUP_ICON_HORZ ) * ( SETUP_ICON_Y_SIZE + SETUP_ICON_Y_CLEARENCE ) );
|
||||
setup_entry[ setup ].y = SETUP_FIRST_Y_POS + ( ( ( setup % ( MAX_SETUP_ICON_VERT * MAX_SETUP_ICON_HORZ ) ) / MAX_SETUP_ICON_HORZ ) * ( SETUP_ICON_Y_SIZE + SETUP_ICON_Y_CLEARENCE ) );
|
||||
setup_entry[ setup ].active = false;
|
||||
// create app icon container
|
||||
setup_entry[ setup ].setup = mainbar_obj_create( setup_cont );
|
||||
setup_entry[ setup ].setup = mainbar_obj_create( setup_cont[ setup / ( MAX_SETUP_ICON_HORZ * MAX_SETUP_ICON_VERT ) ] );
|
||||
lv_obj_reset_style_list( setup_entry[ setup ].setup, LV_OBJ_PART_MAIN );
|
||||
lv_obj_add_style( setup_entry[ setup ].setup, LV_OBJ_PART_MAIN, &setup_style );
|
||||
lv_obj_set_size( setup_entry[ setup ].setup, SETUP_ICON_X_SIZE, SETUP_ICON_Y_SIZE );
|
||||
lv_obj_align( setup_entry[ setup ].setup , setup_cont, LV_ALIGN_IN_TOP_LEFT, setup_entry[ setup ].x, setup_entry[ setup ].y );
|
||||
lv_obj_align( setup_entry[ setup ].setup , setup_cont[ setup / ( MAX_SETUP_ICON_HORZ * MAX_SETUP_ICON_VERT ) ], LV_ALIGN_IN_TOP_LEFT, setup_entry[ setup ].x, setup_entry[ setup ].y );
|
||||
|
||||
lv_obj_set_hidden( setup_entry[ setup ].setup, true );
|
||||
|
||||
log_d("icon x/y: %d/%d", setup_entry[ setup ].x, setup_entry[ setup ].y );
|
||||
log_d("icon screen/x/y: %d/%d/%d", setup / ( MAX_SETUP_ICON_HORZ * MAX_SETUP_ICON_VERT ), setup_entry[ setup ].x, setup_entry[ setup ].y );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,5 +71,5 @@ lv_obj_t *setup_tile_register_setup( void ) {
|
||||
}
|
||||
|
||||
uint32_t setup_get_tile_num( void ) {
|
||||
return( setup_tile_num );
|
||||
return( setup_tile_num[ 0 ] );
|
||||
}
|
||||
|
||||
@@ -26,7 +26,8 @@
|
||||
|
||||
#define MAX_SETUP_ICON_HORZ 3
|
||||
#define MAX_SETUP_ICON_VERT 2
|
||||
#define MAX_SETUP_ICON ( MAX_SETUP_ICON_HORZ * MAX_SETUP_ICON_VERT )
|
||||
#define MAX_SETUP_TILES 2
|
||||
#define MAX_SETUP_ICON ( MAX_SETUP_ICON_HORZ * MAX_SETUP_ICON_VERT * MAX_SETUP_TILES )
|
||||
|
||||
#define SETUP_ICON_X_SIZE 64
|
||||
#define SETUP_ICON_Y_SIZE 64
|
||||
|
||||
@@ -53,6 +53,9 @@ void splash_screen_stage_one( TTGOClass *ttgo ) {
|
||||
lv_obj_align(preload_label, preload, LV_ALIGN_OUT_BOTTOM_MID, 0, 5);
|
||||
|
||||
lv_disp_trig_activity(NULL);
|
||||
|
||||
lv_obj_move_foreground( preload );
|
||||
|
||||
lv_task_handler();
|
||||
|
||||
for( int bl = 0 ; bl < display_get_brightness() ; bl++ ) {
|
||||
@@ -62,6 +65,7 @@ void splash_screen_stage_one( TTGOClass *ttgo ) {
|
||||
}
|
||||
|
||||
void splash_screen_stage_update( const char* msg, int value ) {
|
||||
lv_obj_move_foreground( preload );
|
||||
lv_disp_trig_activity(NULL);
|
||||
lv_task_handler();
|
||||
delay(100);
|
||||
@@ -72,7 +76,7 @@ void splash_screen_stage_update( const char* msg, int value ) {
|
||||
}
|
||||
|
||||
void splash_screen_stage_finish( TTGOClass *ttgo ) {
|
||||
ttgo->bl->adjust( 0 );
|
||||
// ttgo->bl->adjust( 0 );
|
||||
for( int bl = display_get_brightness() ; bl > 0 ; bl-- ) {
|
||||
ttgo->bl->adjust( bl );
|
||||
delay(1);
|
||||
|
||||
@@ -49,6 +49,7 @@ lv_status_bar_t statusicon[ STATUSBAR_NUM ] =
|
||||
{ NULL, NULL, LV_ALIGN_IN_TOP_RIGHT, &statusbarstyle[ STATUSBAR_STYLE_WHITE ] },
|
||||
{ NULL, LV_SYMBOL_BATTERY_FULL, LV_ALIGN_OUT_LEFT_MID, &statusbarstyle[ STATUSBAR_STYLE_WHITE ] },
|
||||
{ NULL, LV_SYMBOL_WIFI, LV_ALIGN_OUT_LEFT_MID, &statusbarstyle[ STATUSBAR_STYLE_WHITE ] },
|
||||
{ NULL, LV_SYMBOL_BLUETOOTH, LV_ALIGN_OUT_LEFT_MID, &statusbarstyle[ STATUSBAR_STYLE_WHITE ] },
|
||||
{ NULL, LV_SYMBOL_BELL, LV_ALIGN_OUT_LEFT_MID, &statusbarstyle[ STATUSBAR_STYLE_WHITE ] },
|
||||
{ NULL, LV_SYMBOL_WARNING, LV_ALIGN_OUT_LEFT_MID, &statusbarstyle[ STATUSBAR_STYLE_WHITE ] },
|
||||
};
|
||||
@@ -178,6 +179,7 @@ void statusbar_setup( void )
|
||||
statusbar_hide_icon( STATUSBAR_BELL );
|
||||
statusbar_hide_icon( STATUSBAR_WARNING );
|
||||
statusbar_hide_icon( STATUSBAR_WIFI );
|
||||
statusbar_style_icon( STATUSBAR_BLUETOOTH, STATUSBAR_STYLE_GRAY );
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
STATUSBAR_BATTERY_PERCENT,
|
||||
STATUSBAR_BATTERY,
|
||||
STATUSBAR_WIFI,
|
||||
STATUSBAR_BLUETOOTH,
|
||||
STATUSBAR_BELL,
|
||||
STATUSBAR_WARNING,
|
||||
STATUSBAR_NUM
|
||||
|
||||
@@ -34,6 +34,8 @@
|
||||
|
||||
#include "blectl.h"
|
||||
|
||||
#include "gui/statusbar.h"
|
||||
|
||||
EventGroupHandle_t blectl_status = NULL;
|
||||
portMUX_TYPE blectlMux = portMUX_INITIALIZER_UNLOCKED;
|
||||
|
||||
@@ -50,11 +52,13 @@ String message;
|
||||
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");
|
||||
};
|
||||
|
||||
void onDisconnect(BLEServer* pServer) {
|
||||
blectl_clear_event( BLECTL_CONNECT );
|
||||
statusbar_style_icon( STATUSBAR_BLUETOOTH, STATUSBAR_STYLE_GRAY );
|
||||
Serial.printf("BLE disconnected\r\n");
|
||||
delay(500);
|
||||
pServer->getAdvertising()->start();
|
||||
@@ -128,7 +132,7 @@ class BleCtlCallbacks : public BLECharacteristicCallbacks
|
||||
return;
|
||||
}
|
||||
message[message.length()] = 0;
|
||||
// processMessage();
|
||||
Serial.println("BLE message: " + message );
|
||||
message.clear();
|
||||
} else {
|
||||
message += rxValue[i];
|
||||
@@ -150,11 +154,15 @@ void blectl_setup( void ) {
|
||||
blectl_status = xEventGroupCreate();
|
||||
blectl_set_event( BLECTL_CONNECT | BLECTL_OFF_REQUEST | BLECTL_ON_REQUEST | BLECTL_PAIRING | BLECTL_STANDBY_REQUEST | BLECTL_ACTIVE | BLECTL_SCAN );
|
||||
|
||||
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 );
|
||||
|
||||
// Create the BLE Device
|
||||
// Name needs to match filter in Gadgetbridge's banglejs getSupportedType() function.
|
||||
// This is too long I think:
|
||||
// BLEDevice::init("Espruino Gadgetbridge Compatible Device");
|
||||
BLEDevice::init("Espruino");
|
||||
BLEDevice::init("Espruino (T-Watch2020)");
|
||||
// The minimum power level (-12dbm) ESP_PWR_LVL_N12 was too low
|
||||
BLEDevice::setPower( ESP_PWR_LVL_N9 );
|
||||
|
||||
@@ -193,8 +201,8 @@ void blectl_setup( void ) {
|
||||
pServer->getAdvertising()->addServiceUUID( pService->getUUID() );
|
||||
// Slow advertising interval for battery life
|
||||
// The maximum 0x4000 interval of ~16 sec was too slow, I could not reliably connect
|
||||
pServer->getAdvertising()->setMinInterval( 1000 );
|
||||
pServer->getAdvertising()->setMaxInterval( 2000 );
|
||||
pServer->getAdvertising()->setMinInterval( 100 );
|
||||
pServer->getAdvertising()->setMaxInterval( 200 );
|
||||
pServer->getAdvertising()->start();
|
||||
Serial.printf("BLE advertising...\r\n");
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
|
||||
typedef struct {
|
||||
bool autoon = true;
|
||||
bool webserver = true;
|
||||
bool webserver = false;
|
||||
} wifictl_config_t;
|
||||
|
||||
/*
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
*/
|
||||
#include "config.h"
|
||||
#include <Arduino.h>
|
||||
#include "esp_bt.h"
|
||||
|
||||
#include "gui/gui.h"
|
||||
#include "gui/splashscreen.h"
|
||||
@@ -41,7 +42,6 @@ TTGOClass *ttgo = TTGOClass::getWatch();
|
||||
|
||||
void setup()
|
||||
{
|
||||
|
||||
Serial.begin(115200);
|
||||
Serial.printf("starting t-watch V1, version: " __FIRMWARE__ "\r\n");
|
||||
ttgo->begin();
|
||||
@@ -51,7 +51,7 @@ void setup()
|
||||
|
||||
motor_setup();
|
||||
|
||||
// force to store all heap data in psram to get more internal ram
|
||||
// force to store all new heap allocations in psram to get more internal ram
|
||||
heap_caps_malloc_extmem_enable( 1 );
|
||||
|
||||
display_setup( ttgo );
|
||||
@@ -69,15 +69,12 @@ void setup()
|
||||
|
||||
splash_screen_stage_update( "init rtc", 50 );
|
||||
ttgo->rtc->syncToSystem();
|
||||
splash_screen_stage_update( "init powermgm", 100 );
|
||||
|
||||
splash_screen_stage_update( "init powermgm", 60 );
|
||||
powermgm_setup( ttgo );
|
||||
splash_screen_stage_update( "init gui", 100 );
|
||||
splash_screen_stage_finish( ttgo );
|
||||
|
||||
splash_screen_stage_update( "init gui", 80 );
|
||||
gui_setup();
|
||||
lv_task_handler();
|
||||
ttgo->bl->adjust( 32 );
|
||||
|
||||
/*
|
||||
* add apps and widgets here!!!
|
||||
*/
|
||||
@@ -88,20 +85,23 @@ void setup()
|
||||
*/
|
||||
|
||||
wifictl_on();
|
||||
display_set_brightness( display_get_brightness() );
|
||||
|
||||
// enable to store data in normal heap
|
||||
heap_caps_malloc_extmem_enable( 16*1024 );
|
||||
|
||||
splash_screen_stage_finish( ttgo );
|
||||
display_set_brightness( display_get_brightness() );
|
||||
|
||||
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()
|
||||
{
|
||||
delay(1);
|
||||
delay(5);
|
||||
gui_loop( ttgo );
|
||||
powermgm_loop( ttgo );
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -1 +1 @@
|
||||
{"version":"2020081202","host":"http://www.neo-guerillaz.de","file":"ttgo-t-watch2020_v1.ino.bin"}
|
||||
{"version":"2020081207","host":"http://www.neo-guerillaz.de","file":"ttgo-t-watch2020_v1.ino.bin"}
|
||||
|
||||
Reference in New Issue
Block a user