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();
lcdLoadImage("r0ket.lcd");
lcdRefresh();
lcdClear();
switch(getInputRaw()){
case BTN_ENTER:
@ -28,6 +29,10 @@ void main_default(void) {
case BTN_UP: // Reset config
f_unlink("r0ket.cfg");
break;
case BTN_RIGHT:
GLOBAL(develmode)=1;
applyConfig();
break;
case BTN_DOWN:
usbMSCInit();
while(1)
@ -83,6 +88,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);

View File

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

View File

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

View File

@ -19,3 +19,9 @@ void execute_menu(void){
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"
// //# MENU flame
void ChkFlame(void) {
do{
lcdClear();

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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){

View File

@ -1,6 +1,7 @@
#include <sysinit.h>
#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 */

View File

@ -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<s_input.maxlength; dx++){
@ -87,6 +88,12 @@ static void inputDraw() {
DoString(dx*CHARWIDTH, 30,tmp);
}
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() {

View File

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

View File

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

View File

@ -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<MESHBUFSIZE;i++){
if(!meshbuffer[i].flags&MF_USED)
continue;
if(meshbuffer[i].flags&MF_LOCK)
continue;
if(meshnice&0xf){
if(getSeconds()%0xf < (meshnice&0x0f)){
meshincctr++;
continue;
};
};
ctr++;
memcpy(buf,meshbuffer[i].pkt,MESHPKTSIZE);
status=nrf_snd_pkt_crc_encr(MESHPKTSIZE,buf,meshkey);
@ -141,6 +150,7 @@ uint8_t mesh_recvqloop_work(void){
_timet = toff;
meshincctr++;
};
meshnice=MO_BODY(meshbuffer[0].pkt)[4];
return 1;
};

View File

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

View File

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

View File

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

View File

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

View File

@ -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)
@ -55,6 +55,9 @@ $(LDFILE):
1boot.int: 1boot.c0d .PHONY
mv $< $@
debug.int: debug.c0d .PHONY
mv $< $@
clean:
rm -f *.o *.elf *.bin usetable.h

View File

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

View File

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

View File

@ -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) {