Merge branch 'master' of github.com:r0ket/r0ket
This commit is contained in:
commit
4b74112148
|
@ -8,6 +8,10 @@ ifeq "$(APP)" "initial"
|
|||
NODEFAULT = y
|
||||
endif
|
||||
|
||||
ifeq "$(APP)" "tester"
|
||||
DEBUG = -d
|
||||
endif
|
||||
|
||||
ifndef NODEFAULT
|
||||
OBJS += default.o
|
||||
endif
|
||||
|
@ -71,7 +75,7 @@ ifeq "$(wildcard $(APP))" "$(APP)"
|
|||
ifndef TYPE
|
||||
TYPE=$(APP)
|
||||
endif
|
||||
TSRCS = $(wildcard $(TYPE)/*.c)
|
||||
TSRCS = $(foreach type,$(TYPE),$(wildcard $(type)/*.c))
|
||||
TOBJS = $(foreach mod,$(TSRCS),$(subst .c,.o,$(mod)))
|
||||
|
||||
TWRAP=$(APP).gen
|
||||
|
@ -81,7 +85,7 @@ TWRAP=$(APP).gen
|
|||
$(APP).o: $(TWRAP)
|
||||
|
||||
$(TWRAP):
|
||||
./mkfirmware $(APP) $(TSRCS) > $@
|
||||
./mkfirmware.pl $(DEBUG) $(APP) $(TSRCS) > $@
|
||||
|
||||
OBJS += $(TOBJS)
|
||||
endif
|
||||
|
|
|
@ -15,9 +15,6 @@ void main_adc(void) {
|
|||
uint32_t brightness = 0;
|
||||
uint8_t c = 0;
|
||||
|
||||
font_direction = FONT_DIR_LTR; // LeftToRight is the default
|
||||
font = &Font_7x8;
|
||||
|
||||
DoString(0, 0, "adc");
|
||||
|
||||
backlightInit();
|
||||
|
|
|
@ -63,10 +63,10 @@ void tick_default(void) {
|
|||
night=isNight();
|
||||
if(night){
|
||||
backlightSetBrightness(GLOBAL(lcdbacklight));
|
||||
push_queue(queue_setinvert);
|
||||
push_queue(queue_unsetinvert);
|
||||
}else{
|
||||
backlightSetBrightness(0);
|
||||
push_queue(queue_unsetinvert);
|
||||
push_queue(queue_setinvert);
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
@ -52,24 +52,16 @@ void adc_check(void) {
|
|||
|
||||
/**************************************************************************/
|
||||
|
||||
const struct MENU_DEF menu_ISP = {"Invoke ISP", &gotoISP};
|
||||
const struct MENU_DEF menu_mirror = {"Mirror", &lcd_mirror};
|
||||
const struct MENU_DEF menu_volt = {"Akku", &adc_check};
|
||||
const struct MENU_DEF menu_nop = {"---", NULL};
|
||||
const struct MENU_DEF menu_msc = {"MSC", &msc_menu};
|
||||
const struct MENU_DEF menu_exe = {"Exec", &execute_menu};
|
||||
static const struct MENU mainmenu = {"Mainmenu", {
|
||||
{"MSC", &msc_menu},
|
||||
{"Exec", &execute_menu},
|
||||
{"---", NULL},
|
||||
{"Mirror", &lcd_mirror},
|
||||
{"Akku", &adc_check},
|
||||
{"Invoke ISP", &gotoISP},
|
||||
{NULL,NULL}
|
||||
}};
|
||||
|
||||
static menuentry menu[] = {
|
||||
&menu_msc,
|
||||
&menu_exe,
|
||||
&menu_nop,
|
||||
&menu_mirror,
|
||||
&menu_volt,
|
||||
&menu_ISP,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static const struct MENU mainmenu = {"Mainmenu", menu};
|
||||
|
||||
void main_exe(void) {
|
||||
|
||||
|
|
|
@ -1,181 +0,0 @@
|
|||
#include <sysinit.h>
|
||||
|
||||
#include "basic/basic.h"
|
||||
|
||||
#include "lcd/render.h"
|
||||
#include "lcd/allfonts.h"
|
||||
|
||||
void backlightInit(void);
|
||||
|
||||
extern void * __sram_top;
|
||||
|
||||
void execute (const void *function, uint16_t length){
|
||||
void (*dst)(void);
|
||||
|
||||
dst=(void (*)(void)) (__sram_top);
|
||||
|
||||
DoString(0,8,"Enter RAM!");
|
||||
DoIntX(0,16,(uint32_t)function);
|
||||
DoIntX(0,24,(uint32_t)dst);
|
||||
lcdDisplay();
|
||||
|
||||
for(int i=0;i<length;i++){
|
||||
((char*)dst)[i]=((char*)function)[i];
|
||||
};
|
||||
|
||||
dst=(void (*)(void)) ((uint32_t)(dst) | 1); // Enable Thumb mode!
|
||||
dst();
|
||||
};
|
||||
|
||||
#include "filesystem/ff.h"
|
||||
void put_rc_y (FRESULT rc, int y) {
|
||||
const TCHAR *p =
|
||||
_T("OK\0DISK_ERR\0INT_ERR\0NOT_READY\0NO_FILE\0NO_PATH\0INVALID_NAME\0")
|
||||
_T("DENIED\0EXIST\0INVALID_OBJECT\0WRITE_PROTECTED\0INVALID_DRIVE\0")
|
||||
_T("NOT_ENABLED\0NO_FILE_SYSTEM\0MKFS_ABORTED\0TIMEOUT\0LOCKED\0")
|
||||
_T("NOT_ENOUGH_CORE\0TOO_MANY_OPEN_FILES\0");
|
||||
FRESULT i;
|
||||
|
||||
for (i = 0; i != rc && *p; i++) {
|
||||
while(*p++) ;
|
||||
}
|
||||
DoString(0,y,p);
|
||||
}
|
||||
|
||||
void put_rc (FRESULT rc){
|
||||
put_rc_y(rc,0);
|
||||
};
|
||||
|
||||
void execute_file (const char * fname){
|
||||
FRESULT res;
|
||||
FIL file;
|
||||
UINT readbytes;
|
||||
void (*dst)(void);
|
||||
|
||||
dst=(void (*)(void)) 0x10001800;
|
||||
|
||||
res=f_open(&file, fname, FA_OPEN_EXISTING|FA_READ);
|
||||
put_rc(res);
|
||||
if(res){
|
||||
return;
|
||||
};
|
||||
|
||||
res = f_read(&file, (char *)dst, RAMCODE, &readbytes);
|
||||
put_rc_y(res,8);
|
||||
if(res){
|
||||
return;
|
||||
};
|
||||
|
||||
int dx;
|
||||
dx=DoString(0,16,"read: ");
|
||||
DoInt(dx,16,readbytes);
|
||||
lcdDisplay();
|
||||
|
||||
dst=(void (*)(void)) ((uint32_t)(dst) | 1); // Enable Thumb mode!
|
||||
dst();
|
||||
|
||||
getInput();
|
||||
};
|
||||
|
||||
/**************************************************************************/
|
||||
|
||||
void main_executor(void) {
|
||||
|
||||
lcdSetPixel(0,0,0); //the spaceinvader module needs this
|
||||
backlightInit();
|
||||
|
||||
//disable the JTAG on PIO3_3
|
||||
IOCON_PIO3_3 = 0x10;
|
||||
|
||||
int yctr=8;
|
||||
int dx=0;
|
||||
|
||||
yctr=18;
|
||||
|
||||
uint8_t trigger;
|
||||
|
||||
trigger=20;
|
||||
|
||||
uint32_t ctr=0;
|
||||
char key;
|
||||
while (1) {
|
||||
ctr++;
|
||||
|
||||
lcdDisplay();
|
||||
delayms(10);
|
||||
|
||||
key= getInput();
|
||||
if(key==BTN_UP){
|
||||
trigger +=1;
|
||||
}else if (key ==BTN_DOWN){
|
||||
trigger -=1;
|
||||
};
|
||||
|
||||
font=&Font_7x8;
|
||||
dx=DoString(0,0,"Trig:");
|
||||
dx=DoInt(dx,0,trigger);
|
||||
DoString(dx,0," ");
|
||||
|
||||
// Easy flashing
|
||||
if(key==BTN_LEFT){
|
||||
DoString(0,8,"Enter ISP!");
|
||||
lcdDisplay();
|
||||
ISPandReset();
|
||||
};
|
||||
|
||||
// DF xecute
|
||||
if(key==BTN_RIGHT){
|
||||
DoString(0,0,"Enter RAM!");
|
||||
lcdDisplay();
|
||||
while(getInput()!=BTN_NONE);
|
||||
|
||||
FATFS FatFs; /* File system object for logical drive */
|
||||
put_rc(f_mount(0, &FatFs));
|
||||
|
||||
execute_file("0:test.c0d");
|
||||
lcdDisplay();
|
||||
while(!getInput());
|
||||
};
|
||||
|
||||
if(key==BTN_UP){
|
||||
#if CFG_USBMSC
|
||||
usbMSCInit();
|
||||
#endif
|
||||
};
|
||||
|
||||
// Display nickname
|
||||
font = &Font_Ubuntu36pt;
|
||||
dx=DoString(0,0,"Sec");
|
||||
|
||||
// Blink LED
|
||||
if(ctr++>trigger){
|
||||
ctr=0;
|
||||
if (gpioGetValue(RB_LED2) == CFG_LED_OFF){
|
||||
gpioSetValue (RB_LED2, CFG_LED_ON);
|
||||
} else {
|
||||
gpioSetValue (RB_LED2, CFG_LED_OFF);
|
||||
};
|
||||
};
|
||||
|
||||
// Print Voltage
|
||||
font = &Font_7x8;
|
||||
dx=DoString(0,yctr+28,"Voltage:");
|
||||
DoInt(dx,yctr+28,GetVoltage());
|
||||
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void tick_executor(void){
|
||||
static int foo=0;
|
||||
static int toggle=0;
|
||||
if(foo++>50){
|
||||
toggle=1-toggle;
|
||||
foo=0;
|
||||
gpioSetValue (RB_LED0, toggle);
|
||||
};
|
||||
return;
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -10,15 +10,13 @@
|
|||
|
||||
#include "final.gen"
|
||||
|
||||
static const struct MENU mainmenu = {"Menu", mentry};
|
||||
|
||||
void initNick();
|
||||
void init_nick();
|
||||
void fancyNickname();
|
||||
|
||||
void main_final(void) {
|
||||
//checkFirstBoot();
|
||||
init_final();
|
||||
|
||||
initNick();
|
||||
while(1){
|
||||
#ifndef FINAL
|
||||
if(getInputRaw()==BTN_LEFT)
|
||||
|
@ -27,7 +25,7 @@ void main_final(void) {
|
|||
if(getInput()){
|
||||
handleMenu(&mainmenu);
|
||||
getInputWaitRelease();
|
||||
initNick();
|
||||
init_nick();
|
||||
};
|
||||
fancyNickname();
|
||||
delayms_queue(100);
|
||||
|
|
|
@ -25,6 +25,7 @@ void applycfg(void){
|
|||
applyConfig();
|
||||
};
|
||||
|
||||
//# MENU config
|
||||
void changer(void){
|
||||
uint8_t numentries = 0;
|
||||
signed char menuselection = 0;
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
#include <sysinit.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "basic/basic.h"
|
||||
#include "lcd/lcd.h"
|
||||
#include "lcd/allfonts.h"
|
||||
#include "lcd/print.h"
|
||||
#include "usb/usbmsc.h"
|
||||
#include "filesystem/ff.h"
|
||||
#include "filesystem/select.h"
|
||||
#include "filesystem/execute.h"
|
||||
|
||||
/**************************************************************************/
|
||||
|
||||
//# MENU execute
|
||||
void execute_menu(void){
|
||||
while(getInput()!=BTN_NONE);
|
||||
executeSelect("C0D");
|
||||
lcdRefresh();
|
||||
};
|
||||
|
|
@ -61,8 +61,21 @@ void setFlamePWM() {
|
|||
flameSetI2C(FLAME_I2C_CR_PWM0, flameI2Cpwm); // set pwm
|
||||
}
|
||||
|
||||
|
||||
void tick_flame(void) { // every 10ms
|
||||
static char night=0;
|
||||
|
||||
if(!flameEnabled)
|
||||
return;
|
||||
|
||||
if(night!=isNight()){
|
||||
night=isNight();
|
||||
if(!night){
|
||||
flameMode = FLAME_OFF;
|
||||
flameI2Cpwm = 0;
|
||||
push_queue(&setFlamePWM);
|
||||
};
|
||||
};
|
||||
|
||||
flameTicks++;
|
||||
|
||||
if (flameI2Cpwm > flameBrightnessMax) {
|
||||
|
@ -118,6 +131,7 @@ void tick_flame(void) { // every 10ms
|
|||
}
|
||||
}
|
||||
|
||||
//# MENU flame
|
||||
void flameInit(void) {
|
||||
|
||||
i2cInit(I2CMASTER); // Init I2C
|
||||
|
@ -135,3 +149,26 @@ void flameInit(void) {
|
|||
flameSetI2C(FLAME_I2C_CR_LS0, FLAME_I2C_LS0_PWM0 << FLAME_I2C_LS0_LED0); // set led0 to pwm
|
||||
}
|
||||
}
|
||||
|
||||
#include "lcd/print.h"
|
||||
|
||||
//# MENU debug ChkFlame
|
||||
void ChkFlame(void) {
|
||||
do{
|
||||
lcdClear();
|
||||
lcdPrint("Enabled:");
|
||||
lcdPrintln(IntToStr(flameEnabled,1,0));
|
||||
|
||||
lcdPrint("State:");
|
||||
lcdPrintln(IntToStr(flameMode,1,0));
|
||||
|
||||
lcdPrint("PWMtarg:");
|
||||
lcdPrintln(IntToStr(flameI2Cpwm,3,0));
|
||||
|
||||
lcdPrint("FTicks:");
|
||||
lcdPrintln(IntToStr(flameTicks,3,0));
|
||||
|
||||
lcdRefresh();
|
||||
delayms_queue(10);
|
||||
} while ((getInputRaw())==BTN_NONE);
|
||||
}
|
||||
|
|
|
@ -16,19 +16,8 @@
|
|||
|
||||
/**************************************************************************/
|
||||
|
||||
void m_init(void){
|
||||
void init_mesh(void){
|
||||
nrf_init();
|
||||
|
||||
struct NRF_CFG config = {
|
||||
.channel= MESH_CHANNEL,
|
||||
.txmac= MESH_MAC,
|
||||
.nrmacs=1,
|
||||
.mac0= MESH_MAC,
|
||||
.maclen ="\x20", // XXX: MESHPKTSIZE
|
||||
};
|
||||
|
||||
nrf_config_set(&config);
|
||||
|
||||
initMesh();
|
||||
};
|
||||
|
||||
|
@ -36,6 +25,7 @@ void m_tset(void){
|
|||
_timet=1311961112;
|
||||
};
|
||||
|
||||
//# MENU debug MeshInfo
|
||||
void m_time(void){
|
||||
struct tm* tm;
|
||||
char c[2]={0,0};
|
||||
|
@ -185,6 +175,7 @@ char *meshmsgs(void){
|
|||
|
||||
|
||||
extern MPKT meshbuffer[MESHBUFSIZE];
|
||||
//# MENU mesh Messages
|
||||
void m_choose(){
|
||||
char list[99];
|
||||
int i=0;
|
||||
|
|
|
@ -33,17 +33,19 @@ void fancyNickname(void) {
|
|||
|
||||
/**************************************************************************/
|
||||
|
||||
void initNick(void){
|
||||
void init_nick(void){
|
||||
readFile("nick.cfg",GLOBAL(nickname),MAXNICK);
|
||||
// readFile("font.cfg",GLOBAL(nickfont),FILENAMELEN);
|
||||
};
|
||||
|
||||
//# MENU nick editNick
|
||||
void doNick(void){
|
||||
input("Nickname:", GLOBAL(nickname), 32, 127, MAXNICK-1);
|
||||
writeFile("nick.cfg",GLOBAL(nickname),strlen(GLOBAL(nickname)));
|
||||
getInputWait();
|
||||
};
|
||||
|
||||
//# MENU nick changeFont
|
||||
void doFont(void){
|
||||
getInputWaitRelease();
|
||||
if( selectFile(GLOBAL(nickfont),"F0N") != 0){
|
||||
|
@ -60,24 +62,3 @@ void doFont(void){
|
|||
lcdDisplay();
|
||||
while(!getInputRaw())delayms(10);
|
||||
};
|
||||
|
||||
|
||||
#if 0
|
||||
void f_font(void){
|
||||
|
||||
if( selectFile(fontname,"F0N") != 0){
|
||||
lcdPrintln("No file selected.");
|
||||
return;
|
||||
};
|
||||
|
||||
lcdClear();
|
||||
lcdPrintln(fontname);
|
||||
setExtFont(fontname);
|
||||
lcdPrintln("PUabc€");
|
||||
setIntFont(&Font_7x8);
|
||||
lcdPrintln("done.");
|
||||
lcdDisplay();
|
||||
while(!getInputRaw())delayms(10);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include "basic/basic.h"
|
||||
#include "basic/config.h"
|
||||
|
||||
#include "lcd/render.h"
|
||||
#include "lcd/print.h"
|
||||
|
||||
#include "usb/usbmsc.h"
|
||||
|
@ -12,6 +13,7 @@
|
|||
|
||||
/**************************************************************************/
|
||||
|
||||
//# MENU debug ChkLight
|
||||
void ChkLight(void) {
|
||||
int dx=0;
|
||||
int dy=8;
|
||||
|
@ -27,6 +29,7 @@ void ChkLight(void) {
|
|||
dx=DoString(0,dy+24,"Done.");
|
||||
}
|
||||
|
||||
//# MENU debug ChkBattery
|
||||
void ChkBattery(void) {
|
||||
do{
|
||||
lcdClear();
|
||||
|
@ -40,10 +43,11 @@ void ChkBattery(void) {
|
|||
lcdPrintln("0");
|
||||
};
|
||||
lcdRefresh();
|
||||
delayms_queue(100);
|
||||
// delayms_queue(100);
|
||||
} while ((getInputRaw())==BTN_NONE);
|
||||
}
|
||||
|
||||
//# MENU debug Uptime
|
||||
void uptime(void) {
|
||||
int t;
|
||||
int h;
|
||||
|
@ -80,6 +84,7 @@ void uptime(void) {
|
|||
lcdPrintln("done.");
|
||||
}
|
||||
|
||||
//# MENU debug Uuid
|
||||
void uuid(void) {
|
||||
IAP_return_t iap_return;
|
||||
iap_return = iapReadSerialNumber();
|
||||
|
@ -94,3 +99,41 @@ void uuid(void) {
|
|||
lcdPrintln(IntToStrX(GetUUID32(),4));
|
||||
lcdRefresh();
|
||||
}
|
||||
|
||||
//# MENU debug Qstatus
|
||||
void Qstatus(void) {
|
||||
int dx=0;
|
||||
int dy=8;
|
||||
lcdClear();
|
||||
dx=DoString(0,dy+16,"Qdepth:");
|
||||
while ((getInputRaw())!=BTN_ENTER){
|
||||
DoInt(dx,dy+16,(the_queue.qend-the_queue.qstart+MAXQENTRIES)%MAXQENTRIES);
|
||||
lcdDisplay();
|
||||
if(getInputRaw()!=BTN_NONE)
|
||||
work_queue();
|
||||
else
|
||||
delayms(10);
|
||||
};
|
||||
dy+=16;
|
||||
dx=DoString(0,dy,"Done.");
|
||||
};
|
||||
|
||||
void blink_led0(void){
|
||||
gpioSetValue (RB_LED0, 1-gpioGetValue(RB_LED0));
|
||||
};
|
||||
|
||||
void tick_alive(void){
|
||||
static int foo=0;
|
||||
|
||||
if(GLOBAL(alivechk)==0)
|
||||
return;
|
||||
|
||||
if(foo++>500/SYSTICKSPEED){
|
||||
foo=0;
|
||||
if(GLOBAL(alivechk)==2)
|
||||
push_queue(blink_led0);
|
||||
else
|
||||
blink_led0();
|
||||
};
|
||||
return;
|
||||
};
|
||||
|
|
|
@ -167,31 +167,19 @@ void msc_menu(void){
|
|||
|
||||
/**************************************************************************/
|
||||
|
||||
const struct MENU_DEF menu_ISP = {"Invoke ISP", &gotoISP};
|
||||
const struct MENU_DEF menu_init = {"F Init", &f_init};
|
||||
const struct MENU_DEF menu_nick = {"F Nick", &f_nick};
|
||||
const struct MENU_DEF menu_font = {"F sel", &f_font};
|
||||
const struct MENU_DEF menu_mirror = {"Mirror", &lcd_mirror};
|
||||
const struct MENU_DEF menu_invert = {"Invert", &lcd_invert};
|
||||
const struct MENU_DEF menu_volt = {"Akku", &adc_check};
|
||||
const struct MENU_DEF menu_msc = {"MSC", &msc_menu};
|
||||
const struct MENU_DEF menu_nop = {"---", NULL};
|
||||
|
||||
static menuentry menu[] = {
|
||||
&menu_init,
|
||||
&menu_nick,
|
||||
&menu_font,
|
||||
&menu_nop,
|
||||
&menu_mirror,
|
||||
&menu_invert,
|
||||
&menu_volt,
|
||||
&menu_msc,
|
||||
&menu_nop,
|
||||
&menu_ISP,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static const struct MENU mainmenu = {"Mainmenu", menu};
|
||||
static const struct MENU mainmenu = {"Mainmenu", {
|
||||
{"Invoke ISP", &gotoISP},
|
||||
{"F Init", &f_init},
|
||||
{"F Nick", &f_nick},
|
||||
{"F sel", &f_font},
|
||||
{"Mirror", &lcd_mirror},
|
||||
{"Invert", &lcd_invert},
|
||||
{"Akku", &adc_check},
|
||||
{"MSC", &msc_menu},
|
||||
{"---", NULL},
|
||||
{NULL,NULL}
|
||||
}};
|
||||
|
||||
void main_font(void) {
|
||||
|
||||
|
|
|
@ -25,42 +25,25 @@ void fs_mount(void);
|
|||
|
||||
/**************************************************************************/
|
||||
|
||||
const struct MENU_DEF menu_incBL = {"Backlight++", &incBacklight};
|
||||
const struct MENU_DEF menu_decBL = {"Backlight--", &decBacklight};
|
||||
const struct MENU_DEF menu_ISP = {"Invoke ISP", &gotoISP};
|
||||
const struct MENU_DEF menu_status = {"FS Status", &fs_status};
|
||||
const struct MENU_DEF menu_mount = {"FS Mount", &fs_mount};
|
||||
const struct MENU_DEF menu_list = {"FS List", &fs_list};
|
||||
const struct MENU_DEF menu_create = {"FS Create", &fs_create};
|
||||
const struct MENU_DEF menu_format = {"FS format", &fs_format};
|
||||
const struct MENU_DEF menu_read = {"FS read", &fs_read};
|
||||
static const struct MENU mainmenu = {"Mainmenu", {
|
||||
{"FS Mount", &fs_mount},
|
||||
{"FS Status", &fs_status},
|
||||
{"FS List", &fs_list},
|
||||
{"FS Create", &fs_create},
|
||||
{"FS read", &fs_read},
|
||||
{"FS format", &fs_format},
|
||||
{"---", NULL},
|
||||
#if CFG_USBMSC
|
||||
const struct MENU_DEF menu_usb = {"USB mount", &usbMSCInit};
|
||||
const struct MENU_DEF menu_usboff = {"USB unmount", &usbMSCOff};
|
||||
{"USB mount", &usbMSCInit},
|
||||
{"USB unmount", &usbMSCOff},
|
||||
{"---", NULL},
|
||||
#endif
|
||||
const struct MENU_DEF menu_nop = {"---", NULL};
|
||||
{"Invoke ISP", &gotoISP},
|
||||
{"Backlight++", &incBacklight},
|
||||
{"Backlight--", &decBacklight},
|
||||
{NULL,NULL}
|
||||
}};
|
||||
|
||||
static menuentry menu[] = {
|
||||
&menu_mount,
|
||||
&menu_status,
|
||||
&menu_list,
|
||||
&menu_create,
|
||||
&menu_read,
|
||||
&menu_nop,
|
||||
&menu_format,
|
||||
&menu_nop,
|
||||
#if CFG_USBMSC
|
||||
&menu_usb,
|
||||
&menu_usboff,
|
||||
#endif
|
||||
&menu_nop,
|
||||
&menu_ISP,
|
||||
&menu_incBL,
|
||||
&menu_decBL,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static const struct MENU mainmenu = {"Mainmenu", menu};
|
||||
|
||||
void main_fs(void) {
|
||||
|
||||
|
|
|
@ -1,251 +0,0 @@
|
|||
#include <sysinit.h>
|
||||
|
||||
#include "basic/basic.h"
|
||||
|
||||
#include "lcd/lcd.h"
|
||||
#include "lcd/print.h"
|
||||
|
||||
#include "funk/nrf24l01p.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "funk/rftransfer.h"
|
||||
#include "funk/openbeacon.h"
|
||||
|
||||
/**************************************************************************/
|
||||
|
||||
#define BEACON_CHANNEL 81
|
||||
#define BEACON_MAC "\x1\x2\x3\x2\1"
|
||||
|
||||
uint32_t const testkey[4] = {
|
||||
0xB4595344,0xD3E119B6,0xA814D0EC,0xEFF5A24E
|
||||
};
|
||||
|
||||
int enctoggle=0;
|
||||
|
||||
void f_init(void){
|
||||
nrf_init();
|
||||
|
||||
struct NRF_CFG config = {
|
||||
.channel= BEACON_CHANNEL,
|
||||
.txmac= BEACON_MAC,
|
||||
.nrmacs=1,
|
||||
.mac0= BEACON_MAC,
|
||||
.maclen ="\x10",
|
||||
};
|
||||
|
||||
nrf_config_set(&config);
|
||||
lcdPrintln("Done.");
|
||||
};
|
||||
|
||||
void f_status(void){
|
||||
int dx=0;
|
||||
int dy=8;
|
||||
uint8_t buf[4];
|
||||
|
||||
buf[0]=C_R_REGISTER | R_CONFIG;
|
||||
buf[1]=0;
|
||||
buf[2]=0;
|
||||
buf[3]=0;
|
||||
dx=DoString(0,dy,"S:");
|
||||
dx=DoCharX(dx,dy,buf[0]);
|
||||
dx=DoCharX(dx,dy,buf[1]);
|
||||
dx=DoCharX(dx,dy,buf[2]);
|
||||
dx=DoCharX(dx,dy,buf[3]);
|
||||
dy+=8;
|
||||
nrf_cmd_rw_long(buf,2);
|
||||
dx=DoString(0,dy,"R:");
|
||||
dx=DoCharX(dx,dy,buf[0]);
|
||||
dx=DoCharX(dx,dy,buf[1]);
|
||||
dx=DoCharX(dx,dy,buf[2]);
|
||||
dx=DoCharX(dx,dy,buf[3]);
|
||||
dy+=8;
|
||||
|
||||
int status=nrf_cmd_status(C_NOP);
|
||||
dx=DoString(0,dy,"St:"); DoCharX(dx,dy,status);dy+=8;
|
||||
};
|
||||
|
||||
void f_recv(void){
|
||||
__attribute__ ((aligned (4))) uint8_t buf[32];
|
||||
int len;
|
||||
|
||||
len=nrf_rcv_pkt_time_encr(1000,sizeof(buf),buf,enctoggle?testkey:NULL);
|
||||
|
||||
if(len==0){
|
||||
lcdPrintln("No pkt (Timeout)");
|
||||
};
|
||||
lcdPrint("Size:");lcdPrintInt(len);lcdNl();
|
||||
lcdPrint("1:");lcdPrintIntHex( *(int*)(buf+ 0) ); lcdNl();
|
||||
lcdPrint("2:");lcdPrintIntHex( *(int*)(buf+ 4) ); lcdNl();
|
||||
lcdPrint("3:");lcdPrintIntHex( *(int*)(buf+ 8) ); lcdNl();
|
||||
lcdPrint("4:");lcdPrintIntHex( *(int*)(buf+12) ); lcdNl();
|
||||
|
||||
len=crc16(buf,14);
|
||||
lcdPrint("crc:");lcdPrintShortHex(len); lcdNl();
|
||||
|
||||
};
|
||||
|
||||
void f_cfg(void){
|
||||
struct NRF_CFG config;
|
||||
|
||||
nrfconfig cfg=&config;
|
||||
|
||||
nrf_config_get(cfg);
|
||||
|
||||
lcdPrint("ch:");lcdPrintInt( cfg->channel ); lcdNl();
|
||||
lcdPrint("nr:");lcdPrintInt( cfg->nrmacs ); lcdNl();
|
||||
|
||||
lcdPrint("0:");
|
||||
lcdPrintCharHex(cfg->mac0[0]);
|
||||
lcdPrintCharHex(cfg->mac0[1]);
|
||||
lcdPrintCharHex(cfg->mac0[2]);
|
||||
lcdPrintCharHex(cfg->mac0[3]);
|
||||
lcdPrintCharHex(cfg->mac0[4]);
|
||||
lcdNl();
|
||||
lcdPrint("1:");
|
||||
lcdPrintCharHex(cfg->mac1[0]);
|
||||
lcdPrintCharHex(cfg->mac1[1]);
|
||||
lcdPrintCharHex(cfg->mac1[2]);
|
||||
lcdPrintCharHex(cfg->mac1[3]);
|
||||
lcdPrintCharHex(cfg->mac1[4]);
|
||||
lcdNl();
|
||||
lcdPrint("2345:");
|
||||
lcdPrintCharHex(cfg->mac2345[0]);
|
||||
lcdPrintCharHex(cfg->mac2345[1]);
|
||||
lcdPrintCharHex(cfg->mac2345[2]);
|
||||
lcdPrintCharHex(cfg->mac2345[3]);
|
||||
lcdNl();
|
||||
lcdPrint("tx:");
|
||||
lcdPrintCharHex(cfg->txmac[0]);
|
||||
lcdPrintCharHex(cfg->txmac[1]);
|
||||
lcdPrintCharHex(cfg->txmac[2]);
|
||||
lcdPrintCharHex(cfg->txmac[3]);
|
||||
lcdPrintCharHex(cfg->txmac[4]);
|
||||
lcdNl();
|
||||
lcdPrint("len:");
|
||||
lcdPrintCharHex(cfg->maclen[0]);
|
||||
lcdPrintCharHex(cfg->maclen[1]);
|
||||
lcdPrintCharHex(cfg->maclen[2]);
|
||||
lcdPrintCharHex(cfg->maclen[3]);
|
||||
lcdPrintCharHex(cfg->maclen[4]);
|
||||
lcdNl();
|
||||
};
|
||||
|
||||
void f_cfg_set(void){
|
||||
struct NRF_CFG config = {
|
||||
.channel= 13,
|
||||
.txmac= "R0KET",
|
||||
.nrmacs=1,
|
||||
.mac0= "R0KET",
|
||||
.maclen ="\x10",
|
||||
};
|
||||
|
||||
nrf_config_set(&config);
|
||||
};
|
||||
|
||||
void f_enctog(void){
|
||||
enctoggle=1-enctoggle;
|
||||
if(enctoggle)
|
||||
lcdPrintln("Encrypt ON!");
|
||||
else
|
||||
lcdPrintln("encrypt off!");
|
||||
|
||||
};
|
||||
|
||||
void f_send(void){
|
||||
uint8_t status;
|
||||
|
||||
status = openbeaconSend();
|
||||
lcdPrint("Status:");
|
||||
lcdPrintCharHex(status);
|
||||
lcdNl();
|
||||
};
|
||||
|
||||
void gotoISP(void) {
|
||||
DoString(0,0,"Enter ISP!");
|
||||
lcdDisplay();
|
||||
ISPandReset();
|
||||
}
|
||||
|
||||
void lcd_mirror(void) {
|
||||
lcdToggleFlag(LCD_MIRRORX);
|
||||
};
|
||||
|
||||
void adc_check(void) {
|
||||
int dx=0;
|
||||
int dy=8;
|
||||
// Print Voltage
|
||||
dx=DoString(0,dy,"Voltage:");
|
||||
while ((getInputRaw())==BTN_NONE){
|
||||
DoInt(dx,dy,GetVoltage());
|
||||
lcdDisplay();
|
||||
};
|
||||
dy+=8;
|
||||
dx=DoString(0,dy,"Done.");
|
||||
};
|
||||
|
||||
void f_sendBlock(void)
|
||||
{
|
||||
uint8_t data[] = "hallo welt, das hier ist ein langer string, der"
|
||||
"per funk verschickt werden soll.";
|
||||
rftransfer_send(strlen((char *)data), data);
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
|
||||
const struct MENU_DEF menu_ISP = {"Invoke ISP", &gotoISP};
|
||||
const struct MENU_DEF menu_init = {"F Init", &f_init};
|
||||
const struct MENU_DEF menu_status = {"F Status", &f_status};
|
||||
const struct MENU_DEF menu_rcv = {"F Recv", &f_recv};
|
||||
const struct MENU_DEF menu_snd = {"F Send", &f_send};
|
||||
const struct MENU_DEF menu_cfg = {"F CfgGet", &f_cfg};
|
||||
const struct MENU_DEF menu_cfg2 = {"F CfgSet", &f_cfg_set};
|
||||
const struct MENU_DEF menu_enc = {"Toggle Encr", &f_enctog};
|
||||
const struct MENU_DEF menu_sndblock={"F Send block", &f_sendBlock};
|
||||
const struct MENU_DEF menu_mirror = {"Mirror", &lcd_mirror};
|
||||
const struct MENU_DEF menu_volt = {"Akku", &adc_check};
|
||||
const struct MENU_DEF menu_nop = {"---", NULL};
|
||||
|
||||
static menuentry menu[] = {
|
||||
&menu_init,
|
||||
&menu_status,
|
||||
&menu_rcv,
|
||||
&menu_snd,
|
||||
&menu_enc,
|
||||
&menu_cfg2,
|
||||
&menu_cfg,
|
||||
&menu_nop,
|
||||
&menu_mirror,
|
||||
&menu_volt,
|
||||
&menu_ISP,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static const struct MENU mainmenu = {"Mainmenu", menu};
|
||||
|
||||
void main_funk(void) {
|
||||
backlightInit();
|
||||
font=&Font_7x8;
|
||||
|
||||
openbeaconSetup();
|
||||
while (1) {
|
||||
lcdFill(0); // clear display buffer
|
||||
lcdDisplay();
|
||||
handleMenu(&mainmenu);
|
||||
gotoISP();
|
||||
}
|
||||
};
|
||||
|
||||
void tick_funk(void){
|
||||
static int foo=0;
|
||||
static int toggle=0;
|
||||
|
||||
if(foo++>50){
|
||||
toggle=1-toggle;
|
||||
foo=0;
|
||||
gpioSetValue (RB_LED0, toggle);
|
||||
};
|
||||
return;
|
||||
};
|
||||
|
||||
|
|
@ -45,26 +45,17 @@ void msc_menu(void){
|
|||
|
||||
extern void (*ram)(void);
|
||||
|
||||
const struct MENU_DEF menu_ISP = {"Invoke ISP", &gotoISP};
|
||||
const struct MENU_DEF menu_again = {"Run Loadable", &ram};
|
||||
const struct MENU_DEF menu_nop = {"---", NULL};
|
||||
const struct MENU_DEF menu_msc = {"MSC", &msc_menu};
|
||||
const struct MENU_DEF menu_volt = {"Akku", &adc_check};
|
||||
const struct MENU_DEF menu_mirror = {"Mirror", &lcd_mirror};
|
||||
const struct MENU_DEF menu_invert = {"Invert", &lcd_invert};
|
||||
static const struct MENU mainmenu = {"Mainmenu", {
|
||||
{"Run Loadable", &ram},
|
||||
{"Invoke ISP", &gotoISP},
|
||||
{"---", NULL},
|
||||
{"MSC", &msc_menu},
|
||||
{"Akku", &adc_check},
|
||||
{"Mirror", &lcd_mirror},
|
||||
{"Invert", &lcd_invert},
|
||||
{NULL,NULL}
|
||||
}};
|
||||
|
||||
static menuentry menu[] = {
|
||||
&menu_again,
|
||||
&menu_ISP,
|
||||
&menu_nop,
|
||||
&menu_msc,
|
||||
&menu_mirror,
|
||||
&menu_invert,
|
||||
&menu_volt,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static const struct MENU mainmenu = {"Mainmenu", menu};
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
|
|
|
@ -21,42 +21,25 @@ void gotoISP(void);
|
|||
|
||||
|
||||
/**************************************************************************/
|
||||
static const struct MENU mainmenu = {"Mainmenu", {
|
||||
{"Backlight++", &incBacklight},
|
||||
{"Backlight--", &decBacklight},
|
||||
{"Invoke ISP", &gotoISP},
|
||||
{"p1e4", NULL},
|
||||
{"p1e5", NULL},
|
||||
{"p1e6", NULL},
|
||||
{"p1e7", NULL},
|
||||
{"p2e1", NULL},
|
||||
{"p2e2", NULL},
|
||||
{"p2e3", NULL},
|
||||
{NULL, NULL},
|
||||
}};
|
||||
|
||||
const struct MENU_DEF menu_incBL = {"Backlight++", &incBacklight};
|
||||
const struct MENU_DEF menu_decBL = {"Backlight--", &decBacklight};
|
||||
const struct MENU_DEF menu_ISP = {"Invoke ISP", &gotoISP};
|
||||
const struct MENU_DEF menu_Ep = {"p1e4", NULL};
|
||||
const struct MENU_DEF menu_Eq = {"p1e5", NULL};
|
||||
const struct MENU_DEF menu_Er = {"p1e6", NULL};
|
||||
const struct MENU_DEF menu_Es = {"p1e7", NULL};
|
||||
const struct MENU_DEF menu_Et = {"p2e1", NULL};
|
||||
const struct MENU_DEF menu_Eu = {"p2e2", NULL};
|
||||
const struct MENU_DEF menu_Ev = {"p2e3", NULL};
|
||||
|
||||
static menuentry menu[] = {
|
||||
&menu_incBL,
|
||||
&menu_decBL,
|
||||
&menu_ISP,
|
||||
&menu_Ep,
|
||||
&menu_Eq,
|
||||
&menu_Er,
|
||||
&menu_Es,
|
||||
&menu_Et,
|
||||
&menu_Eu,
|
||||
&menu_Ev,
|
||||
&menu_Ev,
|
||||
&menu_ISP,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static const struct MENU mainmenu = {"Mainmenu", menu};
|
||||
|
||||
void main_menutest(void) {
|
||||
|
||||
backlightInit();
|
||||
|
||||
font_direction = FONT_DIR_LTR; // LeftToRight is the default
|
||||
|
||||
while (1) {
|
||||
lcdDisplay();
|
||||
delayms(10);
|
||||
|
|
|
@ -1,73 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
APP=$1
|
||||
shift
|
||||
|
||||
for f in $* ; do
|
||||
grep -h '^void ' $f|sed 's/^void //;s/(.*//'|while read a ; do
|
||||
echo "void $a(void);"
|
||||
done
|
||||
done
|
||||
|
||||
for f in $* ; do
|
||||
grep -h '^void ' $f|sed 's/^void //;s/(.*//'|while read a ; do
|
||||
echo "const struct MENU_DEF menu_$a = {\"$a\", &$a};"
|
||||
done
|
||||
done
|
||||
|
||||
echo "const struct MENU_DEF menu_nop = {\"---\", NULL};"
|
||||
echo
|
||||
|
||||
for f in $* ; do
|
||||
t=${f#*/}
|
||||
t=${t%.c}
|
||||
echo "static menuentry mentry_$t[] = {"
|
||||
grep -h '^void ' $f|sed 's/^void //;s/(.*//'|while read a ; do
|
||||
echo "&menu_$a,"
|
||||
done
|
||||
echo "NULL"
|
||||
echo "};"
|
||||
done
|
||||
|
||||
for f in $* ; do
|
||||
t=${f#*/}
|
||||
t=${t%.c}
|
||||
echo "static const struct MENU m_$t = {\"$t\", mentry_$t};"
|
||||
done
|
||||
|
||||
|
||||
for f in $* ; do
|
||||
t=${f#*/}
|
||||
t=${t%.c}
|
||||
echo "void run_$t(void) {"
|
||||
echo "handleMenu(&m_$t);"
|
||||
echo "};"
|
||||
done
|
||||
|
||||
for f in $* ; do
|
||||
t=${f#*/}
|
||||
t=${t%.c}
|
||||
echo "const struct MENU_DEF menu_$t = {\"$t\", &run_$t};"
|
||||
done
|
||||
|
||||
echo "static menuentry mentry[] = {"
|
||||
|
||||
for f in $* ; do
|
||||
t=${f#*/}
|
||||
t=${t%.c}
|
||||
echo "&menu_$t,"
|
||||
done
|
||||
|
||||
echo "NULL"
|
||||
echo "};"
|
||||
|
||||
echo "inline void tick_${APP}(void){"
|
||||
for f in $* ; do
|
||||
grep -h '^void tick_' $f|sed 's/^void //;s/(.*//'|while read a ; do
|
||||
echo "$a();"
|
||||
done
|
||||
done
|
||||
echo "return;"
|
||||
echo "};"
|
||||
|
||||
|
|
@ -0,0 +1,123 @@
|
|||
#!/usr/bin/perl
|
||||
#
|
||||
# vim:set ts=4 sw=4:
|
||||
|
||||
use strict;
|
||||
|
||||
my $debug=0;
|
||||
if($ARGV[0] eq "-d"){
|
||||
$debug=1;
|
||||
shift;
|
||||
};
|
||||
|
||||
my $app=shift;
|
||||
my @files=@ARGV;
|
||||
my %menu;
|
||||
my (@ticks,@inits);
|
||||
|
||||
$\="\n";
|
||||
|
||||
print "// Function definitions:";
|
||||
my $menudef;
|
||||
for my $file (@files){
|
||||
open(F,"<",$file) || die "Can't open $file: $!";
|
||||
while(<F>){
|
||||
chomp;
|
||||
s/\r$//; # Dos line-end
|
||||
|
||||
if(m!^\s*//#\s+(.*?)\s*$!){ # Menu definition
|
||||
$menudef=$1;
|
||||
next;
|
||||
};
|
||||
next if(/^\s*$/);
|
||||
next if(m!^\s*//!);
|
||||
if(m!^\s*void\s+([^(]+)\(!){ # A suitable function
|
||||
my $func=$1;
|
||||
if($func=~/tick_/){
|
||||
push @ticks,$func;
|
||||
print "void $func(void);";
|
||||
};
|
||||
if($func=~/init_/){
|
||||
push @inits,$func;
|
||||
print "void $func(void);";
|
||||
};
|
||||
if($debug){
|
||||
my $f="debug";
|
||||
$file =~ m!([^/.]+)\.! && do {$f=$1};
|
||||
$menudef="MENU $f $func";
|
||||
};
|
||||
if(defined $menudef){
|
||||
my @words=split(/\s+/,$menudef);
|
||||
if($words[0] ne "MENU"){
|
||||
warn "Not a menu definition?";
|
||||
};
|
||||
|
||||
if($#words==1){
|
||||
$menu{$words[1]}=$func;
|
||||
}elsif($#words==2){
|
||||
$menu{$words[1]}{$words[2]}=$func;
|
||||
}else{
|
||||
warn "Couldn't handle $menudef";
|
||||
};
|
||||
print "void $func(void);";
|
||||
};
|
||||
$menudef=undef;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
print "";
|
||||
print "// Submenus:";
|
||||
|
||||
#use Data::Dumper; print Dumper \%menu;
|
||||
|
||||
for (sort keys %menu){
|
||||
if(ref $menu{$_} eq "HASH"){
|
||||
printf "static const struct MENU submenu_${_}={";
|
||||
print qq! "$_", {!;
|
||||
for my $entry(sort keys %{$menu{$_}}){
|
||||
print qq!\t{ "$entry", &$menu{$_}{$entry}},!;
|
||||
};
|
||||
print qq!\t{NULL,NULL}!;
|
||||
print "}};";
|
||||
};
|
||||
};
|
||||
|
||||
print "";
|
||||
|
||||
for (sort keys %menu){
|
||||
if(ref $menu{$_} eq "HASH"){
|
||||
print qq!void run_submenu_$_(void) {!;
|
||||
print qq!\thandleMenu(&submenu_$_);!;
|
||||
print qq!};!;
|
||||
};
|
||||
};
|
||||
|
||||
print "";
|
||||
print "// Main menu:";
|
||||
printf "static const struct MENU mainmenu={";
|
||||
print qq! "Menu:", {!;
|
||||
for (sort keys %menu){
|
||||
if(ref $menu{$_} eq "HASH"){
|
||||
print qq!\t{ "$_", &run_submenu_$_},!;
|
||||
}else{
|
||||
print qq!\t{ "$_", &$menu{$_}},!;
|
||||
};
|
||||
};
|
||||
print qq!\t\t{NULL,NULL}!;
|
||||
print "}};";
|
||||
|
||||
print "";
|
||||
print "// Tick & init functions:";
|
||||
print qq!void tick_$app(void) {!;
|
||||
for (sort @ticks){
|
||||
print qq!\t$_();!;
|
||||
};
|
||||
print qq!};!;
|
||||
|
||||
print qq!void init_$app(void) {!;
|
||||
for (sort @inits){
|
||||
print qq!\t$_();!;
|
||||
};
|
||||
print qq!};!;
|
||||
|
|
@ -1,197 +0,0 @@
|
|||
#include <sysinit.h>
|
||||
|
||||
#include "basic/basic.h"
|
||||
|
||||
#include "lcd/lcd.h"
|
||||
#include "lcd/print.h"
|
||||
|
||||
#include "funk/nrf24l01p.h"
|
||||
#include "usb/usbmsc.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
/**************************************************************************/
|
||||
|
||||
uint32_t const testkey[4] = {
|
||||
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff
|
||||
};
|
||||
|
||||
void f_init(void){
|
||||
nrf_init();
|
||||
|
||||
struct NRF_CFG config = {
|
||||
.channel= 81,
|
||||
.txmac= "REMOT",
|
||||
.nrmacs=1,
|
||||
.mac0= "REMOT",
|
||||
.maclen ="\x10",
|
||||
};
|
||||
|
||||
nrf_config_set(&config);
|
||||
|
||||
lcdPrintln("Done.");
|
||||
};
|
||||
|
||||
void f_recv(void){
|
||||
__attribute__ ((aligned (4))) uint8_t buf[32];
|
||||
int len;
|
||||
|
||||
while(1){
|
||||
len=nrf_rcv_pkt_time_encr(1000,sizeof(buf),buf,testkey);
|
||||
|
||||
if(len==0){
|
||||
lcdPrintln("No pkt (Timeout)");
|
||||
return;
|
||||
};
|
||||
|
||||
lcdClear();
|
||||
lcdPrint("Size:");lcdPrintInt(len);lcdNl();
|
||||
|
||||
lcdPrintCharHex(buf[0]);
|
||||
lcdPrint(" ");
|
||||
lcdPrintCharHex(buf[1]);
|
||||
lcdPrint(" ");
|
||||
lcdPrintCharHex(buf[2]);
|
||||
lcdPrint(" ");
|
||||
lcdPrintCharHex(buf[3]);
|
||||
lcdNl();
|
||||
|
||||
lcdPrint("ct:");lcdPrintIntHex( *(int*)(buf+ 4) ); lcdNl();
|
||||
lcdPrint("id:");lcdPrintIntHex( *(int*)(buf+ 8) ); lcdNl();
|
||||
lcdPrint("xx:");lcdPrintIntHex( *(int*)(buf+12) ); lcdNl();
|
||||
lcdDisplay();
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
void f_send(void){
|
||||
int ctr=1;
|
||||
__attribute__ ((aligned (4))) uint8_t buf[32];
|
||||
int len;
|
||||
int status;
|
||||
|
||||
while(1){
|
||||
|
||||
buf[0]=0x10; // Length: 16 bytes
|
||||
buf[1]='C'; // Proto
|
||||
buf[2]=getInputRaw();
|
||||
buf[3]=0x00; // Unused
|
||||
|
||||
ctr++;
|
||||
*(int*)(buf+4)=ctr;
|
||||
|
||||
/*
|
||||
buf[4]=0x00; // ctr
|
||||
buf[5]=0x00; // ctr
|
||||
buf[6]=0x00; // ctr
|
||||
buf[7]=ctr++; // ctr
|
||||
*/
|
||||
|
||||
buf[8]=0x0; // Object id
|
||||
buf[9]=0x0;
|
||||
buf[10]=0x05;
|
||||
buf[11]=0xec;
|
||||
|
||||
buf[12]=0xff; // salt (0xffff always?)
|
||||
buf[13]=0xff;
|
||||
|
||||
status=nrf_snd_pkt_crc_encr(16,buf,testkey);
|
||||
lcdClear();
|
||||
lcdPrint("Key:"); lcdPrintInt(buf[2]); lcdNl();
|
||||
lcdPrint("F-St:"); lcdPrintInt(status);
|
||||
if(buf[2]==BTN_ENTER)
|
||||
break;
|
||||
lcdDisplay();
|
||||
len=nrf_rcv_pkt_time_encr(10,sizeof(buf),buf,testkey);
|
||||
if(len>0){
|
||||
lcdPrint("Got!");
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
};
|
||||
|
||||
void gotoISP(void) {
|
||||
DoString(0,0,"Enter ISP!");
|
||||
lcdDisplay();
|
||||
ISPandReset();
|
||||
}
|
||||
|
||||
void lcd_mirror(void) {
|
||||
lcdToggleFlag(LCD_MIRRORX);
|
||||
};
|
||||
|
||||
void adc_check(void) {
|
||||
int dx=0;
|
||||
int dy=8;
|
||||
// Print Voltage
|
||||
dx=DoString(0,dy,"Voltage:");
|
||||
while ((getInputRaw())==BTN_NONE){
|
||||
DoInt(dx,dy,GetVoltage());
|
||||
lcdDisplay();
|
||||
};
|
||||
dy+=8;
|
||||
dx=DoString(0,dy,"Done.");
|
||||
};
|
||||
|
||||
void msc_menu(void){
|
||||
DoString(0,8,"MSC Enabled.");
|
||||
lcdDisplay();
|
||||
usbMSCInit();
|
||||
while(!getInputRaw())delayms(10);
|
||||
DoString(0,16,"MSC Disabled.");
|
||||
usbMSCOff();
|
||||
};
|
||||
|
||||
/**************************************************************************/
|
||||
|
||||
const struct MENU_DEF menu_ISP = {"Invoke ISP", &gotoISP};
|
||||
const struct MENU_DEF menu_init = {"F Init", &f_init};
|
||||
const struct MENU_DEF menu_rcv = {"F Recv", &f_recv};
|
||||
const struct MENU_DEF menu_snd = {"F Send", &f_send};
|
||||
//const struct MENU_DEF menu_cfg = {"F Cfg", &f_cfg};
|
||||
const struct MENU_DEF menu_mirror = {"Mirror", &lcd_mirror};
|
||||
const struct MENU_DEF menu_volt = {"Akku", &adc_check};
|
||||
const struct MENU_DEF menu_msc = {"MSC", &msc_menu};
|
||||
const struct MENU_DEF menu_nop = {"---", NULL};
|
||||
|
||||
static menuentry menu[] = {
|
||||
&menu_init,
|
||||
&menu_rcv,
|
||||
&menu_snd,
|
||||
// &menu_cfg,
|
||||
&menu_nop,
|
||||
&menu_mirror,
|
||||
&menu_volt,
|
||||
&menu_msc,
|
||||
&menu_nop,
|
||||
&menu_ISP,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static const struct MENU mainmenu = {"Mainmenu", menu};
|
||||
|
||||
void main_remote(void) {
|
||||
|
||||
font=&Font_7x8;
|
||||
|
||||
while (1) {
|
||||
lcdFill(0); // clear display buffer
|
||||
lcdDisplay();
|
||||
handleMenu(&mainmenu);
|
||||
gotoISP();
|
||||
}
|
||||
};
|
||||
|
||||
void tick_remote(void){
|
||||
static int foo=0;
|
||||
static int toggle=0;
|
||||
if(foo++>80){
|
||||
toggle=1-toggle;
|
||||
foo=0;
|
||||
gpioSetValue (RB_LED0, toggle);
|
||||
};
|
||||
return;
|
||||
};
|
||||
|
||||
|
|
@ -10,8 +10,6 @@
|
|||
|
||||
#include "tester.gen"
|
||||
|
||||
static const struct MENU mainmenu = {"Mainmenu", mentry};
|
||||
|
||||
void main_tester(void) {
|
||||
handleMenu(&mainmenu);
|
||||
gotoISP();
|
||||
|
|
|
@ -172,11 +172,9 @@ struct MENU_DEF {
|
|||
void (*callback)(void);
|
||||
};
|
||||
|
||||
typedef const struct MENU_DEF * menuentry;
|
||||
|
||||
struct MENU {
|
||||
char *title;
|
||||
menuentry *entries;
|
||||
struct MENU_DEF entries[];
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include "basic/random.h"
|
||||
#include "basic/config.h"
|
||||
|
||||
#define CFGVER 24
|
||||
#define CFGVER 1
|
||||
|
||||
struct CDESC the_config[]= {
|
||||
{"version", CFGVER, CFGVER, CFGVER},
|
||||
|
@ -19,7 +19,8 @@ struct CDESC the_config[]= {
|
|||
{"lcdbacklight", 50, 0, 100},
|
||||
{"lcdmirror", 0, 0, 1 },
|
||||
{"lcdinvert", 0, 0, 1 },
|
||||
{"lcdcontrast", 3, 0, 31 },
|
||||
{"lcdcontrast", 14, 0, 31 },
|
||||
{"alivechk", 0, 0, 2 },
|
||||
{"flamemax", 255, 0, 255},
|
||||
{"flamemin", 0, 0, 255},
|
||||
{"flamespeed", 1, 1, 100},
|
||||
|
|
|
@ -27,11 +27,12 @@ extern char nickfont[];
|
|||
#define GLOBALlcdmirror (the_config[ 6].value)
|
||||
#define GLOBALlcdinvert (the_config[ 7].value)
|
||||
#define GLOBALlcdcontrast (the_config[ 8].value)
|
||||
#define GLOBALflamemax (the_config[9].value)
|
||||
#define GLOBALflamemin (the_config[10].value)
|
||||
#define GLOBALflamespeed (the_config[11].value)
|
||||
#define GLOBALflamemaxw (the_config[12].value)
|
||||
#define GLOBALflameminw (the_config[13].value)
|
||||
#define GLOBALalivechk (the_config[ 9].value)
|
||||
#define GLOBALflamemax (the_config[10].value)
|
||||
#define GLOBALflamemin (the_config[11].value)
|
||||
#define GLOBALflamespeed (the_config[12].value)
|
||||
#define GLOBALflamemaxw (the_config[13].value)
|
||||
#define GLOBALflameminw (the_config[14].value)
|
||||
#define GLOBALnickname (nickname)
|
||||
#define GLOBALnickfont (nickfont)
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ void handleMenu(const struct MENU *the_menu) {
|
|||
|
||||
setSystemFont();
|
||||
|
||||
for (numentries = 0; the_menu->entries[numentries] != NULL; numentries++);
|
||||
for (numentries = 0; the_menu->entries[numentries].text != NULL ; numentries++);
|
||||
|
||||
visible_lines = lcdGetVisibleLines()-1; // subtract title line
|
||||
#ifdef SAFETY
|
||||
|
@ -34,7 +34,7 @@ void handleMenu(const struct MENU *the_menu) {
|
|||
lcdPrint("*");
|
||||
}
|
||||
lcdSetCrsrX(14);
|
||||
lcdPrintln(the_menu->entries[i]->text);
|
||||
lcdPrintln(the_menu->entries[i].text);
|
||||
}
|
||||
lcdRefresh();
|
||||
|
||||
|
@ -64,16 +64,16 @@ void handleMenu(const struct MENU *the_menu) {
|
|||
case BTN_LEFT:
|
||||
return;
|
||||
case BTN_RIGHT:
|
||||
if (the_menu->entries[menuselection]->callback!=NULL)
|
||||
the_menu->entries[menuselection]->callback();
|
||||
if (the_menu->entries[menuselection].callback!=NULL)
|
||||
the_menu->entries[menuselection].callback();
|
||||
break;
|
||||
case BTN_ENTER:
|
||||
lcdClear();
|
||||
lcdPrintln("Called...");
|
||||
lcdRefresh();
|
||||
getInputWaitRelease();
|
||||
if (the_menu->entries[menuselection]->callback!=NULL)
|
||||
the_menu->entries[menuselection]->callback();
|
||||
if (the_menu->entries[menuselection].callback!=NULL)
|
||||
the_menu->entries[menuselection].callback();
|
||||
lcdRefresh();
|
||||
getInputWait();
|
||||
|
||||
|
|
Loading…
Reference in New Issue