From f56d4f3ef050529e03be64995e00842c08f21cfc Mon Sep 17 00:00:00 2001 From: schneider Date: Thu, 22 Dec 2011 13:39:14 +0100 Subject: [PATCH 01/20] openbeacon: send nickname in special packets --- firmware/funk/openbeacon.c | 52 ++++++++++++++++++++++++++++---------- 1 file changed, 39 insertions(+), 13 deletions(-) diff --git a/firmware/funk/openbeacon.c b/firmware/funk/openbeacon.c index 170f872..ab559ef 100644 --- a/firmware/funk/openbeacon.c +++ b/firmware/funk/openbeacon.c @@ -5,6 +5,7 @@ #include "sysdefs.h" #include "filesystem/ff.h" #include "basic/uuid.h" +#include "basic/config.h" #include "SECRETS" @@ -77,31 +78,56 @@ void openbeaconSetup(void) #endif } -static uint8_t openbeaconSendPacket(uint32_t id, uint32_t seq, +static void openbeaconSendPacket(uint32_t id, uint32_t seq, uint8_t flags, uint8_t strength) { - uint8_t buf[32]; + uint8_t buf[16]; + uint8_t proto = 0x17; //Tracking volatile uint16_t i; - i = getRandom()&0xfff; + i = (getRandom()&0xfff)+1; while(i--); + static uint32_t n = 0; + if( --n == 0 ){ + n = 123; + proto = 0x23; //Nick name + } + buf[0]=0x10; // Length: 16 bytes - buf[1]=0x17; // Proto - fixed at 0x17? - buf[2]=flags; - buf[3]=strength*85; // Send intensity + buf[1]=proto; + if( proto == 0x17 ){ + buf[2]=flags; + buf[3]=strength*85; // Send intensity - uint32touint8p(seq, buf+4); - uint32touint8p(id, buf+8); - - buf[12]=0xff; // salt (0xffff always?) - buf[13]=0xff; + uint32touint8p(seq, buf+4); + uint32touint8p(id, buf+8); + buf[12]=0xff; // salt (0xffff always?) + buf[13]=0xff; #if ENCRYPT_OPENBEACON - return nrf_snd_pkt_crc_encr(16,buf,openbeaconkey); + nrf_snd_pkt_crc_encr(16,buf,openbeaconkey); #else - return nrf_snd_pkt_crc_encr(16,buf,NULL); + nrf_snd_pkt_crc_encr(16,buf,NULL); #endif + }else{ + uint32touint8p(id, buf+2); + memcpy(buf+6, GLOBAL(nickname), 8); +#if ENCRYPT_OPENBEACON + nrf_snd_pkt_crc_encr(16,buf,openbeaconkey); +#else + nrf_snd_pkt_crc_encr(16,buf,NULL); +#endif + if( strlen(GLOBAL(nickname)) < 9 ) + return; + buf[1]=0x24; + memcpy(buf+6, GLOBAL(nickname)+8, 8); +#if ENCRYPT_OPENBEACON + nrf_snd_pkt_crc_encr(16,buf,openbeaconkey); +#else + nrf_snd_pkt_crc_encr(16,buf,NULL); +#endif + } } void openbeaconSend(void) From 6a9f5d7872995ce2011efaaf66646dac874827a1 Mon Sep 17 00:00:00 2001 From: schneider Date: Thu, 22 Dec 2011 14:34:05 +0100 Subject: [PATCH 02/20] added config l0dable --- firmware/l0dable/config.c | 126 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 126 insertions(+) create mode 100644 firmware/l0dable/config.c diff --git a/firmware/l0dable/config.c b/firmware/l0dable/config.c new file mode 100644 index 0000000..a0a31ae --- /dev/null +++ b/firmware/l0dable/config.c @@ -0,0 +1,126 @@ +#include + +#include "basic/basic.h" +#include "basic/config.h" + +#include "lcd/print.h" +#include "lcd/render.h" +#include "lcd/display.h" + +#include "filesystem/ff.h" + +#include + +/**************************************************************************/ + +#include "usetable.h" + +//# MENU config +void ram(void){ + uint8_t numentries = 0; + signed char menuselection = 0; + uint8_t visible_lines = 0; + uint8_t current_offset = 0; + + for (int i=0;the_config[i].name!=NULL;i++){ + if(!the_config[i].disabled) + numentries++; + }; + + visible_lines = ((RESY/getFontHeight())-1)/2; + + while (1) { + // Display current menu page + lcdClear(); + lcdPrint("Config"); + + lcdSetCrsrX(60); + lcdPrint("["); + lcdPrint(IntToStr((current_offset/visible_lines)+1,1,0)); + lcdPrint("/"); + lcdPrint(IntToStr(((numentries-1)/visible_lines)+1,1,0)); + lcdPrint("]"); + lcdNl(); + + lcdNl(); + + uint8_t j=0; + for (uint8_t i=0;i"); + }; + lcdRefresh(); + } + + switch (getInputWaitRepeat()) { + case BTN_UP: + menuselection--; + if (menuselection < current_offset) { + if (menuselection < 0) { + menuselection = numentries-1; + current_offset = ((numentries-1)/visible_lines) * visible_lines; + } else { + current_offset -= visible_lines; + } + } + break; + case BTN_DOWN: + menuselection++; + if (menuselection > (current_offset + visible_lines-1) || menuselection >= numentries) { + if (menuselection >= numentries) { + menuselection = 0; + current_offset = 0; + } else { + current_offset += visible_lines; + } + } + break; + case BTN_LEFT: + 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[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: + if(menuselection==0) + saveConfig(); + return; + } + } + /* NOTREACHED */ +} From 814062f9601c9423f2808c1a0f2b8c08d7ba9384 Mon Sep 17 00:00:00 2001 From: schneider Date: Thu, 22 Dec 2011 14:41:11 +0100 Subject: [PATCH 03/20] game: do not set MASS_GAME flag by default --- tools/game/r0ketrem0te/game.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/game/r0ketrem0te/game.py b/tools/game/r0ketrem0te/game.py index 83d55aa..8df5f70 100644 --- a/tools/game/r0ketrem0te/game.py +++ b/tools/game/r0ketrem0te/game.py @@ -23,7 +23,7 @@ class Game: self.bridge = bridge.Bridge(device, self.channel, self.gamemac) self.announce = packets.Announce(self.gamemac, self.channel, - self.gameid, 1, self.gameName) + self.gameid, 0, self.gameName) self.announcequeue = Queue.Queue() self.bridge.registerQueue(self.announcequeue) From cf639ee6204dfffd7d980e6c4a5ecd848b9a693f Mon Sep 17 00:00:00 2001 From: schneider Date: Thu, 22 Dec 2011 15:05:04 +0100 Subject: [PATCH 04/20] added l0dable to show OpenBeacon id --- firmware/l0dable/beaconid.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 firmware/l0dable/beaconid.c diff --git a/firmware/l0dable/beaconid.c b/firmware/l0dable/beaconid.c new file mode 100644 index 0000000..7bed0c1 --- /dev/null +++ b/firmware/l0dable/beaconid.c @@ -0,0 +1,22 @@ +#include +#include + +#include "basic/basic.h" +#include "basic/config.h" + +#include "lcd/render.h" +#include "lcd/print.h" + +#include "funk/nrf24l01p.h" +#include "usetable.h" + +/**************************************************************************/ + +void ram(void) { + lcdClear(); + lcdPrintln("OpenBeaconId:"); + lcdPrintIntHex(GetUUID32()); + lcdRefresh(); + do{ + }while ((getInputRaw())==BTN_NONE); +} From 8e26d2b81c13960327ceea437cf681559f701275 Mon Sep 17 00:00:00 2001 From: schneider Date: Thu, 22 Dec 2011 15:05:22 +0100 Subject: [PATCH 05/20] openbeacon: fixed nick broadcast --- firmware/funk/openbeacon.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/firmware/funk/openbeacon.c b/firmware/funk/openbeacon.c index ab559ef..e634f91 100644 --- a/firmware/funk/openbeacon.c +++ b/firmware/funk/openbeacon.c @@ -88,7 +88,7 @@ static void openbeaconSendPacket(uint32_t id, uint32_t seq, i = (getRandom()&0xfff)+1; while(i--); - static uint32_t n = 0; + static uint32_t n = 123; if( --n == 0 ){ n = 123; proto = 0x23; //Nick name @@ -111,6 +111,9 @@ static void openbeaconSendPacket(uint32_t id, uint32_t seq, nrf_snd_pkt_crc_encr(16,buf,NULL); #endif }else{ + if( strlen(GLOBAL(nickname)) > 8 ) + buf[1] = 0x24; + nrf_set_strength(3); uint32touint8p(id, buf+2); memcpy(buf+6, GLOBAL(nickname), 8); #if ENCRYPT_OPENBEACON @@ -120,7 +123,7 @@ static void openbeaconSendPacket(uint32_t id, uint32_t seq, #endif if( strlen(GLOBAL(nickname)) < 9 ) return; - buf[1]=0x24; + buf[1]=0x25; memcpy(buf+6, GLOBAL(nickname)+8, 8); #if ENCRYPT_OPENBEACON nrf_snd_pkt_crc_encr(16,buf,openbeaconkey); From 6ecc1e5f84968c716fac615792ec61b375149035 Mon Sep 17 00:00:00 2001 From: schneider Date: Thu, 22 Dec 2011 15:05:50 +0100 Subject: [PATCH 06/20] added l0dable to see who is nearby --- firmware/l0dable/people.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 firmware/l0dable/people.c diff --git a/firmware/l0dable/people.c b/firmware/l0dable/people.c new file mode 100644 index 0000000..4f85e17 --- /dev/null +++ b/firmware/l0dable/people.c @@ -0,0 +1,38 @@ +#include +#include + +#include "basic/basic.h" +#include "basic/config.h" + +#include "lcd/render.h" +#include "lcd/print.h" + +#include "funk/nrf24l01p.h" +#include "usetable.h" + +/**************************************************************************/ + +void ram(void) { + struct NRF_CFG config; + uint8_t buf[16]; + + config.nrmacs=1; + config.maclen[0] = 16; + config.channel = 81; + memcpy(config.mac0, "\x01\x02\x03\x02\x01", 5); + nrf_config_set(&config); + lcdClear(); + lcdPrintln("People nearby:"); + //lcdPrint("nearby:"); + lcdRefresh(); + do{ + if( nrf_rcv_pkt_time(64,sizeof(buf),buf) == 16 ){ + buf[14] = 0; + if( buf[1] == 0x23 || buf[1] == 0x24){ + lcdPrintln(buf+6); + //lcdPrintln("foo"); + } + lcdRefresh(); + } + }while ((getInputRaw())==BTN_NONE); +} From fa1d207bfe7cfca6e96486353b2e6db5dc01eff8 Mon Sep 17 00:00:00 2001 From: schneider Date: Thu, 22 Dec 2011 15:17:00 +0100 Subject: [PATCH 07/20] format: erase more sectors to be on the safe side --- firmware/filesystem/util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/firmware/filesystem/util.c b/firmware/filesystem/util.c index f8b59b9..d0d7244 100644 --- a/firmware/filesystem/util.c +++ b/firmware/filesystem/util.c @@ -35,7 +35,7 @@ inline void format_formatDF(void) char buf[512]; memset(buf, 0, 512); - for(i=0; i<20; i++) dataflash_write(buf, i, 1); + for(i=0; i<100; i++) dataflash_write(buf, i, 1); memcpy(buf, init1, sizeof(init1)); memcpy(buf+0x24, init2, sizeof(init2)); From d870849e4c333e05fcb6c0e5a9859c37bc7dcfc0 Mon Sep 17 00:00:00 2001 From: schneider Date: Thu, 22 Dec 2011 16:13:33 +0100 Subject: [PATCH 08/20] player: use different buffer for acks --- firmware/l0dable/r_player.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/firmware/l0dable/r_player.c b/firmware/l0dable/r_player.c index 72efbd7..97179d5 100644 --- a/firmware/l0dable/r_player.c +++ b/firmware/l0dable/r_player.c @@ -182,6 +182,7 @@ uint8_t joinGame() { int i; struct packet p; + struct packet ack; p.len=sizeof(p); p.protocol='G'; p.command='J'; @@ -195,11 +196,11 @@ uint8_t joinGame() for(i=0; i<10; i++){ nrf_snd_pkt_crc(sizeof(p),(uint8_t*)&p); - int len = nrf_rcv_pkt_time(30,sizeof(p),(uint8_t*)&p); - if( len==sizeof(p) ){ - if( (p.len==32) && (p.protocol=='G') && p.command=='a' ){ //check sanity, protocol - if( p.id == id && p.ctr == ctr ){ - if( p.c.ack.flags & FLAGS_ACK_JOINOK ){ + int len = nrf_rcv_pkt_time(30,sizeof(ack),(uint8_t*)&ack); + if( len==sizeof(ack) ){ + if( (ack.len==32) && (ack.protocol=='G') && ack.command=='a' ){ //check sanity, protocol + if( ack.id == id && ack.ctr == ctr ){ + if( ack.c.ack.flags & FLAGS_ACK_JOINOK ){ lcdPrintln("Join OK"); lcdRefresh(); return 1; @@ -233,6 +234,10 @@ uint8_t selectGame() nrf_config_set(&config); gamecount = 0; + lcdClear(); + lcdPrintln("Searching for"); + lcdPrintln("games..."); + lcdRefresh(); for(i=0;i<60;i++){ len= nrf_rcv_pkt_time(30, sizeof(p), (uint8_t*)&p); if (len==sizeof(p)){ From acd07331a44f58bbd1f3cf9331f7533f4ae32d2f Mon Sep 17 00:00:00 2001 From: schneider Date: Thu, 22 Dec 2011 17:12:51 +0100 Subject: [PATCH 09/20] player: memset packets to zero --- firmware/l0dable/r_player.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/firmware/l0dable/r_player.c b/firmware/l0dable/r_player.c index 97179d5..056a18d 100644 --- a/firmware/l0dable/r_player.c +++ b/firmware/l0dable/r_player.c @@ -183,6 +183,8 @@ uint8_t joinGame() int i; struct packet p; struct packet ack; + memset((void*)&p, 0, sizeof(p)); + memset((void*)&ack, 0, sizeof(ack)); p.len=sizeof(p); p.protocol='G'; p.command='J'; @@ -288,6 +290,7 @@ uint8_t selectGame() void processNickRequest( struct nickrequest *nq) { struct packet p; + memset((void*)&p, 0, sizeof(p)); p.len=sizeof(p); p.protocol='G'; // Proto p.command='n'; @@ -304,6 +307,7 @@ void processPacket(struct packet *p) if ((p->len==32) && (p->protocol=='G') && (p->id == id || p->id == 0) ){ //check sanity, protocol, id if (p->command=='T'){ struct packet ack; + memset((void*)&ack, 0, sizeof(ack)); ack.len=sizeof(p); ack.protocol='G'; ack.command='a'; @@ -354,6 +358,7 @@ void processText(struct text *t) void sendButton(uint8_t button) { struct packet p; + memset((void*)&p, 0, sizeof(p)); p.len=sizeof(p); p.protocol='G'; // Proto p.command='B'; From fb010d02502bc31f8265961a0c153f876a98e212 Mon Sep 17 00:00:00 2001 From: Stefan `Sec` Zehl Date: Thu, 22 Dec 2011 19:45:52 +0100 Subject: [PATCH 10/20] Change room names. Remove schnitzeljagd protocode --- firmware/applications/final/mesh.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/firmware/applications/final/mesh.c b/firmware/applications/final/mesh.c index f7ade86..8fc4095 100644 --- a/firmware/applications/final/mesh.c +++ b/firmware/applications/final/mesh.c @@ -120,6 +120,7 @@ char *meshmsgs(void){ return msgtypes; }; +#if 0 static inline uint32_t popcount(uint32_t *buf, uint8_t n){ int cnt=0; do { @@ -133,6 +134,7 @@ static inline uint32_t popcount(uint32_t *buf, uint8_t n){ } while(--n); return cnt; } +#endif extern MPKT meshbuffer[MESHBUFSIZE]; //# MENU messages @@ -156,10 +158,13 @@ void m_choose(){ strcpy(p,"Message"); break; case('E'): - strcpy(p,"Kourou"); + strcpy(p,"Saal 1"); break; case('F'): - strcpy(p,"Baikonur"); + strcpy(p,"Saal 2"); + break; + case('G'): + strcpy(p,"Saal 3"); break; case('T'): strcpy(p,"Time"); @@ -167,12 +172,14 @@ void m_choose(){ case('i'): strcpy(p,"Invaders"); break; +#if 0 case('j'): strcpy(p,"Jump"); break; case('r'): strcpy(p,"r0type"); break; +#endif default: p[0]=*mm; p[1]=0; @@ -198,10 +205,13 @@ void m_choose(){ lcdPrintln("Message"); break; case('E'): - lcdPrintln("Kourou"); + lcdPrintln("Saal 1"); break; case('F'): - lcdPrintln("Baikonur"); + lcdPrintln("Saal 2"); + break; + case('G'): + lcdPrintln("Saal 3"); break; case('T'): lcdPrintln("Time"); @@ -209,12 +219,14 @@ void m_choose(){ case('i'): lcdPrintln("Invaders"); break; +#if 0 case('j'): strcpy(p,"Jump"); break; case('r'): strcpy(p,"r0type"); break; +#endif }; if(tmm[i]>='a' && tmm[i]<='z'){ lcdPrintln(IntToStr(MO_TIME(meshbuffer[j].pkt),10,0)); @@ -227,6 +239,7 @@ void m_choose(){ lcdPrint(IntToStr(tm->tm_sec,2,F_LONG|F_ZEROS)); lcdNl(); +#if 0 if(tmm[i]=='Z'){ lcdPrintln(IntToStrX(uint8ptouint32(meshbuffer[j].pkt+ 6),8)); lcdPrintln(IntToStrX(uint8ptouint32(meshbuffer[j].pkt+10),8)); @@ -239,7 +252,9 @@ void m_choose(){ lcdRefresh(); getInputWaitRelease(); continue; - }else if(tmm[i]=='T'){ + }else +#endif + if(tmm[i]=='T'){ lcdPrint(IntToStr(tm->tm_mday,2,F_LONG)); lcdPrint("."); lcdPrint(IntToStr(tm->tm_mon+1,2,0)); From d06b050f82b46f8b490f0ce52163debbe162ca42 Mon Sep 17 00:00:00 2001 From: Stefan `Sec` Zehl Date: Thu, 22 Dec 2011 19:59:56 +0100 Subject: [PATCH 11/20] Lock down mesh propagation: only propagate fahrplan and time. Also fix time limit for 28c3 duration --- firmware/funk/mesh.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/firmware/funk/mesh.c b/firmware/funk/mesh.c index 33df421..5842ae2 100644 --- a/firmware/funk/mesh.c +++ b/firmware/funk/mesh.c @@ -31,9 +31,9 @@ void initMesh(void){ int mesh_sanity(uint8_t * pkt){ if(MO_TYPE(pkt)>='A' && MO_TYPE(pkt)<='Z'){ - if(MO_TIME(pkt)>1313803870) + if(MO_TIME(pkt)>1325379600) return 1; - if(MO_TIME(pkt)<1312075898) + if(MO_TIME(pkt)<1324602000) return 1; }else if(MO_TYPE(pkt)>='a' && MO_TYPE(pkt)<='z'){ if(MO_TIME(pkt)>16777216) @@ -41,7 +41,12 @@ int mesh_sanity(uint8_t * pkt){ if(MO_TIME(pkt)<0) return 1; }; - if(MO_TYPE(pkt)=='t'){ + if(MO_TYPE(pkt)!='E' && + MO_TYPE(pkt)!='F' && + MO_TYPE(pkt)!='G' && + MO_TYPE(pkt)!='T' && + 1 + ){ return 1; }; if(MO_TYPE(pkt)>0x7f || MO_TYPE(pkt)<0x20) @@ -92,7 +97,7 @@ void mesh_cleanup(void){ }; if(mesh_sanity(meshbuffer[i].pkt)){ meshbuffer[i].flags=MF_FREE; -#if 1 +#if 0 setSystemFont(); lcdClear(); lcdPrintln("MESH PANIC!"); From 6c2c5127c6569f349e4b02cb852740eed1c93305 Mon Sep 17 00:00:00 2001 From: schneider Date: Thu, 22 Dec 2011 20:11:03 +0100 Subject: [PATCH 12/20] reactivated graphic lib --- firmware/l0dable/EXPORTS | 25 ++++++++++--------- .../l0dable/{rockets.c.disabled => rockets.c} | 0 2 files changed, 13 insertions(+), 12 deletions(-) rename firmware/l0dable/{rockets.c.disabled => rockets.c} (100%) diff --git a/firmware/l0dable/EXPORTS b/firmware/l0dable/EXPORTS index 2b0fd3f..a28eeb9 100644 --- a/firmware/l0dable/EXPORTS +++ b/firmware/l0dable/EXPORTS @@ -104,18 +104,6 @@ nickname systickGetTicks uint32touint8p uint8ptouint32 -#Add stuff here -#o_init -#o_path_new -#o_move_to -#o_line_to -#o_curve_to -#o_close -#o_set_gray -#o_fill -#o_set_shader -#o_identity -#o_transform #I2C I2CMasterBuffer I2CSlaveBuffer @@ -123,6 +111,7 @@ I2CWriteLength I2CReadLength i2cEngine i2cInit +#stuff timer32Callback0 lcdRead lcdInit @@ -130,3 +119,15 @@ lcdSetCrsr lcdSetCrsrX getInputWaitRepeat applyConfig +o_init +o_path_new +o_move_to +o_line_to +o_curve_to +o_close +o_set_gray +o_fill +o_set_shader +o_identity +o_transform +#Add stuff here diff --git a/firmware/l0dable/rockets.c.disabled b/firmware/l0dable/rockets.c similarity index 100% rename from firmware/l0dable/rockets.c.disabled rename to firmware/l0dable/rockets.c From ee4c420b410d85d4c53b7666fc3ec0c273b50553 Mon Sep 17 00:00:00 2001 From: schneider Date: Thu, 22 Dec 2011 20:15:59 +0100 Subject: [PATCH 13/20] added initial animation before config --- firmware/applications/final.c | 2 + firmware/l0dable/initanim.c | 290 ++++++++++++++++++++++++++++++++++ 2 files changed, 292 insertions(+) create mode 100644 firmware/l0dable/initanim.c diff --git a/firmware/applications/final.c b/firmware/applications/final.c index 26d1487..f42502c 100644 --- a/firmware/applications/final.c +++ b/firmware/applications/final.c @@ -19,8 +19,10 @@ void init_nick(); void fancyNickname(); void main_final(void) { + init_nick(); if(GLOBAL(privacy)>2){ //firstboot + execute_file("initanim.c0d"); if(execute_file("1boot.int")){ lcdPrintln("Badge SETUP"); lcdPrintln("error."); diff --git a/firmware/l0dable/initanim.c b/firmware/l0dable/initanim.c new file mode 100644 index 0000000..2c2abfe --- /dev/null +++ b/firmware/l0dable/initanim.c @@ -0,0 +1,290 @@ +#include +#include "basic/basic.h" +#include "lcd/lcd.h" +#include "usetable.h" + +#define O_FIXED 1023 +#define SPP 10 + +static void draw_rakett (int x, int y, int scale, int angle); +static int my_gray (int x, int y, void *data); +static int o_sin(int x); +static int o_cos(int x); +static int frame_no = 0; + +#define ANIM(start_val, end_val) \ + (((start_val) * (1000-(t))) / 1000 + ((end_val) * ((t))) /1000) + +void ram (void) +{ + char test[512]; /* scratch space */ + o_init (test, sizeof(test)); + int frame_dir = 1; + int inpt; + o_set_shader (my_gray, NULL); + int x; + int y; + int angle; + int scale; + int velocity = 0; + frame_no=0; + + while ((inpt = getInputRaw()) != BTN_ENTER) + { + int t; + + o_identity (); /* reset tranforms */ + o_set_gray (0); + o_rectangle (0,0,RESX, RESY); /* fill background with black */ + o_fill (); /* fill with 50% gray */ + + if (frame_no < 800) + { + o_set_gray (250); + o_rectangle (0,RESY-7,RESX, 10); /* fill background with black */ + o_fill (); /* fill with 50% gray */ + } + + if (frame_no < 100) + { + t = frame_no * 1000 / 100; + x = ANIM(-60 * 10, 100 * 10); + y = RESY/2 * 10; + angle = ANIM(500, 300); + scale = ANIM(1200, 700); + } + else if (frame_no < 300) + { + t = (frame_no - 100) * 1000 / 200; + x = ANIM(100 * 10, 10 * RESX/2); + y = ANIM((RESY/2) * 10, (RESY/2 - 10) * 10); + angle = ANIM(300, 0); + scale = ANIM(700, 300); + } + else if (frame_no < 600) + { + t = (frame_no - 300) * 1000 / 300; + x = RESX/2 * 10; + y = ANIM((RESY/2-10) * 10, (RESY-14) * 10); + angle = 0; + scale = 300; + } + else + { + return; + /* flying time */ + + if (inpt == BTN_UP) + { + velocity ++; + } + else if (inpt == BTN_DOWN) + { + velocity --; + } + else if (inpt == BTN_LEFT) + { + angle -= 5; + } + else if (inpt == BTN_RIGHT) + { + angle += 5; + } + + if (velocity > 10) + velocity = 10; + if (velocity < -10) + velocity = -10; + + { + int c = o_cos ((angle - 900) * 4 * 8192 / 3600) / 4; + int s = o_sin ((angle - 900) * 4 * 8192 / 3600) / 4; + x += (c / 100) * velocity / 10; + y += (s / 100) * velocity / 10; + } + + y++; + + if (y > (RESY-14) * 10) + y = (RESY-14) * 10; + } + + draw_rakett (x, y, scale, angle); + frame_no += frame_dir; + lcdDisplay(); + } +} + +static int my_gray (int x, int y, void *data) +{ + int value = (int)(data); + switch (value) + { + case 0: /* 0.0 */ + return 0; + case 1: /* 0.16 */ + return (x%3==0) ? (y %2)? 0:0: + (x%3==1) ? (y %2)? 0:0: + (y %2)? 0:1; + case 2: /* 0.25 */ + switch (frame_no % 4) { + case 0: + return (x%2) ? (y %2)? 1:0: + (y %2)? 0:0; + case 1: + return (x%2) ? (y %2)? 0:1: + (y %2)? 0:0; + case 2: + return (x%2) ? (y %2)? 0:0: + (y %2)? 0:1; + case 3: + return (x%2) ? (y %2)? 0:0: + (y %2)? 1:0; + } + case 3: /* 0.33 */ + return (x%3==0) ? (y %2)? 1:0: + (x%3==1) ? (y %2)? 0:0: + (y %2)? 0:1; + case 4: /* 0.50 */ + if (frame_no %2) + return (x%2==0) ? (y %2)? 1:0: + (y %2)? 0:1; + else + return (x%2==0) ? (y %2)? 0:1: + (y %2)? 1:0; + case 5: /* 0.66 */ + return (x%3==0) ? (y %2)? 0:1: + (x%3==1) ? (y %2)? 1:1: + (y %2)? 1:0; + case 6: /* 0.75 */ + return (x%2) ? (y %2)? 1:0: + (y %2)? 1:1; + case 7: /* 0.85 */ + return (x%3==0) ? (y %2)? 1:1: + (x%3==1) ? (y %2)? 1:0: + (y %2)? 1:1; + case 8: /* 1.0 */ + return 1; + default: // return ((char)(rnd1())) < value; + /* XXX: use a faster "random" source + for this fallback */ + break; + } + return 0; +} + +/* This is a very simple vector drawing of heart of gold encoded in a + * string (search and replace regexp-fu on an SVG made in inkscape was + * used to create the strings) + * + * to reduce size, all coordinates are encoded as bytes, 'g'ray values + * are in the range 0-100. + */ +static signed char rakett[] = { + ' ', + 'm',38,6, + 'c',38,6,36,13,36,15, + 'c',24,22,23,26,21,32,'c',19,41,23,61,23,61,'c',15,73,14,95,17,110,'l',26,109,'c',26,102,26,87,30,83,'c',30,83,30,88,30,95,'c',31,103,31,108,31,108,'l',36,108,'c',36,108,35,98,36,91,'c',37,83,38,80,38,80,'c',41,79,43,80,47,79,'c',56,85,56,89,58,99,'c',58,103,58,108,58,108,'l',68,108,'c',67,89,69,73,54,58,'c',54,58,56,41,53,31,'c',50,21,40,15,40,15,'l',38,6,'z','g',100,'f','g',100,'s', + ' ', + 'm',33,20,'c',31,20,29,21,27,22,'c',25,24,23,27,22,29,'c',20,35,21,38,21,38,'c',26,38,29,36,34,33,'c',38,31,42,24,34,21,'c',34,21,33,20,33,20,'z','g', 50,'f','.' +}; + +static const signed char * o_process_op (const signed char *g) +{ + switch (*g++) { + + case ' ': o_path_new (); break; + /* all of these path commands are directly in integer coordinates */ + case 'm': + o_move_to (g[0], g[1]); g += 2; +break; + case 'l': o_line_to (g[0], g[1]); g += 2; break; + case 'c': o_curve_to (g[0], g[1], g[2], g[3], g[4], g[5]); g += 6; break; + case 'z': o_close (); break; + + case 'g': o_set_gray (g[0]*10); g ++; break; + + case 'f': o_fill (); break; + case 's': break; + //case 's': o_stroke (); break; + /* 1 = 1 10 = 10 100 = 100 */ +#if 0 + case '!': o_identity (); break; + case 'T': o_translate (g[0] * 100, g[1] * 100); g+=2; break; + /* 1 = 0.01 10 = 0.1 50 = 0.5 100 = 10x */ + case 'S': o_scale (g[0] * 10, g[1] * 10); g+=2; break; + /* -128 = -360 64 = 180 128 = 360 */ + case 'R': o_rotate ((g[0] * 3600)/127); g+=1; break; +#endif + + default: + case '\0': + case '.': /* end */ + return NULL; + } + return g; +} + +static void +orender (const signed char *g) +{ + for (; g; g = o_process_op (g)); +} + +void o_rectangle (int x0, int y0, int width, int height) +{ + o_path_new (); + o_move_to (x0, y0); + o_line_to (x0 + width, y0); + o_line_to (x0 + width, y0+height); + o_line_to (x0, y0+height); + o_close (); +} + +static int o_sin(int x) +{ +#define qN 13 +#define qA 12 +#define qP 15 +#define qR (2*qN-qP) +#define qS (qN+qP+1-qA) + + x= x<<(30-qN); // shift to full s32 range (Q13->Q30) + + if( (x^(x<<1)) < 0) // test for quadrant 1 or 2 + x= (1<<31) - x; + + x= x>>(30-qN); + + return (x * ( (3<>qR) ) >> qS ); +} + +static inline int o_cos(int x) +{ + return o_sin(x + 8192); +} + +static void draw_rakett (int x, int y, int scale, int angle) +{ + /* directly including the matrices used to build up the transform, the fudging factors + depend on internal values of o to add up properly */ + OMatrix mtranslate = {{{O_FIXED,0}, + {0,O_FIXED}, + {x * 100 * SPP * O_FIXED / 1000, y * 100 * SPP * O_FIXED / 1000}}}; + int c = o_cos (angle * 4 * 8192 / 3600) / 4; + int s = o_sin (angle * 4 * 8192 / 3600) / 4; + OMatrix mrotate = {{{c,s}, + {-s,c}, + {0, 0}}}; + OMatrix mscale = {{{scale * O_FIXED / 1000, 0}, + {0,scale * O_FIXED / 1000}, + {0,0}}}; + OMatrix mtranslate2 = {{{O_FIXED,0}, + {0,O_FIXED}, + {-37000 * SPP * O_FIXED / 1000, -60000 * SPP * O_FIXED / 1000}}}; + o_transform (&mtranslate, 1); /* passing 1 as second arg sets the transform to this */ + o_transform (&mrotate, 0); /* passing 0 adds this transformaiton */ + o_transform (&mscale, 0); /* again (it is multiplying the matrices internally) */ + o_transform (&mtranslate2, 0); /* the final translate (first actually) sets the local origin. */ + orender (rakett); /* render the rocket data */ +} From f92234da7853f9eb8bc2d77accbac96e221ecb8a Mon Sep 17 00:00:00 2001 From: schneider Date: Thu, 22 Dec 2011 20:47:21 +0100 Subject: [PATCH 14/20] made initanim internal --- firmware/applications/final.c | 2 +- firmware/l0dable/Makefile | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/firmware/applications/final.c b/firmware/applications/final.c index f42502c..b923d08 100644 --- a/firmware/applications/final.c +++ b/firmware/applications/final.c @@ -22,7 +22,7 @@ void main_final(void) { init_nick(); if(GLOBAL(privacy)>2){ //firstboot - execute_file("initanim.c0d"); + execute_file("initanim.int"); if(execute_file("1boot.int")){ lcdPrintln("Badge SETUP"); lcdPrintln("error."); diff --git a/firmware/l0dable/Makefile b/firmware/l0dable/Makefile index 6c9d56b..fb9fdd5 100644 --- a/firmware/l0dable/Makefile +++ b/firmware/l0dable/Makefile @@ -31,7 +31,7 @@ CRYPTFLAGS=-p skey=`cd .. && ./getkey.pl l0dable_sign` ekey=`cd .. && ./getkey.pl l0dable_crypt` -all: $(OBJS) $(ELFS) $(BINS) $(CODS) $(NIKS) 1boot.int debug.int config.int +all: $(OBJS) $(ELFS) $(BINS) $(CODS) $(NIKS) 1boot.int debug.int config.int initanim.int $(LDFILE): -@echo "MEMORY" > $(LDFILE) @@ -71,6 +71,9 @@ debug.int: debug.c0d .PHONY config.int: config.c0d .PHONY mv $< $@ +initanim.int: initanim.c0d .PHONY + mv $< $@ + clean: rm -f *.o *.elf *.bin usetable.h From 41d96707c0599f07120b46857eeac207078e48e4 Mon Sep 17 00:00:00 2001 From: schneider Date: Thu, 22 Dec 2011 20:47:38 +0100 Subject: [PATCH 15/20] player: show game name when playing --- firmware/l0dable/r_player.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/firmware/l0dable/r_player.c b/firmware/l0dable/r_player.c index 056a18d..cef4126 100644 --- a/firmware/l0dable/r_player.c +++ b/firmware/l0dable/r_player.c @@ -93,6 +93,7 @@ uint16_t gameId; uint8_t interval; uint8_t jitter; uint8_t flags; +uint8_t *gameTitle; void sendButton(uint8_t button); void sendJoin(uint32_t game); @@ -129,6 +130,9 @@ void playGame(void) { int len; struct packet p; + lcdPrintln("Now playing:"); + lcdPrintln(gameTitle); + lcdRefresh(); while(1){ uint8_t button = getInputRaw(); @@ -191,7 +195,6 @@ uint8_t joinGame() p.id= id; p.ctr= ++ctr; p.c.join.gameId=gameId; - lcdClear(); lcdPrintln("Joining game"); lcdRefresh(); @@ -278,7 +281,9 @@ uint8_t selectGame() interval = games[selected].interval; jitter = games[selected].jitter; flags = games[selected].gameFlags; + gameTitle = games[selected].gameTitle; nrf_config_set(&config); + lcdClear(); if( games[selected].gameFlags & FLAGS_MASS_GAME ) return 1; else From de4f010c2a4d77d0aecb6d6c2555ae5ea1d52ea2 Mon Sep 17 00:00:00 2001 From: schneider Date: Thu, 22 Dec 2011 21:32:11 +0100 Subject: [PATCH 16/20] player: fixed length of ack packets --- firmware/l0dable/r_player.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/firmware/l0dable/r_player.c b/firmware/l0dable/r_player.c index cef4126..fd43da8 100644 --- a/firmware/l0dable/r_player.c +++ b/firmware/l0dable/r_player.c @@ -313,7 +313,7 @@ void processPacket(struct packet *p) if (p->command=='T'){ struct packet ack; memset((void*)&ack, 0, sizeof(ack)); - ack.len=sizeof(p); + ack.len=sizeof(ack); ack.protocol='G'; ack.command='a'; ack.id= id; From 68148e38c3644edc41a2f8a19477b9d0c658554e Mon Sep 17 00:00:00 2001 From: schneider Date: Thu, 22 Dec 2011 22:25:41 +0100 Subject: [PATCH 17/20] player: only send acks if not in mass game mode --- firmware/l0dable/r_player.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/firmware/l0dable/r_player.c b/firmware/l0dable/r_player.c index fd43da8..3fe8d8d 100644 --- a/firmware/l0dable/r_player.c +++ b/firmware/l0dable/r_player.c @@ -319,7 +319,8 @@ void processPacket(struct packet *p) ack.id= id; ack.ctr= p->ctr; ack.c.ack.flags = 0; - nrf_snd_pkt_crc(sizeof(ack),(uint8_t*)&ack); + if( p->id ) + nrf_snd_pkt_crc(sizeof(ack),(uint8_t*)&ack); processText(&(p->c.text)); } else if (p->command=='N'){ From 3904870f32e777eb905ea0b87894c946ca11114d Mon Sep 17 00:00:00 2001 From: schneider Date: Fri, 23 Dec 2011 00:33:09 +0100 Subject: [PATCH 18/20] usbcdc: increased ringbuffer size --- firmware/usbcdc/cdcuser.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/firmware/usbcdc/cdcuser.c b/firmware/usbcdc/cdcuser.c index 85fd77d..703ba85 100644 --- a/firmware/usbcdc/cdcuser.c +++ b/firmware/usbcdc/cdcuser.c @@ -41,7 +41,7 @@ volatile unsigned char CDC_DepInEmpty = 1; // Data IN EP is much faster than UART transmits *---------------------------------------------------------------------------*/ /* Buffer masks */ -#define CDC_BUF_SIZE (64) // Output buffer in bytes (power 2) +#define CDC_BUF_SIZE (128) // Output buffer in bytes (power 2) // large enough for file transfer #define CDC_BUF_MASK (CDC_BUF_SIZE-1ul) @@ -342,6 +342,8 @@ void CDC_BulkIn(void) { int numBytesRead, numBytesAvail; CDC_InBufAvailChar(&numBytesAvail); + if( numBytesAvail > 64 ) + numBytesAvail = 64; numBytesRead = CDC_RdInBuf((char*)&BulkBufIn[0], &numBytesAvail); // send over USB if (numBytesRead > 0) { From 23696109cc9345fcb441bd63ef9e9ea18aaca049 Mon Sep 17 00:00:00 2001 From: Stefan `Sec` Zehl Date: Fri, 23 Dec 2011 00:37:46 +0100 Subject: [PATCH 19/20] Disable crypto in serial for now --- firmware/applications/serial/serial.c | 36 +++++++++++++-------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/firmware/applications/serial/serial.c b/firmware/applications/serial/serial.c index 9e52869..f8219a6 100644 --- a/firmware/applications/serial/serial.c +++ b/firmware/applications/serial/serial.c @@ -145,9 +145,7 @@ static int process(char * input){ return -1; puts_plus("\r\n"); - puts_plus("D ["); - puts_plus(input); - puts("]\r\n"); +// puts_plus("D ["); puts_plus(input); puts("]\r\n"); if(input[0]=='i'){ nrf_init(); @@ -161,8 +159,8 @@ static int process(char * input){ config.maclen[0]=0x20; config.nrmacs=1; nrf_config_set(&config); - memcpy(thekey,meshkey,sizeof(thekey)); - funkencrypt=1; +// memcpy(thekey,meshkey,sizeof(thekey)); + funkencrypt=0; }else if(input[1]=='M'){ config.channel=83; memcpy(config.txmac,MESH_MAC,5); @@ -170,11 +168,11 @@ static int process(char * input){ config.maclen[0]=0x20; config.nrmacs=1; nrf_config_set(&config); - static const uint32_t const pubmesh[4] = { - 0x00000042, 0x000005ec, 0x00000023, 0x00000005 - }; - memcpy(thekey,pubmesh,sizeof(thekey)); - funkencrypt=1; +// static const uint32_t const pubmesh[4] = { +// 0x00000042, 0x000005ec, 0x00000023, 0x00000005 +// }; +// memcpy(thekey,pubmesh,sizeof(thekey)); + funkencrypt=0; }else if(input[1]=='r'){ config.channel=REMOTE_CHANNEL; memcpy(config.txmac,REMOTE_MAC,5); @@ -182,8 +180,8 @@ static int process(char * input){ config.maclen[0]=0x10; config.nrmacs=1; nrf_config_set(&config); - memcpy(thekey,remotekey,sizeof(thekey)); - funkencrypt=1; +// memcpy(thekey,remotekey,sizeof(thekey)); + funkencrypt=0; }else if(input[1]=='b'){ config.channel=BEACON_CHANNEL; memcpy(config.txmac,BEACON_MAC,5); @@ -191,8 +189,8 @@ static int process(char * input){ config.maclen[0]=0x10; config.nrmacs=1; nrf_config_set(&config); - memcpy(thekey,openbeaconkey,sizeof(thekey)); - funkencrypt=1; +// memcpy(thekey,openbeaconkey,sizeof(thekey)); + funkencrypt=0; }else if(input[1]=='B'){ config.channel=BEACON_CHANNEL; memcpy(config.txmac,BEACON_MAC,5); @@ -200,11 +198,11 @@ static int process(char * input){ config.maclen[0]=0x10; config.nrmacs=1; nrf_config_set(&config); - static const uint32_t pubbeaconkey[4] = { - 0xB4595344, 0xD3E119B6, 0xA814D0EC, 0xEFF5A24E - }; - memcpy(thekey,pubbeaconkey,sizeof(thekey)); - funkencrypt=1; +// static const uint32_t pubbeaconkey[4] = { +// 0xB4595344, 0xD3E119B6, 0xA814D0EC, 0xEFF5A24E +// }; +// memcpy(thekey,pubbeaconkey,sizeof(thekey)); + funkencrypt=0; }; }else if(input[0]=='t'){ type=input[1]; From d69199e563d5342de7d052cd7f012ae357649324 Mon Sep 17 00:00:00 2001 From: Stefan `Sec` Zehl Date: Fri, 23 Dec 2011 01:07:48 +0100 Subject: [PATCH 20/20] Fix all warnings (except table.c and ff.c). Turn off "unused function" warnings --- firmware/Makefile.inc | 2 +- firmware/applications/final/config.c | 1 + firmware/applications/final/flame_rgb.c | 2 +- firmware/basic/config.c | 1 + firmware/filesystem/execute.c | 2 +- firmware/filesystem/execute.h | 2 +- firmware/filesystem/select.c | 4 ++-- firmware/filesystem/select.h | 4 ++-- firmware/filesystem/util.c | 9 ++++++--- firmware/funk/openbeacon.c | 2 ++ firmware/lcd/display.c | 2 +- 11 files changed, 19 insertions(+), 12 deletions(-) diff --git a/firmware/Makefile.inc b/firmware/Makefile.inc index 2db9163..a0d7fa9 100644 --- a/firmware/Makefile.inc +++ b/firmware/Makefile.inc @@ -42,7 +42,7 @@ CPU_TYPE = cortex-$(CORTEX_TYPE) # Compiler settings, parameters and flags ########################################################################## -CFLAGS = -std=c99 -c -g -Os $(INCLUDE_PATHS) -Wall -mthumb -ffunction-sections -fdata-sections -fmessage-length=0 -mcpu=$(CPU_TYPE) -DTARGET=$(TARGET) -DRAMCODE=$(RAMCODE) -fno-builtin +CFLAGS = -std=c99 -c -g -Os $(INCLUDE_PATHS) -Wall -mthumb -ffunction-sections -fdata-sections -fmessage-length=0 -mcpu=$(CPU_TYPE) -DTARGET=$(TARGET) -DRAMCODE=$(RAMCODE) -fno-builtin -Wno-unused-function LDFLAGS = -nostartfiles diff --git a/firmware/applications/final/config.c b/firmware/applications/final/config.c index 5aecf3b..e096a8d 100644 --- a/firmware/applications/final/config.c +++ b/firmware/applications/final/config.c @@ -8,6 +8,7 @@ #include "lcd/display.h" #include "filesystem/ff.h" +#include "filesystem/execute.h" #include diff --git a/firmware/applications/final/flame_rgb.c b/firmware/applications/final/flame_rgb.c index 3ea22e1..fc17301 100644 --- a/firmware/applications/final/flame_rgb.c +++ b/firmware/applications/final/flame_rgb.c @@ -189,7 +189,7 @@ void init_flame_rgb(void) { flameRGBSetI2C(FLAME_I2C_CR_GRPPWM, 0x00); // overall dimming - rgbDataSize = readTextFile("FLAME.RGB", rgbData, 24); + rgbDataSize = readTextFile("FLAME.RGB", (char *)rgbData, 24); enableConfig(CFG_TYPE_FLAME,1); } diff --git a/firmware/basic/config.c b/firmware/basic/config.c index f933b52..fa58120 100644 --- a/firmware/basic/config.c +++ b/firmware/basic/config.c @@ -3,6 +3,7 @@ #include "lcd/display.h" #include "lcd/print.h" +#include "lcd/backlight.h" #include "filesystem/ff.h" #include "basic/random.h" #include "basic/config.h" diff --git a/firmware/filesystem/execute.c b/firmware/filesystem/execute.c index 7546e74..8111e8e 100644 --- a/firmware/filesystem/execute.c +++ b/firmware/filesystem/execute.c @@ -89,7 +89,7 @@ uint8_t execute_file (const char * fname){ /**************************************************************************/ -void executeSelect(char *ext){ +void executeSelect(const char *ext){ char filename[15]; filename[0]='0'; filename[1]=':'; diff --git a/firmware/filesystem/execute.h b/firmware/filesystem/execute.h index 50a9a53..f421664 100644 --- a/firmware/filesystem/execute.h +++ b/firmware/filesystem/execute.h @@ -2,6 +2,6 @@ #define _EXECUTE_H_ uint8_t execute_file (const char * fname); -void executeSelect(char *ext); +void executeSelect(const char *ext); #endif diff --git a/firmware/filesystem/select.c b/firmware/filesystem/select.c index d6512b6..07399f1 100644 --- a/firmware/filesystem/select.c +++ b/firmware/filesystem/select.c @@ -8,7 +8,7 @@ #define FLEN 13 -int getFiles(char files[][FLEN], uint8_t count, uint16_t skip, char *ext) +int getFiles(char files[][FLEN], uint8_t count, uint16_t skip, const char *ext) { DIR dir; /* Directory object */ FILINFO Finfo; @@ -45,7 +45,7 @@ int getFiles(char files[][FLEN], uint8_t count, uint16_t skip, char *ext) } #define PERPAGE 7 -int selectFile(char *filename, char *extension) +int selectFile(char *filename, const char *extension) { int skip = 0; char key; diff --git a/firmware/filesystem/select.h b/firmware/filesystem/select.h index 966d135..8347840 100644 --- a/firmware/filesystem/select.h +++ b/firmware/filesystem/select.h @@ -4,7 +4,7 @@ #define FLEN 13 -int getFiles(char files[][FLEN], uint8_t count, uint16_t skip, char *ext); -int selectFile(char *filename, char *extension); +int getFiles(char files[][FLEN], uint8_t count, uint16_t skip, const char *ext); +int selectFile(char *filename, const char *extension); #endif diff --git a/firmware/filesystem/util.c b/firmware/filesystem/util.c index d0d7244..f4ace01 100644 --- a/firmware/filesystem/util.c +++ b/firmware/filesystem/util.c @@ -1,5 +1,9 @@ #include #include +#include +#include "at45db041d.h" +#include "lcd/print.h" +#include "usb/usbmsc.h" FATFS FatFs; /* File system object for logical drive */ @@ -29,10 +33,9 @@ const uint8_t init2[] = {0x80, 0x00, 0x29, 0x37, 0x4d, 0x45, 0x20, 0x20, 0x20, 0x20, 0x46, 0x41, 0x54, 0x20, 0x20, 0x20, 0x20, 0x20}; -inline void format_formatDF(void) -{ +inline void format_formatDF(void) { int i; - char buf[512]; + BYTE buf[512]; memset(buf, 0, 512); for(i=0; i<100; i++) dataflash_write(buf, i, 1); diff --git a/firmware/funk/openbeacon.c b/firmware/funk/openbeacon.c index e634f91..3ee67bc 100644 --- a/firmware/funk/openbeacon.c +++ b/firmware/funk/openbeacon.c @@ -1,4 +1,5 @@ #include +#include #include "funk/openbeacon.h" #include "funk/nrf24l01p.h" #include "basic/byteorder.h" @@ -6,6 +7,7 @@ #include "filesystem/ff.h" #include "basic/uuid.h" #include "basic/config.h" +#include "basic/random.h" #include "SECRETS" diff --git a/firmware/lcd/display.c b/firmware/lcd/display.c index 5824c7c..2e60e08 100644 --- a/firmware/lcd/display.c +++ b/firmware/lcd/display.c @@ -270,7 +270,7 @@ void lcdDisplay(void) { unsigned char br=0xFF, bg=0xFF, bb=0xFF; unsigned char frame_r=0x00, frame_g=0x00, frame_b=0x80; uint16_t color,framecolor,backcolor; - uint16_t x,y,i; + uint16_t x,y; bool px; uint16_t actualcolor; color = ((r&0xF8) << 8) | ((g&0xFC)<<3) | ((b&0xF8) >> 3);