bootloader: display fork version

This commit is contained in:
Raphael Coeffic
2021-05-23 19:09:42 +02:00
parent 20f5f3c4d1
commit f97843c746
5 changed files with 13 additions and 5 deletions
+2 -1
View File
@@ -85,7 +85,8 @@ const char * getFirmwareVersion(const char * buffer)
}
for (int i = 0; i < 1024; i++) {
if (memcmp(buffer + i, "edgetx-", 7) == 0) {
if ((memcmp(buffer + i, "edgetx-", 7) == 0)
|| memcmp(buffer + i, "opentx-", 7) == 0) {
return buffer + i;
}
}
@@ -121,15 +121,19 @@ void extractFirmwareVersion(VersionTag* tag)
if (!vers || (vers[0] == 'n' && vers[1] == 'o')) { // "no version found"
memcpy(tag->flavour, "unknown", sizeof("unknown"));
tag->version = "unknown";
return;
}
// skip "opentx-"
vers += sizeof("opentx-") - 1;
tag->fork = vers;
// skip 'edgetx-' / 'opentx-'
vers += sizeof("edgetx-") - 1;
char* fl = tag->flavour;
while(*vers != '-')
*(fl++) = *(vers++);
// skip '-'
tag->version = ++vers;
}
@@ -72,6 +72,7 @@ struct VersionTag
{
char flavour[8];
const char* version;
const char* fork;
};
// Can be called right after openBinFile() to extract the version information
@@ -435,7 +435,6 @@ int main()
state = ST_FLASHING;
}
}
else if (state == ST_FLASHING) {
// commit to flashing
if (!unlocked && (memoryType == MEM_FLASH)) {
@@ -150,7 +150,6 @@ void bootloaderDrawScreen(BootloaderState st, int opt, const char* str)
lcd->drawBitmapPattern(356, 158, LBM_ERROR, BL_RED);
}
else if (st == ST_FLASH_CHECK) {
bootloaderDrawFilename(str, 0, true);
if (opt == FC_ERROR) {
@@ -159,8 +158,12 @@ void bootloaderDrawScreen(BootloaderState st, int opt, const char* str)
}
else if (opt == FC_OK) {
VersionTag tag;
memset(&tag, 0, sizeof(tag));
extractFirmwareVersion(&tag);
lcd->drawText(168, 138, "Fork:", RIGHT | BL_FOREGROUND);
lcd->drawSizedText(174, 138, tag.fork, 6, BL_FOREGROUND);
lcd->drawText(168, 158, "Version:", RIGHT | BL_FOREGROUND);
lcd->drawText(174, 158, tag.version, BL_FOREGROUND);