#include "ssd1306.h" // To use LV_COLOR_FORMAT_I1 we need an extra buffer to hold the converted data. uint8_t SSD1306::oled_buffer_[LCD_H_RES * LCD_V_RES / 8]; SSD1306::SSD1306(i2c_master_bus_handle_t i2c, esp_lcd_panel_ssd1306_config_t config, int width, int height) : IPanelDevice(i2c, (esp_lcd_panel_io_i2c_config_t) { .dev_addr = I2C_HW_ADDR, .control_phase_bytes = 1, .dc_bit_offset = 6, .lcd_cmd_bits = LCD_CMD_BITS, .lcd_param_bits = LCD_CMD_BITS, .scl_speed_hz = LCD_PIXEL_CLOCK_HZ, } ), ssd1306_config_(config) { this->width_ = width; this->height_ = height; this->lv_buf_size_ = width_ * height_ / 8 + LVGL_PALETTE_SIZE; } void SSD1306::init_panel(esp_lcd_panel_dev_config_t &config, esp_lcd_panel_io_handle_t io, esp_lcd_panel_handle_t &panel) { // Allocate SSD1306 panel handle. config.vendor_config = &ssd1306_config_; ESP_ERROR_CHECK(esp_lcd_new_panel_ssd1306(io, &config, &panel)); }