Разделить обычные и онлайн настройки

This commit is contained in:
AidarKC
2026-10-25 15:15:59 +03:00
parent 16015cc45f
commit 5cb3945e98
2 changed files with 18 additions and 6 deletions
@@ -408,7 +408,7 @@ static void topBar(const char *title) {
}else if(gScreen==Screen::Settings){
gTopPhase=label(gRoot,"WAITING",&lv_font_montserrat_20,0x4FB3FF);lv_obj_set_pos(gTopPhase,24,48);
gTopPhaseTime=label(gRoot,"",&lv_font_montserrat_16,0xFFFFFF);lv_obj_set_pos(gTopPhaseTime,142,52);
gPauseButton=button(gRoot,gPaused?"RESUME":"PAUSE",255,44,92,31,0x214D69,pauseClicked);
gPauseButton=button(gRoot,gPaused?"RESUME":"PAUSE",220,44,92,31,0x214D69,pauseClicked);
}
else{
lv_obj_t *heading=label(gRoot,title,&lv_font_montserrat_20,0xFFFFFF);
@@ -451,6 +451,7 @@ static void enterMonitor(lv_event_t *) {
lv_obj_set_pos(gHistory[i],78+i*68,3);}
}
static void home(lv_event_t *); static void settings(lv_event_t *);
static void onlineSettings(lv_event_t *);
static lv_obj_t *button(lv_obj_t *p,const char *text,int x,int y,int w,int h,uint32_t bg,lv_event_cb_t cb,void *userData) { lv_obj_t *b=lv_btn_create(p);lv_obj_set_pos(b,x,y);lv_obj_set_size(b,w,h);card(b,bg);lv_obj_add_event_cb(b,cb,LV_EVENT_CLICKED,userData);lv_obj_t *l=label(b,text,&lv_font_montserrat_20,0xFFFFFF);lv_obj_center(l);return b; }
static void home(lv_event_t *) {enterMonitor(nullptr);}
static void settingChanged(lv_event_t *e){
@@ -463,6 +464,17 @@ static void settingReleased(lv_event_t *e){
}
static void refresh();
static void settings(lv_event_t *) {
gScreen=Screen::Settings;clearUi();legend();topBar("SETTINGS");
lv_obj_t *list=lv_obj_create(gRoot);lv_obj_set_pos(list,20,91);lv_obj_set_size(list,440,280);
card(list,0x10202D);lv_obj_set_style_pad_all(list,10,0);lv_obj_set_flex_flow(list,LV_FLEX_FLOW_COLUMN);lv_obj_set_style_pad_row(list,9,0);
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,"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);
}
static void onlineSettings(lv_event_t *) {
gScreen=Screen::Settings;clearUi();legend();topBar("SETTINGS");
if(gPaused){gPausedBanner=label(gRoot,"PAUSED",&lv_font_montserrat_20,0xFFD34D);
lv_obj_align(gPausedBanner,LV_ALIGN_TOP_MID,0,32);}
@@ -784,7 +796,7 @@ static void wifiScreen(lv_event_t *){
lv_obj_t *name=label(item,n.c_str(),&lv_font_montserrat_16,0xFFFFFF);
lv_obj_set_width(name,365);lv_label_set_long_mode(name,LV_LABEL_LONG_DOT);lv_obj_center(name);
}
button(gRoot,"BACK",140,431,200,39,0x214D69,[](lv_event_t *){if(!gWorkerActive)networkFinish("Wi-Fi off");settings(nullptr);});
button(gRoot,"BACK",140,431,200,39,0x214D69,[](lv_event_t *){if(!gWorkerActive)networkFinish("Wi-Fi off");onlineSettings(nullptr);});
batteryUi();
}
static void wifiPasswordEvent(lv_event_t *e){
@@ -900,7 +912,7 @@ static void timeScreen(lv_event_t *){
gManualParts[0]=t.tm_year+1900;gManualParts[1]=t.tm_mon+1;gManualParts[2]=t.tm_mday;gManualParts[3]=t.tm_hour;gManualParts[4]=t.tm_min;
gManualField=0;gManualDigits="";manualTimeScreen();
});
button(gRoot,"BACK",140,399,200,52,0x214D69,[](lv_event_t *){settings(nullptr);});
button(gRoot,"BACK",140,399,200,52,0x214D69,[](lv_event_t *){onlineSettings(nullptr);});
}
static bool manualValid(){
int y=gManualParts[0],m=gManualParts[1],d=gManualParts[2],h=gManualParts[3],n=gManualParts[4];
@@ -968,7 +980,7 @@ static void onlineScreen(lv_event_t *){
if(gDeviceToken.isEmpty()&&(gAccountLogin.isEmpty()||gAccountPassword.isEmpty())){gWifiNotice="Set login + password in ACCOUNT";return;}
networkStart(NetOperation::Upload);
});
button(gRoot,"SETTINGS",248,300,208,55,0x214D69,[](lv_event_t *){settings(nullptr);});
button(gRoot,"SETTINGS",248,300,208,55,0x214D69,[](lv_event_t *){onlineSettings(nullptr);});
button(gRoot,"BACK",248,377,208,50,0x214D69,[](lv_event_t *){settings(nullptr);});
}
static void accountScreen(lv_event_t *){
@@ -979,7 +991,7 @@ static void accountScreen(lv_event_t *){
lv_obj_t *explain=label(gRoot,"Password is kept in RAM only until pairing.\nToken is saved for subsequent uploads.",&lv_font_montserrat_14,0x9EB4C2);
lv_obj_set_pos(explain,26,205);lv_obj_set_width(explain,420);
button(gRoot,"CHANGE ACCOUNT",24,292,432,58,0xA56A36,[](lv_event_t *){accountConfirmScreen(nullptr);});
button(gRoot,"BACK",140,375,200,52,0x214D69,[](lv_event_t *){settings(nullptr);});
button(gRoot,"BACK",140,375,200,52,0x214D69,[](lv_event_t *){onlineSettings(nullptr);});
}
static void accountConfirmScreen(lv_event_t *){
gScreen=Screen::Account;clearUi();legend();topBar("CHANGE ACCOUNT");
@@ -1005,7 +1017,7 @@ static void firmwareScreen(lv_event_t *){
if(gNetOperation==NetOperation::Firmware||gWorkerActive){lv_obj_t *s=label(gRoot,workerMessage().c_str(),&lv_font_montserrat_16,0xFFD34D);lv_obj_set_pos(s,28,220);}
button(gRoot,"UPDATE STABLE",24,285,208,55,0x2A9D8F,[](lv_event_t *){gFirmwareTarget="1.1";firmwareConfirmScreen(nullptr);});
button(gRoot,"UPDATE TEST",248,285,208,55,0xA56A36,[](lv_event_t *){gFirmwareTarget="1.2";firmwareConfirmScreen(nullptr);});
button(gRoot,"BACK",140,375,200,52,0x214D69,[](lv_event_t *){settings(nullptr);});
button(gRoot,"BACK",140,375,200,52,0x214D69,[](lv_event_t *){onlineSettings(nullptr);});
}
static void networkUiTick(){
if(gScreen!=Screen::Online||!gOnlineStatus)return;