add more fonts for version 1.0.0

This commit is contained in:
Terrence
2025-01-23 13:50:22 +08:00
parent a5d8db6bbb
commit 84f5674359
31 changed files with 176 additions and 58410 deletions

View File

@ -24,6 +24,9 @@
#define PI4IOE_REG_IO_OUT 0x05
#define PI4IOE_REG_IO_PULLUP 0x0D
LV_FONT_DECLARE(font_puhui_16_4);
LV_FONT_DECLARE(font_awesome_16_4);
class Pi4ioe : public I2cDevice {
public:
Pi4ioe(i2c_master_bus_handle_t i2c_bus, uint8_t addr) : I2cDevice(i2c_bus, addr) {
@ -193,7 +196,8 @@ private:
ESP_ERROR_CHECK(esp_lcd_panel_disp_on_off(panel_handle, true));
display_ = new LcdDisplay(io_handle, panel_handle, DISPLAY_BACKLIGHT_PIN, DISPLAY_BACKLIGHT_OUTPUT_INVERT,
DISPLAY_WIDTH, DISPLAY_HEIGHT, DISPLAY_OFFSET_X, DISPLAY_OFFSET_Y, DISPLAY_MIRROR_X, DISPLAY_MIRROR_Y, DISPLAY_SWAP_XY);
DISPLAY_WIDTH, DISPLAY_HEIGHT, DISPLAY_OFFSET_X, DISPLAY_OFFSET_Y, DISPLAY_MIRROR_X, DISPLAY_MIRROR_Y, DISPLAY_SWAP_XY,
&font_puhui_16_4, &font_awesome_16_4);
}
void InitializeButtons() {

View File

@ -13,6 +13,9 @@
#define TAG "CompactMl307Board"
LV_FONT_DECLARE(font_puhui_14_1);
LV_FONT_DECLARE(font_awesome_14_1);
class CompactMl307Board : public Ml307Board {
private:
i2c_master_bus_handle_t display_i2c_bus_;
@ -119,7 +122,8 @@ public:
}
virtual Display* GetDisplay() override {
static Ssd1306Display display(display_i2c_bus_, DISPLAY_WIDTH, DISPLAY_HEIGHT, DISPLAY_MIRROR_X, DISPLAY_MIRROR_Y);
static Ssd1306Display display(display_i2c_bus_, DISPLAY_WIDTH, DISPLAY_HEIGHT, DISPLAY_MIRROR_X, DISPLAY_MIRROR_Y,
&font_puhui_14_1, &font_awesome_14_1);
return &display;
}
};

View File

@ -20,6 +20,9 @@
#define TAG "CompactWifiBoardLCD"
DECLARE_FONT(font_puhui_20_4);
DECLARE_FONT(font_awesome_20_4);
class CompactWifiBoardLCD : public WifiBoard {
private:
@ -72,7 +75,8 @@ private:
esp_lcd_panel_swap_xy(panel, DISPLAY_SWAP_XY);
esp_lcd_panel_mirror(panel, DISPLAY_MIRROR_X, DISPLAY_MIRROR_Y);
display_ = new LcdDisplay(panel_io, panel, DISPLAY_BACKLIGHT_PIN, DISPLAY_BACKLIGHT_OUTPUT_INVERT,
DISPLAY_WIDTH, DISPLAY_HEIGHT, DISPLAY_OFFSET_X, DISPLAY_OFFSET_Y, DISPLAY_MIRROR_X, DISPLAY_MIRROR_Y, DISPLAY_SWAP_XY);
DISPLAY_WIDTH, DISPLAY_HEIGHT, DISPLAY_OFFSET_X, DISPLAY_OFFSET_Y, DISPLAY_MIRROR_X, DISPLAY_MIRROR_Y, DISPLAY_SWAP_XY,
&font_puhui_20_4, &font_awesome_20_4);
}

View File

@ -14,6 +14,9 @@
#define TAG "CompactWifiBoard"
LV_FONT_DECLARE(font_puhui_14_1);
LV_FONT_DECLARE(font_awesome_14_1);
class CompactWifiBoard : public WifiBoard {
private:
i2c_master_bus_handle_t display_i2c_bus_;
@ -124,7 +127,8 @@ public:
}
virtual Display* GetDisplay() override {
static Ssd1306Display display(display_i2c_bus_, DISPLAY_WIDTH, DISPLAY_HEIGHT, DISPLAY_MIRROR_X, DISPLAY_MIRROR_Y);
static Ssd1306Display display(display_i2c_bus_, DISPLAY_WIDTH, DISPLAY_HEIGHT, DISPLAY_MIRROR_X, DISPLAY_MIRROR_Y,
&font_puhui_14_1, &font_awesome_14_1);
return &display;
}
};

View File

@ -16,6 +16,9 @@
#define TAG "EspBox3Board"
LV_FONT_DECLARE(font_puhui_20_4);
LV_FONT_DECLARE(font_awesome_20_4);
// Init ili9341 by custom cmd
static const ili9341_lcd_init_cmd_t vendor_specific_init[] = {
{0xC8, (uint8_t []){0xFF, 0x93, 0x42}, 3, 0},
@ -119,7 +122,8 @@ private:
esp_lcd_panel_mirror(panel, DISPLAY_MIRROR_X, DISPLAY_MIRROR_Y);
esp_lcd_panel_disp_on_off(panel, true);
display_ = new LcdDisplay(panel_io, panel, DISPLAY_BACKLIGHT_PIN, DISPLAY_BACKLIGHT_OUTPUT_INVERT,
DISPLAY_WIDTH, DISPLAY_HEIGHT, DISPLAY_OFFSET_X, DISPLAY_OFFSET_Y, DISPLAY_MIRROR_X, DISPLAY_MIRROR_Y, DISPLAY_SWAP_XY);
DISPLAY_WIDTH, DISPLAY_HEIGHT, DISPLAY_OFFSET_X, DISPLAY_OFFSET_Y, DISPLAY_MIRROR_X, DISPLAY_MIRROR_Y, DISPLAY_SWAP_XY,
&font_puhui_20_4, &font_awesome_20_4);
}
// 物联网初始化,添加对 AI 可见设备

View File

@ -15,6 +15,9 @@
#define TAG "esp_sparkbot"
DECLARE_FONT(font_puhui_16_4);
DECLARE_FONT(font_awesome_16_4);
class SparkBotEs8311AudioCodec : public Es8311AudioCodec {
private:
@ -111,7 +114,8 @@ private:
esp_lcd_panel_invert_color(panel, false);
esp_lcd_panel_disp_on_off(panel, true);
display_ = new LcdDisplay(panel_io, panel, DISPLAY_BACKLIGHT_PIN, DISPLAY_BACKLIGHT_OUTPUT_INVERT,
DISPLAY_WIDTH, DISPLAY_HEIGHT, DISPLAY_OFFSET_X, DISPLAY_OFFSET_Y, DISPLAY_MIRROR_X, DISPLAY_MIRROR_Y, DISPLAY_SWAP_XY);
DISPLAY_WIDTH, DISPLAY_HEIGHT, DISPLAY_OFFSET_X, DISPLAY_OFFSET_Y, DISPLAY_MIRROR_X, DISPLAY_MIRROR_Y, DISPLAY_SWAP_XY,
&font_puhui_16_4, &font_awesome_16_4);
}
// 物联网初始化,添加对 AI 可见设备

View File

@ -18,9 +18,8 @@
#define TAG "waveshare_amoled_1_8"
LV_FONT_DECLARE(font_puhui_14_1);
LV_FONT_DECLARE(font_awesome_30_1);
LV_FONT_DECLARE(font_awesome_14_1);
LV_FONT_DECLARE(font_puhui_30_4);
LV_FONT_DECLARE(font_awesome_30_4);
static const sh8601_lcd_init_cmd_t vendor_specific_init[] = {
{0x11, (uint8_t[]){0x00}, 0, 120},
@ -34,71 +33,34 @@ static const sh8601_lcd_init_cmd_t vendor_specific_init[] = {
{0x51, (uint8_t[]){0xFF}, 1, 0},
};
class SH8601Display : public LcdDisplay {
private:
lv_obj_t *user_messge_label_ = nullptr;
lv_obj_t *ai_messge_label_ = nullptr;
// 在waveshare_amoled_1_8类之前添加新的显示类
class CustomLcdDisplay : public LcdDisplay {
public:
SH8601Display(esp_lcd_panel_io_handle_t panel_io, esp_lcd_panel_handle_t panel,
gpio_num_t backlight_pin, bool backlight_output_invert,
int width, int height, int offset_x, int offset_y, bool mirror_x, bool mirror_y, bool swap_xy)
: LcdDisplay(panel_io, panel, backlight_pin, backlight_output_invert, width, height, offset_x, offset_y, mirror_x, mirror_y, swap_xy) {}
void SetChatMessage(const std::string &role, const std::string &content) override {
if (ai_messge_label_== nullptr || user_messge_label_== nullptr) {
return;
}
DisplayLockGuard lock(this);
ESP_LOGI(TAG, "role:%s", role.c_str());
if(role == "assistant") {
std::string new_content = "AI: " + content;
lv_label_set_text(ai_messge_label_, new_content.c_str());
} else if(role == "user") {
std::string new_content = "User: " + content;
lv_label_set_text(user_messge_label_, new_content.c_str());
} else{
lv_label_set_text(ai_messge_label_, "AI: ");
lv_label_set_text(user_messge_label_, "User: ");
}
}
void SetupUI() override {
DisplayLockGuard lock(this);
lv_obj_del(chat_message_label_);
lv_obj_set_flex_align(content_, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_SPACE_EVENLY); // 子对象居中对齐,等距分布
lv_obj_set_style_text_font(emotion_label_, &font_awesome_30_1, 0);
lv_label_set_text(emotion_label_, FONT_AWESOME_AI_CHIP);
lv_obj_align(emotion_label_, LV_ALIGN_TOP_MID, 0, -10); // 左侧居中向右偏移10个单位
static lv_style_t style_msg;
lv_style_init(&style_msg);
lv_style_set_width(&style_msg, LV_HOR_RES - 25);
user_messge_label_ = lv_label_create(content_);
lv_obj_set_style_text_font(user_messge_label_, &font_puhui_14_1, 0);
lv_label_set_text(user_messge_label_, "User: ");
lv_obj_add_style(user_messge_label_, &style_msg, 0);
lv_obj_align(user_messge_label_, LV_ALIGN_TOP_LEFT, 2, 25);
ai_messge_label_ = lv_label_create(content_);
lv_obj_set_style_text_font(ai_messge_label_, &font_puhui_14_1, 0);
lv_label_set_text(ai_messge_label_, "AI: ");
lv_obj_add_style(ai_messge_label_, &style_msg, 0);
lv_obj_align(ai_messge_label_, LV_ALIGN_TOP_LEFT, 2, 77);
CustomLcdDisplay(esp_lcd_panel_io_handle_t io_handle,
esp_lcd_panel_handle_t panel_handle,
gpio_num_t backlight_pin,
bool backlight_output_invert,
int width,
int height,
int offset_x,
int offset_y,
bool mirror_x,
bool mirror_y,
bool swap_xy)
: LcdDisplay(io_handle, panel_handle, backlight_pin, backlight_output_invert,
width, height, offset_x, offset_y, mirror_x, mirror_y, swap_xy,
&font_puhui_30_4, &font_awesome_30_4) {
// 由于屏幕是带圆角的,所以状态栏需要增加左右内边距
lv_obj_set_style_pad_left(status_bar_, LV_HOR_RES * 0.1, 0);
lv_obj_set_style_pad_right(status_bar_, LV_HOR_RES * 0.1, 0);
}
};
class waveshare_amoled_1_8 : public WifiBoard {
private:
i2c_master_bus_handle_t codec_i2c_bus_;
Button boot_button_;
SH8601Display* display_;
LcdDisplay* display_;
void InitializeCodecI2c() {
// Initialize I2C peripheral
@ -178,18 +140,12 @@ private:
esp_lcd_panel_reset(panel);
esp_lcd_panel_init(panel);
esp_lcd_panel_invert_color(panel, true);
esp_lcd_panel_invert_color(panel, false);
esp_lcd_panel_swap_xy(panel, DISPLAY_SWAP_XY);
esp_lcd_panel_mirror(panel, DISPLAY_MIRROR_X, DISPLAY_MIRROR_Y);
esp_lcd_panel_disp_on_off(panel, true);
display_ = new SH8601Display(panel_io, panel, DISPLAY_BACKLIGHT_PIN, DISPLAY_BACKLIGHT_OUTPUT_INVERT,
display_ = new CustomLcdDisplay(panel_io, panel, DISPLAY_BACKLIGHT_PIN, DISPLAY_BACKLIGHT_OUTPUT_INVERT,
DISPLAY_WIDTH, DISPLAY_HEIGHT, DISPLAY_OFFSET_X, DISPLAY_OFFSET_Y, DISPLAY_MIRROR_X, DISPLAY_MIRROR_Y, DISPLAY_SWAP_XY);
if (display_) {
display_->SetupUI();
} else {
ESP_LOGE(TAG, "Display is not initialized!");
}
}
// 物联网初始化,添加对 AI 可见设备

View File

@ -16,6 +16,9 @@
#define TAG "esp32s3_korvo2_v3"
DECLARE_FONT(font_puhui_20_4);
DECLARE_FONT(font_awesome_20_4);
class esp32s3_korvo2_v3_board : public WifiBoard
{
private:
@ -95,7 +98,8 @@ private:
ESP_ERROR_CHECK(esp_lcd_panel_invert_color(panel, true));
display_ = new LcdDisplay(panel_io, panel, DISPLAY_BACKLIGHT_PIN, DISPLAY_BACKLIGHT_OUTPUT_INVERT,
DISPLAY_WIDTH, DISPLAY_HEIGHT, DISPLAY_OFFSET_X, DISPLAY_OFFSET_Y, DISPLAY_MIRROR_X, DISPLAY_MIRROR_Y, DISPLAY_SWAP_XY);
DISPLAY_WIDTH, DISPLAY_HEIGHT, DISPLAY_OFFSET_X, DISPLAY_OFFSET_Y, DISPLAY_MIRROR_X, DISPLAY_MIRROR_Y, DISPLAY_SWAP_XY,
&font_puhui_20_4, &font_awesome_20_4);
}
// 物联网初始化,添加对 AI 可见设备

View File

@ -5,7 +5,7 @@
#include "button.h"
#include "config.h"
#include "iot/thing_manager.h"
#include "led_strip/single_led.h"
#include "led/single_led.h"
#include <esp_log.h>
#include <esp_spiffs.h>
@ -14,6 +14,9 @@
#define TAG "KevinBoxBoard"
DECLARE_FONT(font_puhui_14_1);
DECLARE_FONT(font_awesome_14_1);
class KevinBoxBoard : public Ml307Board {
private:
i2c_master_bus_handle_t display_i2c_bus_;
@ -81,8 +84,11 @@ private:
}
void InitializeButtons() {
boot_button_.OnClick([this]() {
Application::GetInstance().ToggleChatState();
boot_button_.OnPressDown([this]() {
Application::GetInstance().StartListening();
});
boot_button_.OnPressUp([this]() {
Application::GetInstance().StopListening();
});
volume_up_button_.OnClick([this]() {
@ -149,7 +155,8 @@ public:
}
virtual Display* GetDisplay() override {
static Ssd1306Display display(display_i2c_bus_, DISPLAY_WIDTH, DISPLAY_HEIGHT, DISPLAY_MIRROR_X, DISPLAY_MIRROR_Y);
static Ssd1306Display display(display_i2c_bus_, DISPLAY_WIDTH, DISPLAY_HEIGHT, DISPLAY_MIRROR_X, DISPLAY_MIRROR_Y,
&font_puhui_14_1, &font_awesome_14_1);
return &display;
}
};

View File

@ -16,6 +16,9 @@
#define TAG "KevinBoxBoard"
DECLARE_FONT(font_puhui_14_1);
DECLARE_FONT(font_awesome_14_1);
class KevinBoxBoard : public Ml307Board {
private:
i2c_master_bus_handle_t display_i2c_bus_;
@ -193,7 +196,8 @@ public:
}
virtual Display* GetDisplay() override {
static Ssd1306Display display(display_i2c_bus_, DISPLAY_WIDTH, DISPLAY_HEIGHT, DISPLAY_MIRROR_X, DISPLAY_MIRROR_Y);
static Ssd1306Display display(display_i2c_bus_, DISPLAY_WIDTH, DISPLAY_HEIGHT, DISPLAY_MIRROR_X, DISPLAY_MIRROR_Y,
&font_puhui_14_1, &font_awesome_14_1);
return &display;
}

View File

@ -15,6 +15,9 @@
#define TAG "LichuangC3DevBoard"
LV_FONT_DECLARE(font_puhui_20_4);
LV_FONT_DECLARE(font_awesome_20_4);
class LichuangC3DevBoard : public WifiBoard {
private:
i2c_master_bus_handle_t codec_i2c_bus_;
@ -95,7 +98,8 @@ private:
esp_lcd_panel_swap_xy(panel, DISPLAY_SWAP_XY);
esp_lcd_panel_mirror(panel, DISPLAY_MIRROR_X, DISPLAY_MIRROR_Y);
display_ = new LcdDisplay(panel_io, panel, DISPLAY_BACKLIGHT_PIN, DISPLAY_BACKLIGHT_OUTPUT_INVERT,
DISPLAY_WIDTH, DISPLAY_HEIGHT, DISPLAY_OFFSET_X, DISPLAY_OFFSET_Y, DISPLAY_MIRROR_X, DISPLAY_MIRROR_Y, DISPLAY_SWAP_XY);
DISPLAY_WIDTH, DISPLAY_HEIGHT, DISPLAY_OFFSET_X, DISPLAY_OFFSET_Y, DISPLAY_MIRROR_X, DISPLAY_MIRROR_Y, DISPLAY_SWAP_XY,
&font_puhui_20_4, &font_awesome_20_4);
}
// 物联网初始化,添加对 AI 可见设备

View File

@ -15,6 +15,8 @@
#define TAG "LichuangDevBoard"
LV_FONT_DECLARE(font_puhui_20_4);
LV_FONT_DECLARE(font_awesome_20_4);
class Pca9557 : public I2cDevice {
public:
@ -117,7 +119,8 @@ private:
esp_lcd_panel_swap_xy(panel, DISPLAY_SWAP_XY);
esp_lcd_panel_mirror(panel, DISPLAY_MIRROR_X, DISPLAY_MIRROR_Y);
display_ = new LcdDisplay(panel_io, panel, DISPLAY_BACKLIGHT_PIN, DISPLAY_BACKLIGHT_OUTPUT_INVERT,
DISPLAY_WIDTH, DISPLAY_HEIGHT, DISPLAY_OFFSET_X, DISPLAY_OFFSET_Y, DISPLAY_MIRROR_X, DISPLAY_MIRROR_Y, DISPLAY_SWAP_XY);
DISPLAY_WIDTH, DISPLAY_HEIGHT, DISPLAY_OFFSET_X, DISPLAY_OFFSET_Y, DISPLAY_MIRROR_X, DISPLAY_MIRROR_Y, DISPLAY_SWAP_XY,
&font_puhui_20_4, &font_awesome_20_4);
}
// 物联网初始化,添加对 AI 可见设备

View File

@ -16,6 +16,9 @@
#define TAG "M5StackCoreS3Board"
LV_FONT_DECLARE(font_puhui_20_4);
LV_FONT_DECLARE(font_awesome_20_4);
class Axp2101 : public I2cDevice {
public:
// Power Init
@ -227,7 +230,7 @@ private:
ESP_LOGD(TAG, "Install LCD driver");
esp_lcd_panel_dev_config_t panel_config = {};
panel_config.reset_gpio_num = GPIO_NUM_NC;
panel_config.rgb_ele_order = LCD_RGB_ELEMENT_ORDER_RGB;
panel_config.rgb_ele_order = LCD_RGB_ELEMENT_ORDER_BGR;
panel_config.bits_per_pixel = 16;
ESP_ERROR_CHECK(esp_lcd_new_panel_ili9341(panel_io, &panel_config, &panel));
@ -240,7 +243,8 @@ private:
esp_lcd_panel_mirror(panel, DISPLAY_MIRROR_X, DISPLAY_MIRROR_Y);
display_ = new LcdDisplay(panel_io, panel, DISPLAY_BACKLIGHT_PIN, DISPLAY_BACKLIGHT_OUTPUT_INVERT,
DISPLAY_WIDTH, DISPLAY_HEIGHT, DISPLAY_OFFSET_X, DISPLAY_OFFSET_Y, DISPLAY_MIRROR_X, DISPLAY_MIRROR_Y, DISPLAY_SWAP_XY);
DISPLAY_WIDTH, DISPLAY_HEIGHT, DISPLAY_OFFSET_X, DISPLAY_OFFSET_Y, DISPLAY_MIRROR_X, DISPLAY_MIRROR_Y, DISPLAY_SWAP_XY,
&font_puhui_20_4, &font_awesome_20_4);
}
void InitializeButtons() {

View File

@ -14,6 +14,9 @@
#include "esp_lcd_nv3023.h"
#define TAG "magiclick_2p4"
DECLARE_FONT(font_puhui_16_4);
DECLARE_FONT(font_awesome_16_4);
class magiclick_2p4 : public WifiBoard {
private:
i2c_master_bus_handle_t codec_i2c_bus_;
@ -102,7 +105,8 @@ private:
esp_lcd_panel_mirror(panel, DISPLAY_MIRROR_X, DISPLAY_MIRROR_Y);
ESP_ERROR_CHECK(esp_lcd_panel_disp_on_off(panel, true));
display_ = new LcdDisplay(panel_io, panel, DISPLAY_BACKLIGHT_PIN, DISPLAY_BACKLIGHT_OUTPUT_INVERT,
DISPLAY_WIDTH, DISPLAY_HEIGHT, DISPLAY_OFFSET_X, DISPLAY_OFFSET_Y, DISPLAY_MIRROR_X, DISPLAY_MIRROR_Y, DISPLAY_SWAP_XY);
DISPLAY_WIDTH, DISPLAY_HEIGHT, DISPLAY_OFFSET_X, DISPLAY_OFFSET_Y, DISPLAY_MIRROR_X, DISPLAY_MIRROR_Y, DISPLAY_SWAP_XY,
&font_puhui_16_4, &font_awesome_16_4);
}
// 物联网初始化,添加对 AI 可见设备

View File

@ -14,6 +14,9 @@
#define TAG "XminiC3Board"
DECLARE_FONT(font_puhui_14_1);
DECLARE_FONT(font_awesome_14_1);
class XminiC3Board : public WifiBoard {
private:
i2c_master_bus_handle_t codec_i2c_bus_;
@ -74,7 +77,8 @@ public:
}
virtual Display* GetDisplay() override {
static Ssd1306Display display(codec_i2c_bus_, DISPLAY_WIDTH, DISPLAY_HEIGHT, DISPLAY_MIRROR_X, DISPLAY_MIRROR_Y);
static Ssd1306Display display(codec_i2c_bus_, DISPLAY_WIDTH, DISPLAY_HEIGHT, DISPLAY_MIRROR_X, DISPLAY_MIRROR_Y,
&font_puhui_14_1, &font_awesome_14_1);
return &display;
}