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 -1
View File
@@ -62,7 +62,7 @@ set(LUA_EXPORT lua_export_nv14)
set(TOUCH_DRIVER touch_driver.cpp)
set(HARDWARE_TOUCH YES)
set(RADIO_DEPENDENCIES ${RADIO_DEPENDENCIES} ${BITMAPS_TARGET} truetype_fonts)
set(RADIO_DEPENDENCIES ${RADIO_DEPENDENCIES} ${BITMAPS_TARGET})
set(FIRMWARE_DEPENDENCIES datacopy)
set(HARDWARE_TOUCH ON)
+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()
{
@@ -188,9 +188,3 @@ void handle_battery_charge(uint32_t last_press_time)
}
#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)) / 2942);
}
+9 -1
View File
@@ -19,13 +19,21 @@
* GNU General Public License for more details.
*/
#include "opentx.h"
#include "board.h"
#include "globals.h"
#include "sdcard.h"
#include "touch.h"
#include "debug.h"
#include "hal/adc_driver.h"
#include "stm32_hal_adc.h"
#include "timers_driver.h"
#include "bitmapbuffer.h"
#include "colors.h"
#include <string.h>
#if defined(__cplusplus) && !defined(SIMU)
extern "C" {
#endif
+2 -5
View File
@@ -403,18 +403,13 @@ const etx_serial_port_t* auxSerialGetPort(int port_nr);
#define LCD_DEPTH 16
#define LCD_CONTRAST_DEFAULT 20
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();
void lcdOff();
void lcdOn();
#define lcdSetRefVolt(...)
#define lcdRefreshWait(...)
// Backlight driver
@@ -521,4 +516,6 @@ bool touchPanelEventOccured();
struct TouchState touchPanelRead();
struct TouchState getInternalTouchState();
#define BATTERY_DIVIDER 2942
#endif // _BOARD_H_
@@ -19,10 +19,14 @@
* GNU General Public License for more details.
*/
#include "opentx.h"
#include "board.h"
#include "fw_version.h"
#include "../../common/arm/stm32/bootloader/boot.h"
#include "../../common/arm/stm32/bootloader/bin_files.h"
#include <lvgl/lvgl.h>
#define SELECTED_COLOR (INVERS | COLOR_THEME_SECONDARY1)
#define DEFAULT_PADDING 28
#define DOUBLE_PADDING 56
@@ -73,10 +77,69 @@ const uint8_t LBM_OK[] = {
#define BL_FOREGROUND COLOR2FLAGS(WHITE)
#define BL_SELECTED COLOR2FLAGS(RGB(11, 65, 244)) // deep blue
extern BitmapBuffer * lcdFront;
extern BitmapBuffer * lcd;
static lv_disp_t* disp = nullptr;
static lv_disp_drv_t disp_drv;
static lv_disp_draw_buf_t disp_buf;
void newLcdRefresh(uint16_t* buffer, const rect_t& copy_area);
static void flushLcd(lv_disp_drv_t * disp_drv, const lv_area_t * area, lv_color_t * color_p)
{
lv_area_t refr_area;
lv_area_copy(&refr_area, area);
#if defined(LCD_VERTICAL_INVERT)
lv_coord_t tmp_coord;
tmp_coord = refr_area.y2;
refr_area.y2 = LCD_H - refr_area.y1 - 1;
refr_area.y1 = LCD_H - tmp_coord - 1;
tmp_coord = refr_area.x2;
refr_area.x2 = LCD_W - refr_area.x1 - 1;
refr_area.x1 = LCD_W - tmp_coord - 1;
#endif
if (refr_area.x1 != 0 || refr_area.x2 != 479 || refr_area.y1 != 0 ||
refr_area.y2 != 271) {
TRACE("partial refresh @ 0x%p {%d,%d,%d,%d}", color_p, refr_area.x1,
refr_area.y1, refr_area.x2, refr_area.y2);
} else {
TRACE("full refresh @ 0x%p", color_p);
}
rect_t copy_area = {refr_area.x1, refr_area.y1,
refr_area.x2 - refr_area.x1 + 1,
refr_area.y2 - refr_area.y1 + 1};
newLcdRefresh((uint16_t*)color_p, copy_area);
lv_disp_flush_ready(disp_drv);
}
static void init_disp_drv()
{
lv_disp_draw_buf_init(&disp_buf, lcdFront->getData(), lcd->getData(), LCD_W*LCD_H);
lv_disp_drv_init(&disp_drv); /*Basic initialization*/
disp_drv.draw_buf = &disp_buf; /*Set an initialized buffer*/
disp_drv.flush_cb = flushLcd; /*Set a flush callback to draw to the display*/
disp_drv.hor_res = LCD_W; /*Set the horizontal resolution in pixels*/
disp_drv.ver_res = LCD_H; /*Set the vertical resolution in pixels*/
disp_drv.full_refresh = 0;
disp_drv.direct_mode = 0;
#if defined (LCD_VERTICAL_INVERT)
disp_drv.rotated = LV_DISP_ROT_180;
#endif
disp_drv.sw_rotate = 1;
// Register the driver and save the created display objects
disp = lv_disp_drv_register(&disp_drv);
}
void bootloaderInitScreen()
{
backlightEnable(BACKLIGHT_LEVEL_MAX);
// TODO: init LVGL
lv_init();
init_disp_drv();
}
static void bootloaderDrawTitle(const char* text)
+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>
// TODO share this with Horus (and perhaps other STM32)
/*-----------------------------------------------------------------------*/
@@ -325,6 +326,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 EXTERNAL_MODULE_ON()
{
+1 -1
View File
@@ -19,7 +19,7 @@
* GNU General Public License for more details.
*/
#include "opentx.h"
#include "board.h"
void hapticOff(void)
{
+8 -24
View File
@@ -19,9 +19,16 @@
* GNU General Public License for more details.
*/
#include "opentx.h"
#include "opentx_types.h"
#include "board.h"
#include "keys.h"
#include "hal/adc_driver.h"
#if defined(LUA)
#include "lua/lua_api.h"
#endif
bool trimsAsButtons = false;
void setTrimsAsButtons(bool val) { trimsAsButtons = val; }
@@ -106,29 +113,6 @@ bool keyDown()
return readKeys() || readTrims();
}
/* TODO common to ARM */
void readKeysAndTrims()
{
int i;
uint8_t index = 0;
uint32_t in = readKeys();
uint32_t trims = readTrims();
for (i = 0; i < TRM_BASE; i++) {
keys[index++].input(in & (1 << i));
}
for (i = 1; i <= 1 << (TRM_LAST-TRM_BASE); i <<= 1) {
keys[index++].input(trims & i);
}
if ((in || trims) && (g_eeGeneral.backlightMode & e_backlight_mode_keys)) {
// on keypress turn the light on
resetBacklightTimeout();
}
}
#if !defined(BOOT)
uint32_t switchState(uint8_t index)
{
+3 -1
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"
#define LCD_FIRST_LAYER 0
#define LCD_SECOND_LAYER 1