fix c3 compile

This commit is contained in:
Terrence
2025-01-23 22:44:44 +08:00
parent 2026472d48
commit c46052958f
2 changed files with 27 additions and 90 deletions

View File

@@ -4,7 +4,6 @@
#include <driver/i2c.h> #include <driver/i2c.h>
#include <driver/i2c_master.h> #include <driver/i2c_master.h>
#include <driver/i2s_tdm.h> #include <driver/i2s_tdm.h>
#include <driver/i2s.h>
static const char TAG[] = "Tcircles3AudioCodec"; static const char TAG[] = "Tcircles3AudioCodec";
@@ -21,7 +20,7 @@ Tcircles3AudioCodec::Tcircles3AudioCodec(int input_sample_rate, int output_sampl
CreateVoiceHardware(mic_bclk, mic_ws, mic_data, spkr_bclk, spkr_lrclk, spkr_data); CreateVoiceHardware(mic_bclk, mic_ws, mic_data, spkr_bclk, spkr_lrclk, spkr_data);
gpio_config_t config; gpio_config_t config;
config.pin_bit_mask = BIT64(GPIO_NUM_45); config.pin_bit_mask = BIT64(45);
config.mode = GPIO_MODE_OUTPUT; config.mode = GPIO_MODE_OUTPUT;
config.pull_up_en = GPIO_PULLUP_DISABLE; config.pull_up_en = GPIO_PULLUP_DISABLE;
config.pull_down_en = GPIO_PULLDOWN_ENABLE; config.pull_down_en = GPIO_PULLDOWN_ENABLE;
@@ -30,7 +29,7 @@ Tcircles3AudioCodec::Tcircles3AudioCodec(int input_sample_rate, int output_sampl
config.hys_ctrl_mode = GPIO_HYS_SOFT_ENABLE; config.hys_ctrl_mode = GPIO_HYS_SOFT_ENABLE;
#endif #endif
gpio_config(&config); gpio_config(&config);
gpio_set_level(GPIO_NUM_45, 0); gpio_set_level(gpio_num_t(45), 0);
ESP_LOGI(TAG, "Tcircles3AudioCodec initialized"); ESP_LOGI(TAG, "Tcircles3AudioCodec initialized");
} }
@@ -46,9 +45,9 @@ Tcircles3AudioCodec::~Tcircles3AudioCodec() {
void Tcircles3AudioCodec::CreateVoiceHardware(gpio_num_t mic_bclk, gpio_num_t mic_ws, gpio_num_t mic_data, void Tcircles3AudioCodec::CreateVoiceHardware(gpio_num_t mic_bclk, gpio_num_t mic_ws, gpio_num_t mic_data,
gpio_num_t spkr_bclk, gpio_num_t spkr_lrclk, gpio_num_t spkr_data) { gpio_num_t spkr_bclk, gpio_num_t spkr_lrclk, gpio_num_t spkr_data) {
i2s_chan_config_t mic_chan_config = I2S_CHANNEL_DEFAULT_CONFIG(I2S_NUM_0, I2S_ROLE_MASTER); i2s_chan_config_t mic_chan_config = I2S_CHANNEL_DEFAULT_CONFIG(i2s_port_t(0), I2S_ROLE_MASTER);
mic_chan_config.auto_clear = true; // Auto clear the legacy data in the DMA buffer mic_chan_config.auto_clear = true; // Auto clear the legacy data in the DMA buffer
i2s_chan_config_t spkr_chan_config = I2S_CHANNEL_DEFAULT_CONFIG(I2S_NUM_1, I2S_ROLE_MASTER); i2s_chan_config_t spkr_chan_config = I2S_CHANNEL_DEFAULT_CONFIG(i2s_port_t(1), I2S_ROLE_MASTER);
spkr_chan_config.auto_clear = true; // Auto clear the legacy data in the DMA buffer spkr_chan_config.auto_clear = true; // Auto clear the legacy data in the DMA buffer
ESP_ERROR_CHECK(i2s_new_channel(&mic_chan_config, NULL, &rx_handle_)); ESP_ERROR_CHECK(i2s_new_channel(&mic_chan_config, NULL, &rx_handle_));
@@ -104,9 +103,9 @@ void Tcircles3AudioCodec::EnableInput(bool enable) {
void Tcircles3AudioCodec::EnableOutput(bool enable) { void Tcircles3AudioCodec::EnableOutput(bool enable) {
if (enable){ if (enable){
gpio_set_level(GPIO_NUM_45, 1); gpio_set_level(gpio_num_t(45), 1);
}else{ }else{
gpio_set_level(GPIO_NUM_45, 0); gpio_set_level(gpio_num_t(45), 0);
} }
AudioCodec::EnableOutput(enable); AudioCodec::EnableOutput(enable);
} }

View File

@@ -17,9 +17,8 @@
#define TAG "magiclick_c3" #define TAG "magiclick_c3"
LV_FONT_DECLARE(font_puhui_14_1); LV_FONT_DECLARE(font_puhui_16_4);
LV_FONT_DECLARE(font_awesome_30_4); LV_FONT_DECLARE(font_awesome_16_4);
LV_FONT_DECLARE(font_awesome_14_1);
class NV3023Display : public LcdDisplay { class NV3023Display : public LcdDisplay {
public: public:
@@ -28,95 +27,34 @@ public:
int width, int height, int offset_x, int offset_y, bool mirror_x, bool mirror_y, bool swap_xy) 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, : LcdDisplay(panel_io, panel, backlight_pin, backlight_output_invert,
width, height, offset_x, offset_y, mirror_x, mirror_y, swap_xy, width, height, offset_x, offset_y, mirror_x, mirror_y, swap_xy,
&font_puhui_14_1, &font_awesome_14_1) {} &font_puhui_16_4, &font_awesome_16_4) {}
void SetupUI() override { void SetupUI() override {
DisplayLockGuard lock(this); DisplayLockGuard lock(this);
// 调用父类的 SetupUI 来设置基本布局
LcdDisplay::SetupUI();
// 只需要覆盖颜色相关的样式
auto screen = lv_disp_get_scr_act(lv_disp_get_default()); auto screen = lv_disp_get_scr_act(lv_disp_get_default());
lv_obj_set_style_text_font(screen,text_font_, 0);
lv_obj_set_style_text_color(screen, lv_color_black(), 0); lv_obj_set_style_text_color(screen, lv_color_black(), 0);
/* Container */ // 设置容器背景色
container_ = lv_obj_create(screen); lv_obj_set_style_bg_color(container_, lv_color_black(), 0);
lv_obj_set_size(container_, LV_HOR_RES, LV_VER_RES);
lv_obj_set_flex_flow(container_, LV_FLEX_FLOW_COLUMN);
lv_obj_set_style_pad_all(container_, 0, 0);
lv_obj_set_style_border_width(container_, 0, 0);
lv_obj_set_style_pad_row(container_, 0, 0);
lv_obj_set_style_bg_color(container_,lv_color_black(), 0);
/* Status bar */ // 设置状态栏背景色和文本颜色
status_bar_ = lv_obj_create(container_); lv_obj_set_style_bg_color(status_bar_, lv_color_white(), 0);
lv_obj_set_size(status_bar_, LV_HOR_RES, text_font_->line_height); lv_obj_set_style_text_color(network_label_, lv_color_black(), 0);
lv_obj_set_style_radius(status_bar_, 0, 0); lv_obj_set_style_text_color(notification_label_, lv_color_black(), 0);
lv_obj_set_style_bg_color(status_bar_, lv_color_make(0xff, 0xff, 0xff), 0); lv_obj_set_style_text_color(status_label_, lv_color_black(), 0);
lv_obj_set_style_text_color(mute_label_, lv_color_black(), 0);
/* Content */ lv_obj_set_style_text_color(battery_label_, lv_color_black(), 0);
content_ = lv_obj_create(container_);
lv_obj_set_scrollbar_mode(content_, LV_SCROLLBAR_MODE_OFF); // 设置内容区背景色和文本颜色
lv_obj_set_style_radius(content_, 0, 0); lv_obj_set_style_bg_color(content_, lv_color_black(), 0);
lv_obj_set_width(content_, LV_HOR_RES);
lv_obj_set_flex_grow(content_, 1);
lv_obj_set_style_bg_color(content_,lv_color_black(), 0);
lv_obj_set_style_border_width(content_, 0, 0); lv_obj_set_style_border_width(content_, 0, 0);
lv_obj_set_style_text_color(emotion_label_, lv_color_white(), 0);
lv_obj_set_style_text_color(chat_message_label_, lv_color_white(), 0);
lv_obj_set_flex_flow(content_, LV_FLEX_FLOW_COLUMN); // 垂直布局(从上到下)
lv_obj_set_flex_align(content_, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_SPACE_EVENLY); // 子对象顶部对齐,左右居中对齐,等距分布
emotion_label_ = lv_label_create(content_);
lv_obj_set_style_text_font(emotion_label_, &font_awesome_30_4, 0);
lv_label_set_text(emotion_label_, FONT_AWESOME_AI_CHIP);
lv_obj_set_style_text_color(emotion_label_,lv_color_white(), 0);
chat_message_label_ = lv_label_create(content_);
lv_label_set_text(chat_message_label_, "");
lv_obj_set_width(chat_message_label_, LV_HOR_RES * 0.9); // 限制宽度为屏幕宽度的 90%
lv_label_set_long_mode(chat_message_label_, LV_LABEL_LONG_WRAP); // 设置为自动换行模式
lv_obj_set_style_text_align(chat_message_label_, LV_TEXT_ALIGN_CENTER, 0); // 设置文本居中对齐
lv_obj_set_style_text_color(chat_message_label_,lv_color_white(), 0);
/* Status bar */
lv_obj_set_flex_flow(status_bar_, LV_FLEX_FLOW_ROW);
lv_obj_set_style_pad_all(status_bar_, 0, 0);
lv_obj_set_style_border_width(status_bar_, 0, 0);
lv_obj_set_style_pad_column(status_bar_, 0, 0);
lv_obj_set_style_pad_left(status_bar_, 2, 0);
lv_obj_set_style_pad_right(status_bar_, 2, 0);
network_label_ = lv_label_create(status_bar_);
lv_label_set_text(network_label_, "");
lv_obj_set_style_text_font(network_label_, icon_font_, 0);
lv_obj_set_style_text_color(network_label_,lv_color_black(), 0);
notification_label_ = lv_label_create(status_bar_);
lv_obj_set_flex_grow(notification_label_, 1);
lv_obj_set_style_text_align(notification_label_, LV_TEXT_ALIGN_CENTER, 0);
lv_label_set_text(notification_label_, "通知");
lv_obj_add_flag(notification_label_, LV_OBJ_FLAG_HIDDEN);
lv_obj_set_style_text_color(notification_label_,lv_color_black(), 0);
status_label_ = lv_label_create(status_bar_);
lv_obj_set_flex_grow(status_label_, 1);
lv_label_set_long_mode(status_label_, LV_LABEL_LONG_SCROLL_CIRCULAR);
lv_label_set_text(status_label_, "正在初始化");
lv_obj_set_style_text_align(status_label_, LV_TEXT_ALIGN_CENTER, 0);
lv_obj_set_style_text_color(status_label_,lv_color_black(), 0);
mute_label_ = lv_label_create(status_bar_);
lv_label_set_text(mute_label_, "");
lv_obj_set_style_text_font(mute_label_, icon_font_, 0);
lv_obj_set_style_text_color(mute_label_,lv_color_black(), 0);
battery_label_ = lv_label_create(status_bar_);
lv_label_set_text(battery_label_, "");
lv_obj_set_style_text_font(battery_label_, icon_font_, 0);
lv_obj_set_style_text_color(battery_label_,lv_color_black(), 0);
} }
}; };