63 lines
1.7 KiB
C
Raw Normal View History

2025-02-15 17:51:57 -05:00
#ifndef PANEL_H
#define PANEL_H
#include "panel_device.h"
2025-02-16 14:31:50 -05:00
/**
* Encapsulates esp_lcd_panel handles and operations.
* The only exception is esp_lcd_panel_io_i2c_config_t owned by IPanelDevice.
* This structure requires details specific to the implementing device.
*
* Panel is an implementation detail of Display, not meant to be used directly.
*/
struct Panel {
/**
* Construct a new Panel using an object that implements IPanelDevice.
*
* @param device An object that implements the IPanelDevice interface.
*/
explicit Panel(IPanelDevice &device) :
device_(&device),
esp_io_(nullptr),
esp_panel_(nullptr),
esp_panel_config_(
(esp_lcd_panel_dev_config_t) {
.reset_gpio_num = device_->rst_num_,
.bits_per_pixel = 1,
.vendor_config = device_->vendor_config(),
}
)
{
esp_io_ = device_->create_io_handle();
device_->create_panel(esp_panel_config_, esp_io_, esp_panel_);
ESP_LOGI(TAG, "Resetting panel display");
ESP_ERROR_CHECK(esp_lcd_panel_reset(esp_panel_));
ESP_LOGI(TAG, "Initializing panel display");
ESP_ERROR_CHECK(esp_lcd_panel_init(esp_panel_));
ESP_LOGI(TAG, "Turning on panel display");
ESP_ERROR_CHECK(esp_lcd_panel_disp_on_off(esp_panel_, true));
}
2025-02-15 17:51:57 -05:00
~Panel() = default;
2025-02-16 14:31:50 -05:00
/// Pointer to object using known interface for IPanelDevice.
2025-02-15 17:51:57 -05:00
IPanelDevice *device_;
2025-02-16 14:31:50 -05:00
/// ESP LCD panel IO handle.
2025-02-16 07:21:16 -05:00
esp_lcd_panel_io_handle_t esp_io_;
2025-02-15 17:51:57 -05:00
2025-02-16 14:31:50 -05:00
/// ESP LCD panel handle.
2025-02-15 17:51:57 -05:00
esp_lcd_panel_handle_t esp_panel_;
2025-02-16 14:31:50 -05:00
/// ESP LCD panel configuration structure.
2025-02-15 18:26:26 -05:00
esp_lcd_panel_dev_config_t esp_panel_config_;
2025-02-16 14:40:53 -05:00
private:
/// Tag used for ESP logging.
const char * TAG = "Panel";
2025-02-15 17:51:57 -05:00
};
#endif //PANEL_H