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;
|
uint8_t current_offset = 0;
|
||||||
|
|
||||||
for (int i=0;the_config[i].name!=NULL;i++){
|
for (int i=0;the_config[i].name!=NULL;i++){
|
||||||
numentries++;
|
if(!the_config[i].disabled)
|
||||||
|
numentries++;
|
||||||
};
|
};
|
||||||
|
|
||||||
visible_lines = ((RESY/getFontHeight())-1)/2;
|
visible_lines = ((RESY/getFontHeight())-1)/2;
|
||||||
|
@ -45,15 +46,21 @@ void changer(void){
|
||||||
|
|
||||||
lcdSetCrsrX(60);
|
lcdSetCrsrX(60);
|
||||||
lcdPrint("[");
|
lcdPrint("[");
|
||||||
lcdPrint(IntToStr(current_offset/visible_lines,1,0));
|
lcdPrint(IntToStr((current_offset/visible_lines)+1,1,0));
|
||||||
lcdPrint("/");
|
lcdPrint("/");
|
||||||
lcdPrint(IntToStr((numentries-1)/visible_lines,1,0));
|
lcdPrint(IntToStr(((numentries-1)/visible_lines)+1,1,0));
|
||||||
lcdPrint("]");
|
lcdPrint("]");
|
||||||
lcdNl();
|
lcdNl();
|
||||||
|
|
||||||
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){
|
if(i==0){
|
||||||
lcdPrintln("Save changes:");
|
lcdPrintln("Save changes:");
|
||||||
if (i == menuselection)
|
if (i == menuselection)
|
||||||
|
@ -64,17 +71,25 @@ void changer(void){
|
||||||
else
|
else
|
||||||
lcdPrintln("no");
|
lcdPrintln("no");
|
||||||
}else{
|
}else{
|
||||||
lcdPrintln(the_config[i].name);
|
lcdPrintln(the_config[j].name);
|
||||||
if (i == menuselection)
|
if (j == menuselection)
|
||||||
lcdPrint("*");
|
lcdPrint("*");
|
||||||
lcdSetCrsrX(14);
|
lcdSetCrsrX(14);
|
||||||
lcdPrint("<");
|
lcdPrint("<");
|
||||||
lcdPrint(IntToStr(the_config[i].value,3,F_LONG));
|
lcdPrint(IntToStr(the_config[j].value,3,F_LONG));
|
||||||
lcdPrintln(">");
|
lcdPrintln(">");
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
lcdRefresh();
|
lcdRefresh();
|
||||||
|
|
||||||
|
j=menuselection;
|
||||||
|
int t=0;
|
||||||
|
while(j){
|
||||||
|
if(!the_config[t].disabled)
|
||||||
|
j--;
|
||||||
|
t++;
|
||||||
|
}
|
||||||
|
|
||||||
switch (getInputWaitRepeat()) {
|
switch (getInputWaitRepeat()) {
|
||||||
case BTN_UP:
|
case BTN_UP:
|
||||||
menuselection--;
|
menuselection--;
|
||||||
|
@ -99,21 +114,21 @@ void changer(void){
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case BTN_LEFT:
|
case BTN_LEFT:
|
||||||
if(the_config[menuselection].value >
|
if(the_config[t].value >
|
||||||
the_config[menuselection].min)
|
the_config[t].min)
|
||||||
the_config[menuselection].value--;
|
the_config[t].value--;
|
||||||
if(the_config[menuselection].value > the_config[menuselection].max)
|
if(the_config[t].value > the_config[t].max)
|
||||||
the_config[menuselection].value=
|
the_config[t].value=
|
||||||
the_config[menuselection].max;
|
the_config[t].max;
|
||||||
applyConfig();
|
applyConfig();
|
||||||
break;
|
break;
|
||||||
case BTN_RIGHT:
|
case BTN_RIGHT:
|
||||||
if(the_config[menuselection].value <
|
if(the_config[t].value <
|
||||||
the_config[menuselection].max)
|
the_config[t].max)
|
||||||
the_config[menuselection].value++;
|
the_config[t].value++;
|
||||||
if(the_config[menuselection].value < the_config[menuselection].min)
|
if(the_config[t].value < the_config[t].min)
|
||||||
the_config[menuselection].value=
|
the_config[t].value=
|
||||||
the_config[menuselection].min;
|
the_config[t].min;
|
||||||
applyConfig();
|
applyConfig();
|
||||||
break;
|
break;
|
||||||
case BTN_ENTER:
|
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
|
flameEnabled = (flameSetI2C(FLAME_I2C_CR_LS0, FLAME_I2C_LS0_OFF << FLAME_I2C_LS0_LED0) == I2CSTATE_ACK); // probe i2c
|
||||||
|
|
||||||
if (flameEnabled) {
|
if (!flameEnabled)
|
||||||
flameSetI2C(FLAME_I2C_CR_LS0, FLAME_I2C_LS0_OFF << FLAME_I2C_LS0_LED0); // set led0 off
|
return;
|
||||||
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_LS0, FLAME_I2C_LS0_OFF << FLAME_I2C_LS0_LED0); // set led0 off
|
||||||
flameSetI2C(FLAME_I2C_CR_PWM0, 0x00); // set pwm
|
flameSetI2C(FLAME_I2C_CR_LS0, FLAME_I2C_LS0_OFF << FLAME_I2C_LS0_LED1); // set led1 off
|
||||||
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_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"
|
#include "lcd/print.h"
|
||||||
|
|
|
@ -26,3 +26,23 @@ void msc_menu(void){
|
||||||
fsReInit();
|
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
|
#define CFGVER 1
|
||||||
|
|
||||||
struct CDESC the_config[]= {
|
struct CDESC the_config[]= {
|
||||||
{"version", CFGVER, CFGVER, CFGVER},
|
{"version", CFGVER, CFGVER, CFGVER, 0, 0},
|
||||||
// dflt min max
|
// dflt min max
|
||||||
{"privacy", 3, 0, 2 },
|
{"privacy", 3, 0, 2 , 0, 0},
|
||||||
{"daytrig", 310/2, 0, 255},
|
{"daytrig", 310/2, 0, 255, 0, 0},
|
||||||
{"daytrighyst", 10, 0, 50 },
|
{"daytrighyst", 10, 0, 50 , 0, 0},
|
||||||
{"dayinvert", 1, 0, 1 },
|
{"dayinvert", 1, 0, 1 , 0, 0},
|
||||||
{"lcdbacklight", 50, 0, 100},
|
{"lcdbacklight", 50, 0, 100, 0, 0},
|
||||||
{"lcdmirror", 0, 0, 1 },
|
{"lcdmirror", 0, 0, 1 , 0, 0},
|
||||||
{"lcdinvert", 0, 0, 1 },
|
{"lcdinvert", 0, 0, 1 , 0, 0},
|
||||||
{"lcdcontrast", 14, 0, 31 },
|
{"lcdcontrast", 14, 0, 31 , 0, 0},
|
||||||
{"alivechk", 0, 0, 2 },
|
{"alivechk", 0, 0, 2 , 0, 0},
|
||||||
{"flamemax", 255, 0, 255},
|
{"flamemax", 255, 0, 255, 1, CFG_TYPE_FLAME},
|
||||||
{"flamemin", 0, 0, 255},
|
{"flamemin", 0, 0, 255, 1, CFG_TYPE_FLAME},
|
||||||
{"flamespeed", 1, 1, 100},
|
{"flamespeed", 1, 1, 100, 1, CFG_TYPE_FLAME},
|
||||||
{"flamemaxw", 255, 1, 255},
|
{"flamemaxw", 255, 1, 255, 1, CFG_TYPE_FLAME},
|
||||||
{"flameminw", 0x8f, 1, 255},
|
{"flameminw", 0x8f, 1, 255, 1, CFG_TYPE_FLAME},
|
||||||
{ NULL, 0, 0, 0 },
|
{ NULL, 0, 0, 0 , 0, 0},
|
||||||
};
|
};
|
||||||
|
|
||||||
char nickname[MAXNICK]="anonymous";
|
char nickname[MAXNICK]="anonymous";
|
||||||
|
@ -112,3 +112,10 @@ int readConfig(void){
|
||||||
return 0;
|
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 readConfig(void);
|
||||||
int saveConfig(void);
|
int saveConfig(void);
|
||||||
void applyConfig(void);
|
void applyConfig(void);
|
||||||
|
void enableConfig(char type,char enable);
|
||||||
|
|
||||||
struct CDESC {
|
struct CDESC {
|
||||||
char *name;
|
char *name;
|
||||||
char value;
|
char value;
|
||||||
char min;
|
char min;
|
||||||
char max;
|
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
|
#define MAXNICK 20
|
||||||
extern struct CDESC the_config[];
|
extern struct CDESC the_config[];
|
||||||
extern char nickname[MAXNICK];
|
extern char nickname[MAXNICK];
|
||||||
|
|
|
@ -147,26 +147,6 @@ void Qstatus(void) {
|
||||||
dx=DoString(0,dy,"Done.");
|
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
|
//# MENU debug ShowSP
|
||||||
void getsp(void) {
|
void getsp(void) {
|
||||||
int dx=0;
|
int dx=0;
|
||||||
|
|
Loading…
Reference in New Issue