Fix a few global config regressions, and add sample config menu
This commit is contained in:
parent
cfe6e328e5
commit
e3d46f01bd
|
@ -23,16 +23,102 @@ void applycfg(void){
|
||||||
applyConfig();
|
applyConfig();
|
||||||
};
|
};
|
||||||
|
|
||||||
void show(void){
|
void changer(void){
|
||||||
lcdClear();
|
uint8_t numentries = 0;
|
||||||
lcdPrint("time:"); lcdPrintInt(globalconfig.time); lcdNl();
|
signed char menuselection = 0;
|
||||||
lcdPrint("btrig:"); lcdPrintInt(globalconfig.backlighttrigger); lcdNl();
|
uint8_t visible_lines = 0;
|
||||||
lcdPrint("bval:"); lcdPrintInt(globalconfig.backlightvalue); lcdNl();
|
uint8_t current_offset = 0;
|
||||||
lcdPrint("lcd:"); lcdPrintInt(globalconfig.lcdstate); lcdNl();
|
|
||||||
lcdPrint("priv:"); lcdPrintInt(globalconfig.privacy); lcdNl();
|
|
||||||
lcdRefresh();
|
|
||||||
};
|
|
||||||
|
|
||||||
void lcdmirror(void){
|
for (int i=0;the_config[i].name!=NULL;i++){
|
||||||
lcdToggleFlag(LCD_MIRRORX);
|
numentries++;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
visible_lines = ((RESY/getFontHeight())-1)/2;
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
// Display current menu page
|
||||||
|
lcdClear();
|
||||||
|
lcdPrint("Config");
|
||||||
|
|
||||||
|
lcdSetCrsrX(60);
|
||||||
|
lcdPrint("[");
|
||||||
|
lcdPrint(IntToStr(current_offset/visible_lines,1,0));
|
||||||
|
lcdPrint("/");
|
||||||
|
lcdPrint(IntToStr(numentries/visible_lines,1,0));
|
||||||
|
lcdPrint("]");
|
||||||
|
lcdNl();
|
||||||
|
|
||||||
|
lcdNl();
|
||||||
|
|
||||||
|
for (uint8_t i = current_offset; i < (visible_lines + current_offset) && i < numentries; i++) {
|
||||||
|
if(i==0){
|
||||||
|
lcdPrintln("Save changes:");
|
||||||
|
if (i == menuselection)
|
||||||
|
lcdPrint("*");
|
||||||
|
lcdSetCrsrX(14);
|
||||||
|
if (i == menuselection)
|
||||||
|
lcdPrintln("YES");
|
||||||
|
else
|
||||||
|
lcdPrintln("no");
|
||||||
|
}else{
|
||||||
|
lcdPrintln(the_config[i].name);
|
||||||
|
if (i == menuselection)
|
||||||
|
lcdPrint("*");
|
||||||
|
lcdSetCrsrX(14);
|
||||||
|
lcdPrint("<");
|
||||||
|
lcdPrint(IntToStr(the_config[i].value,3,F_LONG));
|
||||||
|
lcdPrintln(">");
|
||||||
|
};
|
||||||
|
}
|
||||||
|
lcdRefresh();
|
||||||
|
|
||||||
|
switch (getInputWait()) {
|
||||||
|
case BTN_UP:
|
||||||
|
menuselection--;
|
||||||
|
if (menuselection < current_offset) {
|
||||||
|
if (menuselection < 0) {
|
||||||
|
menuselection = numentries-1;
|
||||||
|
current_offset = ((numentries-1)/visible_lines) * visible_lines;
|
||||||
|
} else {
|
||||||
|
current_offset -= visible_lines;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case BTN_DOWN:
|
||||||
|
menuselection++;
|
||||||
|
if (menuselection > (current_offset + visible_lines-1) || menuselection >= numentries) {
|
||||||
|
if (menuselection >= numentries) {
|
||||||
|
menuselection = 0;
|
||||||
|
current_offset = 0;
|
||||||
|
} else {
|
||||||
|
current_offset += visible_lines;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case BTN_LEFT:
|
||||||
|
if(the_config[menuselection].value >
|
||||||
|
the_config[menuselection].min)
|
||||||
|
the_config[menuselection].value--;
|
||||||
|
if(the_config[menuselection].value > the_config[menuselection].max)
|
||||||
|
the_config[menuselection].value=
|
||||||
|
the_config[menuselection].max;
|
||||||
|
applyConfig();
|
||||||
|
break;
|
||||||
|
case BTN_RIGHT:
|
||||||
|
if(the_config[menuselection].value <
|
||||||
|
the_config[menuselection].max)
|
||||||
|
the_config[menuselection].value++;
|
||||||
|
if(the_config[menuselection].value < the_config[menuselection].min)
|
||||||
|
the_config[menuselection].value=
|
||||||
|
the_config[menuselection].min;
|
||||||
|
applyConfig();
|
||||||
|
break;
|
||||||
|
case BTN_ENTER:
|
||||||
|
if(menuselection==0)
|
||||||
|
saveConfig();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
getInputWaitRelease();
|
||||||
|
}
|
||||||
|
/* NOTREACHED */
|
||||||
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ void adc_light(void) {
|
||||||
while ((getInputRaw())==BTN_NONE){
|
while ((getInputRaw())==BTN_NONE){
|
||||||
DoInt(dx,dy,GetLight());
|
DoInt(dx,dy,GetLight());
|
||||||
DoInt(dx,dy+16,isNight());
|
DoInt(dx,dy+16,isNight());
|
||||||
DoInt(dx,dy+8,globalconfig.backlighttrigger);
|
DoInt(dx,dy+8,GLOBAL(nighttrigger));
|
||||||
lcdDisplay();
|
lcdDisplay();
|
||||||
};
|
};
|
||||||
dy+=8;
|
dy+=8;
|
||||||
|
|
|
@ -1,38 +0,0 @@
|
||||||
#include <sysinit.h>
|
|
||||||
|
|
||||||
#include "basic/basic.h"
|
|
||||||
|
|
||||||
#include "lcd/print.h"
|
|
||||||
#include "lcd/display.h"
|
|
||||||
|
|
||||||
#include "filesystem/ff.h"
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
/**************************************************************************/
|
|
||||||
|
|
||||||
void readcfg(void) {
|
|
||||||
readConfig();
|
|
||||||
};
|
|
||||||
|
|
||||||
void savecfg(void){
|
|
||||||
saveConfig();
|
|
||||||
};
|
|
||||||
|
|
||||||
void applycfg(void){
|
|
||||||
applyConfig();
|
|
||||||
};
|
|
||||||
|
|
||||||
void show(void){
|
|
||||||
lcdClear();
|
|
||||||
lcdPrint("time:"); lcdPrintInt(globalconfig.time); lcdNl();
|
|
||||||
lcdPrint("btrig:"); lcdPrintInt(globalconfig.backlighttrigger); lcdNl();
|
|
||||||
lcdPrint("bval:"); lcdPrintInt(globalconfig.backlightvalue); lcdNl();
|
|
||||||
lcdPrint("lcd:"); lcdPrintInt(globalconfig.lcdstate); lcdNl();
|
|
||||||
lcdPrint("priv:"); lcdPrintInt(globalconfig.privacy); lcdNl();
|
|
||||||
lcdRefresh();
|
|
||||||
};
|
|
||||||
|
|
||||||
void lcdmirror(void){
|
|
||||||
lcdToggleFlag(LCD_MIRRORX);
|
|
||||||
};
|
|
|
@ -37,13 +37,46 @@ void adc_light(void) {
|
||||||
while ((getInputRaw())==BTN_NONE){
|
while ((getInputRaw())==BTN_NONE){
|
||||||
DoInt(dx,dy,GetLight());
|
DoInt(dx,dy,GetLight());
|
||||||
DoInt(dx,dy+16,isNight());
|
DoInt(dx,dy+16,isNight());
|
||||||
DoInt(dx,dy+8,globalconfig.backlighttrigger);
|
DoInt(dx,dy+8,GLOBAL(nighttrigger));
|
||||||
lcdDisplay();
|
lcdDisplay();
|
||||||
};
|
};
|
||||||
dy+=8;
|
dy+=8;
|
||||||
dx=DoString(0,dy,"Done.");
|
dx=DoString(0,dy,"Done.");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void uptime(void) {
|
||||||
|
int t;
|
||||||
|
int h;
|
||||||
|
char flag;
|
||||||
|
while ((getInputRaw())==BTN_NONE){
|
||||||
|
lcdClear();
|
||||||
|
lcdPrintln("Uptime:");
|
||||||
|
t=getTimer()/(1000/SYSTICKSPEED);
|
||||||
|
h=t/60/60;
|
||||||
|
flag=F_ZEROS;
|
||||||
|
if(h>0){
|
||||||
|
lcdPrint(IntToStr(h,2,flag));
|
||||||
|
lcdPrint("h");
|
||||||
|
flag|=F_LONG;
|
||||||
|
};
|
||||||
|
h=t/60%60;
|
||||||
|
if(h>0){
|
||||||
|
lcdPrint(IntToStr(h,2,flag));
|
||||||
|
lcdPrint("m");
|
||||||
|
flag|=F_LONG;
|
||||||
|
};
|
||||||
|
h=t%60;
|
||||||
|
if(h>0){
|
||||||
|
lcdPrint(IntToStr(h,2,flag));
|
||||||
|
lcdPrint("s");
|
||||||
|
};
|
||||||
|
lcdNl();
|
||||||
|
lcdRefresh();
|
||||||
|
delayms_queue(200);
|
||||||
|
};
|
||||||
|
lcdPrintln("done.");
|
||||||
|
};
|
||||||
|
|
||||||
void gotoISP(void) {
|
void gotoISP(void) {
|
||||||
DoString(0,0,"Enter ISP!");
|
DoString(0,0,"Enter ISP!");
|
||||||
lcdDisplay();
|
lcdDisplay();
|
||||||
|
|
Loading…
Reference in New Issue