Skip to content

Commit 2d6c834

Browse files
committed
std behaviour
1 parent 052ca9f commit 2d6c834

File tree

3 files changed

+45
-7
lines changed

3 files changed

+45
-7
lines changed

examples/companion_radio/UITask.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ void UITask::renderCurrScreen() {
9999
_display->setColor(DisplayDriver::LIGHT);
100100
_display->print(_msg);
101101

102-
_display->setCursor(100, 9);
102+
_display->setCursor(_display->width() - 28, 9);
103103
_display->setTextSize(2);
104104
_display->setColor(DisplayDriver::ORANGE);
105105
sprintf(tmp, "%d", _msgcount);

src/helpers/ui/GxEPDDisplay.cpp

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,33 @@ bool GxEPDDisplay::begin() {
66
SPI1.begin();
77
display.init(115200, true, 2, false);
88
display.setRotation(3);
9-
display.setFont(&FreeMono9pt7b);
10-
9+
#ifdef TECHO_ZOOM
10+
display.setFont(&FreeMono9pt7b);
11+
#endif
1112
display.setPartialWindow(0, 0, display.width(), display.height());
1213

1314
display.fillScreen(GxEPD_WHITE);
1415
display.display(true);
16+
#if DISP_BACKLIGHT
17+
pinMode(DISP_BACKLIGHT, OUTPUT);
18+
#endif
1519
_init = true;
1620
return true;
1721
}
1822

1923
void GxEPDDisplay::turnOn() {
2024
if (!_init) begin();
25+
#if DISP_BACKLIGHT
26+
digitalWrite(DISP_BACKLIGHT, HIGH);
27+
_isOn = true;
28+
#endif
2129
}
2230

2331
void GxEPDDisplay::turnOff() {
24-
32+
#if DISP_BACKLIGHT
33+
digitalWrite(DISP_BACKLIGHT, LOW);
34+
#endif
35+
_isOn = false;
2536
}
2637

2738
void GxEPDDisplay::clear() {
@@ -34,27 +45,52 @@ void GxEPDDisplay::startFrame(Color bkg) {
3445
}
3546

3647
void GxEPDDisplay::setTextSize(int sz) {
48+
display.setTextSize(sz);
3749
}
3850

3951
void GxEPDDisplay::setColor(Color c) {
4052
display.setTextColor(GxEPD_BLACK);
4153
}
4254

4355
void GxEPDDisplay::setCursor(int x, int y) {
44-
display.setCursor(x*1.5, (y*1.5)+10);
56+
#ifdef TECHO_ZOOM
57+
x = x + (x >> 1);
58+
y = y + (y >> 1);
59+
#endif
60+
display.setCursor(x, (y+10));
4561
}
4662

4763
void GxEPDDisplay::print(const char* str) {
4864
display.print(str);
4965
}
5066

5167
void GxEPDDisplay::fillRect(int x, int y, int w, int h) {
68+
#ifdef TECHO_ZOOM
69+
x = x + (x >> 1);
70+
y = y + (y >> 1);
71+
w = w + (w >> 1);
72+
h = h + (h >> 1);
73+
#endif
74+
display.fillRect(x, y, w, h, GxEPD_BLACK);
5275
}
5376

5477
void GxEPDDisplay::drawRect(int x, int y, int w, int h) {
78+
#ifdef TECHO_ZOOM
79+
x = x + (x >> 1);
80+
y = y + (y >> 1);
81+
w = w + (w >> 1);
82+
h = h + (h >> 1);
83+
#endif
84+
display.drawRect(x, y, w, h, GxEPD_BLACK);
5585
}
5686

5787
void GxEPDDisplay::drawXbm(int x, int y, const uint8_t* bits, int w, int h) {
88+
#ifdef TECHO_ZOOM
89+
x = x + (x >> 1);
90+
y = y + (y >> 1);
91+
w = w + (w >> 1);
92+
h = h + (h >> 1);
93+
#endif
5894
display.drawBitmap(x*1.5, (y*1.5) + 10, bits, w, h, GxEPD_BLACK);
5995
}
6096

src/helpers/ui/GxEPDDisplay.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,17 @@ class GxEPDDisplay : public DisplayDriver {
2525

2626
GxEPD2_BW<GxEPD2_150_BN, 200> display;
2727
bool _init = false;
28+
bool _isOn = false;
2829

2930
public:
30-
GxEPDDisplay() : DisplayDriver(200, 200), display(GxEPD2_150_BN(DISP_CS, DISP_DC, DISP_RST, DISP_BUSY)) {
31+
// there is a margin in y...
32+
GxEPDDisplay() : DisplayDriver(200, 200-10), display(GxEPD2_150_BN(DISP_CS, DISP_DC, DISP_RST, DISP_BUSY)) {
3133

3234
}
3335

3436
bool begin();
3537

36-
bool isOn() override { return true; }
38+
bool isOn() override {return _isOn;};
3739
void turnOn() override;
3840
void turnOff() override;
3941
void clear() override;

0 commit comments

Comments
 (0)