Merge upstream/dev (11 commits) [upstream-sync]
Conflict in examples/companion_radio/ui-new/UITask.cpp: upstream replaced UI_SHOW_CLOCK with the runtime pref ui_show_clock; kept that and our BLE pin condition (shown only while Bluetooth is enabled). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
fd04fdf093
15 files changed
+818
-139
No files matched your search
@@ -425,18 +425,26 @@ void CommonCLI::handleCommand(uint32_t sender_timestamp, char* command, char* re
|
||||
if (start >= end) {
|
||||
strcpy(reply, "no custom var");
|
||||
} else {
|
||||
const int reply_max = 160; // callers pass a 160-byte reply buffer
|
||||
const int next_reserve = 16; // room for "... next:NNN"
|
||||
sprintf(dp, "%d vars\n", end);
|
||||
dp = strchr(dp, 0);
|
||||
int i;
|
||||
for (i = start; i < end && (dp-reply < 134); i++) {
|
||||
sprintf(dp, "%s=%s\n",
|
||||
_sensors->getSettingName(i),
|
||||
_sensors->getSettingValue(i));
|
||||
for (i = start; i < end; i++) {
|
||||
const char* name = _sensors->getSettingName(i);
|
||||
const char* value = _sensors->getSettingValue(i);
|
||||
if (name == NULL) name = "?";
|
||||
if (value == NULL) value = "";
|
||||
int room = reply_max - next_reserve - (int)(dp - reply);
|
||||
int need = snprintf(NULL, 0, "%s=%s\n", name, value);
|
||||
if (need >= room && i > start) break; // continue on the next page
|
||||
snprintf(dp, room, "%s=%s\n", name, value); // a single oversized entry is truncated
|
||||
dp = strchr(dp, 0);
|
||||
if (need >= room) { i++; break; }
|
||||
}
|
||||
if (i < end) {
|
||||
sprintf(dp, "... next:%d", i);
|
||||
} else {
|
||||
snprintf(dp, reply_max - (int)(dp - reply), "... next:%d", i);
|
||||
} else if (dp > reply && *(dp-1) == '\n') {
|
||||
*(dp-1) = 0; // remove last CR
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,9 +25,9 @@ public:
|
||||
virtual bool isEink() { return false; } // default to non-eink, override in eink drivers
|
||||
virtual void forceFullRefresh() {} // next refresh will be full for eink
|
||||
virtual void turnOn() = 0;
|
||||
virtual void turnOn(int max_partial) { turnOn(); }
|
||||
virtual void turnOff() = 0;
|
||||
virtual void blankScreen() {} // to cleanly erase screen before turning off
|
||||
virtual void powerOff() {}
|
||||
virtual void turnOff(bool blank) { turnOff(); }
|
||||
virtual void clear() = 0;
|
||||
virtual void startFrame(ColorVal bkg = UIColor::window_bkg) = 0;
|
||||
virtual void setTextSize(int sz) = 0;
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
|
||||
#include "GxEPDDisplay.h"
|
||||
|
||||
#ifdef EXP_PIN_BACKLIGHT
|
||||
#include <PCA9557.h>
|
||||
extern PCA9557 expander;
|
||||
#endif
|
||||
|
||||
#ifndef DISPLAY_ROTATION
|
||||
#define DISPLAY_ROTATION 3
|
||||
#endif
|
||||
@@ -52,7 +47,7 @@ bool GxEPDDisplay::begin() {
|
||||
}
|
||||
|
||||
display.setPartialWindow(0, 0, display.width(), display.height());
|
||||
resetPartialRefreshCounter();
|
||||
_partial_refresh_count = 0;
|
||||
|
||||
#if DISP_BACKLIGHT
|
||||
digitalWrite(DISP_BACKLIGHT, LOW);
|
||||
@@ -65,26 +60,43 @@ bool GxEPDDisplay::begin() {
|
||||
|
||||
void GxEPDDisplay::turnOn() {
|
||||
if (!_init) begin();
|
||||
#if defined(DISP_BACKLIGHT) && !defined(BACKLIGHT_BTN)
|
||||
digitalWrite(DISP_BACKLIGHT, HIGH);
|
||||
#elif defined(EXP_PIN_BACKLIGHT) && !defined(BACKLIGHT_BTN)
|
||||
expander.digitalWrite(EXP_PIN_BACKLIGHT, HIGH);
|
||||
#endif
|
||||
if (!_isOn) {
|
||||
_isOn = true;
|
||||
}
|
||||
}
|
||||
|
||||
void GxEPDDisplay::powerOff() {
|
||||
display.hibernate();
|
||||
void GxEPDDisplay::turnOn(int max_partial) {
|
||||
setMaxPartialRefresh(max_partial);
|
||||
turnOn();
|
||||
}
|
||||
|
||||
void GxEPDDisplay::turnOff() { // Only stops refresh
|
||||
#if defined(DISP_BACKLIGHT) && !defined(BACKLIGHT_BTN)
|
||||
digitalWrite(DISP_BACKLIGHT, LOW);
|
||||
#elif defined(EXP_PIN_BACKLIGHT) && !defined(BACKLIGHT_BTN)
|
||||
expander.digitalWrite(EXP_PIN_BACKLIGHT, LOW);
|
||||
#endif
|
||||
// 24x24 sleep icon, MSB-first (matches GxEPDDisplay::drawXbm)
|
||||
static const uint8_t sleep_icon_24x24[] = {
|
||||
0x00, 0x00, 0xff, 0x00, 0x00, 0xff, 0x00, 0xe0, 0x0e, 0x03, 0xc0, 0x18,
|
||||
0x0f, 0x80, 0x70, 0x1f, 0x80, 0xff, 0x3f, 0x80, 0xff, 0x3f, 0x00, 0x00,
|
||||
0x7f, 0x3f, 0x00, 0x7f, 0x3f, 0x00, 0xff, 0x0e, 0x00, 0xff, 0x1c, 0x7c,
|
||||
0xff, 0xbf, 0x7c, 0xff, 0xbf, 0x38, 0xff, 0xc0, 0x7c, 0xff, 0xe0, 0x7c,
|
||||
0xff, 0xf0, 0x00, 0x7f, 0xfc, 0x00, 0x7f, 0xff, 0xf8, 0x3f, 0xff, 0xf0,
|
||||
0x1f, 0xff, 0xf0, 0x0f, 0xff, 0xe0, 0x07, 0xff, 0x80, 0x01, 0xff, 0x00
|
||||
};
|
||||
|
||||
void GxEPDDisplay::drawSleepIcon() {
|
||||
const int W = 24, H = 24;
|
||||
int x = (int)(display.width() / scale_x) - W; // top-right, logical coordinates
|
||||
int y = 0;
|
||||
|
||||
display.fillRect((x - 5) * scale_x - 1, y * scale_y, (W+5) * scale_x + 2, (H-2) * scale_y + 1, GxEPD_WHITE);
|
||||
_curr_color = GxEPD_BLACK;
|
||||
drawXbm(x, y, sleep_icon_24x24, W, H);
|
||||
display.display(true);
|
||||
}
|
||||
|
||||
void GxEPDDisplay::turnOff(bool blank) {
|
||||
if (blank) {
|
||||
blankScreen();
|
||||
} else {
|
||||
drawSleepIcon();
|
||||
}
|
||||
_isOn = false;
|
||||
last_display_crc_value=0;
|
||||
}
|
||||
@@ -94,8 +106,10 @@ void GxEPDDisplay::blankScreen() {
|
||||
// no full refresh needed at wakeup
|
||||
display.clearScreen(0xFF); // Clears microcontroller side RAM
|
||||
display.writeScreenBuffer(0xFF); // Forces 0xFF (White) into the display controller's history registers
|
||||
resetPartialRefreshCounter();
|
||||
last_display_crc_value=0;
|
||||
_partial_refresh_count = 0;
|
||||
last_display_crc_value = 0;
|
||||
// we can hibernate as screen has been cleaned
|
||||
display.hibernate();
|
||||
}
|
||||
|
||||
void GxEPDDisplay::clear() {
|
||||
@@ -108,15 +122,18 @@ void GxEPDDisplay::startFrame(ColorVal bkg) {
|
||||
display.fillScreen(bkg);
|
||||
display.setTextColor(_curr_color = UIColor::primary_txt);
|
||||
display_crc.reset();
|
||||
if (_cycles_before_full_refresh != 0) {
|
||||
display.setPartialWindow(0, 0, display.width(), display.height());
|
||||
} else {
|
||||
if (_force_full_refresh
|
||||
|| (_max_partial_refresh > 0
|
||||
&& _partial_refresh_count >= _max_partial_refresh)) {
|
||||
// forces a full wipe of the screen ...
|
||||
display.clearScreen(0xFF); // Clears microcontroller side RAM
|
||||
display.writeScreenBuffer(0xFF); // Forces 0xFF (White) into the display controller's history registers
|
||||
// we'll need a partial refresh after that (whatever crc value is)
|
||||
last_display_crc_value = 0;
|
||||
resetPartialRefreshCounter();
|
||||
_partial_refresh_count = 0;
|
||||
_force_full_refresh = false;
|
||||
} else {
|
||||
display.setPartialWindow(0, 0, display.width(), display.height());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -223,9 +240,7 @@ void GxEPDDisplay::endFrame() {
|
||||
uint32_t crc = display_crc.finalize();
|
||||
if (crc != last_display_crc_value) {
|
||||
display.display(true);
|
||||
if (_cycles_before_full_refresh > 0) {
|
||||
_cycles_before_full_refresh--;
|
||||
}
|
||||
_partial_refresh_count++;
|
||||
}
|
||||
last_display_crc_value = crc;
|
||||
}
|
||||
@@ -16,12 +16,6 @@
|
||||
|
||||
#include "DisplayDriver.h"
|
||||
|
||||
#ifndef EINK_MAX_PARTIAL_REFRESH
|
||||
// 60 to prevent ghosting when refreshing every minute ...
|
||||
// set to -1 to disable the counter
|
||||
#define EINK_MAX_PARTIAL_REFRESH -1
|
||||
#endif
|
||||
|
||||
class GxEPDDisplay : public DisplayDriver {
|
||||
|
||||
#if defined(EINK_DISPLAY_MODEL)
|
||||
@@ -42,8 +36,9 @@ class GxEPDDisplay : public DisplayDriver {
|
||||
uint16_t _curr_color;
|
||||
CRC32 display_crc;
|
||||
int last_display_crc_value = 0;
|
||||
int _cycles_before_full_refresh;
|
||||
int max_partial_refresh = EINK_MAX_PARTIAL_REFRESH; // so this can be changed by an option after
|
||||
bool _force_full_refresh = false;
|
||||
int _partial_refresh_count = 0;
|
||||
int _max_partial_refresh = 0;
|
||||
|
||||
public:
|
||||
#if defined(EINK_DISPLAY_MODEL)
|
||||
@@ -56,12 +51,13 @@ public:
|
||||
|
||||
bool isOn() override { return _isOn; }
|
||||
bool isEink() override { return true; }
|
||||
void forceFullRefresh() override { _cycles_before_full_refresh = 0; };
|
||||
void resetPartialRefreshCounter() { _cycles_before_full_refresh = max_partial_refresh; };
|
||||
void forceFullRefresh() override { _force_full_refresh = true; }
|
||||
void turnOn(int max_partial) override;
|
||||
void turnOn() override;
|
||||
void turnOff() override;
|
||||
void blankScreen() override;
|
||||
void powerOff() override;
|
||||
void turnOff(bool blank) override;
|
||||
void turnOff() override { turnOff(false); }
|
||||
virtual void blankScreen();
|
||||
virtual void setMaxPartialRefresh(int count) {_max_partial_refresh = count; }
|
||||
void clear() override;
|
||||
void startFrame(ColorVal bkg = UIColor::window_bkg) override;
|
||||
void setTextSize(int sz) override;
|
||||
@@ -71,6 +67,7 @@ public:
|
||||
void fillRect(int x, int y, int w, int h) override;
|
||||
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;
|
||||
void drawSleepIcon();
|
||||
uint16_t getTextWidth(const char* str) override;
|
||||
void endFrame() override;
|
||||
};
|
||||
Reference in new issue
Block a user