支持频谱显示,感谢哈哈哈群友的代码
This commit is contained in:
@@ -8,6 +8,11 @@
|
||||
#include <font_emoji.h>
|
||||
|
||||
#include <atomic>
|
||||
#include <vector>
|
||||
#include <esp_timer.h>
|
||||
#include <freertos/FreeRTOS.h>
|
||||
#include <freertos/task.h>
|
||||
#include <freertos/event_groups.h>
|
||||
|
||||
// Theme color structure
|
||||
struct ThemeColors {
|
||||
@@ -42,6 +47,53 @@ protected:
|
||||
virtual bool Lock(int timeout_ms = 0) override;
|
||||
virtual void Unlock() override;
|
||||
|
||||
// FFT 绘制方法
|
||||
void readAudioData();
|
||||
|
||||
|
||||
|
||||
virtual void clearScreen() override;
|
||||
virtual void stopFft() override; // 停止FFT显示
|
||||
|
||||
// 定时任务方法
|
||||
void periodicUpdateTask();
|
||||
static void periodicUpdateTaskWrapper(void* arg);
|
||||
|
||||
// LVGL变量
|
||||
lv_obj_t* canvas_ = nullptr;
|
||||
uint16_t* canvas_buffer_ = nullptr;
|
||||
void create_canvas();
|
||||
uint16_t get_bar_color(int x_pos);
|
||||
void draw_spectrum(float *power_spectrum,int fft_size);
|
||||
void draw_bar(int x,int y,int bar_width,int bar_height,uint16_t color,int bar_index);
|
||||
void draw_block(int x,int y,int block_x_size,int block_y_size,uint16_t color,int bar_index);
|
||||
|
||||
int canvas_width_;
|
||||
int canvas_height_;
|
||||
|
||||
|
||||
int16_t* audio_data=nullptr;
|
||||
int16_t* frame_audio_data=nullptr;
|
||||
uint32_t last_fft_update = 0;
|
||||
bool fft_data_ready = false;
|
||||
float* spectrum_data=nullptr;
|
||||
|
||||
// FFT 相关变量
|
||||
int audio_display_last_update = 0;
|
||||
std::atomic<bool> fft_task_should_stop = false; // FFT任务停止标志
|
||||
TaskHandle_t fft_task_handle = nullptr; // FFT任务句柄
|
||||
|
||||
float* fft_real;
|
||||
float* fft_imag;
|
||||
float* hanning_window_float;
|
||||
void compute(float* real, float* imag, int n, bool forward);
|
||||
|
||||
// 添加缺少的方法声明
|
||||
void drawSpectrumIfReady();
|
||||
void MyUI();
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
// 添加protected构造函数
|
||||
LcdDisplay(esp_lcd_panel_io_handle_t panel_io, esp_lcd_panel_handle_t panel, DisplayFonts fonts, int width, int height);
|
||||
@@ -50,6 +102,7 @@ public:
|
||||
~LcdDisplay();
|
||||
virtual void SetEmotion(const char* emotion) override;
|
||||
virtual void SetIcon(const char* icon) override;
|
||||
virtual void SetMusicInfo(const char* song_name) override;
|
||||
virtual void SetPreviewImage(const lv_img_dsc_t* img_dsc) override;
|
||||
#if CONFIG_USE_WECHAT_MESSAGE_STYLE
|
||||
virtual void SetChatMessage(const char* role, const char* content) override;
|
||||
@@ -57,6 +110,8 @@ public:
|
||||
|
||||
// Add theme switching function
|
||||
virtual void SetTheme(const std::string& theme_name) override;
|
||||
virtual void start() override;
|
||||
|
||||
};
|
||||
|
||||
// RGB LCD显示器
|
||||
@@ -103,4 +158,4 @@ public:
|
||||
bool mirror_x, bool mirror_y, bool swap_xy,
|
||||
DisplayFonts fonts);
|
||||
};
|
||||
#endif // LCD_DISPLAY_H
|
||||
#endif // LCD_DISPLAY_H
|
||||
Reference in New Issue
Block a user