37 lines
1.2 KiB
C
Raw Normal View History

2025-02-15 10:11:49 -05:00
#ifndef SSD1306_H
#define SSD1306_H
#include <esp_lcd_panel_ssd1306.h>
#include "panel_device.h"
// According to SSD1306 datasheet
// https://www.digikey.com/en/products/detail/winstar-display/WEA012864DWPP3N00003/20533255
// Bit number used to represent command and parameter
#define SCREEN_WIDTH 128 // OLED display width, in pixels.
#define SCREEN_HEIGHT 64 // OLED display height, in pixels.
#define LCD_H_RES SCREEN_WIDTH
#define LCD_V_RES SCREEN_HEIGHT
#define I2C_HW_ADDR 0x3C
#define LCD_PIXEL_CLOCK_HZ (400 * 1000)
#define LCD_CMD_BITS 8
#define LCD_PARAM_BITS 8
// Pin may vary based on your schematic.
#define PIN_SDA GPIO_NUM_21
#define PIN_SCL GPIO_NUM_22
#define PIN_RST -1
class SSD1306 : public PanelDevice<esp_lcd_panel_ssd1306_config_t> {
public:
explicit SSD1306(esp_lcd_panel_ssd1306_config_t ssd_config,
int width = SCREEN_WIDTH, int height = SCREEN_HEIGHT);
~SSD1306() = default;
// For LV_COLOR_FORMAT_I1 we need an extra buffer to hold the converted data.
static uint8_t oled_buffer_[LCD_H_RES * LCD_V_RES / 8];
};
#endif // SSD1306_H