2011-08-03 14:34:09 +00:00
|
|
|
#include <sysinit.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "basic/basic.h"
|
|
|
|
#include "basic/config.h"
|
|
|
|
|
|
|
|
#include "lcd/render.h"
|
|
|
|
#include "lcd/print.h"
|
|
|
|
|
|
|
|
#include "usb/usbmsc.h"
|
|
|
|
|
|
|
|
#include "core/iap/iap.h"
|
|
|
|
|
2011-08-04 11:11:28 +00:00
|
|
|
#include "funk/nrf24l01p.h"
|
2011-08-03 14:34:09 +00:00
|
|
|
#include "funk/mesh.h"
|
|
|
|
|
|
|
|
#include "usetable.h"
|
|
|
|
|
|
|
|
/**************************************************************************/
|
2011-08-04 11:11:28 +00:00
|
|
|
void ChkFunk(void);
|
2011-08-03 14:34:09 +00:00
|
|
|
void ChkLight(void);
|
|
|
|
void ChkBattery(void);
|
|
|
|
void m_time(void);
|
|
|
|
void Qstatus(void);
|
|
|
|
void getsp(void);
|
|
|
|
void uptime(void);
|
|
|
|
void uuid(void);
|
2011-12-20 00:23:00 +00:00
|
|
|
void lcdrtest(void);
|
2011-12-25 19:15:42 +00:00
|
|
|
void release(void);
|
2011-08-03 14:34:09 +00:00
|
|
|
|
|
|
|
static const struct MENU submenu_debug={ "debug", {
|
|
|
|
{ "ChkBattery", &ChkBattery},
|
|
|
|
{ "ChkLight", &ChkLight},
|
|
|
|
{ "MeshInfo", &m_time},
|
2011-08-04 11:11:28 +00:00
|
|
|
{ "ChkFunk", &ChkFunk},
|
2011-12-25 19:15:42 +00:00
|
|
|
// { "Qstatus", &Qstatus},
|
2011-08-05 13:04:48 +00:00
|
|
|
// { "ShowSP", &getsp},
|
2011-12-25 19:15:42 +00:00
|
|
|
{ "LcdRead", &lcdrtest},
|
2011-08-03 14:34:09 +00:00
|
|
|
{ "Uptime", &uptime},
|
|
|
|
{ "Uuid", &uuid},
|
2011-12-25 19:15:42 +00:00
|
|
|
{ "Release", &release},
|
2011-08-03 14:34:09 +00:00
|
|
|
{NULL,NULL}
|
|
|
|
}};
|
|
|
|
|
|
|
|
void ram(void) {
|
|
|
|
handleMenu(&submenu_debug);
|
|
|
|
};
|
|
|
|
|
|
|
|
//# MENU debug ChkLight
|
|
|
|
void ChkLight(void) {
|
|
|
|
int dx=0;
|
|
|
|
int dy=8;
|
|
|
|
dx=DoString(0,dy,"Light:");
|
|
|
|
DoString(0,dy+16,"Night:");
|
|
|
|
while ((getInputRaw())==BTN_NONE){
|
|
|
|
DoInt(dx,dy,GetLight());
|
|
|
|
DoInt(dx,dy+16,isNight());
|
|
|
|
DoInt(dx,dy+8,GLOBAL(daytrig));
|
|
|
|
lcdDisplay();
|
|
|
|
delayms_queue(100);
|
|
|
|
};
|
|
|
|
dx=DoString(0,dy+24,"Done.");
|
|
|
|
}
|
|
|
|
|
|
|
|
//# MENU debug ChkBattery
|
|
|
|
void ChkBattery(void) {
|
|
|
|
do{
|
|
|
|
lcdClear();
|
|
|
|
lcdPrintln("Voltage:");
|
|
|
|
lcdPrintln(IntToStr(GetVoltage(),5,0));
|
|
|
|
lcdNl();
|
|
|
|
lcdPrintln("Chrg_stat:");
|
|
|
|
if(gpioGetValue(RB_PWR_CHRG)){
|
2011-08-04 08:53:52 +00:00
|
|
|
lcdPrintln("not charging");
|
2011-08-03 14:34:09 +00:00
|
|
|
}else{
|
2011-08-04 08:53:52 +00:00
|
|
|
lcdPrintln(" CHARGING");
|
2011-08-03 14:34:09 +00:00
|
|
|
};
|
|
|
|
lcdRefresh();
|
|
|
|
delayms_queue(100);
|
|
|
|
} while ((getInputRaw())==BTN_NONE);
|
|
|
|
}
|
|
|
|
|
|
|
|
//# MENU debug Uptime
|
|
|
|
void uptime(void) {
|
|
|
|
int t;
|
|
|
|
int h;
|
|
|
|
char flag;
|
|
|
|
while ((getInputRaw())==BTN_NONE){
|
|
|
|
lcdClear();
|
|
|
|
lcdPrintln("Uptime:");
|
|
|
|
t=(_timectr)/(1000/SYSTICKSPEED);
|
|
|
|
h=t/60/60;
|
|
|
|
flag=F_ZEROS;
|
|
|
|
if(h>0){
|
|
|
|
lcdPrint(IntToStr(h,2,flag));
|
|
|
|
lcdPrint("h");
|
|
|
|
flag|=F_LONG;
|
|
|
|
};
|
|
|
|
h=t/60%60;
|
|
|
|
if(h>0){
|
|
|
|
lcdPrint(IntToStr(h,2,flag));
|
|
|
|
lcdPrint("m");
|
|
|
|
flag|=F_LONG;
|
|
|
|
};
|
|
|
|
h=t%60;
|
|
|
|
if(h>0){
|
|
|
|
lcdPrint(IntToStr(h,2,flag));
|
|
|
|
lcdPrint("s");
|
|
|
|
};
|
|
|
|
lcdNl();
|
|
|
|
lcdNl();
|
|
|
|
lcdPrintln("Ticks:");
|
|
|
|
lcdPrint(IntToStr(_timectr,10,0));
|
|
|
|
lcdRefresh();
|
|
|
|
delayms_queue(222);
|
|
|
|
};
|
|
|
|
lcdPrintln("done.");
|
|
|
|
}
|
|
|
|
|
|
|
|
//# MENU debug Uuid
|
|
|
|
void uuid(void) {
|
|
|
|
IAP_return_t iap_return;
|
|
|
|
iap_return = iapReadSerialNumber();
|
|
|
|
lcdClear();
|
|
|
|
lcdPrintln("UUID:");
|
2011-08-03 21:32:26 +00:00
|
|
|
lcdPrintln(IntToStrX(iap_return.Result[0],8));
|
|
|
|
lcdPrintln(IntToStrX(iap_return.Result[1],8));
|
|
|
|
lcdPrintln(IntToStrX(iap_return.Result[2],8));
|
|
|
|
lcdPrintln(IntToStrX(iap_return.Result[3],8));
|
2011-08-03 14:34:09 +00:00
|
|
|
lcdNl();
|
2011-12-25 19:15:42 +00:00
|
|
|
lcdPrintln("Bacon ID:");
|
2011-08-03 20:01:48 +00:00
|
|
|
lcdPrintln(IntToStrX(GetUUID32(),8));
|
2011-08-03 14:34:09 +00:00
|
|
|
lcdRefresh();
|
2011-08-05 13:04:48 +00:00
|
|
|
while(!getInputRaw())work_queue();
|
2011-08-03 14:34:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//# 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.");
|
|
|
|
};
|
|
|
|
|
|
|
|
//# MENU debug ShowSP
|
|
|
|
void getsp(void) {
|
|
|
|
int dx=0;
|
|
|
|
int dy=8;
|
|
|
|
int x;
|
|
|
|
lcdClear();
|
|
|
|
dx=DoString(0,dy,"SP:");
|
|
|
|
while ((getInputRaw())==BTN_NONE){
|
|
|
|
__asm( "mov %0, sp\n" : "=r" (x) :);
|
|
|
|
DoIntX(0,dy+8,x);
|
|
|
|
lcdDisplay();
|
|
|
|
delayms_queue(50);
|
|
|
|
};
|
|
|
|
dy+=16;
|
|
|
|
dx=DoString(0,dy,"Done.");
|
|
|
|
};
|
|
|
|
|
2011-08-10 23:53:54 +00:00
|
|
|
void m_time_details(int select) {
|
|
|
|
getInputWaitRelease();
|
|
|
|
|
2011-08-12 17:18:48 +00:00
|
|
|
while(getInputWaitTimeout(50) == BTN_NONE){
|
2011-08-10 23:53:54 +00:00
|
|
|
lcdClear();
|
|
|
|
MPKT *mpkt = &meshbuffer[select];
|
|
|
|
uint8_t *pkt = mpkt->pkt;
|
|
|
|
|
|
|
|
if (!mpkt->flags & MF_USED)
|
|
|
|
lcdPrint("<unused>");
|
|
|
|
else {
|
|
|
|
lcdPrint("Type: ");
|
|
|
|
char c[2] = {0, 0};
|
|
|
|
c[0] = mpkt->pkt[0];
|
|
|
|
lcdPrint(c);
|
|
|
|
lcdNl();
|
|
|
|
|
|
|
|
lcdPrint("Gen: ");
|
|
|
|
lcdPrintInt(MO_GEN(pkt) & 0xff);
|
|
|
|
lcdNl();
|
|
|
|
|
|
|
|
lcdPrint("Time: ");
|
|
|
|
lcdPrintInt(MO_TIME(pkt) & 0xffff);
|
|
|
|
lcdNl();
|
|
|
|
lcdPrint("Body: ");
|
|
|
|
lcdNl();
|
|
|
|
|
|
|
|
int x = 0;
|
2011-08-12 17:18:48 +00:00
|
|
|
for(uint8_t *body = MO_BODY(pkt); body < (pkt + 30); body++) {
|
2011-08-10 23:53:54 +00:00
|
|
|
if (*body >= ' ' && *body < 128) {
|
|
|
|
if (x > 12) {
|
|
|
|
lcdNl();
|
|
|
|
x = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
char c[2] = {*body, 0};
|
|
|
|
lcdPrint(c);
|
|
|
|
x++;
|
|
|
|
} else {
|
|
|
|
if (x > 10) {
|
|
|
|
lcdNl();
|
|
|
|
x = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
lcdPrint("\\");
|
|
|
|
lcdPrintInt(*body & 0xff);
|
|
|
|
x += 2;
|
|
|
|
if (*body > 9)
|
|
|
|
x++;
|
|
|
|
if (*body > 99)
|
|
|
|
x++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
lcdRefresh();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-08-03 14:34:09 +00:00
|
|
|
void m_time(void){
|
|
|
|
struct tm* tm;
|
2011-08-10 23:53:54 +00:00
|
|
|
int select=0;
|
2011-08-03 14:34:09 +00:00
|
|
|
char c[2]={0,0};
|
|
|
|
getInputWaitRelease();
|
|
|
|
delayms(100);
|
2011-08-10 23:53:54 +00:00
|
|
|
while(1) {
|
2011-08-03 14:34:09 +00:00
|
|
|
lcdClear();
|
|
|
|
tm= mygmtime(getSeconds());
|
|
|
|
lcdPrint(IntToStr(tm->tm_hour,2,F_LONG));
|
|
|
|
lcdPrint(":");
|
|
|
|
lcdPrint(IntToStr(tm->tm_min,2,F_LONG|F_ZEROS));
|
|
|
|
lcdPrint(":");
|
|
|
|
lcdPrint(IntToStr(tm->tm_sec,2,F_LONG|F_ZEROS));
|
|
|
|
lcdNl();
|
|
|
|
lcdPrint(IntToStr(tm->tm_mday,2,F_LONG));
|
|
|
|
lcdPrint(".");
|
|
|
|
lcdPrint(IntToStr(tm->tm_mon+1,2,0));
|
|
|
|
lcdPrint(".");
|
|
|
|
lcdPrint(IntToStr(tm->tm_year+YEAR0,4,F_LONG|F_ZEROS));
|
|
|
|
lcdNl();
|
|
|
|
|
|
|
|
lcdNl();
|
|
|
|
lcdPrint("<");
|
|
|
|
|
|
|
|
for(int i=0;i<MESHBUFSIZE;i++){
|
|
|
|
if(!meshbuffer[i].flags&MF_USED){
|
|
|
|
c[0]='_';
|
|
|
|
}else{
|
|
|
|
c[0]=meshbuffer[i].pkt[0];
|
|
|
|
};
|
|
|
|
lcdPrint(c);
|
|
|
|
};
|
|
|
|
lcdPrintln(">");
|
|
|
|
|
2011-08-10 23:53:54 +00:00
|
|
|
lcdPrint(" ");
|
|
|
|
for(int i=0; i<MESHBUFSIZE; i++) {
|
|
|
|
lcdPrint(i == select ? "^" : " ");
|
|
|
|
}
|
|
|
|
lcdNl();
|
|
|
|
|
2011-08-03 14:34:09 +00:00
|
|
|
lcdPrint("Gen:");
|
|
|
|
lcdPrintInt(meshgen);
|
|
|
|
lcdNl();
|
|
|
|
lcdPrint("Inc:");
|
|
|
|
lcdPrintInt(meshincctr);
|
|
|
|
lcdNl();
|
2011-08-05 00:19:22 +00:00
|
|
|
lcdPrint("Nice:");
|
|
|
|
lcdPrintInt(meshnice);
|
|
|
|
lcdNl();
|
2011-08-03 14:34:09 +00:00
|
|
|
lcdRefresh();
|
2011-08-10 23:53:54 +00:00
|
|
|
|
2011-08-12 17:18:48 +00:00
|
|
|
uint8_t key = getInputWaitTimeout(100);
|
2011-08-10 23:53:54 +00:00
|
|
|
switch(key) {
|
2011-08-12 17:18:48 +00:00
|
|
|
case BTN_LEFT:
|
2011-08-10 23:53:54 +00:00
|
|
|
select--;
|
|
|
|
if (select < 0)
|
|
|
|
select = MESHBUFSIZE - 1;
|
|
|
|
break;
|
2011-08-12 17:18:48 +00:00
|
|
|
case BTN_RIGHT:
|
2011-08-10 23:53:54 +00:00
|
|
|
select++;
|
|
|
|
if (select >= MESHBUFSIZE)
|
|
|
|
select = 0;
|
|
|
|
break;
|
|
|
|
case BTN_ENTER:
|
|
|
|
m_time_details(select);
|
|
|
|
break;
|
2011-08-12 17:18:48 +00:00
|
|
|
case BTN_UP:
|
|
|
|
case BTN_DOWN:
|
2011-08-10 23:53:54 +00:00
|
|
|
// Exit
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (key != BTN_NONE)
|
|
|
|
getInputWaitRelease();
|
|
|
|
}
|
2011-08-03 14:34:09 +00:00
|
|
|
};
|
2011-08-04 11:11:28 +00:00
|
|
|
|
|
|
|
void ChkFunk(){
|
|
|
|
lcdPrint("st: ");
|
|
|
|
lcdPrintln(IntToStrX(nrf_read_reg(R_STATUS),2));
|
|
|
|
lcdPrint("fifost:");
|
|
|
|
lcdPrintln(IntToStrX(nrf_read_reg(R_FIFO_STATUS),2));
|
|
|
|
lcdPrint("cfg:");
|
|
|
|
lcdPrintln(IntToStrX(nrf_read_reg(R_CONFIG),2));
|
|
|
|
lcdPrintln("Resets:");
|
2011-08-05 00:19:22 +00:00
|
|
|
lcdPrintln(IntToStr(_nrfresets,3,0));
|
2011-08-04 11:11:28 +00:00
|
|
|
lcdRefresh();
|
|
|
|
while(!getInputRaw())work_queue();
|
|
|
|
};
|
|
|
|
|
2011-12-20 00:23:00 +00:00
|
|
|
// //# MENU lcdread
|
|
|
|
void lcdrtest(void){
|
|
|
|
lcdClear();
|
|
|
|
lcdPrint("ID1:"); lcdPrintInt(lcdRead(128+64+16+8 +2 )); lcdNl();
|
|
|
|
lcdPrint("ID2:"); lcdPrintInt(lcdRead(128+64+16+8 +2+1)); lcdNl();
|
|
|
|
lcdPrint("ID3:"); lcdPrintInt(lcdRead(128+64+16+8+4 )); lcdNl();
|
|
|
|
lcdPrint("ID4:"); lcdPrintInt(lcdRead(128+64+16+8+4 +1)); lcdNl();
|
|
|
|
lcdPrint("Tmp:"); lcdPrintInt(lcdRead(128+64+16+8+4+2 )); lcdNl();
|
|
|
|
lcdPrint("VM:"); lcdPrintInt(lcdRead(128+64+16+8+4+2+1)); lcdNl();
|
|
|
|
// lcd_select(); mylcdWrite(0,128+32+8+4+1); lcd_deselect();
|
|
|
|
delayms(10);
|
|
|
|
lcdInit();
|
|
|
|
lcdRefresh();
|
|
|
|
while(!getInputRaw())delayms(10);
|
|
|
|
};
|
2011-12-25 19:15:42 +00:00
|
|
|
|
|
|
|
void release(){
|
|
|
|
lcdPrint("r0ket");
|
|
|
|
lcdPrint("Release: ");
|
|
|
|
lcdPrintln(IntToStrX(getrelease(),8));
|
|
|
|
lcdRefresh();
|
|
|
|
while(!getInputRaw())work_queue();
|
|
|
|
};
|