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

This commit is contained in:
bernd 2011-08-05 02:43:10 +02:00
commit 6552ff4d20
26 changed files with 119 additions and 21 deletions

View File

@ -20,6 +20,7 @@ void main_default(void) {
lcdClear(); lcdClear();
lcdLoadImage("r0ket.lcd"); lcdLoadImage("r0ket.lcd");
lcdRefresh(); lcdRefresh();
lcdClear();
switch(getInputRaw()){ switch(getInputRaw()){
case BTN_ENTER: case BTN_ENTER:
@ -28,6 +29,10 @@ void main_default(void) {
case BTN_UP: // Reset config case BTN_UP: // Reset config
f_unlink("r0ket.cfg"); f_unlink("r0ket.cfg");
break; break;
case BTN_RIGHT:
GLOBAL(develmode)=1;
applyConfig();
break;
case BTN_DOWN: case BTN_DOWN:
usbMSCInit(); usbMSCInit();
while(1) while(1)
@ -83,6 +88,15 @@ void tick_default(void) {
EVERY(50,0){ 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){ if(GetVoltage()<3600){
IOCON_PIO1_11 = 0x0; IOCON_PIO1_11 = 0x0;
gpioSetDir(RB_LED3, gpioDirection_Output); gpioSetDir(RB_LED3, gpioDirection_Output);

View File

@ -9,6 +9,7 @@
#include "basic/ecc.h" #include "basic/ecc.h"
#include "basic/config.h" #include "basic/config.h"
#include "filesystem/execute.h"
/**************************************************************************/ /**************************************************************************/

View File

@ -3,6 +3,7 @@
#include "basic/basic.h" #include "basic/basic.h"
#include "basic/byteorder.h" #include "basic/byteorder.h"
#include "basic/config.h" #include "basic/config.h"
#include "basic/random.h"
#include "funk/nrf24l01p.h" #include "funk/nrf24l01p.h"
#include "funk/openbeacon.h" #include "funk/openbeacon.h"

View File

@ -19,3 +19,9 @@ void execute_menu(void){
lcdRefresh(); lcdRefresh();
}; };
//# MENU |devel
void execute_devel(void){
while(getInput()!=BTN_NONE);
executeSelect("INT");
lcdRefresh();
};

View File

@ -154,6 +154,7 @@ void init_flame(void) {
#include "lcd/print.h" #include "lcd/print.h"
// //# MENU flame
void ChkFlame(void) { void ChkFlame(void) {
do{ do{
lcdClear(); lcdClear();

View File

@ -123,7 +123,7 @@ char *meshmsgs(void){
extern MPKT meshbuffer[MESHBUFSIZE]; extern MPKT meshbuffer[MESHBUFSIZE];
//# MENU Messages //# MENU messages
void m_choose(){ void m_choose(){
char list[99]; char list[99];
int i=0; int i=0;

View File

@ -11,6 +11,7 @@
#include "filesystem/ff.h" #include "filesystem/ff.h"
#include "filesystem/select.h" #include "filesystem/select.h"
#include "filesystem/execute.h"
#include <string.h> #include <string.h>

View File

@ -6,15 +6,19 @@
#include "lcd/render.h" #include "lcd/render.h"
#include "lcd/print.h" #include "lcd/print.h"
#include "lcd/image.h"
#include "usb/usbmsc.h" #include "usb/usbmsc.h"
#include "filesystem/ff.h"
#include "filesystem/select.h"
#include "core/iap/iap.h" #include "core/iap/iap.h"
/**************************************************************************/ /**************************************************************************/
//# MENU msc //# MENU usb_storage
void msc_menu(void){ void msc_menu(void){
lcdClear(); lcdClear();
lcdPrintln("MSC Enabled."); lcdPrintln("MSC Enabled.");
@ -46,3 +50,20 @@ void tick_alive(void){
return; 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);
};

View File

@ -136,6 +136,7 @@ void delayms(uint32_t ms);
// voltage.c // voltage.c
void VoltageCheck(void); void VoltageCheck(void);
uint32_t GetVoltage(void); uint32_t GetVoltage(void);
uint8_t GetChrgStat(void);
// night.c // night.c
void LightCheck(void); void LightCheck(void);

View File

@ -28,6 +28,7 @@ struct CDESC the_config[]= {
{"flamemaxw", 255, 1, 255, 1, CFG_TYPE_FLAME}, {"flamemaxw", 255, 1, 255, 1, CFG_TYPE_FLAME},
{"flameminw", 0x8f, 1, 255, 1, CFG_TYPE_FLAME}, {"flameminw", 0x8f, 1, 255, 1, CFG_TYPE_FLAME},
{"l0nick", 0, 0, 1 , 0, 0}, {"l0nick", 0, 0, 1 , 0, 0},
{"chargeled", 1, 0, 1 , 0, 0},
{ NULL, 0, 0, 0 , 0, 0}, { NULL, 0, 0, 0 , 0, 0},
}; };

View File

@ -19,7 +19,7 @@ struct CDESC {
#define CFG_TYPE_DEVEL 1 #define CFG_TYPE_DEVEL 1
#define CFG_TYPE_FLAME 2 #define CFG_TYPE_FLAME 2
#define MAXNICK 20 #define MAXNICK 17
extern struct CDESC the_config[]; extern struct CDESC the_config[];
extern char nickname[]; extern char nickname[];
extern char nickfont[]; extern char nickfont[];
@ -42,9 +42,10 @@ extern char nickl0[];
#define GLOBALflamemaxw (the_config[14].value) #define GLOBALflamemaxw (the_config[14].value)
#define GLOBALflameminw (the_config[15].value) #define GLOBALflameminw (the_config[15].value)
#define GLOBALl0nick (the_config[16].value) #define GLOBALl0nick (the_config[16].value)
#define GLOBALchargeled (the_config[17].value)
#define GLOBALnickname (nickname) #define GLOBALnickname (nickname)
#define GLOBALnickfont (nickfont) #define GLOBALnickfont (nickfont)
#define GLOBALnickl0 (nickl0) #define GLOBALnickl0 (nickl0)
#define GLOBAL(x) GLOBAL ## x #define GLOBAL(x) GLOBAL ## x

View File

@ -42,10 +42,11 @@ uint8_t work_queue_minimal(void){
return 1; return 1;
}; };
}; };
/* NOTREACHED */
return 0;
}; };
void work_queue(void){ void work_queue(void){
int start;
if (the_queue.qstart == the_queue.qend){ if (the_queue.qstart == the_queue.qend){
WFI; WFI;
@ -57,7 +58,7 @@ void work_queue(void){
uint8_t delayms_queue_plus(uint32_t ms, uint8_t final){ uint8_t delayms_queue_plus(uint32_t ms, uint8_t final){
int ret; int ret=0;
int end=_timectr+ms/SYSTICKSPEED; int end=_timectr+ms/SYSTICKSPEED;
do { do {
if (the_queue.qstart == the_queue.qend){ if (the_queue.qstart == the_queue.qend){

View File

@ -1,6 +1,7 @@
#include <sysinit.h> #include <sysinit.h>
#include "basic/basic.h" #include "basic/basic.h"
#include "basic/config.h"
#include "lcd/print.h" #include "lcd/print.h"
@ -11,7 +12,7 @@ uint8_t menuflags=0;
void handleMenu(const struct MENU *the_menu) { void handleMenu(const struct MENU *the_menu) {
uint8_t back = 0; uint8_t back = 0;
int8_t menuselection = 0; int8_t menuselection = 0;
uint8_t numentries = 0; uint8_t numentries;
uint8_t visible_lines = 0; uint8_t visible_lines = 0;
uint8_t current_offset = 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++); 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 visible_lines = lcdGetVisibleLines()-1; // subtract title line
if(menuflags&MENU_BIG) if(menuflags&MENU_BIG)
@ -81,8 +85,8 @@ void handleMenu(const struct MENU *the_menu) {
break; break;
case BTN_ENTER: case BTN_ENTER:
lcdClear(); lcdClear();
lcdPrintln("Called..."); // lcdPrintln("Called...");
lcdRefresh(); // lcdRefresh();
getInputWaitRelease(); getInputWaitRelease();
if (the_menu->entries[menuselection].callback!=NULL) if (the_menu->entries[menuselection].callback!=NULL)
the_menu->entries[menuselection].callback(); the_menu->entries[menuselection].callback();
@ -91,7 +95,7 @@ void handleMenu(const struct MENU *the_menu) {
if (menuflags&MENU_JUSTONCE) if (menuflags&MENU_JUSTONCE)
return; return;
getInputWait(); // getInputWait();
break; break;
case BTN_NONE: /* timeout */ case BTN_NONE: /* timeout */

View File

@ -80,6 +80,7 @@ static void inputMove() {
static void inputDraw() { static void inputDraw() {
char tmp[2]= {0,0}; char tmp[2]= {0,0};
int pos = 0;
lcdClear(); lcdClear();
DoString(0,0,s_input.prompt); DoString(0,0,s_input.prompt);
for (int dx = 0; dx<= RESX/CHARWIDTH && s_input.pos+dx<s_input.maxlength; dx++){ for (int dx = 0; dx<= RESX/CHARWIDTH && s_input.pos+dx<s_input.maxlength; dx++){
@ -87,6 +88,12 @@ static void inputDraw() {
DoString(dx*CHARWIDTH, 30,tmp); DoString(dx*CHARWIDTH, 30,tmp);
} }
DoString(s_input.dcursor * CHARWIDTH, 40, "-"); DoString(s_input.dcursor * CHARWIDTH, 40, "-");
pos = DoString(0,60,"[");
pos = DoInt(pos,60,s_input.pos+s_input.dcursor+1);
pos = DoString(pos,60,"/");
pos = DoInt(pos,60,s_input.maxlength);
DoString(pos,60,"]");
} }
static void inputClean() { static void inputClean() {

View File

@ -3,10 +3,13 @@
#include "basic/basic.h" #include "basic/basic.h"
#include "funk/nrf24l01p.h" #include "funk/nrf24l01p.h"
uint32_t results=5000; static uint32_t results=5000;
static uint8_t chrg=1;
void VoltageCheck(void){ void VoltageCheck(void){
chrg=gpioGetValue(RB_PWR_CHRG);
results = adcRead(1); results = adcRead(1);
results *= 10560; results *= 10560;
results /= 1024; results /= 1024;
@ -24,3 +27,7 @@ void VoltageCheck(void){
uint32_t GetVoltage(void){ uint32_t GetVoltage(void){
return results; return results;
}; };
uint8_t GetChrgStat(void){
return !chrg;
};

View File

@ -334,6 +334,7 @@ const char* f_get_rc_string (FRESULT rc);
void fsInit(); void fsInit();
int readFile(char * filename, char * data, int len); int readFile(char * filename, char * data, int len);
int writeFile(char * filename, char * data, int len); int writeFile(char * filename, char * data, int len);
void fsReInit();
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -11,6 +11,7 @@
char meshgen=0; // Generation char meshgen=0; // Generation
char meshincctr=0; char meshincctr=0;
char meshmsg=0; char meshmsg=0;
char meshnice=0;
MPKT meshbuffer[MESHBUFSIZE]; MPKT meshbuffer[MESHBUFSIZE];
uint32_t const meshkey[4] = { uint32_t const meshkey[4] = {
@ -89,11 +90,19 @@ void mesh_sendloop(void){
else else
uint32touint8p(0,MO_BODY(meshbuffer[0].pkt)); uint32touint8p(0,MO_BODY(meshbuffer[0].pkt));
MO_BODY(meshbuffer[0].pkt)[4]=meshnice;
for (int i=0;i<MESHBUFSIZE;i++){ for (int i=0;i<MESHBUFSIZE;i++){
if(!meshbuffer[i].flags&MF_USED) if(!meshbuffer[i].flags&MF_USED)
continue; continue;
if(meshbuffer[i].flags&MF_LOCK) if(meshbuffer[i].flags&MF_LOCK)
continue; continue;
if(meshnice&0xf){
if(getSeconds()%0xf < (meshnice&0x0f)){
meshincctr++;
continue;
};
};
ctr++; ctr++;
memcpy(buf,meshbuffer[i].pkt,MESHPKTSIZE); memcpy(buf,meshbuffer[i].pkt,MESHPKTSIZE);
status=nrf_snd_pkt_crc_encr(MESHPKTSIZE,buf,meshkey); status=nrf_snd_pkt_crc_encr(MESHPKTSIZE,buf,meshkey);
@ -141,6 +150,7 @@ uint8_t mesh_recvqloop_work(void){
_timet = toff; _timet = toff;
meshincctr++; meshincctr++;
}; };
meshnice=MO_BODY(meshbuffer[0].pkt)[4];
return 1; return 1;
}; };

View File

@ -30,6 +30,7 @@ typedef struct {
extern char meshgen; // Generation extern char meshgen; // Generation
extern char meshincctr; // Time checker extern char meshincctr; // Time checker
extern char meshnice; // Time checker
extern char meshmsg; // Is there something interesting? extern char meshmsg; // Is there something interesting?
extern MPKT meshbuffer[MESHBUFSIZE]; extern MPKT meshbuffer[MESHBUFSIZE];

View File

@ -5,6 +5,8 @@
#define DEFAULT_SPEED R_RF_SETUP_DR_2M #define DEFAULT_SPEED R_RF_SETUP_DR_2M
uint8_t _nrfresets=0;
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
/* Transmit a byte via SPI */ /* Transmit a byte via SPI */
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
@ -405,11 +407,9 @@ 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){ if(nrf_cmd_status(C_NOP) & R_STATUS_MAX_RT){
_nrfresets++; _nrfresets++;
nrf_init(); nrf_init();
}; };
return _nrfresets;
}; };

View File

@ -165,7 +165,8 @@ int nrf_rcv_pkt_poll_dec(int maxsize, uint8_t * pkt, uint32_t const key[4]);
// more utility. // more utility.
void nrf_rcv_pkt_end(void); void nrf_rcv_pkt_end(void);
uint8_t nrf_check_reset(void); void nrf_check_reset(void);
extern uint8_t _nrfresets;
/* END */ /* END */

View File

@ -32,7 +32,7 @@ void ram(void){
while (!privacy_set) { while (!privacy_set) {
handleMenu(&submenu_privacy); handleMenu(&submenu_privacy);
} }
input("Nickname:", GLOBAL(nickname), 32, 127, MAXNICK-1); input("Nickname?", GLOBAL(nickname), 32, 127, MAXNICK-1);
getInputWaitRelease(); getInputWaitRelease();
again = screen_overview(); again = screen_overview();
} }
@ -60,8 +60,13 @@ static void set_privacy(int level) {
static void screen_intro() { static void screen_intro() {
lcdClear(); lcdClear();
lcdPrintln("Welcome to"); lcdPrintln("");
lcdPrintln("r0ket"); lcdPrintln(" r0ket");
lcdPrintln("");
lcdPrintln("launch config");
lcdPrintln("");
lcdPrintln("press any key");
lcdPrintln("to continue");
lcdRefresh(); lcdRefresh();
getInputWait(); getInputWait();
getInputWaitRelease(); getInputWaitRelease();

View File

@ -86,3 +86,5 @@ input
saveConfig saveConfig
lcdShowAnim lcdShowAnim
lcdLoadImage lcdLoadImage
meshnice
_nrfresets

View File

@ -27,7 +27,7 @@ CFLAGS+=-mlong-calls -fno-toplevel-reorder
CRYPT=cp CRYPT=cp
CRYPTFLAGS=-p CRYPTFLAGS=-p
all: $(OBJS) $(ELFS) $(BINS) $(CODS) $(NIKS) 1boot.int all: $(OBJS) $(ELFS) $(BINS) $(CODS) $(NIKS) 1boot.int debug.int
$(LDFILE): $(LDFILE):
-@echo "MEMORY" > $(LDFILE) -@echo "MEMORY" > $(LDFILE)
@ -55,6 +55,9 @@ $(LDFILE):
1boot.int: 1boot.c0d .PHONY 1boot.int: 1boot.c0d .PHONY
mv $< $@ mv $< $@
debug.int: debug.c0d .PHONY
mv $< $@
clean: clean:
rm -f *.o *.elf *.bin usetable.h rm -f *.o *.elf *.bin usetable.h

View File

@ -204,6 +204,9 @@ void m_time(void){
lcdPrint("Inc:"); lcdPrint("Inc:");
lcdPrintInt(meshincctr); lcdPrintInt(meshincctr);
lcdNl(); lcdNl();
lcdPrint("Nice:");
lcdPrintInt(meshnice);
lcdNl();
lcdRefresh(); lcdRefresh();
delayms_queue(50); delayms_queue(50);
}while ((getInputRaw())==BTN_NONE); }while ((getInputRaw())==BTN_NONE);
@ -217,7 +220,7 @@ void ChkFunk(){
lcdPrint("cfg:"); lcdPrint("cfg:");
lcdPrintln(IntToStrX(nrf_read_reg(R_CONFIG),2)); lcdPrintln(IntToStrX(nrf_read_reg(R_CONFIG),2));
lcdPrintln("Resets:"); lcdPrintln("Resets:");
lcdPrintln(IntToStr(nrf_check_reset(),3,0)); lcdPrintln(IntToStr(_nrfresets,3,0));
lcdRefresh(); lcdRefresh();
while(!getInputRaw())work_queue(); while(!getInputRaw())work_queue();
}; };

View File

@ -79,7 +79,6 @@ void ram(void) {
while(1) { while(1) {
if (!screen_intro()) if (!screen_intro())
return; return;
screen_intro();
game.rokets = 3; game.rokets = 3;
game.level = 1; game.level = 1;
game.score = 0; game.score = 0;
@ -114,7 +113,9 @@ static bool screen_intro() {
char highnick[20]; char highnick[20];
char key=0; char key=0;
bool step = false; bool step = false;
//getInputWaitRelease();
while(key==0) { while(key==0) {
getInputWaitRelease();
lcdFill(0); lcdFill(0);
font = &Font_Invaders; font = &Font_Invaders;
DoString(28,25,step?"ABC":"abc"); DoString(28,25,step?"ABC":"abc");
@ -129,6 +130,7 @@ static bool screen_intro() {
step = !step; step = !step;
key=getInputWaitTimeout(1000); key=getInputWaitTimeout(1000);
} }
//getInputWaitRelease();
return !(key==BTN_LEFT); return !(key==BTN_LEFT);
} }
@ -144,6 +146,7 @@ static bool screen_gameover() {
lcdDisplay(); lcdDisplay();
key=getInputWaitTimeout(5000); key=getInputWaitTimeout(5000);
} }
//getInputWaitRelease();
return !(key==BTN_LEFT); return !(key==BTN_LEFT);
} }

View File

@ -67,6 +67,7 @@ static void lcdWrite(uint8_t cd, uint8_t data) {
#define SDA 0,9 #define SDA 0,9
#define RST 2,2 #define RST 2,2
#ifdef NOTYET
uint8_t lcdRead(uint8_t data) uint8_t lcdRead(uint8_t data)
{ {
uint8_t i; uint8_t i;
@ -109,6 +110,7 @@ uint8_t lcdRead(uint8_t data)
gpioSetDir(SDA, 1); gpioSetDir(SDA, 1);
delayms(1); delayms(1);
} }
#endif
void lcdInit(void) { void lcdInit(void) {