mirror of
https://github.com/MarekZegare4/MeshCore-Solo.git
synced 2026-07-28 15:58:12 +00:00
feat: add runtime display rotation setting for e-ink builds
Adds Settings > Display > Rotation (0°/90°/180°/270°) that persists to NodePrefs and is applied on startup. Falls back to compile-time DISPLAY_ROTATION when the field is missing from an older prefs file. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -7,6 +7,7 @@ class DisplayDriver {
|
||||
int _w, _h;
|
||||
protected:
|
||||
DisplayDriver(int w, int h) { _w = w; _h = h; }
|
||||
void setDimensions(int w, int h) { _w = w; _h = h; }
|
||||
public:
|
||||
enum Color { DARK=0, LIGHT, RED, GREEN, BLUE, YELLOW, ORANGE }; // on b/w screen, colors will be !=0 synonym of light
|
||||
|
||||
@@ -196,5 +197,6 @@ public:
|
||||
}
|
||||
|
||||
virtual void setBrightness(uint8_t level) { } // level 0-4 (min to max), no-op default
|
||||
virtual void setDisplayRotation(uint8_t rot) { } // 0-3, no-op for fixed-orientation displays
|
||||
virtual void endFrame() = 0;
|
||||
};
|
||||
|
||||
@@ -150,6 +150,12 @@ uint16_t GxEPDDisplay::getTextWidth(const char* str) {
|
||||
return w;
|
||||
}
|
||||
|
||||
void GxEPDDisplay::setDisplayRotation(uint8_t rot) {
|
||||
display.setRotation(rot & 3);
|
||||
setDimensions(display.width(), display.height());
|
||||
last_display_crc_value = -1; // force redraw on next endFrame
|
||||
}
|
||||
|
||||
void GxEPDDisplay::endFrame() {
|
||||
uint32_t crc = display_crc.finalize();
|
||||
if (crc != last_display_crc_value) {
|
||||
|
||||
@@ -84,5 +84,6 @@ public:
|
||||
void drawRect(int x, int y, int w, int h) override;
|
||||
void drawXbm(int x, int y, const uint8_t* bits, int w, int h) override;
|
||||
uint16_t getTextWidth(const char* str) override;
|
||||
void setDisplayRotation(uint8_t rot) override;
|
||||
void endFrame() override;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user