1
0
forked from me/IronOS

Only send on display change

This commit is contained in:
Ben V. Brown
2022-11-06 22:10:09 +11:00
parent f11f550e0b
commit 7eb9f3f10d
2 changed files with 15 additions and 6 deletions

View File

@@ -47,11 +47,19 @@ public:
static void initialize(); // Startup the I2C coms (brings screen out of reset etc)
static bool isInitDone();
// Draw the buffer out to the LCD using the DMA Channel
// Draw the buffer out to the LCD if any content has changed.
static void refresh() {
I2C_CLASS::Transmit(DEVICEADDR_OLED, screenBuffer, FRAMEBUFFER_START + (OLED_WIDTH * 2));
// DMA tx time is ~ 20mS Ensure after calling this you delay for at least 25ms
// or we need to goto double buffering
uint32_t hash = 0;
const int len = FRAMEBUFFER_START + (OLED_WIDTH * 2);
for (int i = 0; i < len; i++) {
hash += (i * screenBuffer[i]);
}
if (hash != displayChecksum) {
displayChecksum = hash;
I2C_CLASS::Transmit(DEVICEADDR_OLED, screenBuffer, len);
// DMA tx time is ~ 20mS Ensure after calling this you delay for at least 25ms
// or we need to goto double buffering
}
}
static void setDisplayState(DisplayState state) {
@@ -112,6 +120,7 @@ private:
static DisplayState displayState;
static int16_t cursor_x, cursor_y;
static uint8_t displayOffset;
static uint32_t displayChecksum;
static uint8_t screenBuffer[16 + (OLED_WIDTH * 2) + 10]; // The data buffer
static uint8_t secondFrameBuffer[OLED_WIDTH * 2];
};