2025-02-15 10:11:49 -05:00
|
|
|
|
|
|
|
#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];
|
|
|
|
|
2025-02-15 18:16:25 -05:00
|
|
|
SSD1306::SSD1306(I2C& i2c,
|
2025-02-15 17:12:06 -05:00
|
|
|
esp_lcd_panel_ssd1306_config_t config,
|
2025-02-15 10:11:49 -05:00
|
|
|
int width,
|
|
|
|
int height) :
|
2025-02-15 17:12:06 -05:00
|
|
|
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,
|
2025-02-15 18:16:25 -05:00
|
|
|
},
|
|
|
|
width,
|
|
|
|
height
|
2025-02-15 17:12:06 -05:00
|
|
|
),
|
|
|
|
ssd1306_config_(config)
|
2025-02-15 18:16:25 -05:00
|
|
|
{ }
|
2025-02-15 17:12:06 -05:00
|
|
|
|
|
|
|
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));
|
2025-02-15 10:11:49 -05:00
|
|
|
}
|