30 lines
923 B
C++
30 lines
923 B
C++
|
|
#include "panel.h"
|
|
|
|
Panel::Panel(IPanelDevice *device) :
|
|
device_(device),
|
|
io_handle_(nullptr),
|
|
esp_panel_(nullptr),
|
|
// According to SSD1306 datasheet
|
|
panel_config_(
|
|
(esp_lcd_panel_dev_config_t) {
|
|
.reset_gpio_num = -1, // TODO: PIN_RST,
|
|
.bits_per_pixel = 1,
|
|
// .vendor_config should be set in IPanelDevice::init_panel override
|
|
}
|
|
)
|
|
{
|
|
ESP_LOGI(TAG, "Install panel IO");
|
|
ESP_ERROR_CHECK(esp_lcd_new_panel_io_i2c(
|
|
device_->i2c_bus_, &device_->io_config_, &io_handle_));
|
|
|
|
device_->create_panel(panel_config_, io_handle_, 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));
|
|
}
|