From 8625d1b3ef76c138aae2c7541b354292a37564f9 Mon Sep 17 00:00:00 2001 From: Stefan `Sec` Zehl Date: Sat, 30 Jul 2011 19:06:12 +0200 Subject: [PATCH] Mesh++ Now we can display messages. --- firmware/applications/mesh/mesh.c | 184 ++++++++++++++++++++++++++++-- firmware/funk/mesh.h | 1 + 2 files changed, 178 insertions(+), 7 deletions(-) diff --git a/firmware/applications/mesh/mesh.c b/firmware/applications/mesh/mesh.c index e142c50..c1f2f1c 100644 --- a/firmware/applications/mesh/mesh.c +++ b/firmware/applications/mesh/mesh.c @@ -84,22 +84,192 @@ inline void blink(char a, char b){ }; +int choose(char * texts, int8_t menuselection){ + uint8_t numentries = 0; + uint8_t visible_lines = 0; + uint8_t current_offset = 0; + + char*p=texts; + + do{ + lcdPrintln(p); + while(*p)p++; + numentries++;p++; + }while(*p); + numentries--; + + visible_lines = (RESY/font->u8Height)-1; // subtract title line + + while (1) { + // Display current menu page + lcdClear(); + lcdPrintln(texts); + p=texts; + while(*p++); + for(int i=0;i (current_offset + visible_lines-1) || menuselection >= numentries) { + if (menuselection >= numentries) { + menuselection = 0; + current_offset = 0; + } else { + current_offset += visible_lines; + } + } + break; + case BTN_LEFT: + return -1; + case BTN_RIGHT: + case BTN_ENTER: + return menuselection; + } + getInputWaitRelease(); + } + /* NOTREACHED */ +} + + /***********************************************************************/ +char *meshmsgs(void){ + static char msgtypes[MESHBUFSIZE+1]; + memset(msgtypes,'_',MESHBUFSIZE); + msgtypes[MESHBUFSIZE]=0; + uint8_t lo=0; + uint8_t hi; -void m_cleanup(void){ - mesh_cleanup(); + for(int o=0;olo) + if(MO_TYPE(meshbuffer[i].pkt)tm_hour); + lcdPrint(":"); + lcdPrintInt(tm->tm_min); + lcdPrint(":"); + lcdPrintInt(tm->tm_sec); + lcdNl(); + char *foo=(char *)MO_BODY(meshbuffer[j].pkt); + while(strlen(foo)>13){ + int q; + for(q=0;q<13;q++){ + if(foo[q]==' ') + break; + }; + foo[q]=0; + lcdPrintln(foo); + foo[q]=' '; + foo+=q+1; + }; + lcdPrintln(foo); + lcdRefresh(); + getInputWaitRelease(); + }; }; + void tick_mesh(void){ mesh_systick(); }; diff --git a/firmware/funk/mesh.h b/firmware/funk/mesh.h index b9555a2..7bbe2cf 100644 --- a/firmware/funk/mesh.h +++ b/firmware/funk/mesh.h @@ -17,6 +17,7 @@ #define MO_GEN_set(x,y) (x[1]=y) #define MO_TIME(x) (uint8ptouint32(x+2)) #define MO_TIME_set(x,y) (uint32touint8p(y,x+2)) +#define MO_BODY(x) (x+6) typedef struct { uint8_t pkt[32];