6 namespace ssd1322_base {
8 static const char *
const TAG =
"ssd1322";
10 static const uint8_t SSD1322_MAX_CONTRAST = 255;
11 static const uint8_t SSD1322_COLORMASK = 0x0f;
12 static const uint8_t SSD1322_COLORSHIFT = 4;
13 static const uint8_t SSD1322_PIXELSPERBYTE = 2;
15 static const uint8_t SSD1322_ENABLEGRAYSCALETABLE = 0x00;
16 static const uint8_t SSD1322_SETCOLUMNADDRESS = 0x15;
17 static const uint8_t SSD1322_WRITERAM = 0x5C;
18 static const uint8_t SSD1322_READRAM = 0x5D;
19 static const uint8_t SSD1322_SETROWADDRESS = 0x75;
20 static const uint8_t SSD1322_SETREMAP = 0xA0;
21 static const uint8_t SSD1322_SETSTARTLINE = 0xA1;
22 static const uint8_t SSD1322_SETOFFSET = 0xA2;
23 static const uint8_t SSD1322_SETMODEALLOFF = 0xA4;
24 static const uint8_t SSD1322_SETMODEALLON = 0xA5;
25 static const uint8_t SSD1322_SETMODENORMAL = 0xA6;
26 static const uint8_t SSD1322_SETMODEINVERTED = 0xA7;
27 static const uint8_t SSD1322_ENABLEPARTIALDISPLAY = 0xA8;
28 static const uint8_t SSD1322_EXITPARTIALDISPLAY = 0xA9;
29 static const uint8_t SSD1322_SETFUNCTIONSELECTION = 0xAB;
30 static const uint8_t SSD1322_SETDISPLAYOFF = 0xAE;
31 static const uint8_t SSD1322_SETDISPLAYON = 0xAF;
32 static const uint8_t SSD1322_SETPHASELENGTH = 0xB1;
33 static const uint8_t SSD1322_SETFRONTCLOCKDIVIDER = 0xB3;
34 static const uint8_t SSD1322_DISPLAYENHANCEMENTA = 0xB4;
35 static const uint8_t SSD1322_SETGPIO = 0xB5;
36 static const uint8_t SSD1322_SETSECONDPRECHARGEPERIOD = 0xB6;
37 static const uint8_t SSD1322_SETGRAYSCALETABLE = 0xB8;
38 static const uint8_t SSD1322_SELECTDEFAULTLINEARGRAYSCALETABLE = 0xB9;
39 static const uint8_t SSD1322_SETPRECHARGEVOLTAGE = 0xBB;
40 static const uint8_t SSD1322_SETVCOMHVOLTAGE = 0xBE;
41 static const uint8_t SSD1322_SETCONTRAST = 0xC1;
42 static const uint8_t SSD1322_MASTERCURRENTCONTROL = 0xC7;
43 static const uint8_t SSD1322_SETMULTIPLEXRATIO = 0xCA;
44 static const uint8_t SSD1322_DISPLAYENHANCEMENTB = 0xD1;
45 static const uint8_t SSD1322_SETCOMMANDLOCK = 0xFD;
47 static const uint8_t SSD1322_SETCOMMANDLOCK_UNLOCK = 0x12;
48 static const uint8_t SSD1322_SETCOMMANDLOCK_LOCK = 0x16;
53 this->
command(SSD1322_SETCOMMANDLOCK);
54 this->
data(SSD1322_SETCOMMANDLOCK_UNLOCK);
56 this->
command(SSD1322_SETFRONTCLOCKDIVIDER);
58 this->
command(SSD1322_SETMULTIPLEXRATIO);
60 this->
command(SSD1322_SETOFFSET);
62 this->
command(SSD1322_SETSTARTLINE);
64 this->
command(SSD1322_SETREMAP);
69 this->
command(SSD1322_SETFUNCTIONSELECTION);
71 this->
command(SSD1322_DISPLAYENHANCEMENTA);
74 this->
command(SSD1322_MASTERCURRENTCONTROL);
76 this->
command(SSD1322_SETPHASELENGTH);
78 this->
command(SSD1322_DISPLAYENHANCEMENTB);
81 this->
command(SSD1322_SETPRECHARGEVOLTAGE);
83 this->
command(SSD1322_SETSECONDPRECHARGEPERIOD);
85 this->
command(SSD1322_SETVCOMHVOLTAGE);
87 this->
command(SSD1322_SETMODENORMAL);
88 this->
command(SSD1322_EXITPARTIALDISPLAY);
90 this->
command(SSD1322_SETGRAYSCALETABLE);
107 this->
command(SSD1322_ENABLEGRAYSCALETABLE);
114 this->
command(SSD1322_SETCOLUMNADDRESS);
117 this->
command(SSD1322_SETROWADDRESS);
120 this->
command(SSD1322_WRITERAM);
131 this->
command(SSD1322_SETCONTRAST);
136 this->
command(SSD1322_SETDISPLAYON);
140 this->
command(SSD1322_SETDISPLAYOFF);
167 uint16_t pos = (x / SSD1322_PIXELSPERBYTE) + (y * this->
get_width_internal() / SSD1322_PIXELSPERBYTE);
168 uint8_t shift = (1u - (x % SSD1322_PIXELSPERBYTE)) * SSD1322_COLORSHIFT;
170 color4 = (color4 & SSD1322_COLORMASK) << shift;
172 this->
buffer_[pos] &= (~SSD1322_COLORMASK >> shift);
178 uint8_t
fill = (color4 & SSD1322_COLORMASK) | ((color4 & SSD1322_COLORMASK) << SSD1322_COLORSHIFT);
197 return "SSD1322 256x64";
virtual void digital_write(bool value)=0
size_t get_buffer_length_()
int get_width_internal() override
virtual void data(uint8_t value)=0
int get_height_internal() override
constexpr const T & clamp(const T &v, const T &lo, const T &hi, Compare comp)
void init_internal_(uint32_t buffer_length)
const char * model_str_()
static uint32_t color_to_grayscale4(Color color)
virtual void command(uint8_t value)=0
void draw_absolute_pixel_internal(int x, int y, Color color) override
virtual void write_display_data()=0
Implementation of SPI Controller mode.
void set_brightness(float brightness)
void fill(Color color) override
void IRAM_ATTR HOT delay(uint32_t ms)