mirror of
https://github.com/opentx/opentx.git
synced 2025-07-25 01:05:10 +03:00
Bootloader cosmetics
This commit is contained in:
parent
18461a3b28
commit
24cd7611cf
10 changed files with 64 additions and 67 deletions
|
@ -116,7 +116,6 @@ void lcdPutPattern(coord_t x, coord_t y, const uint8_t * pattern, uint8_t width,
|
|||
}
|
||||
}
|
||||
|
||||
#if !defined(BOOT)
|
||||
struct PatternData
|
||||
{
|
||||
uint8_t width;
|
||||
|
@ -143,6 +142,7 @@ uint8_t getPatternWidth(const PatternData * pattern)
|
|||
|
||||
void getCharPattern(PatternData * pattern, unsigned char c, LcdFlags flags)
|
||||
{
|
||||
#if !defined(BOOT)
|
||||
uint32_t fontsize = FONTSIZE(flags);
|
||||
unsigned char c_remapped = 0;
|
||||
|
||||
|
@ -203,6 +203,11 @@ void getCharPattern(PatternData * pattern, unsigned char c, LcdFlags flags)
|
|||
pattern->height = 7;
|
||||
pattern->data = (c < 0xC0) ? &font_5x7[(c-0x20)*5] : &font_5x7_extra[(c-0xC0)*5];
|
||||
}
|
||||
#else
|
||||
pattern->width = 5;
|
||||
pattern->height = 7;
|
||||
pattern->data = &font_5x7[(c-0x20)*5];
|
||||
#endif
|
||||
}
|
||||
|
||||
uint8_t getCharWidth(char c, LcdFlags flags)
|
||||
|
@ -211,7 +216,6 @@ uint8_t getCharWidth(char c, LcdFlags flags)
|
|||
getCharPattern(&pattern, c, flags);
|
||||
return getPatternWidth(&pattern);
|
||||
}
|
||||
#endif
|
||||
|
||||
void lcdDrawChar(coord_t x, coord_t y, const unsigned char c, LcdFlags flags)
|
||||
{
|
||||
|
@ -288,12 +292,15 @@ void lcdDrawChar(coord_t x, coord_t y, const unsigned char c)
|
|||
lcdDrawChar(x, y, c, 0);
|
||||
}
|
||||
|
||||
#if !defined(BOOT)
|
||||
uint8_t getTextWidth(const char * s, uint8_t len, LcdFlags flags)
|
||||
{
|
||||
uint8_t width = 0;
|
||||
for (int i = 0; len == 0 || i < len; ++i) {
|
||||
#if !defined(BOOT)
|
||||
unsigned char c = (flags & ZCHAR) ? zchar2char(*s) : *s;
|
||||
#else
|
||||
unsigned char c = *s;
|
||||
#endif
|
||||
if (!c) {
|
||||
break;
|
||||
}
|
||||
|
@ -302,7 +309,6 @@ uint8_t getTextWidth(const char * s, uint8_t len, LcdFlags flags)
|
|||
}
|
||||
return width;
|
||||
}
|
||||
#endif
|
||||
|
||||
void lcdDrawSizedText(coord_t x, coord_t y, const char * s, uint8_t len, LcdFlags flags)
|
||||
{
|
||||
|
@ -311,7 +317,6 @@ void lcdDrawSizedText(coord_t x, coord_t y, const char * s, uint8_t len, LcdFlag
|
|||
const uint8_t orig_len = len;
|
||||
uint32_t fontsize = FONTSIZE(flags);
|
||||
|
||||
#if !defined(BOOT)
|
||||
uint8_t width = 0;
|
||||
if (flags & RIGHT) {
|
||||
width = getTextWidth(s, len, flags);
|
||||
|
@ -321,7 +326,6 @@ void lcdDrawSizedText(coord_t x, coord_t y, const char * s, uint8_t len, LcdFlag
|
|||
width = getTextWidth(s, len, flags);
|
||||
x -= width / 2;
|
||||
}
|
||||
#endif
|
||||
|
||||
bool setx = false;
|
||||
while (len--) {
|
||||
|
|
|
@ -44,7 +44,7 @@ typedef uint8_t display_t;
|
|||
#define BLINK 0x01
|
||||
#define INVERS 0x02
|
||||
#if defined(BOLD_FONT)
|
||||
#define BOLD 0x40
|
||||
#define BOLD 0x40u
|
||||
#else
|
||||
#define BOLD 0x00
|
||||
#endif
|
||||
|
@ -55,7 +55,7 @@ typedef uint8_t display_t;
|
|||
#define FIXEDWIDTH 0x10
|
||||
/* no 0x80 here because of "GV"1 which is aligned LEFT */
|
||||
/* no 0x10 here because of "MODEL"01 which uses LEADING0 */
|
||||
#define ZCHAR 0x80
|
||||
#define ZCHAR 0x80u
|
||||
|
||||
/* lcdDrawNumber additional flags */
|
||||
#define LEADING0 0x10
|
||||
|
|
|
@ -149,9 +149,9 @@ void lcdPutPattern(coord_t x, coord_t y, const uint8_t * pattern, uint8_t width,
|
|||
}
|
||||
}
|
||||
|
||||
#if !defined(BOOT)
|
||||
void getCharPattern(PatternData * pattern, unsigned char c, LcdFlags flags)
|
||||
{
|
||||
#if !defined(BOOT)
|
||||
uint32_t fontsize = FONTSIZE(flags);
|
||||
unsigned char c_remapped = 0;
|
||||
|
||||
|
@ -212,6 +212,11 @@ void getCharPattern(PatternData * pattern, unsigned char c, LcdFlags flags)
|
|||
pattern->height = 7;
|
||||
pattern->data = (c < 0xC0) ? &font_5x7[(c-0x20)*5] : &font_5x7_extra[(c-0xC0)*5];
|
||||
}
|
||||
#else
|
||||
pattern->width = 5;
|
||||
pattern->height = 7;
|
||||
pattern->data = &font_5x7[(c-0x20) * 5];
|
||||
#endif
|
||||
}
|
||||
|
||||
uint8_t getCharWidth(char c, LcdFlags flags)
|
||||
|
@ -220,7 +225,6 @@ uint8_t getCharWidth(char c, LcdFlags flags)
|
|||
getCharPattern(&pattern, c, flags);
|
||||
return getPatternWidth(&pattern);
|
||||
}
|
||||
#endif
|
||||
|
||||
void lcdDrawChar(coord_t x, coord_t y, const unsigned char c, LcdFlags flags)
|
||||
{
|
||||
|
@ -240,12 +244,15 @@ void lcdDrawChar(coord_t x, coord_t y, const unsigned char c)
|
|||
lcdDrawChar(x, y, c, 0);
|
||||
}
|
||||
|
||||
#if !defined(BOOT)
|
||||
uint8_t getTextWidth(const char * s, uint8_t len, LcdFlags flags)
|
||||
{
|
||||
uint8_t width = 0;
|
||||
for (int i = 0; len == 0 || i < len; ++i) {
|
||||
#if !defined(BOOT)
|
||||
unsigned char c = (flags & ZCHAR) ? zchar2char(*s) : *s;
|
||||
#else
|
||||
unsigned char c = *s;
|
||||
#endif
|
||||
if (!c) {
|
||||
break;
|
||||
}
|
||||
|
@ -254,7 +261,6 @@ uint8_t getTextWidth(const char * s, uint8_t len, LcdFlags flags)
|
|||
}
|
||||
return width;
|
||||
}
|
||||
#endif
|
||||
|
||||
void lcdDrawSizedText(coord_t x, coord_t y, const char * s, uint8_t len, LcdFlags flags)
|
||||
{
|
||||
|
@ -264,7 +270,6 @@ void lcdDrawSizedText(coord_t x, coord_t y, const char * s, uint8_t len, LcdFlag
|
|||
bool setx = false;
|
||||
uint8_t width = 0;
|
||||
|
||||
#if !defined(BOOT)
|
||||
if (flags & RIGHT) {
|
||||
width = getTextWidth(s, len, flags);
|
||||
x -= width;
|
||||
|
@ -273,7 +278,6 @@ void lcdDrawSizedText(coord_t x, coord_t y, const char * s, uint8_t len, LcdFlag
|
|||
width = getTextWidth(s, len, flags);
|
||||
x -= width / 2;
|
||||
}
|
||||
#endif
|
||||
|
||||
while (len--) {
|
||||
#if defined(BOOT)
|
||||
|
|
|
@ -691,7 +691,7 @@ extern const char vers_stamp[];
|
|||
* @param buffer If non-null find the firmware version in the buffer instead
|
||||
* @return The opentx version string starting with "opentx-" or "no version found" if the version string is not found
|
||||
*/
|
||||
const char * getOtherVersion(char * buffer);
|
||||
const char * getFirmwareVersion(const char * buffer = nullptr);
|
||||
|
||||
#define g_blinkTmr10ms (*(uint8_t*)&g_tmr10ms)
|
||||
|
||||
|
|
|
@ -60,35 +60,29 @@
|
|||
* @return
|
||||
*/
|
||||
#if defined(STM32) && !defined(SIMU)
|
||||
|
||||
__SECTION_USED(".fwversiondata") const char firmware_version[] = "opentx-" FLAVOUR "-" DISPLAY_VERSION " (" GIT_STR ")";
|
||||
__SECTION_USED(".bootversiondata") const char boot_version[] = "opentx-" FLAVOUR "-" DISPLAY_VERSION " (" GIT_STR ")";
|
||||
__SECTION_USED(".fwversiondata") const char firmware_version[] = "opentx-" FLAVOUR "-" VERSION DISPLAY_VERSION " (" GIT_STR ")";
|
||||
__SECTION_USED(".bootversiondata") const char boot_version[] = "opentx-" FLAVOUR "-" VERSION DISPLAY_VERSION " (" GIT_STR ")";
|
||||
|
||||
/**
|
||||
* Tries to find opentx version in the first 1024 byte of either firmware/bootloader (the one not running) or the buffer
|
||||
* @param buffer If non-null find the firmware version in the buffer instead
|
||||
*/
|
||||
const char * getOtherVersion(char* buffer)
|
||||
const char * getFirmwareVersion(const char * buffer)
|
||||
{
|
||||
if (buffer == nullptr) {
|
||||
#if defined(BOOT)
|
||||
const char * startother = (char*)(FIRMWARE_ADDRESS+BOOTLOADER_SIZE);
|
||||
buffer = (const char *)(FIRMWARE_ADDRESS + BOOTLOADER_SIZE);
|
||||
#else
|
||||
const char * startother = (char*)(FIRMWARE_ADDRESS);
|
||||
buffer = (const char *)FIRMWARE_ADDRESS;
|
||||
#endif
|
||||
if (buffer != nullptr)
|
||||
startother = buffer;
|
||||
}
|
||||
|
||||
const char * other_str = nullptr;
|
||||
for (int i = 0; i < 1024; i++) {
|
||||
if (memcmp(startother+i, "opentx-", 7) == 0) {
|
||||
other_str = startother + i;
|
||||
break;
|
||||
if (memcmp(buffer + i, "opentx-", 7) == 0) {
|
||||
return buffer + i;
|
||||
}
|
||||
}
|
||||
|
||||
if (other_str != nullptr)
|
||||
return other_str;
|
||||
else
|
||||
return "no version found";
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -117,7 +117,7 @@ FRESULT openBinFile(MemoryType mt, unsigned int index)
|
|||
|
||||
void extractFirmwareVersion(VersionTag* tag)
|
||||
{
|
||||
const char* vers = getOtherVersion((char*)Block_buffer);
|
||||
const char * vers = getFirmwareVersion((const char *)Block_buffer);
|
||||
if (!vers || (vers[0] == 'n' && vers[1] == 'o')) { // "no version found"
|
||||
memcpy(tag->flavour, "unknown", sizeof("unknown"));
|
||||
tag->version = "unknown";
|
||||
|
|
|
@ -34,12 +34,12 @@
|
|||
#if LCD_W >= 480
|
||||
#define STR_INVALID_FIRMWARE "Not a valid firmware file"
|
||||
#elif LCD_W >= 212
|
||||
#define STR_OR_PLUGIN_USB_CABLE INDENT "Or plug in a USB cable for mass storage"
|
||||
#define STR_OR_PLUGIN_USB_CABLE "Or plug in a USB cable for mass storage"
|
||||
#define STR_HOLD_ENTER_TO_START "\012Hold [ENT] to start writing"
|
||||
#define STR_INVALID_FIRMWARE "\011Not a valid firmware file! "
|
||||
#define STR_INVALID_EEPROM "\011Not a valid EEPROM file! "
|
||||
#else
|
||||
#define STR_OR_PLUGIN_USB_CABLE INDENT "Or plug in a USB cable"
|
||||
#define STR_OR_PLUGIN_USB_CABLE "Or plug in a USB cable"
|
||||
#define STR_HOLD_ENTER_TO_START "\006Hold [ENT] to start"
|
||||
#define STR_INVALID_FIRMWARE "\004Not a valid firmware! "
|
||||
#define STR_INVALID_EEPROM "\004Not a valid EEPROM! "
|
||||
|
|
|
@ -408,7 +408,7 @@ const FATDirEntry_t g_DIRroot[] =
|
|||
0xA302,
|
||||
0x3D55,
|
||||
0x0002,
|
||||
sizeof(firmware_txt) + strlen(getOtherVersion(nullptr))
|
||||
sizeof(firmware_txt) + strlen(getFirmwareVersion())
|
||||
},
|
||||
{
|
||||
{ 'F', 'I', 'R', 'M', 'W', 'A', 'R', 'E'},
|
||||
|
@ -512,13 +512,11 @@ int32_t fat12Read(uint8_t * buffer, uint16_t sector, uint16_t count)
|
|||
else if (sector == 3) {
|
||||
memcpy(buffer, g_DIRroot, sizeof(g_DIRroot) ) ;
|
||||
}
|
||||
else if (sector == 4)
|
||||
{
|
||||
else if (sector == 4) {
|
||||
memcpy(buffer, firmware_txt, sizeof(firmware_txt));
|
||||
memcpy(buffer + sizeof(firmware_txt), getOtherVersion(nullptr), strlen(getOtherVersion(nullptr)));
|
||||
strcpy((char *)(buffer + sizeof(firmware_txt)), getFirmwareVersion());
|
||||
}
|
||||
else if (sector < RESERVED_SECTORS)
|
||||
{
|
||||
else if (sector < RESERVED_SECTORS) {
|
||||
// allocated to firmware.txt
|
||||
}
|
||||
else if (sector < RESERVED_SECTORS + (FLASHSIZE/BLOCK_SIZE )) {
|
||||
|
|
|
@ -84,7 +84,7 @@ void bootloaderDrawScreen(BootloaderState st, int opt, const char* str)
|
|||
|
||||
bootloaderDrawFooter();
|
||||
lcdDrawText( 36, 242, "Current Firmware:");
|
||||
lcdDrawText(200, 242, getOtherVersion(nullptr));
|
||||
lcdDrawText(200, 242, getFirmwareVersion());
|
||||
}
|
||||
else if (st == ST_USB) {
|
||||
|
||||
|
|
|
@ -21,28 +21,25 @@ void bootloaderDrawFilename(const char *str, uint8_t line, bool selected)
|
|||
void bootloaderDrawScreen(BootloaderState st, int opt, const char *str)
|
||||
{
|
||||
lcdClear();
|
||||
lcdDrawText(0, 0, BOOTLOADER_TITLE, INVERS);
|
||||
lcdDrawText(LCD_W / 2, 0, BOOTLOADER_TITLE, CENTERED);
|
||||
lcdInvertLine(0);
|
||||
|
||||
if (st == ST_START) {
|
||||
lcdDrawTextAlignedLeft(2*FH, "\010Write Firmware");
|
||||
lcdDrawTextAlignedLeft(3*FH, "\010Restore EEPROM");
|
||||
lcdDrawTextAlignedLeft(4*FH, "\010Exit");
|
||||
|
||||
#if LCD_W >= 212
|
||||
lcdDrawTextAlignedLeft(6*FH, "\001Curr FW:");
|
||||
lcdDrawText(50, 6*FH, getOtherVersion(nullptr));
|
||||
#else
|
||||
lcdDrawTextAlignedLeft(6 * FH, "\001FW:");
|
||||
|
||||
// Remove opentx- from string
|
||||
const char *other_ver = getOtherVersion(nullptr);
|
||||
if (strstr(other_ver, "opentx-"))
|
||||
other_ver = other_ver + 7;
|
||||
lcdDrawText(20, 6 * FH, other_ver);
|
||||
#endif
|
||||
|
||||
lcdInvertLine(2 + opt);
|
||||
lcdDrawTextAlignedLeft(7 * FH, STR_OR_PLUGIN_USB_CABLE);
|
||||
|
||||
lcdDrawText(LCD_W / 2, 5 * FH + FH / 2, STR_OR_PLUGIN_USB_CABLE, CENTERED);
|
||||
|
||||
// Remove "opentx-" from string
|
||||
const char * vers = getFirmwareVersion();
|
||||
#if LCD_W < 212
|
||||
if (strncmp(vers, "opentx-", 7) == 0)
|
||||
vers += 7;
|
||||
#endif
|
||||
lcdDrawText(LCD_W / 2, 7 * FH, vers, CENTERED);
|
||||
lcdInvertLine(7);
|
||||
}
|
||||
else if (st == ST_USB) {
|
||||
lcdDrawTextAlignedLeft(4 * FH, STR_USB_CONNECTED);
|
||||
|
@ -65,11 +62,11 @@ void bootloaderDrawScreen(BootloaderState st, int opt, const char *str)
|
|||
}
|
||||
else if (opt == FC_OK) {
|
||||
if (memoryType == MEM_FLASH) {
|
||||
const char * vers = getOtherVersion((char *) Block_buffer);
|
||||
const char * vers = getFirmwareVersion((const char *)Block_buffer);
|
||||
#if LCD_W < 212
|
||||
// Remove opentx- from string
|
||||
if (strstr(vers, "opentx-"))
|
||||
vers = vers + 7;
|
||||
// Remove "opentx-" from string
|
||||
if (strncmp(vers, "opentx-", 7) == 0)
|
||||
vers += 7;
|
||||
#endif
|
||||
bootloaderDrawMsg(INDENT_WIDTH, vers, 0, false);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue