fix no oled display error

This commit is contained in:
Terrence
2025-03-08 19:56:56 +08:00
parent e1b84e824c
commit 5568c70cb4
14 changed files with 27 additions and 38 deletions

View File

@ -8,7 +8,6 @@ set(SOURCES "audio_codecs/audio_codec.cc"
"led/circular_strip.cc" "led/circular_strip.cc"
"led/gpio_led.cc" "led/gpio_led.cc"
"display/display.cc" "display/display.cc"
"display/no_display.cc"
"display/lcd_display.cc" "display/lcd_display.cc"
"display/oled_display.cc" "display/oled_display.cc"
"protocols/protocol.cc" "protocols/protocol.cc"

View File

@ -29,7 +29,7 @@ private:
i2c_master_bus_handle_t display_i2c_bus_; i2c_master_bus_handle_t display_i2c_bus_;
esp_lcd_panel_io_handle_t panel_io_ = nullptr; esp_lcd_panel_io_handle_t panel_io_ = nullptr;
esp_lcd_panel_handle_t panel_ = nullptr; esp_lcd_panel_handle_t panel_ = nullptr;
OledDisplay* display_ = nullptr; Display* display_ = nullptr;
void InitializeDisplayI2c() { void InitializeDisplayI2c() {
i2c_master_bus_config_t bus_config = { i2c_master_bus_config_t bus_config = {
@ -83,6 +83,7 @@ private:
ESP_ERROR_CHECK(esp_lcd_panel_reset(panel_)); ESP_ERROR_CHECK(esp_lcd_panel_reset(panel_));
if (esp_lcd_panel_init(panel_) != ESP_OK) { if (esp_lcd_panel_init(panel_) != ESP_OK) {
ESP_LOGE(TAG, "Failed to initialize display"); ESP_LOGE(TAG, "Failed to initialize display");
display_ = new NoDisplay();
return; return;
} }

View File

@ -24,7 +24,7 @@ private:
i2c_master_bus_handle_t display_i2c_bus_; i2c_master_bus_handle_t display_i2c_bus_;
esp_lcd_panel_io_handle_t panel_io_ = nullptr; esp_lcd_panel_io_handle_t panel_io_ = nullptr;
esp_lcd_panel_handle_t panel_ = nullptr; esp_lcd_panel_handle_t panel_ = nullptr;
OledDisplay* display_ = nullptr; Display* display_ = nullptr;
Button boot_button_; Button boot_button_;
Button touch_button_; Button touch_button_;
Button volume_up_button_; Button volume_up_button_;
@ -82,6 +82,7 @@ private:
ESP_ERROR_CHECK(esp_lcd_panel_reset(panel_)); ESP_ERROR_CHECK(esp_lcd_panel_reset(panel_));
if (esp_lcd_panel_init(panel_) != ESP_OK) { if (esp_lcd_panel_init(panel_) != ESP_OK) {
ESP_LOGE(TAG, "Failed to initialize display"); ESP_LOGE(TAG, "Failed to initialize display");
display_ = new NoDisplay();
return; return;
} }

View File

@ -25,7 +25,7 @@ private:
i2c_master_bus_handle_t display_i2c_bus_; i2c_master_bus_handle_t display_i2c_bus_;
esp_lcd_panel_io_handle_t panel_io_ = nullptr; esp_lcd_panel_io_handle_t panel_io_ = nullptr;
esp_lcd_panel_handle_t panel_ = nullptr; esp_lcd_panel_handle_t panel_ = nullptr;
OledDisplay* display_ = nullptr; Display* display_ = nullptr;
Button boot_button_; Button boot_button_;
Button touch_button_; Button touch_button_;
Button volume_up_button_; Button volume_up_button_;
@ -83,6 +83,7 @@ private:
ESP_ERROR_CHECK(esp_lcd_panel_reset(panel_)); ESP_ERROR_CHECK(esp_lcd_panel_reset(panel_));
if (esp_lcd_panel_init(panel_) != ESP_OK) { if (esp_lcd_panel_init(panel_) != ESP_OK) {
ESP_LOGE(TAG, "Failed to initialize display"); ESP_LOGE(TAG, "Failed to initialize display");
display_ = new NoDisplay();
return; return;
} }

View File

@ -1,7 +1,7 @@
#include "board.h" #include "board.h"
#include "system_info.h" #include "system_info.h"
#include "settings.h" #include "settings.h"
#include "display/no_display.h" #include "display/display.h"
#include "assets/lang_config.h" #include "assets/lang_config.h"
#include <esp_log.h> #include <esp_log.h>

View File

@ -26,7 +26,7 @@ private:
i2c_master_bus_handle_t codec_i2c_bus_; i2c_master_bus_handle_t codec_i2c_bus_;
esp_lcd_panel_io_handle_t panel_io_ = nullptr; esp_lcd_panel_io_handle_t panel_io_ = nullptr;
esp_lcd_panel_handle_t panel_ = nullptr; esp_lcd_panel_handle_t panel_ = nullptr;
OledDisplay* display_ = nullptr; Display* display_ = nullptr;
Button boot_button_; Button boot_button_;
Button volume_up_button_; Button volume_up_button_;
Button volume_down_button_; Button volume_down_button_;
@ -108,6 +108,7 @@ private:
ESP_ERROR_CHECK(esp_lcd_panel_reset(panel_)); ESP_ERROR_CHECK(esp_lcd_panel_reset(panel_));
if (esp_lcd_panel_init(panel_) != ESP_OK) { if (esp_lcd_panel_init(panel_) != ESP_OK) {
ESP_LOGE(TAG, "Failed to initialize display"); ESP_LOGE(TAG, "Failed to initialize display");
display_ = new NoDisplay();
return; return;
} }

View File

@ -57,7 +57,7 @@ private:
i2c_master_bus_handle_t codec_i2c_bus_; i2c_master_bus_handle_t codec_i2c_bus_;
esp_lcd_panel_io_handle_t panel_io_ = nullptr; esp_lcd_panel_io_handle_t panel_io_ = nullptr;
esp_lcd_panel_handle_t panel_ = nullptr; esp_lcd_panel_handle_t panel_ = nullptr;
OledDisplay* display_ = nullptr; Display* display_ = nullptr;
Pmic* pmic_ = nullptr; Pmic* pmic_ = nullptr;
Button boot_button_; Button boot_button_;
Button volume_up_button_; Button volume_up_button_;
@ -137,6 +137,7 @@ private:
ESP_ERROR_CHECK(esp_lcd_panel_reset(panel_)); ESP_ERROR_CHECK(esp_lcd_panel_reset(panel_));
if (esp_lcd_panel_init(panel_) != ESP_OK) { if (esp_lcd_panel_init(panel_) != ESP_OK) {
ESP_LOGE(TAG, "Failed to initialize display"); ESP_LOGE(TAG, "Failed to initialize display");
display_ = new NoDisplay();
return; return;
} }

View File

@ -58,7 +58,7 @@ private:
i2c_master_bus_handle_t codec_i2c_bus_; i2c_master_bus_handle_t codec_i2c_bus_;
esp_lcd_panel_io_handle_t panel_io_ = nullptr; esp_lcd_panel_io_handle_t panel_io_ = nullptr;
esp_lcd_panel_handle_t panel_ = nullptr; esp_lcd_panel_handle_t panel_ = nullptr;
OledDisplay* display_ = nullptr; Display* display_ = nullptr;
Pmic* pmic_ = nullptr; Pmic* pmic_ = nullptr;
Button boot_button_; Button boot_button_;
Button volume_up_button_; Button volume_up_button_;
@ -156,6 +156,7 @@ private:
ESP_ERROR_CHECK(esp_lcd_panel_reset(panel_)); ESP_ERROR_CHECK(esp_lcd_panel_reset(panel_));
if (esp_lcd_panel_init(panel_) != ESP_OK) { if (esp_lcd_panel_init(panel_) != ESP_OK) {
ESP_LOGE(TAG, "Failed to initialize display"); ESP_LOGE(TAG, "Failed to initialize display");
display_ = new NoDisplay();
return; return;
} }

View File

@ -30,7 +30,7 @@ private:
Button boot_button_; Button boot_button_;
Button volume_up_button_; Button volume_up_button_;
Button volume_down_button_; Button volume_down_button_;
OledDisplay* display_; Display* display_;
PowerSaveTimer* power_save_timer_; PowerSaveTimer* power_save_timer_;
PowerManager* power_manager_; PowerManager* power_manager_;
esp_lcd_panel_io_handle_t panel_io_ = nullptr; esp_lcd_panel_io_handle_t panel_io_ = nullptr;
@ -127,6 +127,7 @@ private:
ESP_ERROR_CHECK(esp_lcd_panel_reset(panel_)); ESP_ERROR_CHECK(esp_lcd_panel_reset(panel_));
if (esp_lcd_panel_init(panel_) != ESP_OK) { if (esp_lcd_panel_init(panel_) != ESP_OK) {
ESP_LOGE(TAG, "Failed to initialize display"); ESP_LOGE(TAG, "Failed to initialize display");
display_ = new NoDisplay();
return; return;
} }

View File

@ -32,7 +32,7 @@ private:
Button boot_button_; Button boot_button_;
Button volume_up_button_; Button volume_up_button_;
Button volume_down_button_; Button volume_down_button_;
OledDisplay* display_; Display* display_;
PowerSaveTimer* power_save_timer_; PowerSaveTimer* power_save_timer_;
PowerManager* power_manager_; PowerManager* power_manager_;
esp_lcd_panel_io_handle_t panel_io_ = nullptr; esp_lcd_panel_io_handle_t panel_io_ = nullptr;
@ -129,6 +129,7 @@ private:
ESP_ERROR_CHECK(esp_lcd_panel_reset(panel_)); ESP_ERROR_CHECK(esp_lcd_panel_reset(panel_));
if (esp_lcd_panel_init(panel_) != ESP_OK) { if (esp_lcd_panel_init(panel_) != ESP_OK) {
ESP_LOGE(TAG, "Failed to initialize display"); ESP_LOGE(TAG, "Failed to initialize display");
display_ = new NoDisplay();
return; return;
} }

View File

@ -27,7 +27,7 @@ private:
i2c_master_bus_handle_t codec_i2c_bus_; i2c_master_bus_handle_t codec_i2c_bus_;
esp_lcd_panel_io_handle_t panel_io_ = nullptr; esp_lcd_panel_io_handle_t panel_io_ = nullptr;
esp_lcd_panel_handle_t panel_ = nullptr; esp_lcd_panel_handle_t panel_ = nullptr;
OledDisplay* display_ = nullptr; Display* display_ = nullptr;
Button boot_button_; Button boot_button_;
bool press_to_talk_enabled_ = false; bool press_to_talk_enabled_ = false;
PowerSaveTimer* power_save_timer_; PowerSaveTimer* power_save_timer_;
@ -107,6 +107,7 @@ private:
ESP_ERROR_CHECK(esp_lcd_panel_reset(panel_)); ESP_ERROR_CHECK(esp_lcd_panel_reset(panel_));
if (esp_lcd_panel_init(panel_) != ESP_OK) { if (esp_lcd_panel_init(panel_) != ESP_OK) {
ESP_LOGE(TAG, "Failed to initialize display"); ESP_LOGE(TAG, "Failed to initialize display");
display_ = new NoDisplay();
return; return;
} }

View File

@ -75,4 +75,12 @@ private:
Display *display_; Display *display_;
}; };
class NoDisplay : public Display {
private:
virtual bool Lock(int timeout_ms = 0) override {
return true;
}
virtual void Unlock() override {}
};
#endif #endif

View File

@ -1,11 +0,0 @@
#include "no_display.h"
NoDisplay::NoDisplay() {}
NoDisplay::~NoDisplay() {}
bool NoDisplay::Lock(int timeout_ms) {
return true;
}
void NoDisplay::Unlock() {}

View File

@ -1,16 +0,0 @@
#ifndef _NO_DISPLAY_H_
#define _NO_DISPLAY_H_
#include "display.h"
class NoDisplay : public Display {
private:
virtual bool Lock(int timeout_ms = 0) override;
virtual void Unlock() override;
public:
NoDisplay();
~NoDisplay();
};
#endif