Merge pull request #7 from astro/master

debug menu: browse mesh pkt details
This commit is contained in:
Sec 2011-08-12 08:35:08 -07:00
commit af90e5646d
1 changed files with 91 additions and 3 deletions

View File

@ -165,12 +165,72 @@ void getsp(void) {
dx=DoString(0,dy,"Done.");
};
void m_time_details(int select) {
getInputWaitRelease();
while(getInputWaitTimeout(50) != BTN_LEFT){
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;
for(uint8_t *body = MO_BODY(pkt); body < pkt + 32; body++) {
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();
}
}
void m_time(void){
struct tm* tm;
int select=0;
char c[2]={0,0};
getInputWaitRelease();
delayms(100);
do{
while(1) {
lcdClear();
tm= mygmtime(getSeconds());
lcdPrint(IntToStr(tm->tm_hour,2,F_LONG));
@ -199,6 +259,12 @@ void m_time(void){
};
lcdPrintln(">");
lcdPrint(" ");
for(int i=0; i<MESHBUFSIZE; i++) {
lcdPrint(i == select ? "^" : " ");
}
lcdNl();
lcdPrint("Gen:");
lcdPrintInt(meshgen);
lcdNl();
@ -209,8 +275,30 @@ void m_time(void){
lcdPrintInt(meshnice);
lcdNl();
lcdRefresh();
delayms_queue(50);
}while ((getInputRaw())==BTN_NONE);
uint8_t key = getInputWaitTimeout(50);
switch(key) {
case BTN_UP:
select--;
if (select < 0)
select = MESHBUFSIZE - 1;
break;
case BTN_DOWN:
select++;
if (select >= MESHBUFSIZE)
select = 0;
break;
case BTN_RIGHT:
case BTN_ENTER:
m_time_details(select);
break;
case BTN_LEFT:
// Exit
return;
}
if (key != BTN_NONE)
getInputWaitRelease();
}
};
void ChkFunk(){