Merge git://github.com/r0ket/r0ket

This commit is contained in:
bernd 2011-08-04 14:55:00 +02:00
commit bef559180d
7 changed files with 106 additions and 65 deletions

View File

@ -33,6 +33,7 @@ void changer(void){
uint8_t current_offset = 0;
for (int i=0;the_config[i].name!=NULL;i++){
if(!the_config[i].disabled)
numentries++;
};
@ -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:

View File

@ -137,7 +137,9 @@ void init_flame(void) {
flameEnabled = (flameSetI2C(FLAME_I2C_CR_LS0, FLAME_I2C_LS0_OFF << FLAME_I2C_LS0_LED0) == I2CSTATE_ACK); // probe i2c
if (flameEnabled) {
if (!flameEnabled)
return;
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
@ -146,7 +148,8 @@ void init_flame(void) {
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"

View File

@ -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;
};

View File

@ -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;
}
}
}

View File

@ -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];

View File

@ -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();

View File

@ -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;