mirror of
https://github.com/wled/WLED.git
synced 2025-07-10 12:26:31 +00:00
Added 128x64 SSD1306 display.
This commit is contained in:
parent
cf9cf9d7bb
commit
1be8e7e216
@ -63,8 +63,9 @@ typedef enum {
|
|||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
NONE = 0,
|
NONE = 0,
|
||||||
SSD1306, // U8X8_SSD1306_128X32_UNIVISION_HW_I2C
|
SSD1306, // U8X8_SSD1306_128X32_UNIVISION_HW_I2C
|
||||||
SH1106 // U8X8_SH1106_128X64_WINSTAR_HW_I2C
|
SH1106, // U8X8_SH1106_128X64_WINSTAR_HW_I2C
|
||||||
|
SSD1306_64 // U8X8_SSD1306_128X64_UNIVISION_HW_I2C
|
||||||
} DisplayType;
|
} DisplayType;
|
||||||
|
|
||||||
class FourLineDisplayUsermod : public Usermod {
|
class FourLineDisplayUsermod : public Usermod {
|
||||||
@ -141,6 +142,10 @@ class FourLineDisplayUsermod : public Usermod {
|
|||||||
u8x8 = (void *) new U8X8_SH1106_128X64_WINSTAR_HW_I2C(U8X8_PIN_NONE, sclPin, sdaPin); // Pins are Reset, SCL, SDA
|
u8x8 = (void *) new U8X8_SH1106_128X64_WINSTAR_HW_I2C(U8X8_PIN_NONE, sclPin, sdaPin); // Pins are Reset, SCL, SDA
|
||||||
(static_cast<U8X8_SH1106_128X64_WINSTAR_HW_I2C*>(u8x8))->begin();
|
(static_cast<U8X8_SH1106_128X64_WINSTAR_HW_I2C*>(u8x8))->begin();
|
||||||
break;
|
break;
|
||||||
|
case SSD1306_64:
|
||||||
|
u8x8 = (void *) new U8X8_SSD1306_128X64_NONAME_HW_I2C(U8X8_PIN_NONE, sclPin, sdaPin); // Pins are Reset, SCL, SDA
|
||||||
|
(static_cast<U8X8_SSD1306_128X32_UNIVISION_HW_I2C*>(u8x8))->begin();
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
u8x8 = nullptr;
|
u8x8 = nullptr;
|
||||||
type = NONE;
|
type = NONE;
|
||||||
@ -180,6 +185,9 @@ class FourLineDisplayUsermod : public Usermod {
|
|||||||
case SH1106:
|
case SH1106:
|
||||||
(static_cast<U8X8_SH1106_128X64_WINSTAR_HW_I2C*>(u8x8))->setFlipMode(mode);
|
(static_cast<U8X8_SH1106_128X64_WINSTAR_HW_I2C*>(u8x8))->setFlipMode(mode);
|
||||||
break;
|
break;
|
||||||
|
case SSD1306_64:
|
||||||
|
(static_cast<U8X8_SSD1306_128X64_NONAME_HW_I2C*>(u8x8))->setFlipMode(mode);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -192,21 +200,29 @@ class FourLineDisplayUsermod : public Usermod {
|
|||||||
case SH1106:
|
case SH1106:
|
||||||
(static_cast<U8X8_SH1106_128X64_WINSTAR_HW_I2C*>(u8x8))->setContrast(contrast);
|
(static_cast<U8X8_SH1106_128X64_WINSTAR_HW_I2C*>(u8x8))->setContrast(contrast);
|
||||||
break;
|
break;
|
||||||
|
case SSD1306_64:
|
||||||
|
(static_cast<U8X8_SSD1306_128X64_NONAME_HW_I2C*>(u8x8))->setContrast(contrast);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void drawString(uint8_t col, uint8_t row, const char *string) {
|
void drawString(uint8_t col, uint8_t row, const char *string, bool ignoreLH=false) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case SSD1306:
|
case SSD1306:
|
||||||
(static_cast<U8X8_SSD1306_128X32_UNIVISION_HW_I2C*>(u8x8))->setFont(u8x8_font_chroma48medium8_r);
|
(static_cast<U8X8_SSD1306_128X32_UNIVISION_HW_I2C*>(u8x8))->setFont(u8x8_font_chroma48medium8_r);
|
||||||
if (lineHeight==2) (static_cast<U8X8_SSD1306_128X32_UNIVISION_HW_I2C*>(u8x8))->draw1x2String(col, row, string);
|
if (!ignoreLH && lineHeight==2) (static_cast<U8X8_SSD1306_128X32_UNIVISION_HW_I2C*>(u8x8))->draw1x2String(col, row, string);
|
||||||
else (static_cast<U8X8_SSD1306_128X32_UNIVISION_HW_I2C*>(u8x8))->drawString(col, row, string);
|
else (static_cast<U8X8_SSD1306_128X32_UNIVISION_HW_I2C*>(u8x8))->drawString(col, row, string);
|
||||||
break;
|
break;
|
||||||
case SH1106:
|
case SH1106:
|
||||||
(static_cast<U8X8_SH1106_128X64_WINSTAR_HW_I2C*>(u8x8))->setFont(u8x8_font_chroma48medium8_r);
|
(static_cast<U8X8_SH1106_128X64_WINSTAR_HW_I2C*>(u8x8))->setFont(u8x8_font_chroma48medium8_r);
|
||||||
if (lineHeight==2) (static_cast<U8X8_SH1106_128X64_WINSTAR_HW_I2C*>(u8x8))->draw1x2String(col, row, string);
|
if (!ignoreLH && lineHeight==2) (static_cast<U8X8_SH1106_128X64_WINSTAR_HW_I2C*>(u8x8))->draw1x2String(col, row, string);
|
||||||
else (static_cast<U8X8_SH1106_128X64_WINSTAR_HW_I2C*>(u8x8))->drawString(col, row, string);
|
else (static_cast<U8X8_SH1106_128X64_WINSTAR_HW_I2C*>(u8x8))->drawString(col, row, string);
|
||||||
|
break;
|
||||||
|
case SSD1306_64:
|
||||||
|
(static_cast<U8X8_SSD1306_128X64_NONAME_HW_I2C*>(u8x8))->setFont(u8x8_font_chroma48medium8_r);
|
||||||
|
if (!ignoreLH && lineHeight==2) (static_cast<U8X8_SSD1306_128X64_NONAME_HW_I2C*>(u8x8))->draw1x2String(col, row, string);
|
||||||
|
else (static_cast<U8X8_SSD1306_128X64_NONAME_HW_I2C*>(u8x8))->drawString(col, row, string);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
@ -222,21 +238,30 @@ class FourLineDisplayUsermod : public Usermod {
|
|||||||
(static_cast<U8X8_SH1106_128X64_WINSTAR_HW_I2C*>(u8x8))->setFont(u8x8_font_chroma48medium8_r);
|
(static_cast<U8X8_SH1106_128X64_WINSTAR_HW_I2C*>(u8x8))->setFont(u8x8_font_chroma48medium8_r);
|
||||||
(static_cast<U8X8_SH1106_128X64_WINSTAR_HW_I2C*>(u8x8))->draw2x2String(col, row, string);
|
(static_cast<U8X8_SH1106_128X64_WINSTAR_HW_I2C*>(u8x8))->draw2x2String(col, row, string);
|
||||||
break;
|
break;
|
||||||
|
case SSD1306_64:
|
||||||
|
(static_cast<U8X8_SSD1306_128X64_NONAME_HW_I2C*>(u8x8))->setFont(u8x8_font_chroma48medium8_r);
|
||||||
|
(static_cast<U8X8_SSD1306_128X64_NONAME_HW_I2C*>(u8x8))->draw2x2String(col, row, string);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void drawGlyph(uint8_t col, uint8_t row, char glyph, const uint8_t *font) {
|
void drawGlyph(uint8_t col, uint8_t row, char glyph, const uint8_t *font, bool ignoreLH=false) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case SSD1306:
|
case SSD1306:
|
||||||
(static_cast<U8X8_SSD1306_128X32_UNIVISION_HW_I2C*>(u8x8))->setFont(font);
|
(static_cast<U8X8_SSD1306_128X32_UNIVISION_HW_I2C*>(u8x8))->setFont(font);
|
||||||
if (lineHeight==2) (static_cast<U8X8_SSD1306_128X32_UNIVISION_HW_I2C*>(u8x8))->draw1x2Glyph(col, row, glyph);
|
if (!ignoreLH && lineHeight==2) (static_cast<U8X8_SSD1306_128X32_UNIVISION_HW_I2C*>(u8x8))->draw1x2Glyph(col, row, glyph);
|
||||||
else (static_cast<U8X8_SSD1306_128X32_UNIVISION_HW_I2C*>(u8x8))->drawGlyph(col, row, glyph);
|
else (static_cast<U8X8_SSD1306_128X32_UNIVISION_HW_I2C*>(u8x8))->drawGlyph(col, row, glyph);
|
||||||
break;
|
break;
|
||||||
case SH1106:
|
case SH1106:
|
||||||
(static_cast<U8X8_SH1106_128X64_WINSTAR_HW_I2C*>(u8x8))->setFont(font);
|
(static_cast<U8X8_SH1106_128X64_WINSTAR_HW_I2C*>(u8x8))->setFont(font);
|
||||||
if (lineHeight==2) (static_cast<U8X8_SH1106_128X64_WINSTAR_HW_I2C*>(u8x8))->draw1x2Glyph(col, row, glyph);
|
if (!ignoreLH && lineHeight==2) (static_cast<U8X8_SH1106_128X64_WINSTAR_HW_I2C*>(u8x8))->draw1x2Glyph(col, row, glyph);
|
||||||
else (static_cast<U8X8_SH1106_128X64_WINSTAR_HW_I2C*>(u8x8))->drawGlyph(col, row, glyph);
|
else (static_cast<U8X8_SH1106_128X64_WINSTAR_HW_I2C*>(u8x8))->drawGlyph(col, row, glyph);
|
||||||
|
break;
|
||||||
|
case SSD1306_64:
|
||||||
|
(static_cast<U8X8_SSD1306_128X64_NONAME_HW_I2C*>(u8x8))->setFont(font);
|
||||||
|
if (!ignoreLH && lineHeight==2) (static_cast<U8X8_SSD1306_128X64_NONAME_HW_I2C*>(u8x8))->draw1x2Glyph(col, row, glyph);
|
||||||
|
else (static_cast<U8X8_SSD1306_128X64_NONAME_HW_I2C*>(u8x8))->drawGlyph(col, row, glyph);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
@ -248,6 +273,8 @@ class FourLineDisplayUsermod : public Usermod {
|
|||||||
return (static_cast<U8X8_SSD1306_128X32_UNIVISION_HW_I2C*>(u8x8))->getCols();
|
return (static_cast<U8X8_SSD1306_128X32_UNIVISION_HW_I2C*>(u8x8))->getCols();
|
||||||
case SH1106:
|
case SH1106:
|
||||||
return (static_cast<U8X8_SH1106_128X64_WINSTAR_HW_I2C*>(u8x8))->getCols();
|
return (static_cast<U8X8_SH1106_128X64_WINSTAR_HW_I2C*>(u8x8))->getCols();
|
||||||
|
case SSD1306_64:
|
||||||
|
return (static_cast<U8X8_SSD1306_128X64_NONAME_HW_I2C*>(u8x8))->getCols();
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -260,6 +287,9 @@ class FourLineDisplayUsermod : public Usermod {
|
|||||||
case SH1106:
|
case SH1106:
|
||||||
(static_cast<U8X8_SH1106_128X64_WINSTAR_HW_I2C*>(u8x8))->clear();
|
(static_cast<U8X8_SH1106_128X64_WINSTAR_HW_I2C*>(u8x8))->clear();
|
||||||
break;
|
break;
|
||||||
|
case SSD1306_64:
|
||||||
|
(static_cast<U8X8_SSD1306_128X64_NONAME_HW_I2C*>(u8x8))->clear();
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -272,6 +302,9 @@ class FourLineDisplayUsermod : public Usermod {
|
|||||||
case SH1106:
|
case SH1106:
|
||||||
(static_cast<U8X8_SH1106_128X64_WINSTAR_HW_I2C*>(u8x8))->setPowerSave(save);
|
(static_cast<U8X8_SH1106_128X64_WINSTAR_HW_I2C*>(u8x8))->setPowerSave(save);
|
||||||
break;
|
break;
|
||||||
|
case SSD1306_64:
|
||||||
|
(static_cast<U8X8_SSD1306_128X64_NONAME_HW_I2C*>(u8x8))->setPowerSave(save);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -400,7 +433,7 @@ class FourLineDisplayUsermod : public Usermod {
|
|||||||
// Fourth row
|
// Fourth row
|
||||||
drawLineFour();
|
drawLineFour();
|
||||||
|
|
||||||
drawGlyph(0, 2, 66 + (bri > 0 ? 3 : 0), u8x8_font_open_iconic_weather_2x2); // sun/moon icon
|
drawGlyph(0, 2*lineHeight, 66 + (bri > 0 ? 3 : 0), u8x8_font_open_iconic_weather_2x2); // sun/moon icon
|
||||||
drawGlyph(0, 0, 80, u8x8_font_open_iconic_embedded_1x1); // wifi icon
|
drawGlyph(0, 0, 80, u8x8_font_open_iconic_embedded_1x1); // wifi icon
|
||||||
drawGlyph(0, lineHeight, 68, u8x8_font_open_iconic_embedded_1x1); // home icon
|
drawGlyph(0, lineHeight, 68, u8x8_font_open_iconic_embedded_1x1); // home icon
|
||||||
//if (markLineNum>1) drawGlyph(2, markLineNum*lineHeight, 66, u8x8_font_open_iconic_arrow_1x1); // arrow icon
|
//if (markLineNum>1) drawGlyph(2, markLineNum*lineHeight, 66, u8x8_font_open_iconic_arrow_1x1); // arrow icon
|
||||||
@ -599,7 +632,7 @@ class FourLineDisplayUsermod : public Usermod {
|
|||||||
draw2x2String(TIME_INDENT+2, lineHeight*2, lineBuffer);
|
draw2x2String(TIME_INDENT+2, lineHeight*2, lineBuffer);
|
||||||
if (useAMPM) drawString(12, lineHeight*2, (isAM ? "AM" : "PM"));
|
if (useAMPM) drawString(12, lineHeight*2, (isAM ? "AM" : "PM"));
|
||||||
sprintf_P(lineBuffer, PSTR("%02d"), secondCurrent);
|
sprintf_P(lineBuffer, PSTR("%02d"), secondCurrent);
|
||||||
drawString(12, lineHeight*2+1, lineBuffer);
|
drawString(12, lineHeight*2+1, lineBuffer, true);
|
||||||
} else {
|
} else {
|
||||||
drawString(9, lineHeight*2, lineBuffer);
|
drawString(9, lineHeight*2, lineBuffer);
|
||||||
}
|
}
|
||||||
@ -680,7 +713,6 @@ class FourLineDisplayUsermod : public Usermod {
|
|||||||
newScl = top["pin"][0];
|
newScl = top["pin"][0];
|
||||||
newSda = top["pin"][1];
|
newSda = top["pin"][1];
|
||||||
newType = top["type"];
|
newType = top["type"];
|
||||||
lineHeight = type==SH1106 ? 2 : 1;
|
|
||||||
if (top[FPSTR(_flip)].is<bool>()) {
|
if (top[FPSTR(_flip)].is<bool>()) {
|
||||||
flip = top[FPSTR(_flip)].as<bool>();
|
flip = top[FPSTR(_flip)].as<bool>();
|
||||||
} else {
|
} else {
|
||||||
@ -715,11 +747,13 @@ class FourLineDisplayUsermod : public Usermod {
|
|||||||
sclPin = newScl;
|
sclPin = newScl;
|
||||||
sdaPin = newSda;
|
sdaPin = newSda;
|
||||||
type = newType;
|
type = newType;
|
||||||
|
lineHeight = type==SSD1306 ? 1 : 2;
|
||||||
} else {
|
} else {
|
||||||
// changing paramters from settings page
|
// changing paramters from settings page
|
||||||
if (sclPin!=newScl || sdaPin!=newSda || type!=newType) {
|
if (sclPin!=newScl || sdaPin!=newSda || type!=newType) {
|
||||||
if (type==SSD1306) delete (static_cast<U8X8_SSD1306_128X32_UNIVISION_HW_I2C*>(u8x8));
|
if (type==SSD1306) delete (static_cast<U8X8_SSD1306_128X32_UNIVISION_HW_I2C*>(u8x8));
|
||||||
if (type==SH1106) delete (static_cast<U8X8_SH1106_128X64_WINSTAR_HW_I2C*>(u8x8));
|
if (type==SH1106) delete (static_cast<U8X8_SH1106_128X64_WINSTAR_HW_I2C*>(u8x8));
|
||||||
|
if (type==SSD1306_64) delete (static_cast<U8X8_SSD1306_128X64_NONAME_HW_I2C*>(u8x8));
|
||||||
pinManager.deallocatePin(sclPin);
|
pinManager.deallocatePin(sclPin);
|
||||||
pinManager.deallocatePin(sdaPin);
|
pinManager.deallocatePin(sdaPin);
|
||||||
sclPin = newScl;
|
sclPin = newScl;
|
||||||
@ -729,7 +763,7 @@ class FourLineDisplayUsermod : public Usermod {
|
|||||||
return;
|
return;
|
||||||
} else
|
} else
|
||||||
type = newType;
|
type = newType;
|
||||||
lineHeight = type==SH1106 ? 2 : 1;
|
lineHeight = type==SSD1306 ? 1 : 2;
|
||||||
setup();
|
setup();
|
||||||
needRedraw |= true;
|
needRedraw |= true;
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// version code in format yymmddb (b = daily build)
|
// version code in format yymmddb (b = daily build)
|
||||||
#define VERSION 2104221
|
#define VERSION 2104231
|
||||||
|
|
||||||
//uncomment this if you have a "my_config.h" file you'd like to use
|
//uncomment this if you have a "my_config.h" file you'd like to use
|
||||||
//#define WLED_USE_MY_CONFIG
|
//#define WLED_USE_MY_CONFIG
|
||||||
|
Loading…
x
Reference in New Issue
Block a user