From b6f330b032ea8c1b3ef5a52f8c9cf67e24bb6cf8 Mon Sep 17 00:00:00 2001 From: Stefan `Sec` Zehl Date: Fri, 5 Aug 2011 00:52:23 +0200 Subject: [PATCH 01/11] kiu wanted it lowercase --- firmware/applications/final/mesh.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/firmware/applications/final/mesh.c b/firmware/applications/final/mesh.c index 20593fd..a7b27af 100644 --- a/firmware/applications/final/mesh.c +++ b/firmware/applications/final/mesh.c @@ -123,7 +123,7 @@ char *meshmsgs(void){ extern MPKT meshbuffer[MESHBUFSIZE]; -//# MENU Messages +//# MENU messages void m_choose(){ char list[99]; int i=0; From 9a1ff1184203bfe20860eed005a68a8b9d1aeb1d Mon Sep 17 00:00:00 2001 From: Stefan `Sec` Zehl Date: Fri, 5 Aug 2011 00:53:38 +0200 Subject: [PATCH 02/11] option to enable devel mode --- firmware/applications/default.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/firmware/applications/default.c b/firmware/applications/default.c index db93123..5e1800c 100644 --- a/firmware/applications/default.c +++ b/firmware/applications/default.c @@ -22,6 +22,9 @@ void main_default(void) { case BTN_UP: // Reset config f_unlink("r0ket.cfg"); break; + case BTN_RIGHT: + GLOBAL(develmode)=1; + break; case BTN_DOWN: usbMSCInit(); while(1) From e68960f0c7ff173781c1fbfef4951a8fdc0c1d30 Mon Sep 17 00:00:00 2001 From: Stefan `Sec` Zehl Date: Fri, 5 Aug 2011 01:22:34 +0200 Subject: [PATCH 03/11] Add charge led function --- firmware/applications/default.c | 9 +++++++++ firmware/basic/basic.h | 1 + firmware/basic/config.c | 1 + firmware/basic/config.h | 3 ++- firmware/basic/voltage.c | 9 ++++++++- 5 files changed, 21 insertions(+), 2 deletions(-) diff --git a/firmware/applications/default.c b/firmware/applications/default.c index 8a87a05..0584753 100644 --- a/firmware/applications/default.c +++ b/firmware/applications/default.c @@ -86,6 +86,15 @@ void tick_default(void) { EVERY(50,0){ + if(GLOBAL(chargeled)){ + IOCON_PIO1_11 = 0x0; + gpioSetDir(RB_LED3, gpioDirection_Output); + if(GetChrgStat()) + gpioSetValue (RB_LED3, 1); + else + gpioSetValue (RB_LED3, 0); + }; + if(GetVoltage()<3600){ IOCON_PIO1_11 = 0x0; gpioSetDir(RB_LED3, gpioDirection_Output); diff --git a/firmware/basic/basic.h b/firmware/basic/basic.h index ac0734a..2c84047 100644 --- a/firmware/basic/basic.h +++ b/firmware/basic/basic.h @@ -136,6 +136,7 @@ void delayms(uint32_t ms); // voltage.c void VoltageCheck(void); uint32_t GetVoltage(void); +uint8_t GetChrgStat(void); // night.c void LightCheck(void); diff --git a/firmware/basic/config.c b/firmware/basic/config.c index 351015f..7fad0a0 100644 --- a/firmware/basic/config.c +++ b/firmware/basic/config.c @@ -28,6 +28,7 @@ struct CDESC the_config[]= { {"flamemaxw", 255, 1, 255, 1, CFG_TYPE_FLAME}, {"flameminw", 0x8f, 1, 255, 1, CFG_TYPE_FLAME}, {"l0nick", 0, 0, 1 , 0, 0}, + {"chargeled", 1, 0, 1 , 0, 0}, { NULL, 0, 0, 0 , 0, 0}, }; diff --git a/firmware/basic/config.h b/firmware/basic/config.h index f018fc2..0d1d729 100644 --- a/firmware/basic/config.h +++ b/firmware/basic/config.h @@ -42,9 +42,10 @@ extern char nickl0[]; #define GLOBALflamemaxw (the_config[14].value) #define GLOBALflameminw (the_config[15].value) #define GLOBALl0nick (the_config[16].value) +#define GLOBALchargeled (the_config[17].value) #define GLOBALnickname (nickname) #define GLOBALnickfont (nickfont) -#define GLOBALnickl0 (nickl0) +#define GLOBALnickl0 (nickl0) #define GLOBAL(x) GLOBAL ## x diff --git a/firmware/basic/voltage.c b/firmware/basic/voltage.c index 6af313f..2ae6d12 100644 --- a/firmware/basic/voltage.c +++ b/firmware/basic/voltage.c @@ -3,10 +3,13 @@ #include "basic/basic.h" #include "funk/nrf24l01p.h" -uint32_t results=5000; +static uint32_t results=5000; +static uint8_t chrg=1; void VoltageCheck(void){ + chrg=gpioGetValue(RB_PWR_CHRG); + results = adcRead(1); results *= 10560; results /= 1024; @@ -24,3 +27,7 @@ void VoltageCheck(void){ uint32_t GetVoltage(void){ return results; }; + +uint8_t GetChrgStat(void){ + return !chrg; +}; From 793304b5682abd40e59c8193864942bbfba4b682 Mon Sep 17 00:00:00 2001 From: iggy Date: Fri, 5 Aug 2011 01:25:28 +0200 Subject: [PATCH 04/11] more verbose input(), MAXNICK reduced to 17 --- firmware/basic/config.h | 2 +- firmware/basic/stringin.c | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/firmware/basic/config.h b/firmware/basic/config.h index f018fc2..7c6fbea 100644 --- a/firmware/basic/config.h +++ b/firmware/basic/config.h @@ -19,7 +19,7 @@ struct CDESC { #define CFG_TYPE_DEVEL 1 #define CFG_TYPE_FLAME 2 -#define MAXNICK 20 +#define MAXNICK 17 extern struct CDESC the_config[]; extern char nickname[]; extern char nickfont[]; diff --git a/firmware/basic/stringin.c b/firmware/basic/stringin.c index 0e5bfa5..5a3c408 100644 --- a/firmware/basic/stringin.c +++ b/firmware/basic/stringin.c @@ -80,6 +80,7 @@ static void inputMove() { static void inputDraw() { char tmp[2]= {0,0}; + int pos = 0; lcdClear(); DoString(0,0,s_input.prompt); for (int dx = 0; dx<= RESX/CHARWIDTH && s_input.pos+dx Date: Fri, 5 Aug 2011 01:33:48 +0200 Subject: [PATCH 05/11] Big warning cleanup in firmware. --- firmware/applications/final.c | 1 + firmware/applications/final/beacon.c | 1 + firmware/applications/final/flame.c | 1 + firmware/applications/final/nickname.c | 1 + firmware/basic/idle.c | 5 +++-- firmware/filesystem/ff.h | 1 + firmware/funk/nrf24l01p.c | 3 +-- firmware/funk/nrf24l01p.h | 2 +- firmware/lcd/display.c | 2 ++ 9 files changed, 12 insertions(+), 5 deletions(-) diff --git a/firmware/applications/final.c b/firmware/applications/final.c index 9ffd509..eb6d32e 100644 --- a/firmware/applications/final.c +++ b/firmware/applications/final.c @@ -9,6 +9,7 @@ #include "basic/ecc.h" #include "basic/config.h" +#include "filesystem/execute.h" /**************************************************************************/ diff --git a/firmware/applications/final/beacon.c b/firmware/applications/final/beacon.c index 53cb977..d4292ea 100644 --- a/firmware/applications/final/beacon.c +++ b/firmware/applications/final/beacon.c @@ -3,6 +3,7 @@ #include "basic/basic.h" #include "basic/byteorder.h" #include "basic/config.h" +#include "basic/random.h" #include "funk/nrf24l01p.h" #include "funk/openbeacon.h" diff --git a/firmware/applications/final/flame.c b/firmware/applications/final/flame.c index 1b5f5fa..6359137 100644 --- a/firmware/applications/final/flame.c +++ b/firmware/applications/final/flame.c @@ -154,6 +154,7 @@ void init_flame(void) { #include "lcd/print.h" +// //# MENU flame void ChkFlame(void) { do{ lcdClear(); diff --git a/firmware/applications/final/nickname.c b/firmware/applications/final/nickname.c index 2882293..a6288ea 100644 --- a/firmware/applications/final/nickname.c +++ b/firmware/applications/final/nickname.c @@ -11,6 +11,7 @@ #include "filesystem/ff.h" #include "filesystem/select.h" +#include "filesystem/execute.h" #include diff --git a/firmware/basic/idle.c b/firmware/basic/idle.c index 9682675..838ddd5 100644 --- a/firmware/basic/idle.c +++ b/firmware/basic/idle.c @@ -42,10 +42,11 @@ uint8_t work_queue_minimal(void){ return 1; }; }; + /* NOTREACHED */ + return 0; }; void work_queue(void){ - int start; if (the_queue.qstart == the_queue.qend){ WFI; @@ -57,7 +58,7 @@ void work_queue(void){ uint8_t delayms_queue_plus(uint32_t ms, uint8_t final){ - int ret; + int ret=0; int end=_timectr+ms/SYSTICKSPEED; do { if (the_queue.qstart == the_queue.qend){ diff --git a/firmware/filesystem/ff.h b/firmware/filesystem/ff.h index 611a703..2685387 100644 --- a/firmware/filesystem/ff.h +++ b/firmware/filesystem/ff.h @@ -334,6 +334,7 @@ const char* f_get_rc_string (FRESULT rc); void fsInit(); int readFile(char * filename, char * data, int len); int writeFile(char * filename, char * data, int len); +void fsReInit(); #ifdef __cplusplus } diff --git a/firmware/funk/nrf24l01p.c b/firmware/funk/nrf24l01p.c index 56c6b63..db1460a 100644 --- a/firmware/funk/nrf24l01p.c +++ b/firmware/funk/nrf24l01p.c @@ -405,11 +405,10 @@ void nrf_off() { }; -uint8_t nrf_check_reset(void){ +void nrf_check_reset(void){ static uint8_t _nrfresets=0; if(nrf_cmd_status(C_NOP) & R_STATUS_MAX_RT){ _nrfresets++; nrf_init(); }; - return _nrfresets; }; diff --git a/firmware/funk/nrf24l01p.h b/firmware/funk/nrf24l01p.h index 67d69d8..42f6e3f 100644 --- a/firmware/funk/nrf24l01p.h +++ b/firmware/funk/nrf24l01p.h @@ -165,7 +165,7 @@ int nrf_rcv_pkt_poll_dec(int maxsize, uint8_t * pkt, uint32_t const key[4]); // more utility. void nrf_rcv_pkt_end(void); -uint8_t nrf_check_reset(void); +void nrf_check_reset(void); /* END */ diff --git a/firmware/lcd/display.c b/firmware/lcd/display.c index d3fb731..40bd2ae 100644 --- a/firmware/lcd/display.c +++ b/firmware/lcd/display.c @@ -67,6 +67,7 @@ static void lcdWrite(uint8_t cd, uint8_t data) { #define SDA 0,9 #define RST 2,2 +#ifdef NOTYET uint8_t lcdRead(uint8_t data) { uint8_t i; @@ -109,6 +110,7 @@ uint8_t lcdRead(uint8_t data) gpioSetDir(SDA, 1); delayms(1); } +#endif void lcdInit(void) { From cc366d2f8c2789962e9685507cee7dca4e097217 Mon Sep 17 00:00:00 2001 From: iggy Date: Fri, 5 Aug 2011 01:44:34 +0200 Subject: [PATCH 06/11] 1boot improvements --- firmware/applications/default.c | 1 + firmware/l0dable/1boot.c | 11 ++++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/firmware/applications/default.c b/firmware/applications/default.c index 0584753..004d0e2 100644 --- a/firmware/applications/default.c +++ b/firmware/applications/default.c @@ -20,6 +20,7 @@ void main_default(void) { lcdClear(); lcdLoadImage("r0ket.lcd"); lcdRefresh(); + lcdClear(); switch(getInputRaw()){ case BTN_ENTER: diff --git a/firmware/l0dable/1boot.c b/firmware/l0dable/1boot.c index 3b57a42..0b1c4df 100644 --- a/firmware/l0dable/1boot.c +++ b/firmware/l0dable/1boot.c @@ -32,7 +32,7 @@ void ram(void){ while (!privacy_set) { handleMenu(&submenu_privacy); } - input("Nickname:", GLOBAL(nickname), 32, 127, MAXNICK-1); + input("Nickname?", GLOBAL(nickname), 32, 127, MAXNICK-1); getInputWaitRelease(); again = screen_overview(); } @@ -60,8 +60,13 @@ static void set_privacy(int level) { static void screen_intro() { lcdClear(); - lcdPrintln("Welcome to"); - lcdPrintln("r0ket"); + lcdPrintln(""); + lcdPrintln(" r0ket"); + lcdPrintln(""); + lcdPrintln("launch config"); + lcdPrintln(""); + lcdPrintln("press any key"); + lcdPrintln("to continue"); lcdRefresh(); getInputWait(); getInputWaitRelease(); From 4836f5b8f5e2e799757be79b1f5188e84c965d1f Mon Sep 17 00:00:00 2001 From: Stefan `Sec` Zehl Date: Fri, 5 Aug 2011 01:58:12 +0200 Subject: [PATCH 07/11] Devel-menu egg --- firmware/applications/default.c | 1 + firmware/applications/final/exe.c | 6 ++++++ firmware/basic/menu.c | 12 ++++++++---- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/firmware/applications/default.c b/firmware/applications/default.c index 0584753..0104352 100644 --- a/firmware/applications/default.c +++ b/firmware/applications/default.c @@ -30,6 +30,7 @@ void main_default(void) { break; case BTN_RIGHT: GLOBAL(develmode)=1; + applyConfig(); break; case BTN_DOWN: usbMSCInit(); diff --git a/firmware/applications/final/exe.c b/firmware/applications/final/exe.c index bd7c7c1..d277caa 100644 --- a/firmware/applications/final/exe.c +++ b/firmware/applications/final/exe.c @@ -19,3 +19,9 @@ void execute_menu(void){ lcdRefresh(); }; +//# MENU |devel +void execute_devel(void){ + while(getInput()!=BTN_NONE); + executeSelect("INT"); + lcdRefresh(); +}; diff --git a/firmware/basic/menu.c b/firmware/basic/menu.c index fc1fe48..43a353f 100644 --- a/firmware/basic/menu.c +++ b/firmware/basic/menu.c @@ -1,6 +1,7 @@ #include #include "basic/basic.h" +#include "basic/config.h" #include "lcd/print.h" @@ -11,7 +12,7 @@ uint8_t menuflags=0; void handleMenu(const struct MENU *the_menu) { uint8_t back = 0; int8_t menuselection = 0; - uint8_t numentries = 0; + uint8_t numentries; uint8_t visible_lines = 0; uint8_t current_offset = 0; @@ -21,6 +22,9 @@ void handleMenu(const struct MENU *the_menu) { for (numentries = 0; the_menu->entries[numentries].text != NULL ; numentries++); + if(the_menu->entries[numentries-1].text[0]=='|' && !GLOBAL(develmode)) + numentries--; + visible_lines = lcdGetVisibleLines()-1; // subtract title line if(menuflags&MENU_BIG) @@ -81,8 +85,8 @@ void handleMenu(const struct MENU *the_menu) { break; case BTN_ENTER: lcdClear(); - lcdPrintln("Called..."); - lcdRefresh(); +// lcdPrintln("Called..."); +// lcdRefresh(); getInputWaitRelease(); if (the_menu->entries[menuselection].callback!=NULL) the_menu->entries[menuselection].callback(); @@ -91,7 +95,7 @@ void handleMenu(const struct MENU *the_menu) { if (menuflags&MENU_JUSTONCE) return; - getInputWait(); +// getInputWait(); break; case BTN_NONE: /* timeout */ From be448224ed909d0faff14ef0ddfb7aac29de341d Mon Sep 17 00:00:00 2001 From: Stefan `Sec` Zehl Date: Fri, 5 Aug 2011 01:58:44 +0200 Subject: [PATCH 08/11] rename msc menu. Also add some random unused sample code for images --- firmware/applications/final/util.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/firmware/applications/final/util.c b/firmware/applications/final/util.c index 5dbca8f..a3c8c10 100644 --- a/firmware/applications/final/util.c +++ b/firmware/applications/final/util.c @@ -6,15 +6,19 @@ #include "lcd/render.h" #include "lcd/print.h" +#include "lcd/image.h" #include "usb/usbmsc.h" +#include "filesystem/ff.h" +#include "filesystem/select.h" + #include "core/iap/iap.h" /**************************************************************************/ -//# MENU msc +//# MENU usb_storage void msc_menu(void){ lcdClear(); lcdPrintln("MSC Enabled."); @@ -46,3 +50,20 @@ void tick_alive(void){ return; }; + +// //# MENU img img +void t_img(void){ + char fname[FILENAMELEN]; + selectFile(fname, "LCD"); + lcdLoadImage(fname); + lcdRefresh(); + getInputWait(); +}; + +// //# MENU img anim +void t_ani(void){ + char fname[FILENAMELEN]; + selectFile(fname, "LCD"); + lcdShowAnim(fname,1000); +}; + From 5a3c0579142abbcd9767ffca726146f1d6fe94d8 Mon Sep 17 00:00:00 2001 From: Stefan `Sec` Zehl Date: Fri, 5 Aug 2011 02:00:32 +0200 Subject: [PATCH 09/11] hide debug from default menu --- firmware/l0dable/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/firmware/l0dable/Makefile b/firmware/l0dable/Makefile index 3799bb0..d0364fd 100644 --- a/firmware/l0dable/Makefile +++ b/firmware/l0dable/Makefile @@ -27,7 +27,7 @@ CFLAGS+=-mlong-calls -fno-toplevel-reorder CRYPT=cp CRYPTFLAGS=-p -all: $(OBJS) $(ELFS) $(BINS) $(CODS) $(NIKS) 1boot.int +all: $(OBJS) $(ELFS) $(BINS) $(CODS) $(NIKS) 1boot.int debug.int $(LDFILE): -@echo "MEMORY" > $(LDFILE) From c505028b41717badc4999372eb10cf1d802d223b Mon Sep 17 00:00:00 2001 From: Stefan `Sec` Zehl Date: Fri, 5 Aug 2011 02:19:22 +0200 Subject: [PATCH 10/11] FIrst mesh slowdown patch --- firmware/funk/mesh.c | 10 ++++++++++ firmware/funk/mesh.h | 1 + firmware/funk/nrf24l01p.c | 3 ++- firmware/funk/nrf24l01p.h | 1 + firmware/l0dable/EXPORTS | 2 ++ firmware/l0dable/Makefile | 3 +++ firmware/l0dable/debug.c | 5 ++++- 7 files changed, 23 insertions(+), 2 deletions(-) diff --git a/firmware/funk/mesh.c b/firmware/funk/mesh.c index 6ff2c27..21459e6 100644 --- a/firmware/funk/mesh.c +++ b/firmware/funk/mesh.c @@ -11,6 +11,7 @@ char meshgen=0; // Generation char meshincctr=0; char meshmsg=0; +char meshnice=0; MPKT meshbuffer[MESHBUFSIZE]; uint32_t const meshkey[4] = { @@ -89,11 +90,19 @@ void mesh_sendloop(void){ else uint32touint8p(0,MO_BODY(meshbuffer[0].pkt)); + MO_BODY(meshbuffer[0].pkt)[4]=meshnice; + for (int i=0;i Date: Fri, 5 Aug 2011 02:36:04 +0200 Subject: [PATCH 11/11] bugfix %) --- firmware/l0dable/invaders.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/firmware/l0dable/invaders.c b/firmware/l0dable/invaders.c index e405664..1f4f425 100644 --- a/firmware/l0dable/invaders.c +++ b/firmware/l0dable/invaders.c @@ -79,7 +79,6 @@ void ram(void) { while(1) { if (!screen_intro()) return; - screen_intro(); game.rokets = 3; game.level = 1; game.score = 0; @@ -114,7 +113,9 @@ static bool screen_intro() { char highnick[20]; char key=0; bool step = false; + //getInputWaitRelease(); while(key==0) { + getInputWaitRelease(); lcdFill(0); font = &Font_Invaders; DoString(28,25,step?"ABC":"abc"); @@ -129,6 +130,7 @@ static bool screen_intro() { step = !step; key=getInputWaitTimeout(1000); } + //getInputWaitRelease(); return !(key==BTN_LEFT); } @@ -144,6 +146,7 @@ static bool screen_gameover() { lcdDisplay(); key=getInputWaitTimeout(5000); } + //getInputWaitRelease(); return !(key==BTN_LEFT); }