ui : manage colors and ensure fw using ssd1306 still compile
This commit is contained in:
@@ -7,7 +7,7 @@ class DisplayDriver {
|
||||
protected:
|
||||
DisplayDriver(int w, int h) { _w = w; _h = h; }
|
||||
public:
|
||||
enum Color { DARK, LIGHT };
|
||||
enum Color { DARK=0, LIGHT, RED, GREEN, BLUE, YELLOW, ORANGE }; // on b/w screen, colors will be !=0 synonym of light
|
||||
|
||||
int width() const { return _w; }
|
||||
int height() const { return _h; }
|
||||
|
||||
@@ -38,7 +38,7 @@ void SSD1306Display::setTextSize(int sz) {
|
||||
}
|
||||
|
||||
void SSD1306Display::setColor(Color c) {
|
||||
_color = (c == LIGHT) ? SSD1306_WHITE : SSD1306_BLACK;
|
||||
_color = (c != 0) ? SSD1306_WHITE : SSD1306_BLACK;
|
||||
display.setTextColor(_color);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
#ifdef ST7789
|
||||
|
||||
#include "ST7789Display.h"
|
||||
|
||||
bool ST7789Display::i2c_probe(TwoWire& wire, uint8_t addr) {
|
||||
@@ -59,7 +61,32 @@ void ST7789Display::setTextSize(int sz) {
|
||||
}
|
||||
|
||||
void ST7789Display::setColor(Color c) {
|
||||
_color = (c == LIGHT) ? ST77XX_WHITE : ST77XX_BLACK;
|
||||
switch (c) {
|
||||
case DisplayDriver::DARK :
|
||||
_color = ST77XX_BLACK;
|
||||
break;
|
||||
case DisplayDriver::LIGHT :
|
||||
_color = ST77XX_WHITE;
|
||||
break;
|
||||
case DisplayDriver::RED :
|
||||
_color = ST77XX_RED;
|
||||
break;
|
||||
case DisplayDriver::GREEN :
|
||||
_color = ST77XX_GREEN;
|
||||
break;
|
||||
case DisplayDriver::BLUE :
|
||||
_color = ST77XX_BLUE;
|
||||
break;
|
||||
case DisplayDriver::YELLOW :
|
||||
_color = ST77XX_YELLOW;
|
||||
break;
|
||||
case DisplayDriver::ORANGE :
|
||||
_color = ST77XX_ORANGE;
|
||||
break;
|
||||
default:
|
||||
_color = ST77XX_WHITE;
|
||||
break;
|
||||
}
|
||||
display.setTextColor(_color);
|
||||
}
|
||||
|
||||
@@ -80,9 +107,11 @@ void ST7789Display::drawRect(int x, int y, int w, int h) {
|
||||
}
|
||||
|
||||
void ST7789Display::drawXbm(int x, int y, const uint8_t* bits, int w, int h) {
|
||||
display.drawBitmap(x, y, bits, w, h, ST77XX_BLUE);
|
||||
display.drawBitmap(x, y, bits, w, h, _color);
|
||||
}
|
||||
|
||||
void ST7789Display::endFrame() {
|
||||
// display.display();
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -9,7 +9,7 @@
|
||||
class ST7789Display : public DisplayDriver {
|
||||
Adafruit_ST7789 display;
|
||||
bool _isOn;
|
||||
uint8_t _color;
|
||||
uint16_t _color;
|
||||
|
||||
bool i2c_probe(TwoWire& wire, uint8_t addr);
|
||||
public:
|
||||
|
||||
Reference in New Issue
Block a user