config now allows hiding of variables.
flame options are hidden unless flame present also fix alivechk setting
This commit is contained in:
parent
9b115fea4c
commit
a7894361e6
|
@ -33,7 +33,8 @@ void changer(void){
|
|||
uint8_t current_offset = 0;
|
||||
|
||||
for (int i=0;the_config[i].name!=NULL;i++){
|
||||
numentries++;
|
||||
if(!the_config[i].disabled)
|
||||
numentries++;
|
||||
};
|
||||
|
||||
visible_lines = ((RESY/getFontHeight())-1)/2;
|
||||
|
@ -45,15 +46,21 @@ void changer(void){
|
|||
|
||||
lcdSetCrsrX(60);
|
||||
lcdPrint("[");
|
||||
lcdPrint(IntToStr(current_offset/visible_lines,1,0));
|
||||
lcdPrint(IntToStr((current_offset/visible_lines)+1,1,0));
|
||||
lcdPrint("/");
|
||||
lcdPrint(IntToStr((numentries-1)/visible_lines,1,0));
|
||||
lcdPrint(IntToStr(((numentries-1)/visible_lines)+1,1,0));
|
||||
lcdPrint("]");
|
||||
lcdNl();
|
||||
|
||||
lcdNl();
|
||||
|
||||
for (uint8_t i = current_offset; i < (visible_lines + current_offset) && i < numentries; i++) {
|
||||
uint8_t j=0;
|
||||
for (uint8_t i=0;i<current_offset;i++,j++)
|
||||
if(the_config[j].disabled)
|
||||
j++;
|
||||
|
||||
for (uint8_t i = current_offset; i < (visible_lines + current_offset) && i < numentries; i++,j++) {
|
||||
while(the_config[j].disabled)j++;
|
||||
if(i==0){
|
||||
lcdPrintln("Save changes:");
|
||||
if (i == menuselection)
|
||||
|
@ -64,17 +71,25 @@ void changer(void){
|
|||
else
|
||||
lcdPrintln("no");
|
||||
}else{
|
||||
lcdPrintln(the_config[i].name);
|
||||
if (i == menuselection)
|
||||
lcdPrintln(the_config[j].name);
|
||||
if (j == menuselection)
|
||||
lcdPrint("*");
|
||||
lcdSetCrsrX(14);
|
||||
lcdPrint("<");
|
||||
lcdPrint(IntToStr(the_config[i].value,3,F_LONG));
|
||||
lcdPrint(IntToStr(the_config[j].value,3,F_LONG));
|
||||
lcdPrintln(">");
|
||||
};
|
||||
}
|
||||
lcdRefresh();
|
||||
|
||||
j=menuselection;
|
||||
int t=0;
|
||||
while(j){
|
||||
if(!the_config[t].disabled)
|
||||
j--;
|
||||
t++;
|
||||
}
|
||||
|
||||
switch (getInputWaitRepeat()) {
|
||||
case BTN_UP:
|
||||
menuselection--;
|
||||
|
@ -99,21 +114,21 @@ void changer(void){
|
|||
}
|
||||
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;
|
||||
if(the_config[t].value >
|
||||
the_config[t].min)
|
||||
the_config[t].value--;
|
||||
if(the_config[t].value > the_config[t].max)
|
||||
the_config[t].value=
|
||||
the_config[t].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;
|
||||
if(the_config[t].value <
|
||||
the_config[t].max)
|
||||
the_config[t].value++;
|
||||
if(the_config[t].value < the_config[t].min)
|
||||
the_config[t].value=
|
||||
the_config[t].min;
|
||||
applyConfig();
|
||||
break;
|
||||
case BTN_ENTER:
|
||||
|
|
|
@ -137,16 +137,19 @@ void init_flame(void) {
|
|||
|
||||
flameEnabled = (flameSetI2C(FLAME_I2C_CR_LS0, FLAME_I2C_LS0_OFF << FLAME_I2C_LS0_LED0) == I2CSTATE_ACK); // probe i2c
|
||||
|
||||
if (flameEnabled) {
|
||||
flameSetI2C(FLAME_I2C_CR_LS0, FLAME_I2C_LS0_OFF << FLAME_I2C_LS0_LED0); // set led0 off
|
||||
flameSetI2C(FLAME_I2C_CR_LS0, FLAME_I2C_LS0_OFF << FLAME_I2C_LS0_LED1); // set led1 off
|
||||
flameSetI2C(FLAME_I2C_CR_LS0, FLAME_I2C_LS0_OFF << FLAME_I2C_LS0_LED2); // set led2 off
|
||||
flameSetI2C(FLAME_I2C_CR_LS0, FLAME_I2C_LS0_OFF << FLAME_I2C_LS0_LED3); // set led3 off
|
||||
if (!flameEnabled)
|
||||
return;
|
||||
|
||||
flameSetI2C(FLAME_I2C_CR_PSC0, 0x00); // set prescaler
|
||||
flameSetI2C(FLAME_I2C_CR_PWM0, 0x00); // set pwm
|
||||
flameSetI2C(FLAME_I2C_CR_LS0, FLAME_I2C_LS0_PWM0 << FLAME_I2C_LS0_LED0); // set led0 to pwm
|
||||
}
|
||||
flameSetI2C(FLAME_I2C_CR_LS0, FLAME_I2C_LS0_OFF << FLAME_I2C_LS0_LED0); // set led0 off
|
||||
flameSetI2C(FLAME_I2C_CR_LS0, FLAME_I2C_LS0_OFF << FLAME_I2C_LS0_LED1); // set led1 off
|
||||
flameSetI2C(FLAME_I2C_CR_LS0, FLAME_I2C_LS0_OFF << FLAME_I2C_LS0_LED2); // set led2 off
|
||||
flameSetI2C(FLAME_I2C_CR_LS0, FLAME_I2C_LS0_OFF << FLAME_I2C_LS0_LED3); // set led3 off
|
||||
|
||||
flameSetI2C(FLAME_I2C_CR_PSC0, 0x00); // set prescaler
|
||||
flameSetI2C(FLAME_I2C_CR_PWM0, 0x00); // set pwm
|
||||
flameSetI2C(FLAME_I2C_CR_LS0, FLAME_I2C_LS0_PWM0 << FLAME_I2C_LS0_LED0); // set led0 to pwm
|
||||
|
||||
enableConfig(CFG_TYPE_FLAME,1);
|
||||
}
|
||||
|
||||
#include "lcd/print.h"
|
||||
|
|
|
@ -26,3 +26,23 @@ void msc_menu(void){
|
|||
fsReInit();
|
||||
};
|
||||
|
||||
void blink_led0(void){
|
||||
gpioSetValue (RB_LED0, 1-gpioGetValue(RB_LED0));
|
||||
};
|
||||
|
||||
void tick_alive(void){
|
||||
static int foo=0;
|
||||
|
||||
if(GLOBAL(alivechk)==0)
|
||||
return;
|
||||
|
||||
if(foo++>500/SYSTICKSPEED){
|
||||
foo=0;
|
||||
if(GLOBAL(alivechk)==2)
|
||||
push_queue(blink_led0);
|
||||
else
|
||||
blink_led0();
|
||||
};
|
||||
return;
|
||||
};
|
||||
|
||||
|
|
|
@ -10,23 +10,23 @@
|
|||
#define CFGVER 1
|
||||
|
||||
struct CDESC the_config[]= {
|
||||
{"version", CFGVER, CFGVER, CFGVER},
|
||||
{"version", CFGVER, CFGVER, CFGVER, 0, 0},
|
||||
// dflt min max
|
||||
{"privacy", 3, 0, 2 },
|
||||
{"daytrig", 310/2, 0, 255},
|
||||
{"daytrighyst", 10, 0, 50 },
|
||||
{"dayinvert", 1, 0, 1 },
|
||||
{"lcdbacklight", 50, 0, 100},
|
||||
{"lcdmirror", 0, 0, 1 },
|
||||
{"lcdinvert", 0, 0, 1 },
|
||||
{"lcdcontrast", 14, 0, 31 },
|
||||
{"alivechk", 0, 0, 2 },
|
||||
{"flamemax", 255, 0, 255},
|
||||
{"flamemin", 0, 0, 255},
|
||||
{"flamespeed", 1, 1, 100},
|
||||
{"flamemaxw", 255, 1, 255},
|
||||
{"flameminw", 0x8f, 1, 255},
|
||||
{ NULL, 0, 0, 0 },
|
||||
{"privacy", 3, 0, 2 , 0, 0},
|
||||
{"daytrig", 310/2, 0, 255, 0, 0},
|
||||
{"daytrighyst", 10, 0, 50 , 0, 0},
|
||||
{"dayinvert", 1, 0, 1 , 0, 0},
|
||||
{"lcdbacklight", 50, 0, 100, 0, 0},
|
||||
{"lcdmirror", 0, 0, 1 , 0, 0},
|
||||
{"lcdinvert", 0, 0, 1 , 0, 0},
|
||||
{"lcdcontrast", 14, 0, 31 , 0, 0},
|
||||
{"alivechk", 0, 0, 2 , 0, 0},
|
||||
{"flamemax", 255, 0, 255, 1, CFG_TYPE_FLAME},
|
||||
{"flamemin", 0, 0, 255, 1, CFG_TYPE_FLAME},
|
||||
{"flamespeed", 1, 1, 100, 1, CFG_TYPE_FLAME},
|
||||
{"flamemaxw", 255, 1, 255, 1, CFG_TYPE_FLAME},
|
||||
{"flameminw", 0x8f, 1, 255, 1, CFG_TYPE_FLAME},
|
||||
{ NULL, 0, 0, 0 , 0, 0},
|
||||
};
|
||||
|
||||
char nickname[MAXNICK]="anonymous";
|
||||
|
@ -112,3 +112,10 @@ int readConfig(void){
|
|||
return 0;
|
||||
};
|
||||
|
||||
void enableConfig(char type,char enable){
|
||||
CONF_ITER{
|
||||
if(the_config[i].type == type){
|
||||
the_config[i].disabled=!enable;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,15 +4,21 @@
|
|||
int readConfig(void);
|
||||
int saveConfig(void);
|
||||
void applyConfig(void);
|
||||
|
||||
void enableConfig(char type,char enable);
|
||||
|
||||
struct CDESC {
|
||||
char *name;
|
||||
char value;
|
||||
char min;
|
||||
char max;
|
||||
unsigned disabled :1;
|
||||
unsigned type :3;
|
||||
};
|
||||
|
||||
#define CFG_TYPE_BASIC 0
|
||||
#define CFG_TYPE_DEVEL 1
|
||||
#define CFG_TYPE_FLAME 2
|
||||
|
||||
#define MAXNICK 20
|
||||
extern struct CDESC the_config[];
|
||||
extern char nickname[MAXNICK];
|
||||
|
|
|
@ -147,26 +147,6 @@ void Qstatus(void) {
|
|||
dx=DoString(0,dy,"Done.");
|
||||
};
|
||||
|
||||
void blink_led0(void){
|
||||
gpioSetValue (RB_LED0, 1-gpioGetValue(RB_LED0));
|
||||
};
|
||||
|
||||
void tick_alive(void){
|
||||
static int foo=0;
|
||||
|
||||
if(GLOBAL(alivechk)==0)
|
||||
return;
|
||||
|
||||
if(foo++>500/SYSTICKSPEED){
|
||||
foo=0;
|
||||
if(GLOBAL(alivechk)==2)
|
||||
push_queue(blink_led0);
|
||||
else
|
||||
blink_led0();
|
||||
};
|
||||
return;
|
||||
};
|
||||
|
||||
//# MENU debug ShowSP
|
||||
void getsp(void) {
|
||||
int dx=0;
|
||||
|
|
Loading…
Reference in New Issue