From e1f06bff6d99b3a2a3038bcd41054227e63c9a2a Mon Sep 17 00:00:00 2001 From: geeksville Date: Fri, 7 Feb 2020 17:26:42 -0800 Subject: [PATCH] placeholder debug and nodeinfo screens are in --- TODO.md | 1 + images/compass.png | Bin 0 -> 845 bytes images/face.png | Bin 0 -> 329 bytes images/genfiles.sh | 8 +++ images/pin.png | Bin 0 -> 288 bytes src/MeshService.cpp | 4 ++ src/compass.xbm | 28 ++++++++++ src/icon.xbm | 2 +- src/images.h | 4 ++ src/main.ino | 8 +-- src/pin.xbm | 6 +++ src/screen.cpp | 122 ++++++++++++++++++++++++++++++++------------ 12 files changed, 143 insertions(+), 40 deletions(-) create mode 100644 images/compass.png create mode 100644 images/face.png create mode 100644 images/pin.png create mode 100644 src/compass.xbm create mode 100644 src/pin.xbm diff --git a/TODO.md b/TODO.md index 38bbf8564..f8ca81d78 100644 --- a/TODO.md +++ b/TODO.md @@ -33,6 +33,7 @@ * optionally do lora messaging only during special scheduled intervals (unless nodes are told to go to low latency mode), then deep sleep except during those intervals - before implementing calculate what battery life would be with this feature * see section 7.3 of https://cdn.sparkfun.com/assets/learn_tutorials/8/0/4/RFM95_96_97_98W.pdf and have hope radio wake only when a valid packet is received. Possibly even wake the ESP32 from deep sleep via GPIO. * never enter deep sleep while connected to USB power (but still go to other low power modes) +* when main cpu is idle (in loop), turn cpu clock rate down and/or activate special sleep modes. We want almost everything shutdown until it gets an interrupt. # dynamic nodenum assignment tasks diff --git a/images/compass.png b/images/compass.png new file mode 100644 index 0000000000000000000000000000000000000000..8639dde5241d720e47e97d63280ec8073928c2b4 GIT binary patch literal 845 zcmV-T1G4;yP)#lVG9=+yX8ERp5{xHUHji zpp{U_HZYT?`L8j?9|8**v=)F3qI+?V9EzAG`pJL8ybHFR1@oG~n3fdK5 zCqnyMD1U=lw{4f>? z_x3dx!Iwhpfuq4RJQ6vd+X@|LaCzX7ZK|}T#$YdWfH@nXn+!gQPf7;U&=$FG#5GJ> zNXZrDQ+Hpfk-6$|4U-BuDX!mJ+sV#5aUEMgkYNk16N(0hQBC0|#IPTf@^&4dl)?{? zZ8MSQ35F!KuPg-|wJ>7Kv9t|?1x$(96>Y8NVoPKJ4Z{9_kBH@(s5B-H{%*+ zDd4KLo$Sb5EgO+}%x65fl&HG-N=1#q+2#)!-U-R35Zh2NIE*JE=Q9_v6(Qzfwt;!E zM0h#9>>^kIJ_x~|z!4{#(Nuu%B3BcIgRgUhpUMupTgqwRt;o>@&S)iA6XHG09=4*O zJxkbp54fkG{f{DMBQKNeo0&Q1-?({2H;f!`WQC;t~}U&Kt;zqT^vI+ zCa%3;>%|->a`fZ;q^S)rmTU}~uF%=48Pkwzwm@3oPSeR8)xGk!I}W<4sO)0M)_vCF z)1k~ESFxw~{?q^O*#9q(^E$KfgstO6Hl7b{=jG2?{anjs`k^b6dq?0#pGVBKZxZM1 z;Ot9OzaS$UlYH$*j{J0sLz?Rf;?$>Gbnidt`p2Nq_A^u2=MR08e>j&s-fhugf9}rx zSq~1ruR2!yd0{~A^KGm<4r|5cWC(l^Tzo{?hV{kvtpO{p{aPedHEr59tv`|RNuCB9 UcBC=v0Q!i*)78&qol`;+0NTHVf&c&j literal 0 HcmV?d00001 diff --git a/images/genfiles.sh b/images/genfiles.sh index 1a2f7b8ed..bc14f6e8e 100755 --- a/images/genfiles.sh +++ b/images/genfiles.sh @@ -1,3 +1,11 @@ # using height of 50 to have 14 pixels beneath icon for text inkscape -z -e icon.png -w 50 -h 50 icon-24px.svg convert icon.png -background white -alpha Background ../src/icon.xbm + +inkscape -z -e compass.png -w 48 -h 48 location_searching-24px.svg +convert compass.png -background white -alpha Background ../src/compass.xbm + +inkscape -z -e face.png -w 13 -h 13 face-24px.svg + +inkscape -z -e pin.png -w 13 -h 13 room-24px.svg +convert pin.png -background white -alpha Background ../src/pin.xbm diff --git a/images/pin.png b/images/pin.png new file mode 100644 index 0000000000000000000000000000000000000000..112a7ce8ed6a7537c73dc2626d2f6cab93d87fbc GIT binary patch literal 288 zcmeAS@N?(olHy`uVBq!ia0vp@Ak4uAB#T}@sR2?f#ZI0f96(URk~}U&Kt*#sT^vI+ zCa%5U%g5*_(DqPW$gD$pN7u%OTuJJFN`4QR9_igV!22iX2%EQ2@@3`Rq#3RHE3f!p zk6xMeZ;7JWjpW{g`Uzbkktv#LsSfPdFYGw1^n*uyi@oFDj4J&rlU7W7(z}&omuunn z2i@=WO$+#f-`{v7_(}LxYWdl{^-g)4jToXV#2T1q-B*whUvN=h;kp*X=~WFI&TTps cHT5ftzO9~*xJKwfrom); sendOurOwner(mp->from); + + String lcd = String("Joined: ") + mp->payload.variant.user.long_name; + screen_print(lcd.c_str()); } fromNum++; diff --git a/src/compass.xbm b/src/compass.xbm new file mode 100644 index 000000000..115a7a1d4 --- /dev/null +++ b/src/compass.xbm @@ -0,0 +1,28 @@ +#define compass_width 48 +#define compass_height 48 +static char compass_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xC0, 0x03, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x03, 0x00, 0x00, + 0x00, 0x00, 0xC0, 0x03, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x03, 0x00, 0x00, + 0x00, 0x00, 0xFC, 0x3F, 0x00, 0x00, 0x00, 0x80, 0xFF, 0xFF, 0x01, 0x00, + 0x00, 0xC0, 0xFF, 0xFF, 0x03, 0x00, 0x00, 0xF0, 0xFF, 0xFF, 0x0F, 0x00, + 0x00, 0xF8, 0xFF, 0xFF, 0x1F, 0x00, 0x00, 0xFC, 0x07, 0xE0, 0x3F, 0x00, + 0x00, 0xFE, 0x01, 0x80, 0x7F, 0x00, 0x00, 0xFE, 0x00, 0x00, 0x7F, 0x00, + 0x00, 0x7F, 0x00, 0x00, 0xFE, 0x00, 0x80, 0x3F, 0x00, 0x00, 0xFC, 0x01, + 0x80, 0x1F, 0x00, 0x00, 0xF8, 0x01, 0x80, 0x0F, 0x00, 0x00, 0xF0, 0x01, + 0xC0, 0x0F, 0x00, 0x00, 0xF0, 0x03, 0xC0, 0x07, 0x00, 0x00, 0xE0, 0x03, + 0xC0, 0x07, 0x00, 0x00, 0xE0, 0x03, 0xC0, 0x07, 0x00, 0x00, 0xE0, 0x03, + 0xFC, 0x07, 0x00, 0x00, 0xE0, 0x3F, 0xFC, 0x07, 0x00, 0x00, 0xE0, 0x3F, + 0xFC, 0x07, 0x00, 0x00, 0xE0, 0x3F, 0xFC, 0x07, 0x00, 0x00, 0xE0, 0x3F, + 0xC0, 0x07, 0x00, 0x00, 0xE0, 0x03, 0xC0, 0x07, 0x00, 0x00, 0xE0, 0x03, + 0xC0, 0x07, 0x00, 0x00, 0xE0, 0x03, 0xC0, 0x0F, 0x00, 0x00, 0xF0, 0x03, + 0x80, 0x0F, 0x00, 0x00, 0xF0, 0x01, 0x80, 0x1F, 0x00, 0x00, 0xF8, 0x01, + 0x80, 0x3F, 0x00, 0x00, 0xFC, 0x01, 0x00, 0x7F, 0x00, 0x00, 0xFE, 0x00, + 0x00, 0xFE, 0x00, 0x00, 0x7F, 0x00, 0x00, 0xFE, 0x01, 0x80, 0x7F, 0x00, + 0x00, 0xFC, 0x07, 0xE0, 0x3F, 0x00, 0x00, 0xF8, 0xFF, 0xFF, 0x1F, 0x00, + 0x00, 0xF0, 0xFF, 0xFF, 0x0F, 0x00, 0x00, 0xC0, 0xFF, 0xFF, 0x03, 0x00, + 0x00, 0x80, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0x00, 0xFC, 0x3F, 0x00, 0x00, + 0x00, 0x00, 0xC0, 0x03, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x03, 0x00, 0x00, + 0x00, 0x00, 0xC0, 0x03, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x03, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }; diff --git a/src/icon.xbm b/src/icon.xbm index 7b07a22e2..d7394c8e7 100644 --- a/src/icon.xbm +++ b/src/icon.xbm @@ -1,6 +1,6 @@ #define icon_width 50 #define icon_height 50 -static const char icon_bits[] = { +static char icon_bits[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x80, 0xFF, 0xFF, 0x07, 0x00, 0x00, 0x00, 0xE0, 0xFF, 0xFF, 0x1F, 0x00, 0x00, 0x00, diff --git a/src/images.h b/src/images.h index 6d1232cab..6a9992c2d 100644 --- a/src/images.h +++ b/src/images.h @@ -7,8 +7,12 @@ const uint8_t SATELLITE_IMAGE[] PROGMEM = { }; +const #include "icon.xbm" +const +#include "compass.xbm" + #if 0 const uint8_t activeSymbol[] PROGMEM = { B00000000, diff --git a/src/main.ino b/src/main.ino index 0550fc234..c15f1e338 100644 --- a/src/main.ino +++ b/src/main.ino @@ -352,11 +352,7 @@ void setup() // Init GPS gps.setup(); - // Show logo on first boot after removing battery - //if (bootCount == 0) { - screen_print(APP_NAME " " APP_VERSION); - screen_show_logo(); - //} + screen_print("Started..."); service.init(); @@ -430,6 +426,6 @@ void loop() // No GPS lock yet, let the OS put the main CPU in low power mode for 100ms (or until another interrupt comes in) // i.e. don't just keep spinning in loop as fast as we can. - DEBUG_MSG("msecs %d\n", msecstosleep); + //DEBUG_MSG("msecs %d\n", msecstosleep); delay(msecstosleep); } \ No newline at end of file diff --git a/src/pin.xbm b/src/pin.xbm new file mode 100644 index 000000000..e8c8f8930 --- /dev/null +++ b/src/pin.xbm @@ -0,0 +1,6 @@ +#define pin_width 13 +#define pin_height 13 +static char pin_bits[] = { + 0x00, 0x00, 0xF0, 0x01, 0xF8, 0x03, 0xFC, 0x07, 0xBC, 0x07, 0xBC, 0x07, + 0xFC, 0x07, 0xF8, 0x03, 0xF8, 0x03, 0xF0, 0x01, 0xE0, 0x00, 0xE0, 0x00, + 0x00, 0x00, }; diff --git a/src/screen.cpp b/src/screen.cpp index 589b060b7..462d2ac24 100644 --- a/src/screen.cpp +++ b/src/screen.cpp @@ -110,30 +110,105 @@ void drawTextMessageFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16 String sender = "KH:"; display->drawString(0 + x, 0 + y, sender); display->setFont(ArialMT_Plain_10); - display->drawStringMaxWidth(4 + x, 10 + y, 128, " Lorem ipsum\n dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore."); + display->drawStringMaxWidth(4 + x, 10 + y, 128, " Lorem ipsum\n dolor sit amet, consetetur sadipscing elitr, sed diam"); - ui.disableIndicator(); + // ui.disableIndicator(); } -void drawFrame5(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y) +/// Draw a series of fields in a column, wrapping to multiple colums if needed +void drawColumns(OLEDDisplay *display, int16_t x, int16_t y, const char **fields) { + // The coordinates define the left starting point of the text + display->setTextAlignment(TEXT_ALIGN_LEFT); + + const char **f = fields; + int xo = x, yo = y; + while (*f) + { + display->drawString(xo, yo, *f); + yo += FONT_HEIGHT; + if (yo > SCREEN_HEIGHT - FONT_HEIGHT) + { + xo += SCREEN_WIDTH / 2; + yo = 0; + } + f++; + } +} + +/// Draw a series of fields in a row, wrapping to multiple rows if needed +/// @return the max y we ended up printing to +uint32_t drawRows(OLEDDisplay *display, int16_t x, int16_t y, const char **fields) +{ + // The coordinates define the left starting point of the text + display->setTextAlignment(TEXT_ALIGN_LEFT); + + const char **f = fields; + int xo = x, yo = y; + while (*f) + { + display->drawString(xo, yo, *f); + xo += SCREEN_WIDTH / 2; // hardwired for two columns per row.... + if (xo >= SCREEN_WIDTH) + { + yo += FONT_HEIGHT; + xo = 0; + } + f++; + } + + yo += FONT_HEIGHT; // include the last line in our total + + return yo; +} + +void drawNodeInfo(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y) +{ + display->setFont(ArialMT_Plain_10); + + // The coordinates define the left starting point of the text + display->setTextAlignment(TEXT_ALIGN_LEFT); + + const char *fields[] = { + "Kevin Hester (KH)", + "4.2 mi", + "Signal: good", + "24 minutes ago", + NULL}; + drawColumns(display, x, y, fields); + + display->drawXbm(x + (SCREEN_WIDTH - compass_width), y + (SCREEN_HEIGHT - compass_height) / 2, compass_width, compass_height, (const uint8_t *)compass_bits); +} + +void drawDebugInfo(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y) +{ + display->setFont(ArialMT_Plain_10); + + // The coordinates define the left starting point of the text + display->setTextAlignment(TEXT_ALIGN_LEFT); + + const char *fields[] = { + "Batt 89%", + "GPS 75%", + "Users 4/12", + NULL}; + uint32_t yo = drawRows(display, x, y, fields); + + display->drawLogBuffer(x, yo); } // This array keeps function pointers to all frames // frames are the single views that slide in -FrameCallback frames[] = {drawBootScreen, drawTextMessageFrame}; +FrameCallback frames[] = {drawBootScreen, drawTextMessageFrame, drawNodeInfo, drawDebugInfo}; FrameCallback *nonBootFrames = frames + 1; - // Overlays are statically drawn on top of a frame eg. a clock -OverlayCallback overlays[] = {msOverlay}; +OverlayCallback overlays[] = {/* msOverlay */}; // how many frames are there? const int frameCount = sizeof(frames) / sizeof(frames[0]); const int overlaysCount = sizeof(overlays) / sizeof(overlays[0]); - - void _screen_header() { if (!disp) @@ -157,18 +232,6 @@ void _screen_header() #endif } -void screen_show_logo() -{ - if (!disp) - return; - -#if 0 - uint8_t x = (display->getWidth() - TTN_IMAGE_WIDTH) / 2; - uint8_t y = SCREEN_HEADER_HEIGHT + (display->getHeight() - SCREEN_HEADER_HEIGHT - TTN_IMAGE_HEIGHT) / 2 + 1; - display->drawXbm(x, y, TTN_IMAGE_WIDTH, TTN_IMAGE_HEIGHT, TTN_IMAGE); -#endif -} - void screen_off() { if (!disp) @@ -208,12 +271,7 @@ void screen_print(const char *text) return; dispdev.print(text); - /* if (_screen_line + 8 > dispdev.getHeight()) - { - // scroll - } - _screen_line += 8; */ - screen_loop(); + // ui.update(); } void screen_setup() @@ -242,8 +300,8 @@ void screen_setup() // SLIDE_LEFT, SLIDE_RIGHT, SLIDE_UP, SLIDE_DOWN ui.setFrameAnimation(SLIDE_LEFT); - // Add frames - ui.setFrames(frames, frameCount); + // Add frames - we subtract one from the framecount so there won't be a visual glitch when we take the boot screen out of the sequence. + ui.setFrames(frames, frameCount - 1); // Add overlays ui.setOverlays(overlays, overlaysCount); @@ -252,7 +310,7 @@ void screen_setup() ui.init(); // Scroll buffer - dispdev.setLogBuffer(5, 30); + dispdev.setLogBuffer(5, 32); // dispdev.flipScreenVertically(); // looks better without this on lora32 // dispdev.setFont(Custom_ArialMT_Plain_10); @@ -295,14 +353,12 @@ uint32_t screen_loop() #endif static bool showingBootScreen = true; - - - - uint32_t msecstosleep = ui.update(); + ui.update(); // Once we finish showing the bootscreen, remove it from the loop if (showingBootScreen && ui.getUiState()->currentFrame == 1) { + showingBootScreen = false; ui.setFrames(nonBootFrames, frameCount - 1); }