mirror of
https://github.com/meshtastic/firmware.git
synced 2025-06-21 04:22:22 +00:00
Enable OEM Bootlogo, needs protobuf update
This commit is contained in:
parent
79a41bd81c
commit
f279f9614e
@ -31,6 +31,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
#include "graphics/images.h"
|
#include "graphics/images.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "mesh-pb-constants.h"
|
#include "mesh-pb-constants.h"
|
||||||
|
#include "mesh/generated/deviceonly.pb.h"
|
||||||
#include "mesh/Channels.h"
|
#include "mesh/Channels.h"
|
||||||
#include "modules/TextMessageModule.h"
|
#include "modules/TextMessageModule.h"
|
||||||
#include "sleep.h"
|
#include "sleep.h"
|
||||||
@ -44,6 +45,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
|
|
||||||
using namespace meshtastic; /** @todo remove */
|
using namespace meshtastic; /** @todo remove */
|
||||||
|
|
||||||
|
extern bool loadProto(const char *filename, size_t protoSize, size_t objSize, const pb_msgdesc_t *fields, void *dest_struct);
|
||||||
|
|
||||||
namespace graphics
|
namespace graphics
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -77,6 +80,10 @@ static char ourId[5];
|
|||||||
// GeoCoord object for the screen
|
// GeoCoord object for the screen
|
||||||
GeoCoord geoCoord;
|
GeoCoord geoCoord;
|
||||||
|
|
||||||
|
// OEM Config File
|
||||||
|
static const char *oemConfigFile = "/prefs/oem.proto";
|
||||||
|
OEMStore oemStore;
|
||||||
|
|
||||||
#ifdef SHOW_REDRAWS
|
#ifdef SHOW_REDRAWS
|
||||||
static bool heartbeat = false;
|
static bool heartbeat = false;
|
||||||
#endif
|
#endif
|
||||||
@ -148,6 +155,54 @@ static void drawBootScreen(OLEDDisplay *display, OLEDDisplayUiState *state, int1
|
|||||||
drawIconScreen(region, display, state, x, y);
|
drawIconScreen(region, display, state, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void drawOEMIconScreen(const char *upperMsg, 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
|
||||||
|
|
||||||
|
// draw centered icon left to right and centered above the one line of app text
|
||||||
|
display->drawXbm(x + (SCREEN_WIDTH - oemStore.oem_icon_width) / 2, y + (SCREEN_HEIGHT - FONT_HEIGHT_MEDIUM - oemStore.oem_icon_height) / 2 + 2,
|
||||||
|
oemStore.oem_icon_width, oemStore.oem_icon_height, (const uint8_t *)oemStore.oem_icon_bits.bytes);
|
||||||
|
|
||||||
|
switch(oemStore.oem_font){
|
||||||
|
case 0:
|
||||||
|
display->setFont(FONT_SMALL);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
display->setFont(FONT_LARGE);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
display->setFont(FONT_MEDIUM);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
||||||
|
const char *title = oemStore.oem_text;
|
||||||
|
display->drawString(x + getStringCenteredX(title), y + SCREEN_HEIGHT - FONT_HEIGHT_MEDIUM, title);
|
||||||
|
display->setFont(FONT_SMALL);
|
||||||
|
|
||||||
|
// Draw region in upper left
|
||||||
|
if (upperMsg)
|
||||||
|
display->drawString(x + 0, y + 0, upperMsg);
|
||||||
|
|
||||||
|
// Draw version in upper right
|
||||||
|
char buf[16];
|
||||||
|
snprintf(buf, sizeof(buf), "%s",
|
||||||
|
xstr(APP_VERSION_SHORT)); // Note: we don't bother printing region or now, it makes the string too long
|
||||||
|
display->drawString(x + SCREEN_WIDTH - display->getStringWidth(buf), y + 0, buf);
|
||||||
|
screen->forceDisplay();
|
||||||
|
|
||||||
|
// FIXME - draw serial # somewhere?
|
||||||
|
}
|
||||||
|
|
||||||
|
static void drawOEMBootScreen(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y)
|
||||||
|
{
|
||||||
|
// Draw region in upper left
|
||||||
|
const char *region = myRegion ? myRegion->name : NULL;
|
||||||
|
drawOEMIconScreen(region, display, state, x, y);
|
||||||
|
}
|
||||||
|
|
||||||
// Used on boot when a certificate is being created
|
// Used on boot when a certificate is being created
|
||||||
static void drawSSLScreen(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y)
|
static void drawSSLScreen(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y)
|
||||||
{
|
{
|
||||||
@ -813,8 +868,8 @@ void Screen::setup()
|
|||||||
dispdev.setDetected(screen_model);
|
dispdev.setDetected(screen_model);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// I think this is not needed - redundant with ui.init
|
// Load OEM config from Proto file if existent
|
||||||
// dispdev.resetOrientation();
|
loadProto(oemConfigFile, OEMStore_size, sizeof(oemConfigFile), OEMStore_fields, &oemStore);
|
||||||
|
|
||||||
// Initialising the UI will init the display too.
|
// Initialising the UI will init the display too.
|
||||||
ui.init();
|
ui.init();
|
||||||
@ -867,6 +922,7 @@ void Screen::setup()
|
|||||||
// twice initially.
|
// twice initially.
|
||||||
ui.update();
|
ui.update();
|
||||||
ui.update();
|
ui.update();
|
||||||
|
serialSinceMsec = millis();
|
||||||
|
|
||||||
// Subscribe to status updates
|
// Subscribe to status updates
|
||||||
powerStatusObserver.observe(&powerStatus->onNewStatus);
|
powerStatusObserver.observe(&powerStatus->onNewStatus);
|
||||||
@ -897,7 +953,7 @@ int32_t Screen::runOnce()
|
|||||||
return RUN_SAME;
|
return RUN_SAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show boot screen for first 3 seconds, then switch to normal operation.
|
// Show boot screen for first 5 seconds, then switch to normal operation.
|
||||||
// serialSinceMsec adjusts for additional serial wait time during nRF52 bootup
|
// serialSinceMsec adjusts for additional serial wait time during nRF52 bootup
|
||||||
static bool showingBootScreen = true;
|
static bool showingBootScreen = true;
|
||||||
if (showingBootScreen && (millis() > (5000 + serialSinceMsec))) {
|
if (showingBootScreen && (millis() > (5000 + serialSinceMsec))) {
|
||||||
@ -906,6 +962,21 @@ int32_t Screen::runOnce()
|
|||||||
showingBootScreen = false;
|
showingBootScreen = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If we have an OEM Boot screen, toggle after 2,5 seconds
|
||||||
|
if(strlen(oemStore.oem_text) > 0){
|
||||||
|
static bool showingOEMBootScreen = true;
|
||||||
|
if (showingOEMBootScreen && (millis() > (2500 + serialSinceMsec))) {
|
||||||
|
DEBUG_MSG("Switch to OEM screen...\n");
|
||||||
|
// Change frames.
|
||||||
|
static FrameCallback bootOEMFrames[] = {drawOEMBootScreen};
|
||||||
|
static const int bootOEMFrameCount = sizeof(bootOEMFrames) / sizeof(bootOEMFrames[0]);
|
||||||
|
ui.setFrames(bootOEMFrames, bootOEMFrameCount);
|
||||||
|
ui.update();
|
||||||
|
ui.update();
|
||||||
|
showingOEMBootScreen = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef DISABLE_WELCOME_UNSET
|
#ifndef DISABLE_WELCOME_UNSET
|
||||||
if (showingNormalScreen && radioConfig.preferences.region == RegionCode_Unset) {
|
if (showingNormalScreen && radioConfig.preferences.region == RegionCode_Unset) {
|
||||||
setWelcomeFrames();
|
setWelcomeFrames();
|
||||||
|
Loading…
Reference in New Issue
Block a user