7namespace ssd1306_base {
9static const char *
const TAG =
"ssd1306";
11static const uint8_t SSD1306_MAX_CONTRAST = 255;
12static const uint8_t SSD1305_MAX_BRIGHTNESS = 255;
14static const uint8_t SSD1306_COMMAND_DISPLAY_OFF = 0xAE;
15static const uint8_t SSD1306_COMMAND_DISPLAY_ON = 0xAF;
16static const uint8_t SSD1306_COMMAND_SET_DISPLAY_CLOCK_DIV = 0xD5;
17static const uint8_t SSD1306_COMMAND_SET_MULTIPLEX = 0xA8;
18static const uint8_t SSD1306_COMMAND_SET_DISPLAY_OFFSET_Y = 0xD3;
19static const uint8_t SSD1306_COMMAND_SET_START_LINE = 0x40;
20static const uint8_t SSD1306_COMMAND_CHARGE_PUMP = 0x8D;
21static const uint8_t SSD1306_COMMAND_MEMORY_MODE = 0x20;
22static const uint8_t SSD1306_COMMAND_SEGRE_MAP = 0xA0;
23static const uint8_t SSD1306_COMMAND_COM_SCAN_INC = 0xC0;
24static const uint8_t SSD1306_COMMAND_COM_SCAN_DEC = 0xC8;
25static const uint8_t SSD1306_COMMAND_SET_COM_PINS = 0xDA;
26static const uint8_t SSD1306_COMMAND_SET_CONTRAST = 0x81;
27static const uint8_t SSD1306_COMMAND_SET_PRE_CHARGE = 0xD9;
28static const uint8_t SSD1306_COMMAND_SET_VCOM_DETECT = 0xDB;
29static const uint8_t SSD1306_COMMAND_DISPLAY_ALL_ON_RESUME = 0xA4;
30static const uint8_t SSD1306_COMMAND_DEACTIVATE_SCROLL = 0x2E;
31static const uint8_t SSD1306_COMMAND_COLUMN_ADDRESS = 0x21;
32static const uint8_t SSD1306_COMMAND_PAGE_ADDRESS = 0x22;
33static const uint8_t SSD1306_COMMAND_NORMAL_DISPLAY = 0xA6;
34static const uint8_t SSD1306_COMMAND_INVERSE_DISPLAY = 0xA7;
36static const uint8_t SSD1306B_COMMAND_SELECT_IREF = 0xAD;
38static const uint8_t SSD1305_COMMAND_SET_BRIGHTNESS = 0x82;
39static const uint8_t SSD1305_COMMAND_SET_AREA_COLOR = 0xD8;
41static const uint8_t SH1107_COMMAND_SET_START_LINE = 0xDC;
42static const uint8_t SH1107_COMMAND_CHARGE_PUMP = 0xAD;
48struct ModelDimensions {
52static constexpr ModelDimensions MODEL_DIMS[] PROGMEM = {
89 "MODEL_DIMS must have one entry per SSD1306Model");
91 "ModelStrings must have one entry per SSD1306Model plus fallback");
106 this->
command(SSD1306_COMMAND_DISPLAY_OFF);
111 this->
command(SSD1306_COMMAND_SET_DISPLAY_CLOCK_DIV);
118 this->
command(SSD1305_COMMAND_SET_AREA_COLOR);
123 this->
command(SSD1306_COMMAND_SET_MULTIPLEX);
127 this->
command(SSD1306_COMMAND_SET_DISPLAY_OFFSET_Y);
132 this->
command(SH1107_COMMAND_SET_START_LINE);
136 this->
command(SSD1306_COMMAND_SET_START_LINE | 0x00);
143 this->
command(SH1107_COMMAND_CHARGE_PUMP);
152 this->
command(SSD1306B_COMMAND_SELECT_IREF);
157 this->
command(SSD1306_COMMAND_CHARGE_PUMP);
166 this->
command(SSD1306_COMMAND_MEMORY_MODE);
175 this->
command(SSD1306_COMMAND_COM_SCAN_INC | (this->
flip_y_ << 3));
179 this->
command(SSD1306_COMMAND_SET_COM_PINS);
206 this->
command(SSD1306_COMMAND_SET_PRE_CHARGE);
214 this->
command(SSD1306_COMMAND_SET_VCOM_DETECT);
230 this->
command(SSD1306_COMMAND_DISPLAY_ALL_ON_RESUME);
236 this->
command(SSD1306_COMMAND_DEACTIVATE_SCROLL);
255 this->
command(SSD1306_COMMAND_COLUMN_ADDRESS);
272 this->
command(SSD1306_COMMAND_PAGE_ADDRESS);
303 this->
contrast_ = clamp(contrast, 0.0F, 1.0F);
305 this->
command(SSD1306_COMMAND_SET_CONTRAST);
315 this->
command(SSD1305_COMMAND_SET_BRIGHTNESS);
320 this->
command(SSD1306_COMMAND_DISPLAY_ON);
324 this->
command(SSD1306_COMMAND_DISPLAY_OFF);
345 uint8_t subpos =
y & 0x07;
355 Display::fill(color);
359 uint8_t
fill = color.
is_on() ? 0xFF : 0x00;
376 return ModelStrings::get_log_str(
static_cast<uint8_t
>(this->
model_), ModelStrings::LAST_INDEX);
PROGMEM_STRING_TABLE(ModelStrings, "SSD1306 128x32", "SSD1306 128x64", "SSD1306 96x16", "SSD1306 64x48", "SSD1306 64x32", "SSD1306 72x40", "SH1106 128x32", "SH1106 128x64", "SH1106 96x16", "SH1106 64x48", "SH1107 128x64", "SH1107 128x128", "SSD1305 128x32", "SSD1305 128x64", "Unknown")