From a52c028e66bcfaf37700a10594b88b7e1cf2a93a Mon Sep 17 00:00:00 2001 From: Stefan `Sec` Zehl Date: Tue, 3 Jan 2012 02:54:12 +0100 Subject: [PATCH] Add debugmesh l0dable. (Can be used as l0nick :-) --- firmware/l0dable/Makefile | 5 +- firmware/l0dable/dbgmesh.c | 175 +++++++++++++++++++++++++++++++++++++ 2 files changed, 179 insertions(+), 1 deletion(-) create mode 100644 firmware/l0dable/dbgmesh.c diff --git a/firmware/l0dable/Makefile b/firmware/l0dable/Makefile index fb9fdd5..342abb7 100644 --- a/firmware/l0dable/Makefile +++ b/firmware/l0dable/Makefile @@ -31,7 +31,7 @@ CRYPTFLAGS=-p skey=`cd .. && ./getkey.pl l0dable_sign` ekey=`cd .. && ./getkey.pl l0dable_crypt` -all: $(OBJS) $(ELFS) $(BINS) $(CODS) $(NIKS) 1boot.int debug.int config.int initanim.int +all: $(OBJS) $(ELFS) $(BINS) $(CODS) $(NIKS) 1boot.int debug.int config.int initanim.int dbgmesh.int $(LDFILE): -@echo "MEMORY" > $(LDFILE) @@ -68,6 +68,9 @@ endif debug.int: debug.c0d .PHONY mv $< $@ +dbgmesh.int: debug.c0d .PHONY + mv $< $@ + config.int: config.c0d .PHONY mv $< $@ diff --git a/firmware/l0dable/dbgmesh.c b/firmware/l0dable/dbgmesh.c new file mode 100644 index 0000000..5216cd2 --- /dev/null +++ b/firmware/l0dable/dbgmesh.c @@ -0,0 +1,175 @@ +#include +#include + +#include "basic/basic.h" +#include "basic/config.h" + +#include "lcd/render.h" +#include "lcd/print.h" + +#include "funk/nrf24l01p.h" +#include "funk/mesh.h" + +#include "usetable.h" + +/**************************************************************************/ +void m_time(void); + +void ram(void) { + m_time(); +}; + +void m_time_details(int select) { + getInputWaitRelease(); + + while(getInputWaitTimeout(50) == BTN_NONE){ + lcdClear(); + MPKT *mpkt = &meshbuffer[select]; + uint8_t *pkt = mpkt->pkt; + + if (!mpkt->flags & MF_USED) + lcdPrint(""); + 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 + 30); 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){ + int active=0; + struct tm* tm; + int select=0; + char c[2]={0,0}; + getInputWaitRelease(); + delayms(100); + while(1) { + 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"); + + if(active){ + lcdPrint(" "); + for(int i=0; i= MESHBUFSIZE) + select = 0; + break; + case BTN_ENTER: + m_time_details(select); + break; + case BTN_UP: + active=0; + break; + case BTN_DOWN: + // Exit + return; + } + }else{ + switch(key) { + case BTN_UP: + active=1; + break; + default: + return; + }; + }; + if (key != BTN_NONE) + getInputWaitRelease(); + } +};