From 9b115fea4c156f4ca55a3a3d618ab821a47debaa Mon Sep 17 00:00:00 2001 From: Stefan `Sec` Zehl Date: Thu, 4 Aug 2011 13:52:36 +0200 Subject: [PATCH 1/2] File selector now omits extension for display. --- firmware/filesystem/select.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/firmware/filesystem/select.c b/firmware/filesystem/select.c index 6ca3c47..d6512b6 100644 --- a/firmware/filesystem/select.c +++ b/firmware/filesystem/select.c @@ -75,7 +75,17 @@ int selectFile(char *filename, char *extension) lcdPrint("*"); else lcdPrint(" "); + lcdSetCrsrX(14); + int dot=-1; + for(int j=0;files[j];j++) + if(files[i][j]=='.'){ + files[i][j]=0; + dot=j; + break; + }; lcdPrintln(files[i]); + if(dot>0) + files[i][dot]='.'; } lcdRefresh(); key=getInputWait(); From a7894361e6cbf796175662cfdf0d50a68f4d9328 Mon Sep 17 00:00:00 2001 From: Stefan `Sec` Zehl Date: Thu, 4 Aug 2011 14:33:39 +0200 Subject: [PATCH 2/2] config now allows hiding of variables. flame options are hidden unless flame present also fix alivechk setting --- firmware/applications/final/config.c | 53 ++++++++++++++++++---------- firmware/applications/final/flame.c | 21 ++++++----- firmware/applications/final/util.c | 20 +++++++++++ firmware/basic/config.c | 39 +++++++++++--------- firmware/basic/config.h | 8 ++++- firmware/l0dable/debug.c | 20 ----------- 6 files changed, 96 insertions(+), 65 deletions(-) diff --git a/firmware/applications/final/config.c b/firmware/applications/final/config.c index 444c8ea..3761494 100644 --- a/firmware/applications/final/config.c +++ b/firmware/applications/final/config.c @@ -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"); }; } 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: diff --git a/firmware/applications/final/flame.c b/firmware/applications/final/flame.c index 06d02b1..1b5f5fa 100644 --- a/firmware/applications/final/flame.c +++ b/firmware/applications/final/flame.c @@ -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" diff --git a/firmware/applications/final/util.c b/firmware/applications/final/util.c index aa99c61..5dbca8f 100644 --- a/firmware/applications/final/util.c +++ b/firmware/applications/final/util.c @@ -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; +}; + diff --git a/firmware/basic/config.c b/firmware/basic/config.c index 84f6d5a..2533e06 100644 --- a/firmware/basic/config.c +++ b/firmware/basic/config.c @@ -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; + } + } +} diff --git a/firmware/basic/config.h b/firmware/basic/config.h index bcd4f98..9654b38 100644 --- a/firmware/basic/config.h +++ b/firmware/basic/config.h @@ -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]; diff --git a/firmware/l0dable/debug.c b/firmware/l0dable/debug.c index 50b2c2b..a0d29f8 100644 --- a/firmware/l0dable/debug.c +++ b/firmware/l0dable/debug.c @@ -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;