mirror of
https://github.com/meshtastic/firmware.git
synced 2025-05-01 11:42:45 +00:00
Show current region on the boot screen
This commit is contained in:
parent
0b3c25f6d9
commit
a5d7bacdbf
@ -92,21 +92,24 @@ static void drawBootScreen(OLEDDisplay *display, OLEDDisplayUiState *state, int1
|
|||||||
// needs to be drawn relative to x and y
|
// needs to be drawn relative to x and y
|
||||||
|
|
||||||
// draw centered left to right and centered above the one line of app text
|
// draw centered left to right and centered above the one line of app text
|
||||||
display->drawXbm(x + (SCREEN_WIDTH - icon_width) / 2, y + (SCREEN_HEIGHT - FONT_HEIGHT_MEDIUM - icon_height) / 2, icon_width,
|
display->drawXbm(x + (SCREEN_WIDTH - icon_width) / 2,
|
||||||
icon_height, (const uint8_t *)icon_bits);
|
y + (SCREEN_HEIGHT - FONT_HEIGHT_MEDIUM - icon_height) / 2 + 2,
|
||||||
|
icon_width, icon_height, (const uint8_t *)icon_bits);
|
||||||
|
|
||||||
display->setFont(FONT_MEDIUM);
|
display->setFont(FONT_MEDIUM);
|
||||||
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
||||||
const char *title = "meshtastic.org";
|
const char *title = "meshtastic.org";
|
||||||
display->drawString(x + getStringCenteredX(title), y + SCREEN_HEIGHT - FONT_HEIGHT_MEDIUM, title);
|
display->drawString(x + getStringCenteredX(title), y + SCREEN_HEIGHT - FONT_HEIGHT_MEDIUM, title);
|
||||||
display->setFont(FONT_SMALL);
|
display->setFont(FONT_SMALL);
|
||||||
const char *region = xstr(HW_VERSION);
|
|
||||||
if (*region && region[3] == '-') // Skip past 1.0- in the 1.0-EU865 string
|
const char *region = myRegion ? myRegion->name : NULL;
|
||||||
region += 4;
|
if (region)
|
||||||
|
display->drawString(x + 0, y + 0, region);
|
||||||
|
|
||||||
char buf[16];
|
char buf[16];
|
||||||
snprintf(buf, sizeof(buf), "%s",
|
snprintf(buf, sizeof(buf), "%s",
|
||||||
xstr(APP_VERSION)); // Note: we don't bother printing region or now, it makes the string too long
|
xstr(APP_VERSION)); // Note: we don't bother printing region or now, it makes the string too long
|
||||||
display->drawString(SCREEN_WIDTH - 20, 0, buf);
|
display->drawString(x + SCREEN_WIDTH - display->getStringWidth(buf), y + 0, buf);
|
||||||
screen->forceDisplay();
|
screen->forceDisplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1139,7 +1142,7 @@ int Screen::handleStatusUpdate(const meshtastic::Status *arg)
|
|||||||
// DEBUG_MSG("Screen got status update %d\n", arg->getStatusType());
|
// DEBUG_MSG("Screen got status update %d\n", arg->getStatusType());
|
||||||
switch (arg->getStatusType()) {
|
switch (arg->getStatusType()) {
|
||||||
case STATUS_TYPE_NODE:
|
case STATUS_TYPE_NODE:
|
||||||
if (nodeDB.updateTextMessage || nodeStatus->getLastNumTotal() != nodeStatus->getNumTotal()) {
|
if (showingNormalScreen && (nodeDB.updateTextMessage || nodeStatus->getLastNumTotal() != nodeStatus->getNumTotal())) {
|
||||||
setFrames(); // Regen the list of screens
|
setFrames(); // Regen the list of screens
|
||||||
}
|
}
|
||||||
nodeDB.updateGUI = false;
|
nodeDB.updateGUI = false;
|
||||||
|
19
src/main.cpp
19
src/main.cpp
@ -290,14 +290,6 @@ void setup()
|
|||||||
|
|
||||||
// Initialize the screen first so we can show the logo while we start up everything else.
|
// Initialize the screen first so we can show the logo while we start up everything else.
|
||||||
screen = new graphics::Screen(SSD1306_ADDRESS);
|
screen = new graphics::Screen(SSD1306_ADDRESS);
|
||||||
#if defined(ST7735_CS) || defined(HAS_EINK)
|
|
||||||
screen->setup();
|
|
||||||
#else
|
|
||||||
if (ssd1306_found)
|
|
||||||
screen->setup();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
screen->print("Started...\n");
|
|
||||||
|
|
||||||
readFromRTC(); // read the main CPU RTC at first (in case we can't get GPS time)
|
readFromRTC(); // read the main CPU RTC at first (in case we can't get GPS time)
|
||||||
|
|
||||||
@ -338,6 +330,17 @@ void setup()
|
|||||||
|
|
||||||
service.init();
|
service.init();
|
||||||
|
|
||||||
|
// Don't call screen setup until after nodedb is setup (because we need
|
||||||
|
// the current region name)
|
||||||
|
#if defined(ST7735_CS) || defined(HAS_EINK)
|
||||||
|
screen->setup();
|
||||||
|
#else
|
||||||
|
if (ssd1306_found)
|
||||||
|
screen->setup();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
screen->print("Started...\n");
|
||||||
|
|
||||||
// We have now loaded our saved preferences from flash
|
// We have now loaded our saved preferences from flash
|
||||||
|
|
||||||
// ONCE we will factory reset the GPS for bug #327
|
// ONCE we will factory reset the GPS for bug #327
|
||||||
|
@ -17,3 +17,6 @@ struct RegionInfo {
|
|||||||
};
|
};
|
||||||
|
|
||||||
extern const RegionInfo regions[];
|
extern const RegionInfo regions[];
|
||||||
|
extern const RegionInfo *myRegion;
|
||||||
|
|
||||||
|
extern void initRegion();
|
@ -245,6 +245,9 @@ void NodeDB::init()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update the global myRegion
|
||||||
|
initRegion();
|
||||||
|
|
||||||
strncpy(myNodeInfo.firmware_version, optstr(APP_VERSION), sizeof(myNodeInfo.firmware_version));
|
strncpy(myNodeInfo.firmware_version, optstr(APP_VERSION), sizeof(myNodeInfo.firmware_version));
|
||||||
strncpy(myNodeInfo.hw_model, HW_VENDOR, sizeof(myNodeInfo.hw_model));
|
strncpy(myNodeInfo.hw_model, HW_VENDOR, sizeof(myNodeInfo.hw_model));
|
||||||
|
|
||||||
|
@ -26,7 +26,20 @@ const RegionInfo regions[] = {
|
|||||||
RDEF(Unset, 903.08f, 2.16f, 13, 0) // Assume US freqs if unset, Must be last
|
RDEF(Unset, 903.08f, 2.16f, 13, 0) // Assume US freqs if unset, Must be last
|
||||||
};
|
};
|
||||||
|
|
||||||
static const RegionInfo *myRegion;
|
const RegionInfo *myRegion;
|
||||||
|
|
||||||
|
void initRegion()
|
||||||
|
{
|
||||||
|
if (!myRegion) {
|
||||||
|
const RegionInfo *r = regions;
|
||||||
|
for (; r->code != RegionCode_Unset && r->code != radioConfig.preferences.region; r++)
|
||||||
|
;
|
||||||
|
myRegion = r;
|
||||||
|
DEBUG_MSG("Wanted region %d, using %s\n", radioConfig.preferences.region, r->name);
|
||||||
|
|
||||||
|
myNodeInfo.num_channels = myRegion->numChannels; // Tell our android app how many channels we have
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ## LoRaWAN for North America
|
* ## LoRaWAN for North America
|
||||||
@ -95,16 +108,6 @@ RadioInterface::RadioInterface()
|
|||||||
{
|
{
|
||||||
assert(sizeof(PacketHeader) == 4 || sizeof(PacketHeader) == 16); // make sure the compiler did what we expected
|
assert(sizeof(PacketHeader) == 4 || sizeof(PacketHeader) == 16); // make sure the compiler did what we expected
|
||||||
|
|
||||||
if (!myRegion) {
|
|
||||||
const RegionInfo *r = regions;
|
|
||||||
for (; r->code != RegionCode_Unset && r->code != radioConfig.preferences.region; r++)
|
|
||||||
;
|
|
||||||
myRegion = r;
|
|
||||||
DEBUG_MSG("Wanted region %d, using %s\n", radioConfig.preferences.region, r->name);
|
|
||||||
|
|
||||||
myNodeInfo.num_channels = myRegion->numChannels; // Tell our android app how many channels we have
|
|
||||||
}
|
|
||||||
|
|
||||||
// Can't print strings this early - serial not setup yet
|
// Can't print strings this early - serial not setup yet
|
||||||
// DEBUG_MSG("Set meshradio defaults name=%s\n", channelSettings.name);
|
// DEBUG_MSG("Set meshradio defaults name=%s\n", channelSettings.name);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user