fix oled not displaying text

This commit is contained in:
Terrence
2025-02-20 14:21:41 +08:00
parent 455c71167e
commit 8659087f5d
2 changed files with 5 additions and 5 deletions

View File

@@ -133,18 +133,18 @@ void Ssd1306Display::Unlock() {
lvgl_port_unlock(); lvgl_port_unlock();
} }
void Ssd1306Display::SetChatMessage(const std::string &role, const std::string &content) { void Ssd1306Display::SetChatMessage(const char* role, const char* content) {
DisplayLockGuard lock(this); DisplayLockGuard lock(this);
if (chat_message_label_ == nullptr) { if (chat_message_label_ == nullptr) {
return; return;
} }
if (content_right_ == nullptr) { if (content_right_ == nullptr) {
lv_label_set_text(chat_message_label_, content.c_str()); lv_label_set_text(chat_message_label_, content);
} else { } else {
if (content.empty()) { if (content == nullptr || content[0] == '\0') {
lv_obj_add_flag(content_right_, LV_OBJ_FLAG_HIDDEN); lv_obj_add_flag(content_right_, LV_OBJ_FLAG_HIDDEN);
} else { } else {
lv_label_set_text(chat_message_label_, content.c_str()); lv_label_set_text(chat_message_label_, content);
lv_obj_clear_flag(content_right_, LV_OBJ_FLAG_HIDDEN); lv_obj_clear_flag(content_right_, LV_OBJ_FLAG_HIDDEN);
} }
} }

View File

@@ -32,7 +32,7 @@ public:
const lv_font_t* text_font, const lv_font_t* icon_font); const lv_font_t* text_font, const lv_font_t* icon_font);
~Ssd1306Display(); ~Ssd1306Display();
virtual void SetChatMessage(const std::string &role, const std::string &content); virtual void SetChatMessage(const char* role, const char* content) override;
}; };
#endif // SSD1306_DISPLAY_H #endif // SSD1306_DISPLAY_H