mirror of
https://gitee.com/dlmu-cone/tronone-h7-scaffold
synced 2026-07-23 19:25:09 +08:00
feat: redesign PRTS main menu cards with large icons, black boot screen
This commit is contained in:
@@ -653,13 +653,9 @@ void TFT_ShowBootScreen(void)
|
||||
}
|
||||
|
||||
tft_transfer_ok = true;
|
||||
uint16_t band_h = TFT_LCD_H / 3U;
|
||||
TFT_FillRect(0U, 0U, TFT_LCD_W, band_h, TFT_COLOR_BLUE);
|
||||
TFT_FillRect(0U, band_h, TFT_LCD_W, band_h, TFT_COLOR_GREEN);
|
||||
TFT_FillRect(0U, (uint16_t) (band_h * 2U), TFT_LCD_W, (uint16_t) (TFT_LCD_H - band_h * 2U), TFT_COLOR_RED);
|
||||
TFT_DrawString(16U, 22U, "DM LCD", TFT_COLOR_WHITE, TFT_COLOR_BLUE, 3U);
|
||||
TFT_DrawString(16U, (uint16_t) (band_h + 24U), "BOOT", TFT_COLOR_BLACK, TFT_COLOR_GREEN, 3U);
|
||||
TFT_DrawString(16U, (uint16_t) (band_h * 2U + 24U), "WAIT IMU", TFT_COLOR_WHITE, TFT_COLOR_RED, 2U);
|
||||
TFT_Clear(TFT_COLOR_BLACK);
|
||||
TFT_DrawString(20U, 80U, "TronOneH7-Scaffold", TFT_COLOR_WHITE, TFT_COLOR_BLACK, 2U);
|
||||
TFT_DrawString(107U, 130U, "Starting...", TFT_COLOR_WHITE, TFT_COLOR_BLACK, 1U);
|
||||
}
|
||||
|
||||
const char *TFT_RobotModeText(RobotMode_t mode)
|
||||
|
||||
@@ -662,7 +662,7 @@
|
||||
#define LV_FONT_MONTSERRAT_26 0
|
||||
#define LV_FONT_MONTSERRAT_28 0
|
||||
#define LV_FONT_MONTSERRAT_30 0
|
||||
#define LV_FONT_MONTSERRAT_32 0
|
||||
#define LV_FONT_MONTSERRAT_32 1
|
||||
#define LV_FONT_MONTSERRAT_34 0
|
||||
#define LV_FONT_MONTSERRAT_36 0
|
||||
#define LV_FONT_MONTSERRAT_38 0
|
||||
@@ -670,7 +670,7 @@
|
||||
#define LV_FONT_MONTSERRAT_42 0
|
||||
#define LV_FONT_MONTSERRAT_44 0
|
||||
#define LV_FONT_MONTSERRAT_46 0
|
||||
#define LV_FONT_MONTSERRAT_48 0
|
||||
#define LV_FONT_MONTSERRAT_48 1
|
||||
|
||||
/* Demonstrate special features */
|
||||
#define LV_FONT_MONTSERRAT_28_COMPRESSED 0 /**< bpp = 3 */
|
||||
|
||||
@@ -59,16 +59,16 @@ typedef enum
|
||||
typedef struct
|
||||
{
|
||||
const char *title;
|
||||
const char *subtitle;
|
||||
const char *hint;
|
||||
const char *desc;
|
||||
const char *icon_text;
|
||||
uint32_t color;
|
||||
PRTS_Page_t page;
|
||||
} PRTS_MenuCard_t;
|
||||
|
||||
static const PRTS_MenuCard_t prts_menu_cards_data[PRTS_MENU_CARD_COUNT] = {
|
||||
{"状态", "温度 / 遥控", "STATUS", 0x40C4FF, PRTS_PAGE_STATUS},
|
||||
{"监视", "摇杆 / 性能", "MONITOR", 0xFFD666, PRTS_PAGE_MONITOR},
|
||||
{"资源", "字体 / 存储", "ASSETS", 0x25D366, PRTS_PAGE_ASSETS},
|
||||
{"状态", "状态", LV_SYMBOL_OK, 0x40C4FF, PRTS_PAGE_STATUS},
|
||||
{"监视", "监视", LV_SYMBOL_EYE_OPEN, 0xFFD666, PRTS_PAGE_MONITOR},
|
||||
{"资源", "资源", LV_SYMBOL_DRIVE, 0x25D366, PRTS_PAGE_ASSETS},
|
||||
};
|
||||
|
||||
static bool prts_initialized = false;
|
||||
@@ -91,8 +91,12 @@ static lv_obj_t *prts_assets_screen = NULL;
|
||||
static lv_obj_t *prts_main_status_title = NULL;
|
||||
static lv_obj_t *prts_menu_cards[PRTS_MENU_CARD_COUNT] = {NULL};
|
||||
static lv_obj_t *prts_menu_dots[PRTS_MENU_CARD_COUNT] = {NULL};
|
||||
static lv_obj_t *prts_menu_status_value = NULL;
|
||||
static lv_obj_t *prts_menu_monitor_value = NULL;
|
||||
static lv_obj_t *prts_menu_icon_labels[PRTS_MENU_CARD_COUNT] = {NULL};
|
||||
|
||||
#define PRTS_MAX_SCREENS 4
|
||||
static lv_obj_t *prts_status_indicators[PRTS_MAX_SCREENS];
|
||||
static uint8_t prts_status_indicator_count = 0;
|
||||
|
||||
|
||||
static lv_obj_t *prts_temperature_panel = NULL;
|
||||
static lv_obj_t *prts_temperature_label = NULL;
|
||||
@@ -100,7 +104,6 @@ static lv_obj_t *prts_temperature_accent = NULL;
|
||||
static lv_obj_t *prts_mode_panel = NULL;
|
||||
static lv_obj_t *prts_mode_label = NULL;
|
||||
static lv_obj_t *prts_mode_accent = NULL;
|
||||
static lv_obj_t *prts_status_bar = NULL;
|
||||
|
||||
static lv_obj_t *prts_adc0_label = NULL;
|
||||
static lv_obj_t *prts_adc1_label = NULL;
|
||||
@@ -192,6 +195,31 @@ static const char *prts_robot_mode_text(RobotMode_t mode)
|
||||
}
|
||||
}
|
||||
|
||||
static const char *prts_robot_mode_icon(RobotMode_t mode)
|
||||
{
|
||||
switch (mode)
|
||||
{
|
||||
case NORMAL_MODE:
|
||||
return LV_SYMBOL_OK;
|
||||
case SYS_ERROR_OCCURRED:
|
||||
return LV_SYMBOL_CLOSE;
|
||||
case REMOTE_NOT_CONNECTED:
|
||||
return LV_SYMBOL_WIFI;
|
||||
case REMOTE_NOT_READY:
|
||||
return LV_SYMBOL_REFRESH;
|
||||
case REMOTE_READY:
|
||||
return LV_SYMBOL_OK;
|
||||
case REMOTE_PROTECT:
|
||||
return LV_SYMBOL_WARNING;
|
||||
case AUTO_SHOOTING_MODE:
|
||||
return LV_SYMBOL_PLAY;
|
||||
case IMU_CALIBERATION_MODE:
|
||||
return LV_SYMBOL_REFRESH;
|
||||
default:
|
||||
return LV_SYMBOL_OK;
|
||||
}
|
||||
}
|
||||
|
||||
static lv_color_t prts_robot_mode_color(RobotMode_t mode)
|
||||
{
|
||||
switch (mode)
|
||||
@@ -430,7 +458,7 @@ static lv_obj_t *prts_create_bar(lv_obj_t *parent, const char *hint)
|
||||
|
||||
lv_obj_set_size(bar, PRTS_SCREEN_W, PRTS_HINT_H);
|
||||
lv_obj_align(bar, LV_ALIGN_BOTTOM_MID, 0, 0);
|
||||
lv_obj_set_style_bg_color(bar, lv_color_hex(0x111111), 0);
|
||||
lv_obj_set_style_bg_color(bar, lv_color_hex(0x000000), 0);
|
||||
lv_obj_set_style_border_width(bar, 0, 0);
|
||||
lv_obj_set_style_radius(bar, 0, 0);
|
||||
lv_obj_set_style_pad_all(bar, 0, 0);
|
||||
@@ -452,7 +480,7 @@ static lv_obj_t *prts_create_status_bar(lv_obj_t *parent, const char *title_text
|
||||
|
||||
lv_obj_set_size(bar, PRTS_SCREEN_W, PRTS_STATUS_H);
|
||||
lv_obj_align(bar, LV_ALIGN_TOP_MID, 0, 0);
|
||||
lv_obj_set_style_bg_color(bar, lv_color_hex(0x111111), 0);
|
||||
lv_obj_set_style_bg_color(bar, lv_color_hex(0x000000), 0);
|
||||
lv_obj_set_style_border_width(bar, 0, 0);
|
||||
lv_obj_set_style_radius(bar, 0, 0);
|
||||
lv_obj_set_style_pad_all(bar, 0, 0);
|
||||
@@ -477,6 +505,19 @@ static lv_obj_t *prts_create_status_bar(lv_obj_t *parent, const char *title_text
|
||||
prts_main_status_title = title;
|
||||
}
|
||||
|
||||
if (prts_status_indicator_count < PRTS_MAX_SCREENS)
|
||||
{
|
||||
lv_obj_t *indicator = lv_obj_create(bar);
|
||||
lv_obj_remove_flag(indicator, LV_OBJ_FLAG_SCROLLABLE);
|
||||
lv_obj_set_pos(indicator, 218, 11);
|
||||
lv_obj_set_size(indicator, 46, 8);
|
||||
lv_obj_set_style_radius(indicator, 2, 0);
|
||||
lv_obj_set_style_border_width(indicator, 0, 0);
|
||||
lv_obj_set_style_bg_color(indicator, lv_color_hex(0xD9D9D9), 0);
|
||||
lv_obj_set_style_bg_opa(indicator, LV_OPA_COVER, 0);
|
||||
prts_status_indicators[prts_status_indicator_count++] = indicator;
|
||||
}
|
||||
|
||||
return bar;
|
||||
}
|
||||
|
||||
@@ -508,17 +549,6 @@ static lv_obj_t *prts_create_value_accent(lv_obj_t *parent, lv_color_t color)
|
||||
return accent;
|
||||
}
|
||||
|
||||
static lv_obj_t *prts_create_card_text(lv_obj_t *parent, const char *text, int32_t y, lv_color_t color)
|
||||
{
|
||||
lv_obj_t *label = lv_label_create(parent);
|
||||
lv_label_set_text(label, text);
|
||||
lv_label_set_long_mode(label, LV_LABEL_LONG_MODE_CLIP);
|
||||
prts_style_label(label, color);
|
||||
lv_obj_set_pos(label, 14, y);
|
||||
lv_obj_set_size(label, PRTS_CARD_W - 30, 20);
|
||||
return label;
|
||||
}
|
||||
|
||||
static void prts_update_dots(void)
|
||||
{
|
||||
for (uint8_t i = 0U; i < PRTS_MENU_CARD_COUNT; i++)
|
||||
@@ -654,7 +684,7 @@ static void prts_create_main_screen(void)
|
||||
lv_obj_t *dot_row;
|
||||
|
||||
prts_main_screen = lv_obj_create(NULL);
|
||||
lv_obj_set_style_bg_color(prts_main_screen, lv_color_hex(0x1A1A1A), 0);
|
||||
lv_obj_set_style_bg_color(prts_main_screen, lv_color_hex(0x000000), 0);
|
||||
lv_obj_remove_flag(prts_main_screen, LV_OBJ_FLAG_SCROLLABLE);
|
||||
|
||||
prts_create_status_bar(prts_main_screen, "主菜单");
|
||||
@@ -676,7 +706,8 @@ static void prts_create_main_screen(void)
|
||||
for (uint8_t i = 0U; i < PRTS_MENU_CARD_COUNT; i++)
|
||||
{
|
||||
lv_obj_t *card = lv_button_create(banner);
|
||||
lv_obj_t *accent;
|
||||
lv_obj_t *icon_label;
|
||||
lv_obj_t *desc_label;
|
||||
|
||||
lv_obj_set_size(card, PRTS_CARD_W, PRTS_CARD_H);
|
||||
lv_obj_add_style(card, &prts_style_card_normal, 0);
|
||||
@@ -685,30 +716,21 @@ static void prts_create_main_screen(void)
|
||||
lv_obj_add_event_cb(card, prts_card_event_cb, LV_EVENT_FOCUSED, (void *) (uintptr_t) i);
|
||||
lv_obj_add_event_cb(card, prts_card_event_cb, LV_EVENT_CLICKED, (void *) (uintptr_t) i);
|
||||
|
||||
accent = lv_obj_create(card);
|
||||
lv_obj_remove_flag(accent, LV_OBJ_FLAG_SCROLLABLE);
|
||||
lv_obj_set_pos(accent, 0, 0);
|
||||
lv_obj_set_size(accent, 4, PRTS_CARD_H - 20);
|
||||
lv_obj_set_style_radius(accent, 0, 0);
|
||||
lv_obj_set_style_border_width(accent, 0, 0);
|
||||
lv_obj_set_style_pad_all(accent, 0, 0);
|
||||
lv_obj_set_style_bg_color(accent, lv_color_hex(prts_menu_cards_data[i].color), 0);
|
||||
lv_obj_set_style_bg_opa(accent, LV_OPA_COVER, 0);
|
||||
icon_label = lv_label_create(card);
|
||||
lv_label_set_text(icon_label, prts_menu_cards_data[i].icon_text);
|
||||
lv_obj_set_style_text_font(icon_label, &lv_font_montserrat_48, 0);
|
||||
lv_obj_set_style_text_color(icon_label, lv_color_hex(prts_menu_cards_data[i].color), 0);
|
||||
lv_obj_center(icon_label);
|
||||
|
||||
(void) prts_create_card_text(card, prts_menu_cards_data[i].hint, 8, lv_color_hex(prts_menu_cards_data[i].color));
|
||||
|
||||
(void) prts_create_card_text(card, prts_menu_cards_data[i].title, 42, lv_color_hex(0xFFFFFF));
|
||||
(void) prts_create_card_text(card, prts_menu_cards_data[i].subtitle, 70, lv_color_hex(0xD1D1D6));
|
||||
|
||||
if (i == 0U)
|
||||
{
|
||||
prts_menu_status_value = prts_create_card_text(card, "UNKNOWN", 108, lv_color_hex(0xD9D9D9));
|
||||
}
|
||||
else if (i == 1U)
|
||||
{
|
||||
prts_menu_monitor_value = prts_create_card_text(card, "ADC --", 108, lv_color_hex(0xFFD666));
|
||||
}
|
||||
desc_label = lv_label_create(card);
|
||||
lv_label_set_text(desc_label, prts_menu_cards_data[i].desc);
|
||||
lv_obj_set_style_text_font(desc_label, prts_font(), 0);
|
||||
lv_obj_set_style_text_color(desc_label, lv_color_hex(0xEBEBF5), 0);
|
||||
lv_obj_set_width(desc_label, PRTS_CARD_W - 20);
|
||||
lv_obj_set_style_text_align(desc_label, LV_TEXT_ALIGN_CENTER, 0);
|
||||
lv_obj_align(desc_label, LV_ALIGN_BOTTOM_MID, 0, -14);
|
||||
|
||||
prts_menu_icon_labels[i] = icon_label;
|
||||
prts_menu_cards[i] = card;
|
||||
}
|
||||
|
||||
@@ -757,7 +779,7 @@ static void prts_create_status_screen(void)
|
||||
lv_obj_t *caption;
|
||||
|
||||
prts_status_screen = lv_obj_create(NULL);
|
||||
lv_obj_set_style_bg_color(prts_status_screen, lv_color_hex(0x1A1A1A), 0);
|
||||
lv_obj_set_style_bg_color(prts_status_screen, lv_color_hex(0x000000), 0);
|
||||
lv_obj_remove_flag(prts_status_screen, LV_OBJ_FLAG_SCROLLABLE);
|
||||
lv_obj_add_event_cb(prts_status_screen, prts_page_key_event_cb, LV_EVENT_KEY, NULL);
|
||||
|
||||
@@ -791,15 +813,6 @@ static void prts_create_status_screen(void)
|
||||
prts_style_label(prts_mode_label, lv_color_hex(0xD9D9D9));
|
||||
lv_obj_set_pos(prts_mode_label, 12, 7);
|
||||
lv_obj_set_size(prts_mode_label, 210, 18);
|
||||
|
||||
prts_status_bar = lv_obj_create(prts_status_screen);
|
||||
lv_obj_remove_flag(prts_status_bar, LV_OBJ_FLAG_SCROLLABLE);
|
||||
lv_obj_set_pos(prts_status_bar, 222, 11);
|
||||
lv_obj_set_size(prts_status_bar, 46, 8);
|
||||
lv_obj_set_style_radius(prts_status_bar, 2, 0);
|
||||
lv_obj_set_style_border_width(prts_status_bar, 0, 0);
|
||||
lv_obj_set_style_bg_color(prts_status_bar, lv_color_hex(0xD9D9D9), 0);
|
||||
lv_obj_set_style_bg_opa(prts_status_bar, LV_OPA_COVER, 0);
|
||||
}
|
||||
|
||||
static lv_obj_t *prts_create_metric_label(lv_obj_t *parent, const char *text, int32_t x, int32_t y)
|
||||
@@ -819,7 +832,7 @@ static void prts_create_monitor_screen(void)
|
||||
lv_obj_t *title;
|
||||
|
||||
prts_monitor_screen = lv_obj_create(NULL);
|
||||
lv_obj_set_style_bg_color(prts_monitor_screen, lv_color_hex(0x1A1A1A), 0);
|
||||
lv_obj_set_style_bg_color(prts_monitor_screen, lv_color_hex(0x000000), 0);
|
||||
lv_obj_remove_flag(prts_monitor_screen, LV_OBJ_FLAG_SCROLLABLE);
|
||||
lv_obj_add_event_cb(prts_monitor_screen, prts_page_key_event_cb, LV_EVENT_KEY, NULL);
|
||||
|
||||
@@ -846,7 +859,7 @@ static void prts_create_assets_screen(void)
|
||||
lv_obj_t *label;
|
||||
|
||||
prts_assets_screen = lv_obj_create(NULL);
|
||||
lv_obj_set_style_bg_color(prts_assets_screen, lv_color_hex(0x1A1A1A), 0);
|
||||
lv_obj_set_style_bg_color(prts_assets_screen, lv_color_hex(0x000000), 0);
|
||||
lv_obj_remove_flag(prts_assets_screen, LV_OBJ_FLAG_SCROLLABLE);
|
||||
lv_obj_add_event_cb(prts_assets_screen, prts_page_key_event_cb, LV_EVENT_KEY, NULL);
|
||||
|
||||
@@ -931,9 +944,15 @@ void PRTS_UpdateStatus(float temperature_c, RobotMode_t mode)
|
||||
prts_label_set_text_if_changed(prts_mode_label, prts_robot_mode_text(mode));
|
||||
lv_obj_set_style_text_color(prts_mode_label, prts_robot_mode_text_color(mode), 0);
|
||||
lv_obj_set_style_bg_color(prts_mode_accent, mode_color, 0);
|
||||
lv_obj_set_style_bg_color(prts_status_bar, mode_color, 0);
|
||||
prts_label_set_text_if_changed(prts_menu_status_value, prts_robot_mode_text(mode));
|
||||
lv_obj_set_style_text_color(prts_menu_status_value, mode_color, 0);
|
||||
for (uint8_t i = 0; i < prts_status_indicator_count; i++)
|
||||
{
|
||||
lv_obj_set_style_bg_color(prts_status_indicators[i], mode_color, 0);
|
||||
}
|
||||
if (prts_menu_icon_labels[0] != NULL)
|
||||
{
|
||||
lv_label_set_text(prts_menu_icon_labels[0], prts_robot_mode_icon(mode));
|
||||
lv_obj_set_style_text_color(prts_menu_icon_labels[0], mode_color, 0);
|
||||
}
|
||||
prts_last_mode = mode;
|
||||
}
|
||||
}
|
||||
@@ -976,9 +995,6 @@ static void prts_update_monitor(uint32_t now_ms)
|
||||
(unsigned int) ((((uint32_t) adc1) * 3300U / 65535U) / 1000U),
|
||||
(unsigned int) ((((uint32_t) adc1) * 3300U / 65535U) % 1000U));
|
||||
prts_label_set_text_if_changed(prts_joy_voltage_label, text);
|
||||
|
||||
(void) snprintf(text, sizeof(text), "PA5 %4u", (unsigned int) raw12);
|
||||
prts_label_set_text_if_changed(prts_menu_monitor_value, text);
|
||||
}
|
||||
|
||||
uint32_t PRTS_Task(void)
|
||||
|
||||
Reference in New Issue
Block a user