Get t-watch-ultra working better on BaseUI

This commit is contained in:
Jonathan Bennett
2026-04-20 00:20:53 -05:00
parent fe45e5fde6
commit 97824c6ba0
3 changed files with 42 additions and 30 deletions
+1 -1
View File
@@ -438,7 +438,7 @@ void Screen::handleSetOn(bool on, FrameCallback einkScreensaver)
#endif
// some screens seem to need a kick in the pants to turn back on
#if defined(MUZI_BASE) || defined(M5STACK_CARDPUTER_ADV)
#if defined(MUZI_BASE) || defined(M5STACK_CARDPUTER_ADV) || defined(TFT_RESET_AFTER_SLEEP)
dispdev->init();
dispdev->setBrightness(brightness);
dispdev->flipScreenVertically();
+37 -28
View File
@@ -82,42 +82,19 @@ class LGFX : public lgfx::LGFX_Device
setPanel(&_panel_instance);
}
bool enableFrameBuffer(bool auto_display = false)
{
if (_panel_instance.initPanelFb()) {
auto fbPanel = _panel_instance.getPanelFb();
if (fbPanel) {
fbPanel->setBus(&_bus_instance);
fbPanel->setAutoDisplay(auto_display);
setPanel(fbPanel);
return true;
}
}
return false;
}
void disableFrameBuffer()
{
auto fbPanel = _panel_instance.getPanelFb();
if (fbPanel) {
_panel_instance.deinitPanelFb();
setPanel(&_panel_instance);
}
}
bool init()
{
#ifdef CO5300_RESET
LOG_DEBUG("LGFX_Panel_CO5300::init()");
lgfx::pinMode(CO5300_RESET, lgfx::pin_mode_t::output);
lgfx::gpio_hi(CO5300_RESET);
delay(200);
delay(20);
lgfx::gpio_lo(CO5300_RESET);
delay(300);
delay(30);
lgfx::gpio_hi(CO5300_RESET);
delay(200);
delay(20);
#endif
return lgfx::LGFX_Device::init() && enableFrameBuffer(false);
return lgfx::LGFX_Device::init();
}
};
@@ -1385,13 +1362,41 @@ void TFTDisplay::display(bool fromBlank)
if (x_LastPixelUpdate >= displayWidth) {
x_LastPixelUpdate = displayWidth - 1;
}
int y_offset = 0;
#if defined(CO5300_CS)
uint8_t lines_updated = 2;
if (y % 2 == 0) {
y_byteIndex = ((y + 1) / 8) * displayWidth;
y_byteMask = (1 << ((y + 1) & 7));
uint32_t bufferIndex = 1;
for (x = x_FirstPixelUpdate; x < x_LastPixelUpdate; x++) {
isset = buffer[x + y_byteIndex] & y_byteMask;
linePixelBuffer[bufferIndex++ + x_LastPixelUpdate] = isset ? colorTftMesh : colorTftBlack;
}
} else {
y_offset = -1;
memcpy(&linePixelBuffer[x_LastPixelUpdate + 1], &linePixelBuffer[x_FirstPixelUpdate],
2 * (x_LastPixelUpdate - x_FirstPixelUpdate + 1));
y_byteIndex = ((y - 1) / 8) * displayWidth;
y_byteMask = (1 << ((y - 1) & 7));
uint32_t bufferIndex = 0;
for (x = x_FirstPixelUpdate; x < x_LastPixelUpdate; x++) {
isset = buffer[x + y_byteIndex] & y_byteMask;
linePixelBuffer[bufferIndex++ + x_FirstPixelUpdate] = isset ? colorTftMesh : colorTftBlack;
}
}
#else
uint8_t lines_updated = 1;
#endif
#if defined(HACKADAY_COMMUNICATOR)
tft->draw16bitBeRGBBitmap(x_FirstPixelUpdate, y, &linePixelBuffer[x_FirstPixelUpdate],
(x_LastPixelUpdate - x_FirstPixelUpdate + 1), 1);
#else
// Step 4: Send the changed pixels on this line to the screen as a single block transfer.
// This function accepts pixel data MSB first so it can dump the memory straight out the SPI port.
tft->pushRect(x_FirstPixelUpdate, y, (x_LastPixelUpdate - x_FirstPixelUpdate + 1), 1,
tft->pushRect(x_FirstPixelUpdate, y + y_offset, (x_LastPixelUpdate - x_FirstPixelUpdate + 1), lines_updated,
&linePixelBuffer[x_FirstPixelUpdate]);
#endif
somethingChanged = true;
@@ -1617,7 +1622,11 @@ bool TFTDisplay::connect()
tft->fillScreen(TFT_BLACK);
if (this->linePixelBuffer == NULL) {
#if defined(CO5300_CS)
this->linePixelBuffer = (uint16_t *)malloc(sizeof(uint16_t) * displayWidth * 2);
#else
this->linePixelBuffer = (uint16_t *)malloc(sizeof(uint16_t) * displayWidth);
#endif
if (!this->linePixelBuffer) {
LOG_ERROR("Not enough memory to create TFT line buffer\n");
+4 -1
View File
@@ -18,6 +18,8 @@
#define TFT_OFFSET_ROTATION 0
#define SCREEN_TRANSITION_FRAMERATE 5 // fps
#define USE_TFTDISPLAY 1
#define HAS_SCREEN 1
#define TFT_RESET_AFTER_SLEEP
#define HAS_TOUCHSCREEN 1
#define SCREEN_TOUCH_INT 12
@@ -42,7 +44,7 @@
#define DAC_I2S_BCK 9
#define DAC_I2S_WS 10
#define DAC_I2S_DOUT 11
#define DAC_I2S_MCLK 0 // TODO
#define DAC_I2S_MCLK -1 // TODO
#define HAS_AXP2101
// #define PMU_IRQ 7
@@ -67,6 +69,7 @@
#define USE_SX1262
// #define USE_SX1280
#define HW_SPI1_DEVICE
#define LORA_SCK 35
#define LORA_MISO 33