diff --git a/breath_button_monitor/breathmonitor_v3 with server/firmware/firmware.ino b/breath_button_monitor/breathmonitor_v3 with server/firmware/firmware.ino index 9dca81e..eace42e 100644 --- a/breath_button_monitor/breathmonitor_v3 with server/firmware/firmware.ino +++ b/breath_button_monitor/breathmonitor_v3 with server/firmware/firmware.ino @@ -470,7 +470,7 @@ static void settings(lv_event_t *) { struct Item{const char *name;uint8_t *v;uint8_t max;}; Item items[]={{"Breath limit",&gLimit,4},{"Cycle tick",&gTick,10},{"Alert volume",&gAlert,10},{"Screen timeout",&gScreenTimeout,3}}; for(auto &it:items){lv_obj_t *row=lv_obj_create(list);lv_obj_set_size(row,400,67);card(row,0x172C3C);lv_obj_t *n=label(row,it.name,&lv_font_montserrat_16,0xFFFFFF);lv_obj_set_pos(n,12,6);lv_obj_t *sl=lv_slider_create(row);lv_obj_set_pos(sl,12,36);lv_obj_set_size(sl,376,16);lv_slider_set_range(sl,0,it.max);lv_slider_set_value(sl,*it.v,LV_ANIM_OFF);lv_obj_add_event_cb(sl,settingChanged,LV_EVENT_VALUE_CHANGED,it.v);if(it.v==&gLimit)lv_obj_add_event_cb(sl,settingReleased,LV_EVENT_RELEASED,it.v);} - button(gRoot,"ONLINE SETTINGS",24,383,220,42,0x214D69,[](lv_event_t *){onlineSettings(nullptr);}); + button(gRoot,"ONLINE",24,383,220,42,0x214D69,[](lv_event_t *){onlineScreen(nullptr);}); button(gRoot,"BACK",256,383,200,42,0x214D69,[](lv_event_t *){if(gPaused)togglePause();enterMonitor(nullptr);}); lv_obj_t *rot=lv_checkbox_create(gRoot);lv_checkbox_set_text(rot,"ROTATION CONTROL");lv_obj_set_pos(rot,32,437);if(gRotation)lv_obj_add_state(rot,LV_STATE_CHECKED);lv_obj_add_event_cb(rot,[](lv_event_t *e){gRotation=lv_obj_has_state(lv_event_get_target(e),LV_STATE_CHECKED);gRotationArmed=false;gOrientation=-1;gScreenEdgeOrientation=-1;gScreenEdgeCandidate=-1;saveSettings();appendEvent(10,UINT64_MAX,0,0,0,0,gRotation);},LV_EVENT_VALUE_CHANGED,nullptr); } @@ -828,7 +828,7 @@ static void kbClicked(lv_event_t *e){ if(!strcmp(key,"")){gKbSymbols=!gKbSymbols;gKbPage=false;wifiPasswordScreen();return;} if(!strcmp(key,"")){gKbPage=!gKbPage;wifiPasswordScreen();return;} if(!strcmp(key,"")){gKbShift=!gKbShift;wifiPasswordScreen();return;} - if(!strcmp(key,"")){gKbShowPassword=!gKbShowPassword;lv_textarea_set_password_mode(gPasswordField,!gKbShowPassword);return;} + if(!strcmp(key,"")){gKbShowPassword=true;lv_textarea_set_password_mode(gPasswordField,false);return;} if(!strcmp(key,"")){if(gKbValue.length())gKbValue.remove(gKbValue.length()-1);kbRefreshField();return;} if(!strcmp(key,"")){gKbValue="";kbRefreshField();return;} if(gKbValue.length()>=(gInputTarget==InputTarget::AccountLogin?24:63))return; @@ -851,7 +851,7 @@ static void wifiPasswordScreen(){ gPasswordField=lv_textarea_create(gRoot); lv_obj_set_pos(gPasswordField,18,109);lv_obj_set_size(gPasswordField,444,51); lv_textarea_set_one_line(gPasswordField,true); - lv_textarea_set_password_mode(gPasswordField,gInputTarget!=InputTarget::AccountLogin&&!gKbShowPassword); + lv_textarea_set_password_mode(gPasswordField,false); lv_textarea_set_max_length(gPasswordField,63); lv_obj_set_style_text_font(gPasswordField,&lv_font_montserrat_20,0); kbRefreshField(); @@ -871,7 +871,7 @@ static void wifiPasswordScreen(){ kbButton(gKbPage?"< 1/2":"2/2 >","",200,347,80,47,0x365873); kbButton("SPACE","",292,347,79,47,0x365873,14); kbButton("DEL","",383,347,79,47,0x7D3A3A); - kbButton(gKbShowPassword?"HIDE":"SHOW","",18,406,79,54,0x53606B,14); + kbButton("TEXT","",18,406,79,54,0x53606B,14); kbButton("CLEAR","",109,406,79,54,0x7D3A3A,14); kbButton("CANCEL","",200,406,118,54,0x5A6570,14); kbButton(gInputTarget==InputTarget::WifiPass?"CONNECT":"SAVE","",330,406,132,54,0x2A9D8F,14); @@ -1041,7 +1041,7 @@ static bool requestToken(WiFiClientSecure &secure,const String &login,const Stri static bool doPair(WiFiClientSecure &secure){ String token;String login=gPendingAccountLogin.length()?gPendingAccountLogin:gAccountLogin;String password=gPendingAccountPassword.length()?gPendingAccountPassword:gAccountPassword; if(!requestToken(secure,login,password,token))return false; - gAccountLogin=login;gDeviceToken=token;gAccountPassword="";gAccountPrefs.putString("login",gAccountLogin);gAccountPrefs.putString("token",gDeviceToken);gPendingAccountLogin="";gPendingAccountPassword="";gChangingAccount=false;workerSet("Device paired");return true; + gAccountLogin=login;gAccountPassword=password;gDeviceToken=token;gAccountPrefs.putString("login",gAccountLogin);gAccountPrefs.putString("password",gAccountPassword);gAccountPrefs.putString("token",gDeviceToken);gPendingAccountLogin="";gPendingAccountPassword="";gChangingAccount=false;workerSet("Device paired");return true; } static bool clearLocalAccountData(){ if(!gFileReady)return false; @@ -1052,7 +1052,7 @@ static bool clearLocalAccountData(){ static bool changeAccount(WiFiClientSecure &secure){ String token;if(!requestToken(secure,gPendingAccountLogin,gPendingAccountPassword,token))return false; if(!clearLocalAccountData()){workerSet("New account authorized, local reset failed");return false;} - gAccountLogin=gPendingAccountLogin;gDeviceToken=token;gAccountPassword="";gAccountPrefs.putString("login",gAccountLogin);gAccountPrefs.putString("token",gDeviceToken);gPendingAccountLogin="";gPendingAccountPassword="";gChangingAccount=false;workerSet("Account changed; local data cleared");return true; + gAccountLogin=gPendingAccountLogin;gAccountPassword=gPendingAccountPassword;gDeviceToken=token;gAccountPrefs.putString("login",gAccountLogin);gAccountPrefs.putString("password",gAccountPassword);gAccountPrefs.putString("token",gDeviceToken);gPendingAccountLogin="";gPendingAccountPassword="";gChangingAccount=false;workerSet("Account changed; local data cleared");return true; } static bool uploadFiles(WiFiClientSecure &secure){ if(gDeviceToken.isEmpty()&&!doPair(secure))return false; @@ -1201,7 +1201,7 @@ static void formatPromptScreen(){ } void setup(){Serial.begin(115200);Wire.begin(PIN_I2C_SDA,PIN_I2C_SCL);initPower();pinMode(PIN_INHALE,INPUT_PULLUP);pinMode(PIN_EXHALE,INPUT_PULLUP);initAudio();gfx->begin();gBus->writeC8D8(0x36,0xA0);gfx->setBrightness(220);gTouch.setPins(PIN_TP_INT,-1);gTouch.begin(Wire,0x5A,PIN_I2C_SDA,PIN_I2C_SCL);gTouch.setMaxCoordinates(DISP_W,DISP_H);gTouch.setSwapXY(true);gTouch.setMirrorXY(true,false);loadSettings();initClock();initImu();initEvents();appendEvent(2);wifiLoad(); gAccountPrefs.begin("breath-account",false); - gAccountLogin=gAccountPrefs.getString("login","");gDeviceToken=gAccountPrefs.getString("token",""); + gAccountLogin=gAccountPrefs.getString("login","");gAccountPassword=gAccountPrefs.getString("password","");gDeviceToken=gAccountPrefs.getString("token",""); uint64_t chip=ESP.getEfuseMac();char ident[20];snprintf(ident,sizeof(ident),"%012llX",(unsigned long long)chip);gDeviceId=ident; lv_init();gBuf1=(lv_color_t *)heap_caps_malloc(DISP_W*40*sizeof(lv_color_t),MALLOC_CAP_DMA);gBuf2=(lv_color_t *)heap_caps_malloc(DISP_W*40*sizeof(lv_color_t),MALLOC_CAP_DMA);lv_disp_draw_buf_init(&gDrawBuf,gBuf1,gBuf2,DISP_W*40);static lv_disp_drv_t dd;lv_disp_drv_init(&dd);dd.hor_res=DISP_W;dd.ver_res=DISP_H;dd.flush_cb=flush;dd.rounder_cb=rounder;dd.draw_buf=&gDrawBuf;lv_disp_drv_register(&dd);static lv_indev_drv_t id;lv_indev_drv_init(&id);id.type=LV_INDEV_TYPE_POINTER;id.read_cb=touchRead;lv_indev_drv_register(&id);const esp_timer_create_args_t ta={.callback=&tick,.name="lvgl_tick"};esp_timer_handle_t timer;esp_timer_create(&ta,&timer);esp_timer_start_periodic(timer,LVGL_TICK_MS*1000);gLastActivity=millis();if(gFileMountFailed)formatPromptScreen();else enterMonitor(nullptr);} void loop(){uint32_t now=millis();poll(gInhale,true);poll(gExhale,false);pollPowerKey();pollOrientation();usbCommands();wifiTick();ntpTick();networkFinishTick();reminders();if(now-gLastUi>=UI_MS){gLastUi=now;refresh();timeUiTick();networkUiTick();}if(now-gLastBatt>=BATT_MS){gLastBatt=now;batteryUi();}uint32_t timeout=SCREEN_TIMEOUTS[gScreenTimeout];if(gScreenOn&&!(gRotation && gImuOk && gScreenEdgeOrientation==2)&&gScreen!=Screen::Settings&&gScreen!=Screen::Wifi&&gScreen!=Screen::WifiPassword&&gScreen!=Screen::Time&&gScreen!=Screen::ManualTime&&gScreen!=Screen::Online&&gScreen!=Screen::Account&&(int32_t)(now-gKey1WakeUntil)>=0&&timeout&&now-gLastActivity>=timeout){gScreenOn=false;gfx->setBrightness(0);}lv_timer_handler();applyRotationScreenPolicy();if((int32_t)(millis()-gKey1WakeUntil)<0){gScreenOn=true;gfx->setBrightness(220);}delay(5);} diff --git a/breath_button_monitor/breathmonitor_v3 with server/server/src/main/resources/firmware/breathmonitor-v1.2.bin b/breath_button_monitor/breathmonitor_v3 with server/server/src/main/resources/firmware/breathmonitor-v1.2.bin index 6271a3f..696fc9f 100644 Binary files a/breath_button_monitor/breathmonitor_v3 with server/server/src/main/resources/firmware/breathmonitor-v1.2.bin and b/breath_button_monitor/breathmonitor_v3 with server/server/src/main/resources/firmware/breathmonitor-v1.2.bin differ