6 namespace ssd1306_base {
8 static const char *
const TAG =
"ssd1306";
10 static const uint8_t SSD1306_MAX_CONTRAST = 255;
11 static const uint8_t SSD1305_MAX_BRIGHTNESS = 255;
13 static const uint8_t SSD1306_COMMAND_DISPLAY_OFF = 0xAE;
14 static const uint8_t SSD1306_COMMAND_DISPLAY_ON = 0xAF;
15 static const uint8_t SSD1306_COMMAND_SET_DISPLAY_CLOCK_DIV = 0xD5;
16 static const uint8_t SSD1306_COMMAND_SET_MULTIPLEX = 0xA8;
17 static const uint8_t SSD1306_COMMAND_SET_DISPLAY_OFFSET_Y = 0xD3;
18 static const uint8_t SSD1306_COMMAND_SET_START_LINE = 0x40;
19 static const uint8_t SSD1306_COMMAND_CHARGE_PUMP = 0x8D;
20 static const uint8_t SSD1306_COMMAND_MEMORY_MODE = 0x20;
21 static const uint8_t SSD1306_COMMAND_SEGRE_MAP = 0xA0;
22 static const uint8_t SSD1306_COMMAND_COM_SCAN_INC = 0xC0;
23 static const uint8_t SSD1306_COMMAND_COM_SCAN_DEC = 0xC8;
24 static const uint8_t SSD1306_COMMAND_SET_COM_PINS = 0xDA;
25 static const uint8_t SSD1306_COMMAND_SET_CONTRAST = 0x81;
26 static const uint8_t SSD1306_COMMAND_SET_PRE_CHARGE = 0xD9;
27 static const uint8_t SSD1306_COMMAND_SET_VCOM_DETECT = 0xDB;
28 static const uint8_t SSD1306_COMMAND_DISPLAY_ALL_ON_RESUME = 0xA4;
29 static const uint8_t SSD1306_COMMAND_DEACTIVATE_SCROLL = 0x2E;
30 static const uint8_t SSD1306_COMMAND_COLUMN_ADDRESS = 0x21;
31 static const uint8_t SSD1306_COMMAND_PAGE_ADDRESS = 0x22;
32 static const uint8_t SSD1306_COMMAND_NORMAL_DISPLAY = 0xA6;
33 static const uint8_t SSD1306_COMMAND_INVERSE_DISPLAY = 0xA7;
35 static const uint8_t SSD1305_COMMAND_SET_BRIGHTNESS = 0x82;
36 static const uint8_t SSD1305_COMMAND_SET_AREA_COLOR = 0xD8;
38 static const uint8_t SH1107_COMMAND_SET_START_LINE = 0xDC;
39 static const uint8_t SH1107_COMMAND_CHARGE_PUMP = 0xAD;
54 this->
command(SSD1306_COMMAND_DISPLAY_OFF);
59 this->
command(SSD1306_COMMAND_SET_DISPLAY_CLOCK_DIV);
66 this->
command(SSD1305_COMMAND_SET_AREA_COLOR);
71 this->
command(SSD1306_COMMAND_SET_MULTIPLEX);
75 this->
command(SSD1306_COMMAND_SET_DISPLAY_OFFSET_Y);
80 this->
command(SH1107_COMMAND_SET_START_LINE);
84 this->
command(SSD1306_COMMAND_SET_START_LINE | 0x00);
91 this->
command(SH1107_COMMAND_CHARGE_PUMP);
99 this->
command(SSD1306_COMMAND_CHARGE_PUMP);
108 this->
command(SSD1306_COMMAND_MEMORY_MODE);
117 this->
command(SSD1306_COMMAND_COM_SCAN_INC | (this->
flip_y_ << 3));
121 this->
command(SSD1306_COMMAND_SET_COM_PINS);
147 this->
command(SSD1306_COMMAND_SET_PRE_CHARGE);
155 this->
command(SSD1306_COMMAND_SET_VCOM_DETECT);
171 this->
command(SSD1306_COMMAND_DISPLAY_ALL_ON_RESUME);
177 this->
command(SSD1306_COMMAND_DEACTIVATE_SCROLL);
196 this->
command(SSD1306_COMMAND_COLUMN_ADDRESS);
213 this->
command(SSD1306_COMMAND_PAGE_ADDRESS);
244 this->
command(SSD1306_COMMAND_SET_CONTRAST);
254 this->
command(SSD1305_COMMAND_SET_BRIGHTNESS);
259 this->
command(SSD1306_COMMAND_DISPLAY_ON);
263 this->
command(SSD1306_COMMAND_DISPLAY_OFF);
324 uint8_t subpos = y & 0x07;
326 this->
buffer_[pos] |= (1 << subpos);
328 this->
buffer_[pos] &= ~(1 << subpos);
332 uint8_t
fill = color.
is_on() ? 0xFF : 0x00;
351 return "SSD1306 128x32";
353 return "SSD1306 128x64";
355 return "SSD1306 64x32";
357 return "SSD1306 96x16";
359 return "SSD1306 64x48";
361 return "SSD1306 72x40";
363 return "SH1106 128x32";
365 return "SH1106 128x64";
367 return "SH1106 96x16";
369 return "SH1106 64x48";
371 return "SH1107 128x64";
373 return "SSD1305 128x32";
375 return "SSD1305 128x64";
int get_height_internal() override
virtual void digital_write(bool value)=0
void set_invert(bool invert)
virtual void write_display_data()=0
constexpr const T & clamp(const T &v, const T &lo, const T &hi, Compare comp)
bool is_on() ESPHOME_ALWAYS_INLINE
void set_contrast(float contrast)
size_t get_buffer_length_()
void init_internal_(uint32_t buffer_length)
const char * model_str_()
int get_width_internal() override
void draw_absolute_pixel_internal(int x, int y, Color color) override
Implementation of SPI Controller mode.
virtual void command(uint8_t value)=0
void fill(Color color) override
void set_brightness(float brightness)
void IRAM_ATTR HOT delay(uint32_t ms)