Remove legacy fonts and make the bootloader compile with LVGL

This commit is contained in:
Raphael Coeffic
2022-06-11 15:38:08 +02:00
committed by Raphael Coeffic
parent 0404919667
commit ee0c37157d
74 changed files with 2027 additions and 775 deletions
-1
View File
@@ -179,7 +179,6 @@ add_definitions(-DPCBREV_${PCBREV})
set(RADIO_DEPENDENCIES
${RADIO_DEPENDENCIES}
${BITMAPS_TARGET}
truetype_fonts
)
set(FIRMWARE_DEPENDENCIES datacopy)
+2 -1
View File
@@ -19,7 +19,8 @@
* GNU General Public License for more details.
*/
#include "opentx.h"
#include "opentx_types.h"
#include "board.h"
void backlightInit()
{
+6 -14
View File
@@ -20,13 +20,17 @@
*/
#include "stm32_hal_ll.h"
#include "opentx.h"
#include "hal/adc_driver.h"
#include "hal/serial_driver.h"
#include "hal/serial_port.h"
#include "board.h"
#include "timers_driver.h"
#include "dataconstants.h"
#include "opentx_types.h"
#include "globals.h"
#include "sdcard.h"
#include "debug.h"
#if defined(AUX_SERIAL) || defined(AUX2_SERIAL)
#include "aux_serial_driver.h"
@@ -317,18 +321,6 @@ void boardOff()
}
}
#if defined (RADIO_TX16S)
#define BATTERY_DIVIDER 1495
#else
#define BATTERY_DIVIDER 1629
#endif
uint16_t getBatteryVoltage()
{
int32_t instant_vbat = anaIn(TX_VOLTAGE); // using filtered ADC value on purpose
return (uint16_t)((instant_vbat * (1000 + g_eeGeneral.txVoltageCalibration)) / BATTERY_DIVIDER);
}
bool isBacklightEnabled()
{
if(globalData.unexpectedShutdown)
+10 -6
View File
@@ -24,6 +24,10 @@
#include "definitions.h"
#include "opentx_constants.h"
// Defines used in board_common.h
#define ROTARY_ENCODER_NAVIGATION
#include "board_common.h"
#include "hal.h"
#include "hal/serial_port.h"
@@ -310,7 +314,6 @@ uint32_t readTrims();
#define TRIMS_PRESSED() (readTrims())
// Rotary encoder driver
#define ROTARY_ENCODER_NAVIGATION
void rotaryEncoderInit();
void rotaryEncoderCheck();
@@ -530,17 +533,12 @@ void ledBlue();
#define LCD_PHYS_W LCD_W
#define LCD_DEPTH 16
void lcdInit();
void lcdRefresh();
void lcdCopy(void * dest, void * src);
void DMAFillRect(uint16_t * dest, uint16_t destw, uint16_t desth, uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t color);
void DMACopyBitmap(uint16_t * dest, uint16_t destw, uint16_t desth, uint16_t x, uint16_t y, const uint16_t * src, uint16_t srcw, uint16_t srch, uint16_t srcx, uint16_t srcy, uint16_t w, uint16_t h);
void DMACopyAlphaBitmap(uint16_t * dest, uint16_t destw, uint16_t desth, uint16_t x, uint16_t y, const uint16_t * src, uint16_t srcw, uint16_t srch, uint16_t srcx, uint16_t srcy, uint16_t w, uint16_t h);
void DMABitmapConvert(uint16_t * dest, const uint8_t * src, uint16_t w, uint16_t h, uint32_t format);
void lcdStoreBackupBuffer();
int lcdRestoreBackupBuffer();
void lcdSetContrast();
#define lcdOff() backlightEnable(0) /* just disable the backlight */
#define lcdSetRefVolt(...)
#define lcdRefreshWait(...)
// Backlight driver
@@ -677,4 +675,10 @@ void bluetoothWriteWakeup();
uint8_t bluetoothIsWriting();
void bluetoothDisable();
#if defined (RADIO_TX16S)
#define BATTERY_DIVIDER 1495
#else
#define BATTERY_DIVIDER 1629
#endif
#endif // _BOARD_H_
@@ -19,9 +19,14 @@
* GNU General Public License for more details.
*/
#include "opentx.h"
#include "../../common/arm/stm32/bootloader/boot.h"
#include "../../common/arm/stm32/bootloader/bin_files.h"
#include "board.h"
#include "fw_version.h"
#include "lcd.h"
#include "targets/common/arm/stm32/bootloader/boot.h"
#include "targets/common/arm/stm32/bootloader/bin_files.h"
#include <lvgl/lvgl.h>
const uint8_t __bmp_plug_usb_rle[] {
#include "bmp_plug_usb.lbm"
@@ -38,26 +43,12 @@ const uint8_t __bmp_background_rle[] {
};
RLEBitmap BMP_BACKGROUND(BMP_ARGB4444, __bmp_background_rle);
const uint8_t LBM_FLASH[] = {
#include "icon_flash.lbm"
};
const uint8_t LBM_EXIT[] = {
#include "icon_exit.lbm"
};
const uint8_t LBM_SD[] = {
#include "icon_sd.lbm"
};
//TODO: replace with LV_SYMBOL_FILE
const uint8_t LBM_FILE[] = {
#include "icon_file.lbm"
};
const uint8_t LBM_ERROR[] = {
#include "icon_error.lbm"
};
//TODO: replace with LV_SYMBOL_OK
const uint8_t LBM_OK[] = {
#include "icon_ok.lbm"
};
@@ -68,11 +59,12 @@ const uint8_t LBM_OK[] = {
#define BL_FOREGROUND COLOR2FLAGS(WHITE)
#define BL_SELECTED COLOR2FLAGS(RGB(11, 65, 244)) // deep blue
extern BitmapBuffer * lcd;
void bootloaderInitScreen()
{
backlightEnable(BACKLIGHT_LEVEL_MAX);
// TODO: init LVGL
lcdInitDisplayDriver();
}
static void bootloaderDrawTitle(unsigned int x, const char* text)
@@ -113,18 +105,21 @@ static void bootloaderDrawBackground()
void bootloaderDrawScreen(BootloaderState st, int opt, const char* str)
{
lcdInitDirectDrawing();
bootloaderDrawBackground();
if (st == ST_START) {
bootloaderDrawTitle(88, BOOTLOADER_TITLE);
bootloaderDrawTitle(88, BOOTLOADER_TITLE);
lcd->drawBitmapPattern(90, 72, LBM_FLASH, BL_FOREGROUND);
lcd->drawText(124, 75, "Write Firmware", BL_FOREGROUND);
lcd->drawText(102, 75, LV_SYMBOL_CHARGE, BL_FOREGROUND);
coord_t pos = lcd->drawText(124, 75, "Write Firmware", BL_FOREGROUND);
pos += 8;
lcd->drawBitmapPattern(90, 107, LBM_EXIT, BL_FOREGROUND);
lcd->drawText(100, 110, LV_SYMBOL_NEW_LINE, BL_FOREGROUND);
lcd->drawText(124, 110, "Exit", BL_FOREGROUND);
lcd->drawSolidRect(119, (opt == 0) ? 72 : 107, 270, 26, 2, BL_SELECTED);
pos -= 92;
lcd->drawSolidRect(92, (opt == 0) ? 72 : 107, pos, 26, 2, BL_SELECTED);
lcd->drawBitmap(60, 166, &BMP_PLUG_USB);
lcd->drawText(195, 175, "Or plug in a USB cable", BL_FOREGROUND);
@@ -141,62 +136,55 @@ void bootloaderDrawScreen(BootloaderState st, int opt, const char* str)
else if (st == ST_FILE_LIST || st == ST_DIR_CHECK || st == ST_FLASH_CHECK ||
st == ST_FLASHING || st == ST_FLASH_DONE) {
bootloaderDrawTitle(126, "SD>FIRMWARE");
lcd->drawBitmapPattern(87, 16, LBM_SD, BL_FOREGROUND);
bootloaderDrawTitle(88, LV_SYMBOL_SD_CARD " /FIRMWARE");
if (st == ST_FLASHING || st == ST_FLASH_DONE) {
LcdFlags color = BL_RED;
LcdFlags color = BL_RED;
if (st == ST_FLASH_DONE) {
color = BL_GREEN;
opt = 100; // Completed > 100%
}
if (st == ST_FLASH_DONE) {
color = BL_GREEN;
opt = 100; // Completed > 100%
}
lcd->drawRect(70, 120, 340, 31, 2, SOLID, BL_SELECTED);
lcd->drawSolidFilledRect(74, 124, (332 * opt) / 100, 23, color);
} else if (st == ST_DIR_CHECK) {
if (opt == FR_NO_PATH) {
lcd->drawText(90, 168, LV_SYMBOL_CLOSE " Directory is missing",
BL_FOREGROUND);
} else {
lcd->drawText(90, 168, LV_SYMBOL_CLOSE " Directory is empty",
BL_FOREGROUND);
}
} else if (st == ST_FLASH_CHECK) {
bootloaderDrawFilename(str, 0, true);
lcd->drawRect(70, 120, 340, 31, 2, SOLID, BL_SELECTED);
lcd->drawSolidFilledRect(74, 124, (332 * opt) / 100, 23, color);
if (opt == FC_ERROR) {
lcd->drawText(94, 168, LV_SYMBOL_CLOSE " " STR_INVALID_FIRMWARE,
BL_FOREGROUND);
} 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);
lcd->drawText(168, 178, "Radio:", RIGHT | BL_FOREGROUND);
lcd->drawText(174, 178, tag.flavour, BL_FOREGROUND);
lcd->drawBitmapPattern(356, 158, LBM_OK, BL_GREEN);
}
}
else if (st == ST_DIR_CHECK) {
if (opt == FR_NO_PATH) {
lcd->drawText(90, 168, "Directory is missing", BL_FOREGROUND);
}
else {
lcd->drawText(90, 168, "Directory is empty", BL_FOREGROUND);
}
lcd->drawBitmapPattern(356, 158, LBM_ERROR, BL_RED);
}
else if (st == ST_FLASH_CHECK) {
bootloaderDrawFilename(str, 0, true);
if (opt == FC_ERROR) {
lcd->drawText(94, 168, STR_INVALID_FIRMWARE, BL_FOREGROUND);
lcd->drawBitmapPattern(356, 158, LBM_ERROR, BL_RED);
}
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);
lcd->drawText(168, 178, "Radio:", RIGHT | BL_FOREGROUND);
lcd->drawText(174, 178, tag.flavour, BL_FOREGROUND);
lcd->drawBitmapPattern(356, 158, LBM_OK, BL_GREEN);
}
}
bootloaderDrawFooter();
if ( st != ST_DIR_CHECK && (st != ST_FLASH_CHECK || opt == FC_OK)) {
lcd->drawBitmapPattern(28, 242, LBM_FLASH, BL_FOREGROUND);
lcd->drawText(28, 242, LV_SYMBOL_CHARGE, BL_FOREGROUND);
if (st == ST_FILE_LIST) {
lcd->drawText(56, 244, "[ENT] to select file", BL_FOREGROUND);
@@ -213,14 +201,11 @@ void bootloaderDrawScreen(BootloaderState st, int opt, const char* str)
}
if (st != ST_FLASHING) {
lcd->drawBitmapPattern(305, 242, LBM_EXIT, BL_FOREGROUND);
//lcd->drawBitmapPattern(305, 242, LBM_EXIT, BL_FOREGROUND);
lcd->drawText(305, 244, LV_SYMBOL_NEW_LINE, BL_FOREGROUND);
lcd->drawText(335, 244, "[RTN] to exit", BL_FOREGROUND);
}
}
// wait for next frame
// while ((LTDC->CDSR & LTDC_CDSR_VSYNCS) == 0);
// while ((LTDC->CDSR & LTDC_CDSR_VSYNCS) != 0);
}
void bootloaderDrawFilename(const char* str, uint8_t line, bool selected)
+8 -2
View File
@@ -26,10 +26,11 @@
/*-----------------------------------------------------------------------*/
#include "diskio.h"
#include <string.h>
#include "opentx.h"
#include "debug.h"
#include "targets/common/arm/stm32/sdio_sd.h"
#include <string.h>
/*-----------------------------------------------------------------------*/
/* Lock / unlock functions */
/*-----------------------------------------------------------------------*/
@@ -328,6 +329,11 @@ void sdInit(void)
}
}
#else
#include "audio.h"
#include "sdcard.h"
#include "disk_cache.h"
void sdInit()
{
TRACE("sdInit");
+1 -1
View File
@@ -19,7 +19,7 @@
* GNU General Public License for more details.
*/
#include "opentx.h"
#include "board.h"
void hapticOff(void)
{
+3 -23
View File
@@ -19,7 +19,9 @@
* GNU General Public License for more details.
*/
#include "opentx.h"
#include "opentx_types.h"
#include "board.h"
#include "keys.h"
uint32_t readKeys()
{
@@ -90,28 +92,6 @@ bool keyDown()
return readKeys() || readTrims();
}
/* TODO common to ARM */
void readKeysAndTrims()
{
uint32_t i;
uint8_t index = 0;
uint32_t keys_input = readKeys();
for (i = 0; i < TRM_BASE; i++) {
keys[index++].input(keys_input & (1 << i));
}
uint32_t trims_input = readTrims();
for (i = 1; i <= 1 << (TRM_LAST-TRM_BASE); i <<= 1) {
keys[index++].input(trims_input & i);
}
if ((keys_input || trims_input) && (g_eeGeneral.backlightMode & e_backlight_mode_keys)) {
// on keypress turn the light on
resetBacklightTimeout();
}
}
#define ADD_2POS_CASE(x) \
case SW_S ## x ## 0: \
xxx = SWITCHES_GPIO_REG_ ## x & SWITCHES_GPIO_PIN_ ## x ; \
+6 -7
View File
@@ -19,7 +19,9 @@
* GNU General Public License for more details.
*/
#include "opentx.h"
#include "opentx_types.h"
#include "libopenui_config.h"
#include "lcd.h"
#if defined(RADIO_T18)
#define HBP 43
@@ -279,7 +281,7 @@ void LCD_LayerInit()
Active high width = LCD_W
number of bytes per pixel = 2 (pixel_format : RGB565)
*/
LTDC_Layer_InitStruct.LTDC_CFBLineLength = ((LCD__PHYS_W * 2) + 3);
LTDC_Layer_InitStruct.LTDC_CFBLineLength = ((LCD_PHYS_W * 2) + 3);
/* the pitch is the increment from the start of one line of pixels to the
start of the next line in bytes, then :
Pitch = Active high width x number of bytes per pixel */
@@ -657,8 +659,9 @@ static void lcdSwitchLayers()
while(_frameBufferAddressReloaded == 0);
}
void newLcdRefresh(uint16_t * buffer)
void newLcdRefresh(uint16_t * buffer, const rect_t& refr_area)
{
(void)refr_area;
#if 0
lcdSwitchLayers();
#else
@@ -669,7 +672,3 @@ void newLcdRefresh(uint16_t * buffer)
#endif
}
void lcdRefresh()
{
//lcdSwitchLayers();
}
+1 -1
View File
@@ -19,7 +19,7 @@
* GNU General Public License for more details.
*/
#include "opentx.h"
#include "board.h"
void ledInit()
{
@@ -19,7 +19,7 @@
* GNU General Public License for more details.
*/
#include "opentx.h"
#include "board.h"
void usbChargerInit()
{
@@ -34,6 +34,8 @@ void usbChargerInit()
bool usbChargerLed()
{
return GPIO_ReadInputDataBit(USB_CHARGER_GPIO, USB_USBDet_GPIO_PIN) == 0 ? 0 : GPIO_ReadInputDataBit(USB_CHARGER_GPIO, USB_CHARGER_GPIO_PIN) == Bit_RESET;
}
if (GPIO_ReadInputDataBit(USB_CHARGER_GPIO, USB_USBDet_GPIO_PIN) == 0)
return 0;
return GPIO_ReadInputDataBit(USB_CHARGER_GPIO, USB_CHARGER_GPIO_PIN) == Bit_RESET;
}