Bugfix (sclPin, sdaPin).
Removed unnecessary static_cast.
This commit is contained in:
parent
83c6f72eb0
commit
e80594d61d
@ -168,7 +168,6 @@ class FourLineDisplayUsermod : public Usermod {
|
|||||||
// network here
|
// network here
|
||||||
void setup() {
|
void setup() {
|
||||||
if (type == NONE) return;
|
if (type == NONE) return;
|
||||||
byte i;
|
|
||||||
if (type == SSD1306_SPI || type == SSD1306_SPI64) {
|
if (type == SSD1306_SPI || type == SSD1306_SPI64) {
|
||||||
PinManagerPinType pins[5] = { { ioPin[0], true }, { ioPin[1], true}, { ioPin[2], true }, { ioPin[3], true}, { ioPin[4], true }};
|
PinManagerPinType pins[5] = { { ioPin[0], true }, { ioPin[1], true}, { ioPin[2], true }, { ioPin[3], true}, { ioPin[4], true }};
|
||||||
if (!pinManager.allocateMultiplePins(pins, 5, PinOwner::UM_FourLineDisplay)) { type=NONE; return; }
|
if (!pinManager.allocateMultiplePins(pins, 5, PinOwner::UM_FourLineDisplay)) { type=NONE; return; }
|
||||||
@ -242,17 +241,14 @@ class FourLineDisplayUsermod : public Usermod {
|
|||||||
}
|
}
|
||||||
if (nullptr == u8x8) {
|
if (nullptr == u8x8) {
|
||||||
DEBUG_PRINTLN(F("Display init failed."));
|
DEBUG_PRINTLN(F("Display init failed."));
|
||||||
pinManager.deallocatePin(sclPin, PinOwner::UM_FourLineDisplay);
|
for (byte i=0; i<5 && ioPin[i]>=0; i++) pinManager.deallocatePin(ioPin[i], PinOwner::UM_FourLineDisplay);
|
||||||
pinManager.deallocatePin(sdaPin, PinOwner::UM_FourLineDisplay);
|
|
||||||
sclPin = -1;
|
|
||||||
sdaPin = -1;
|
|
||||||
type = NONE;
|
type = NONE;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
initDone = true;
|
initDone = true;
|
||||||
DEBUG_PRINTLN(F("Starting display."));
|
DEBUG_PRINTLN(F("Starting display."));
|
||||||
(static_cast<U8X8*>(u8x8))->begin(); // why a static cast here? variable is of this type...
|
u8x8->begin();
|
||||||
setFlipMode(flip);
|
setFlipMode(flip);
|
||||||
setContrast(contrast); //Contrast setup will help to preserve OLED lifetime. In case OLED need to be brighter increase number up to 255
|
setContrast(contrast); //Contrast setup will help to preserve OLED lifetime. In case OLED need to be brighter increase number up to 255
|
||||||
setPowerSave(0);
|
setPowerSave(0);
|
||||||
@ -278,40 +274,40 @@ class FourLineDisplayUsermod : public Usermod {
|
|||||||
*/
|
*/
|
||||||
void setFlipMode(uint8_t mode) {
|
void setFlipMode(uint8_t mode) {
|
||||||
if (type==NONE) return;
|
if (type==NONE) return;
|
||||||
(static_cast<U8X8*>(u8x8))->setFlipMode(mode);
|
u8x8->setFlipMode(mode);
|
||||||
}
|
}
|
||||||
void setContrast(uint8_t contrast) {
|
void setContrast(uint8_t contrast) {
|
||||||
if (type==NONE) return;
|
if (type==NONE) return;
|
||||||
(static_cast<U8X8*>(u8x8))->setContrast(contrast);
|
u8x8->setContrast(contrast);
|
||||||
}
|
}
|
||||||
void drawString(uint8_t col, uint8_t row, const char *string, bool ignoreLH=false) {
|
void drawString(uint8_t col, uint8_t row, const char *string, bool ignoreLH=false) {
|
||||||
if (type==NONE) return;
|
if (type==NONE) return;
|
||||||
(static_cast<U8X8*>(u8x8))->setFont(u8x8_font_chroma48medium8_r);
|
u8x8->setFont(u8x8_font_chroma48medium8_r);
|
||||||
if (!ignoreLH && lineHeight==2) (static_cast<U8X8*>(u8x8))->draw1x2String(col, row, string);
|
if (!ignoreLH && lineHeight==2) u8x8->draw1x2String(col, row, string);
|
||||||
else (static_cast<U8X8*>(u8x8))->drawString(col, row, string);
|
else u8x8->drawString(col, row, string);
|
||||||
}
|
}
|
||||||
void draw2x2String(uint8_t col, uint8_t row, const char *string) {
|
void draw2x2String(uint8_t col, uint8_t row, const char *string) {
|
||||||
if (type==NONE) return;
|
if (type==NONE) return;
|
||||||
(static_cast<U8X8*>(u8x8))->setFont(u8x8_font_chroma48medium8_r);
|
u8x8->setFont(u8x8_font_chroma48medium8_r);
|
||||||
(static_cast<U8X8*>(u8x8))->draw2x2String(col, row, string);
|
u8x8->draw2x2String(col, row, string);
|
||||||
}
|
}
|
||||||
void drawGlyph(uint8_t col, uint8_t row, char glyph, const uint8_t *font, bool ignoreLH=false) {
|
void drawGlyph(uint8_t col, uint8_t row, char glyph, const uint8_t *font, bool ignoreLH=false) {
|
||||||
if (type==NONE) return;
|
if (type==NONE) return;
|
||||||
(static_cast<U8X8*>(u8x8))->setFont(font);
|
u8x8->setFont(font);
|
||||||
if (!ignoreLH && lineHeight==2) (static_cast<U8X8*>(u8x8))->draw1x2Glyph(col, row, glyph);
|
if (!ignoreLH && lineHeight==2) u8x8->draw1x2Glyph(col, row, glyph);
|
||||||
else (static_cast<U8X8*>(u8x8))->drawGlyph(col, row, glyph);
|
else u8x8->drawGlyph(col, row, glyph);
|
||||||
}
|
}
|
||||||
uint8_t getCols() {
|
uint8_t getCols() {
|
||||||
if (type==NONE) return 0;
|
if (type==NONE) return 0;
|
||||||
return (static_cast<U8X8*>(u8x8))->getCols();
|
return u8x8->getCols();
|
||||||
}
|
}
|
||||||
void clear() {
|
void clear() {
|
||||||
if (type==NONE) return;
|
if (type==NONE) return;
|
||||||
(static_cast<U8X8*>(u8x8))->clear();
|
u8x8->clear();
|
||||||
}
|
}
|
||||||
void setPowerSave(uint8_t save) {
|
void setPowerSave(uint8_t save) {
|
||||||
if (type==NONE) return;
|
if (type==NONE) return;
|
||||||
(static_cast<U8X8*>(u8x8))->setPowerSave(save);
|
u8x8->setPowerSave(save);
|
||||||
}
|
}
|
||||||
|
|
||||||
void center(String &line, uint8_t width) {
|
void center(String &line, uint8_t width) {
|
||||||
@ -726,7 +722,7 @@ class FourLineDisplayUsermod : public Usermod {
|
|||||||
bool pinsChanged = false;
|
bool pinsChanged = false;
|
||||||
for (byte i=0; i<5; i++) if (ioPin[i] != newPin[i]) { pinsChanged = true; break; }
|
for (byte i=0; i<5; i++) if (ioPin[i] != newPin[i]) { pinsChanged = true; break; }
|
||||||
if (pinsChanged || type!=newType) {
|
if (pinsChanged || type!=newType) {
|
||||||
if (type != NONE) delete (static_cast<U8X8*>(u8x8));
|
if (type != NONE) delete u8x8;
|
||||||
for (byte i=0; i<5; i++) {
|
for (byte i=0; i<5; i++) {
|
||||||
if (ioPin[i]>=0) pinManager.deallocatePin(ioPin[i], PinOwner::UM_FourLineDisplay);
|
if (ioPin[i]>=0) pinManager.deallocatePin(ioPin[i], PinOwner::UM_FourLineDisplay);
|
||||||
ioPin[i] = newPin[i];
|
ioPin[i] = newPin[i];
|
||||||
@ -736,10 +732,8 @@ class FourLineDisplayUsermod : public Usermod {
|
|||||||
return true;
|
return true;
|
||||||
} else type = newType;
|
} else type = newType;
|
||||||
setup();
|
setup();
|
||||||
if (sclPin >= 0 && sdaPin >= 0) {
|
|
||||||
needsRedraw |= true;
|
needsRedraw |= true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
setContrast(contrast);
|
setContrast(contrast);
|
||||||
setFlipMode(flip);
|
setFlipMode(flip);
|
||||||
if (needsRedraw && !wakeDisplay()) redraw(true);
|
if (needsRedraw && !wakeDisplay()) redraw(true);
|
||||||
|
Loading…
Reference in New Issue
Block a user