11static constexpr uint8_t SH1122_MAX_CONTRAST = 255;
12static constexpr uint8_t SH1122_COLORMASK = 0x0f;
13static constexpr uint8_t SH1122_COLORSHIFT = 4;
14static constexpr uint8_t SH1122_PIXELSPERBYTE = 2;
16static constexpr uint8_t SH1122_SETLOWCOLUMNADDRESS = 0x00;
17static constexpr uint8_t SH1122_SETHIGHCOLUMNADDRESS = 0x10;
18static constexpr uint8_t SH1122_SETDISCHARGEVSLLEVEL = 0x30;
19static constexpr uint8_t SH1122_SETDISPLAYSTARTLINE = 0x40;
20static constexpr uint8_t SH1122_SETCONTRASTCURRENT = 0x81;
21static constexpr uint8_t SH1122_SETSEGMENTREMAP = 0xA0;
22static constexpr uint8_t SH1122_SETDISPLAYOFFON = 0xA4;
23static constexpr uint8_t SH1122_SETNORMALDISPLAY = 0xA6;
24static constexpr uint8_t SH1122_SETMULTIPLEXRATIO = 0xA8;
25static constexpr uint8_t SH1122_DCDCSETTING = 0xAD;
26static constexpr uint8_t SH1122_SETDISPLAYOFF = 0xAE;
27static constexpr uint8_t SH1122_SETDISPLAYON = 0xAF;
28static constexpr uint8_t SH1122_SETROWADDRESS = 0xB0;
29static constexpr uint8_t SH1122_SETSCANDIRECTION = 0xC0;
30static constexpr uint8_t SH1122_SETDISPLAYOFFSET = 0xD3;
31static constexpr uint8_t SH1122_SETCLOCKDIVIDER = 0xD5;
32static constexpr uint8_t SH1122_SETDISCHARGEPRECHARGEPERIOD = 0xD9;
33static constexpr uint8_t SH1122_SETVCOMDESELECTLEVEL = 0xDB;
34static constexpr uint8_t SH1122_SETVSEGMLEVEL = 0xDC;
44 this->
command2_(SH1122_SETCLOCKDIVIDER, 0x50);
45 this->
command2_(SH1122_SETMULTIPLEXRATIO, 0x3F);
46 this->
command2_(SH1122_SETDISPLAYOFFSET, 0x00);
47 this->
command2_(SH1122_SETROWADDRESS, 0x00);
48 this->
command_(SH1122_SETDISPLAYSTARTLINE | 32);
49 this->
command_(SH1122_SETDISCHARGEVSLLEVEL);
50 this->
command2_(SH1122_DCDCSETTING, 0x81);
51 this->
command_(SH1122_SETSEGMENTREMAP | 0x01);
52 this->
command_(SH1122_SETSCANDIRECTION | 0x08);
53 this->
command2_(SH1122_SETDISCHARGEPRECHARGEPERIOD, 0x28);
54 this->
command2_(SH1122_SETVCOMDESELECTLEVEL, 0x35);
55 this->
command2_(SH1122_SETVSEGMLEVEL, 0x35);
56 this->
command_(SH1122_SETNORMALDISPLAY);
57 this->
command_(SH1122_SETHIGHCOLUMNADDRESS);
58 this->
command_(SH1122_SETLOWCOLUMNADDRESS);
59 this->
command_(SH1122_SETDISPLAYOFFON);
66 const uint8_t set_address[] = {SH1122_SETHIGHCOLUMNADDRESS, SH1122_SETLOWCOLUMNADDRESS, SH1122_SETROWADDRESS, 0x00};
83 this->
command_(SH1122_SETDISPLAYOFF);
110 const uint32_t color4 = display::ColorUtil::color_to_grayscale4(color) & SH1122_COLORMASK;
111 const uint16_t
pos = (
x / SH1122_PIXELSPERBYTE) + (
y * width / SH1122_PIXELSPERBYTE);
112 const uint8_t shift = (1u - (
x % SH1122_PIXELSPERBYTE)) * SH1122_COLORSHIFT;
113 this->
buffer_[
pos] = (this->
buffer_[
pos] & (
static_cast<uint8_t
>(~SH1122_COLORMASK) >> shift)) | (color4 << shift);
118 Display::fill(color);
121 const uint32_t color4 = display::ColorUtil::color_to_grayscale4(color);
122 const uint8_t
fill = (color4 & SH1122_COLORMASK) | ((color4 & SH1122_COLORMASK) << SH1122_COLORSHIFT);
140 return LOG_STR(
"SH1122 256x64");
142 return LOG_STR(
"Unknown");