From 0a369da4a2817eb158a317f33fd8d740c7a30620 Mon Sep 17 00:00:00 2001 From: geeksville Date: Fri, 7 Feb 2020 14:52:45 -0800 Subject: [PATCH] make a bootscreen --- .vscode/settings.json | 3 ++- TODO.md | 6 ++++-- images/genfiles.sh | 3 +++ images/icon.png | Bin 0 -> 1118 bytes src/configuration.h | 2 +- src/icon.xbm | 33 +++++++++++++++++++++++++++++++++ src/images.h | 30 +----------------------------- src/screen.cpp | 30 ++++++++++++++++++++---------- 8 files changed, 64 insertions(+), 43 deletions(-) create mode 100755 images/genfiles.sh create mode 100644 images/icon.png create mode 100644 src/icon.xbm diff --git a/.vscode/settings.json b/.vscode/settings.json index 557670551..ac9d660e2 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -40,6 +40,7 @@ "cinttypes": "cpp", "utility": "cpp", "typeinfo": "cpp", - "string": "cpp" + "string": "cpp", + "*.xbm": "cpp" } } \ No newline at end of file diff --git a/TODO.md b/TODO.md index 506aa3730..6dd789cf4 100644 --- a/TODO.md +++ b/TODO.md @@ -1,8 +1,9 @@ # High priority * make nice screens (boot, about to sleep, debug info (gps signal, #people), latest text, person info - one frame per person on network) +* we are currently spinning like crazy in loop, instead sleep unless we have work to do +* have radiohead ISR send messages to RX queue directly, to allow that thread to block until we have something to send * turn framerate from ui->state.frameState to 1 fps (or less) unless in transition -* use a better font * very occasionally send our position and user packet (if for nothing else so that other nodes update last_seen) * switch to my gui layout manager * make basic gui. different screens: debug, one page for each user in the user db, last received text message @@ -99,4 +100,5 @@ until the phone pulls those packets. Ever so often power on bluetooth just so w * correctly map nodeids to nodenums, currently we just do a proof of concept by always doing a broadcast * add interrupt detach/sleep mode config to lora radio so we can enable deepsleep without panicing * make jtag work on second board -* implement regen owner and radio prefs \ No newline at end of file +* implement regen owner and radio prefs +* use a better font \ No newline at end of file diff --git a/images/genfiles.sh b/images/genfiles.sh new file mode 100755 index 000000000..1a2f7b8ed --- /dev/null +++ b/images/genfiles.sh @@ -0,0 +1,3 @@ +# 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 diff --git a/images/icon.png b/images/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..00e765b446632682b64501643ae2953f1042c13e GIT binary patch literal 1118 zcmV-k1flzhP)SQEjVzubY0#jQmfmF~g z!bOW{WfY+aj#0EQh?Wv+=n@I7kWBq>l&=ZBe)Bzu^87kzW;+W_z|P{3`cOOgFZ|e zz1W2PIFEnZEPrDkHtOu4wv2h$f*)FNw$(C%r=`J}5j=oH9TX7D*U}Pg3++s2FNW}{ zG$T1&#;_!G6sPfLD$PF@vE^AC3jyhzUaeri}5;fwMqTGb4Yp5JdxpTtTVnpkdG=W-<~o02^O^>qKN@~nz8p%;Ppr=qsZA?Wpuvs zReWov;~1SrCn=(6GtSJJjLjDU=Pwlp^7=p=SH3&#%5dtIQy=bbl)f6?gUWkmXW$G< zhhdSEi=wb&IlPI56>UBUw!g}7;stYC&d_^-^mh2ZLU}~i zRfwqjU-`U3%!a_bjN1a|oxpjw`JoshSBFNUp}y9Y8-GlSUJw`w*%mhNk_0t>KPS;TI$NJJA$l!dgDE@}%imY$q$%n9i>%n9i> zOsA0CU*lB%B(DmV$tR^xNEw(}fhrNRO3XweW`&qR99MSwc+LBmjJxWnnu$?qh8JC#CW07*qoM6N<$f+ffW<^TWy literal 0 HcmV?d00001 diff --git a/src/configuration.h b/src/configuration.h index 3fb8206a9..f562ae77c 100644 --- a/src/configuration.h +++ b/src/configuration.h @@ -29,7 +29,7 @@ along with this program. If not, see . // Version // ----------------------------------------------------------------------------- -#define APP_NAME "meshtastic" +#define APP_NAME "Meshtastic" #define APP_VERSION "0.0.1" // ----------------------------------------------------------------------------- diff --git a/src/icon.xbm b/src/icon.xbm new file mode 100644 index 000000000..7b07a22e2 --- /dev/null +++ b/src/icon.xbm @@ -0,0 +1,33 @@ +#define icon_width 50 +#define icon_height 50 +static const char icon_bits[]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, + 0x00, 0x00, 0x00, 0x00, 0xF8, 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, + 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x3F, 0x00, 0x00, 0x00, 0x00, + 0x00, 0xE0, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x0F, 0x00, 0x00, + 0x00, 0x00, 0x00, 0xC0, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x0F, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xC0, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x0F, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xC0, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0x1F, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xF0, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, + 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 0xFF, 0x00, 0x00, 0x00, 0x00, + 0x00, 0xFE, 0xFF, 0x01, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFC, 0x03, 0x00, + 0x00, 0x00, 0x80, 0x7F, 0xF8, 0x07, 0x00, 0x00, 0x00, 0x00, 0x3F, 0xF0, + 0x03, 0x00, 0x00, 0x00, 0x00, 0x1E, 0xE0, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x0C, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, }; diff --git a/src/images.h b/src/images.h index b74c9cbd1..6d1232cab 100644 --- a/src/images.h +++ b/src/images.h @@ -7,35 +7,7 @@ const uint8_t SATELLITE_IMAGE[] PROGMEM = { }; - -#define WiFi_Logo_width 60 -#define WiFi_Logo_height 36 -const uint8_t WiFi_Logo_bits[] PROGMEM = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xFF, 0x07, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xE0, 0xFF, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFF, - 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 0xFF, 0xFF, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xFE, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, - 0xFF, 0x03, 0x00, 0x00, 0x00, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, - 0x00, 0xFF, 0xFF, 0xFF, 0x07, 0xC0, 0x83, 0x01, 0x80, 0xFF, 0xFF, 0xFF, - 0x01, 0x00, 0x07, 0x00, 0xC0, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x0C, 0x00, - 0xC0, 0xFF, 0xFF, 0x7C, 0x00, 0x60, 0x0C, 0x00, 0xC0, 0x31, 0x46, 0x7C, - 0xFC, 0x77, 0x08, 0x00, 0xE0, 0x23, 0xC6, 0x3C, 0xFC, 0x67, 0x18, 0x00, - 0xE0, 0x23, 0xE4, 0x3F, 0x1C, 0x00, 0x18, 0x00, 0xE0, 0x23, 0x60, 0x3C, - 0x1C, 0x70, 0x18, 0x00, 0xE0, 0x03, 0x60, 0x3C, 0x1C, 0x70, 0x18, 0x00, - 0xE0, 0x07, 0x60, 0x3C, 0xFC, 0x73, 0x18, 0x00, 0xE0, 0x87, 0x70, 0x3C, - 0xFC, 0x73, 0x18, 0x00, 0xE0, 0x87, 0x70, 0x3C, 0x1C, 0x70, 0x18, 0x00, - 0xE0, 0x87, 0x70, 0x3C, 0x1C, 0x70, 0x18, 0x00, 0xE0, 0x8F, 0x71, 0x3C, - 0x1C, 0x70, 0x18, 0x00, 0xC0, 0xFF, 0xFF, 0x3F, 0x00, 0x00, 0x08, 0x00, - 0xC0, 0xFF, 0xFF, 0x1F, 0x00, 0x00, 0x0C, 0x00, 0x80, 0xFF, 0xFF, 0x1F, - 0x00, 0x00, 0x06, 0x00, 0x80, 0xFF, 0xFF, 0x0F, 0x00, 0x00, 0x07, 0x00, - 0x00, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0xF8, 0xFF, 0xFF, - 0xFF, 0x7F, 0x00, 0x00, 0x00, 0x00, 0xFE, 0xFF, 0xFF, 0x01, 0x00, 0x00, - 0x00, 0x00, 0xFC, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFF, - 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFF, 0x1F, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x80, 0xFF, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - }; +#include "icon.xbm" #if 0 const uint8_t activeSymbol[] PROGMEM = { diff --git a/src/screen.cpp b/src/screen.cpp index ee85fa4ba..ae668d2eb 100644 --- a/src/screen.cpp +++ b/src/screen.cpp @@ -29,7 +29,10 @@ along with this program. If not, see . #include "OLEDDisplayUi.h" #include "screen.h" -#define SCREEN_HEADER_HEIGHT 14 +#define FONT_HEIGHT 14 // actually 13 for "ariel 10" but want a little extra space + +#define SCREEN_WIDTH 128 +#define SCREEN_HEIGHT 64 #ifdef I2C_SDA SSD1306Wire dispdev(SSD1306_ADDRESS, I2C_SDA, I2C_SCL); @@ -38,10 +41,10 @@ SSD1306Wire dispdev(SSD1306_ADDRESS, 0, 0); // fake values to keep build happy, #endif bool disp; // true if we are using display -uint8_t _screen_line = SCREEN_HEADER_HEIGHT - 1; OLEDDisplayUi ui(&dispdev); + void msOverlay(OLEDDisplay *display, OLEDDisplayUiState *state) { display->setTextAlignment(TEXT_ALIGN_RIGHT); @@ -49,13 +52,19 @@ void msOverlay(OLEDDisplay *display, OLEDDisplayUiState *state) display->drawString(128, 0, String(millis())); } -void drawFrame1(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y) +void drawBootScreen(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y) { // draw an xbm image. // Please note that everything that should be transitioned // needs to be drawn relative to x and y - display->drawXbm(x + 34, y + 14, WiFi_Logo_width, WiFi_Logo_height, WiFi_Logo_bits); + display->drawXbm(x + 32, y, icon_width, icon_height,(const uint8_t *) icon_bits); + + display->setFont(ArialMT_Plain_10); + display->setTextAlignment(TEXT_ALIGN_CENTER); + display->drawString(64 + x, SCREEN_HEIGHT - FONT_HEIGHT, APP_NAME " " APP_VERSION); + + ui.disableIndicator(); } void drawFrame2(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y) @@ -91,7 +100,8 @@ void drawFrame3(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int1 display->drawString(128 + x, 33 + y, "Right aligned (128,33)"); } -void drawFrame4(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y) +/// Draw the last text message we received +void drawLastTextFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y) { // Demo for drawStringMaxWidth: // with the third parameter you can define the width after which words will be wrapped. @@ -107,14 +117,14 @@ void drawFrame5(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int1 // This array keeps function pointers to all frames // frames are the single views that slide in -FrameCallback frames[] = {drawFrame1, drawFrame2, drawFrame3, drawFrame4, drawFrame5}; +FrameCallback frames[] = {drawBootScreen, drawFrame2, drawFrame3, drawLastTextFrame, drawFrame5}; // how many frames are there? int frameCount = 5; +int overlaysCount = 1; // Overlays are statically drawn on top of a frame eg. a clock OverlayCallback overlays[] = {msOverlay}; -int overlaysCount = 1; void _screen_header() { @@ -190,11 +200,11 @@ void screen_print(const char *text) return; dispdev.print(text); - if (_screen_line + 8 > dispdev.getHeight()) + /* if (_screen_line + 8 > dispdev.getHeight()) { // scroll } - _screen_line += 8; + _screen_line += 8; */ screen_loop(); } @@ -236,7 +246,7 @@ void screen_setup() // Scroll buffer dispdev.setLogBuffer(5, 30); - dispdev.flipScreenVertically(); + // dispdev.flipScreenVertically(); // looks better without this on lora32 dispdev.setFont(Custom_ArialMT_Plain_10); #endif }