#include #include #include #include "basic/basic.h" #include "basic/byteorder.h" #include "basic/config.h" #include "lcd/lcd.h" #include "lcd/print.h" #include "funk/nrf24l01p.h" #include "funk/mesh.h" #include /**************************************************************************/ void init_mesh(void){ nrf_init(); initMesh(); }; 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/getFontHeight())-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; for(int o=0;olo) if(MO_TYPE(meshbuffer[i].pkt)='a' && tmm[i]<='z'){ lcdPrintln(IntToStr(MO_TIME(meshbuffer[j].pkt),10,0)); }else{ struct tm *tm= mygmtime(MO_TIME(meshbuffer[j].pkt)); 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(); if(tmm[i]=='T'){ 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(); MO_BODY(meshbuffer[j].pkt)[0]=0; }; }; 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){ if(GLOBAL(privacy)<2) mesh_systick(); if(_timectr%64) if(meshmsg){ gpioSetValue (RB_LED1, 1); meshmsg=0; }; };