From 16da194336ea8e5f44fc2de4ac3a1b37ac39a8cd Mon Sep 17 00:00:00 2001 From: Stefan `Sec` Zehl Date: Thu, 4 Aug 2011 16:57:18 +0200 Subject: [PATCH] Support l0dable nickname display. --- firmware/applications/final/nickname.c | 27 ++++++++++++++++++++++++++ firmware/basic/config.c | 4 +++- firmware/basic/config.h | 5 ++++- firmware/filesystem/execute.c | 11 ++++++----- firmware/filesystem/execute.h | 2 +- firmware/l0dable/EXPORTS | 5 +++++ firmware/l0dable/Makefile | 4 ---- 7 files changed, 46 insertions(+), 12 deletions(-) diff --git a/firmware/applications/final/nickname.c b/firmware/applications/final/nickname.c index 11cf4ed..2882293 100644 --- a/firmware/applications/final/nickname.c +++ b/firmware/applications/final/nickname.c @@ -16,7 +16,20 @@ /**************************************************************************/ +void simpleNickname(void); + void fancyNickname(void) { + if(GLOBAL(l0nick)){ + if(execute_file(GLOBAL(nickl0),0,0)) + GLOBAL(l0nick)=0; + } + + if(!GLOBAL(l0nick)) + simpleNickname(); + return; +} + +void simpleNickname(void) { int dx=0; int dy=0; static uint32_t ctr=0; @@ -44,6 +57,7 @@ void fancyNickname(void) { void init_nick(void){ readFile("nick.cfg",GLOBAL(nickname),MAXNICK); readFile("font.cfg",GLOBAL(nickfont),FILENAMELEN); + readFile("l0nick.cfg",GLOBAL(nickl0),FILENAMELEN); }; //# MENU nick editNick @@ -71,3 +85,16 @@ void doFont(void){ setIntFont(&Font_7x8); while(!getInputRaw())delayms(10); }; + +//# MENU nick chooseAnim +void doAnim(void){ + getInputWaitRelease(); + if( selectFile(GLOBAL(nickl0),"NIK") != 0){ + lcdPrintln("No file selected."); + GLOBAL(l0nick)=0; + return; + }; + writeFile("l0nick.cfg",GLOBAL(nickl0),strlen(GLOBAL(nickl0))); + GLOBAL(l0nick)=1; + getInputWaitRelease(); +}; diff --git a/firmware/basic/config.c b/firmware/basic/config.c index cd26120..351015f 100644 --- a/firmware/basic/config.c +++ b/firmware/basic/config.c @@ -7,7 +7,7 @@ #include "basic/random.h" #include "basic/config.h" -#define CFGVER 2 +#define CFGVER 3 struct CDESC the_config[]= { {"version", CFGVER, CFGVER, CFGVER, 0, 0}, @@ -27,11 +27,13 @@ struct CDESC the_config[]= { {"flamespeed", 1, 1, 100, 1, CFG_TYPE_FLAME}, {"flamemaxw", 255, 1, 255, 1, CFG_TYPE_FLAME}, {"flameminw", 0x8f, 1, 255, 1, CFG_TYPE_FLAME}, + {"l0nick", 0, 0, 1 , 0, 0}, { NULL, 0, 0, 0 , 0, 0}, }; char nickname[MAXNICK]="anonymous"; char nickfont[FILENAMELEN]; +char nickl0[FILENAMELEN]; #define CONFFILE "r0ket.cfg" #define CONF_ITER for(int i=0;the_config[i].name!=NULL;i++) diff --git a/firmware/basic/config.h b/firmware/basic/config.h index 106dc5b..f018fc2 100644 --- a/firmware/basic/config.h +++ b/firmware/basic/config.h @@ -21,8 +21,9 @@ struct CDESC { #define MAXNICK 20 extern struct CDESC the_config[]; -extern char nickname[MAXNICK]; +extern char nickname[]; extern char nickfont[]; +extern char nickl0[]; #define GLOBALversion (the_config[ 0].value) #define GLOBALprivacy (the_config[ 1].value) @@ -40,8 +41,10 @@ extern char nickfont[]; #define GLOBALflamespeed (the_config[13].value) #define GLOBALflamemaxw (the_config[14].value) #define GLOBALflameminw (the_config[15].value) +#define GLOBALl0nick (the_config[16].value) #define GLOBALnickname (nickname) #define GLOBALnickfont (nickfont) +#define GLOBALnickl0 (nickl0) #define GLOBAL(x) GLOBAL ## x diff --git a/firmware/filesystem/execute.c b/firmware/filesystem/execute.c index 3ae2a86..c50426c 100644 --- a/firmware/filesystem/execute.c +++ b/firmware/filesystem/execute.c @@ -20,7 +20,7 @@ extern void * sram_top; /**************************************************************************/ -void execute_file (const char * fname, uint8_t checksignature, uint8_t decode){ +uint8_t execute_file (const char * fname, uint8_t checksignature, uint8_t decode){ FRESULT res; FIL file; UINT readbytes; @@ -38,7 +38,7 @@ void execute_file (const char * fname, uint8_t checksignature, uint8_t decode){ //lcdPrintln(f_get_rc_string(res)); //lcdRefresh(); if(res){ - return; + return -1; }; res = f_read(&file, (char *)dst, RAMCODE, &readbytes); @@ -46,7 +46,7 @@ void execute_file (const char * fname, uint8_t checksignature, uint8_t decode){ //lcdPrintln(f_get_rc_string(res)); //lcdRefresh(); if(res){ - return; + return -1; }; if( decode || checksignature ) //only accept files with fixed length @@ -55,7 +55,7 @@ void execute_file (const char * fname, uint8_t checksignature, uint8_t decode){ lcdPrint("readbytes&3"); lcdRefresh(); while(1); - return; + return -1; } if( checksignature ){ uint32_t mac[4]; @@ -72,7 +72,7 @@ void execute_file (const char * fname, uint8_t checksignature, uint8_t decode){ lcdPrintIntHex(mac[3]); lcdNl(); lcdRefresh(); while(1); - return; + return -1; } //lcdPrint("macok"); //lcdRefresh(); @@ -90,6 +90,7 @@ void execute_file (const char * fname, uint8_t checksignature, uint8_t decode){ dst=(void (*)(void)) ((uint32_t)(dst) | 1); // Enable Thumb mode! dst(); + return 0; }; diff --git a/firmware/filesystem/execute.h b/firmware/filesystem/execute.h index 8c52cae..4e2c654 100644 --- a/firmware/filesystem/execute.h +++ b/firmware/filesystem/execute.h @@ -1,7 +1,7 @@ #ifndef _EXECUTE_H_ #define _EXECUTE_H_ -void execute_file (const char * fname, uint8_t checksignature, uint8_t decode); +uint8_t execute_file (const char * fname, uint8_t checksignature, uint8_t decode); void executeSelect(char *ext); #endif diff --git a/firmware/l0dable/EXPORTS b/firmware/l0dable/EXPORTS index c8ddcd5..68ede56 100644 --- a/firmware/l0dable/EXPORTS +++ b/firmware/l0dable/EXPORTS @@ -72,3 +72,8 @@ nrf_check_reset sspSend sspReceive sspSendReceive +getInputWait +lcdGetPixel +nickfont +setExtFont +getFontHeight diff --git a/firmware/l0dable/Makefile b/firmware/l0dable/Makefile index 8da03dc..c97d8de 100644 --- a/firmware/l0dable/Makefile +++ b/firmware/l0dable/Makefile @@ -44,10 +44,6 @@ $(LDFILE): clean: rm -f *.o *.elf *.bin usetable.h -IDIR=/cygdrive/f -install: - for a in $(BINS) ; do f=$${a#*/};cp $$a $(IDIR)/$${f%.bin}.c0d ; done - $(OBJS): usetable.h usetable.h: