Optimise update modes¶
The different update modes are detailed at the screen library page.
While global update ensures the optimal quality, other modes may provoke ghosting: fast update on the whole screen and especially partial update outside the modified window.
The solution presented below forces the use of a slower update mode to limit ghosting.
Configure¶
The function below counts the number of refreshes (table updateCount[]
) for every update mode. When the counter of the selected mode (parameter mode
) reaches a threshold (constant table updateMax[]
) , the function automatically performs a slower update (with mode - 1
).
enum updateMode_e
{
updateGlobal = 0,
updateFast,
updatePartial
};
uint8_t updateCount[3] = { 0 };
const uint8_t updateMax[3] = {4, 4, 4};
void flushMode(updateMode_e mode)
{
updateCount[mode] += 1;
updateCount[mode] %= updateMax[mode];
if ((updateCount[mode] == 0) and (mode > updateGlobal))
{
flushMode(mode - 1);
}
else
{
switch (mode)
{
case updatePartial:
myScreen.flushPartial();
break;
case updateFast:
myScreen.flushFast();
break;
default:
myScreen.flush();
break;
}
}
}
The procedure is non-destructive, as it keeps the frame-buffer unchanged and only modifies the way the panel is updated.
Use¶
Instead of calling the flush functions of the screen, the main loop calls the flushMode()
function previously defined.
myScreen.setFontSolid(true);
for (uint8_t i = 0; i < 36; i++)
{
myScreen.gText(0, 0, formatString("Loop %3i", i));
flushMode(updatePartial);
}
Legacy version 5
Legacy version 5 requires beginPartial()
to start partial mode and reset the coordinates of the window.
myScreen.beginPartial();
myScreen.gText(0, 0, formatString("Loop %3i", i));
myScreen.flushPartial();
beginPartial()
starts the partial mode and resets the coordinates of the window.
Example¶
// SDK
#include "hV_HAL_Peripherals.h"
// Configuration
#include "hV_Configuration.h"
// Libraries
#include "PDLS_EXT3_Advanced_Fast_Small.h"
// Variables
Screen_EPD_EXT3_Fast myScreen(eScreen_EPD_EXT3_271_Fast, boardRaspberryPiPico_RP2040);
// Utilities
enum updateMode_e
{
updateGlobal,
updateFast,
updatePartial
};
uint8_t updateCount[3] = { 0 };
const uint8_t updateMax = 6;
void flushMode(updateMode_e mode)
{
updateCount[mode] += 1;
updateCount[mode] %= updateMax;
if ((updateCount[mode] == 0) and (mode > 0))
{
flushMode((updateMode_e)(mode - 1));
}
else
{
switch (mode)
{
case updatePartial:
myScreen.flushPartial();
break;
case updateFast:
myScreen.flushFast();
break;
default:
myScreen.flush();
break;
}
}
}
void setup()
{
hV_HAL_begin();
myScreen.begin();
myScreen.setOrientation(ORIENTATION_LANDSCAPE);
myScreen.setFontSolid(true);
for (uint8_t i = 0; i < 36; i++)
{
myScreen.beginPartial();
myScreen.gText(0, 0, formatString("Loop %3i", i));
flushMode(updatePartial);
}
hV_HAL_end();
}
void loop()
{
hV_HAL_delayMilliseconds(1000);
}