Split display checksum out
This commit is contained in:
@@ -372,6 +372,7 @@ void OLED::setRotation(bool leftHanded) {
|
|||||||
const int len = FRAMEBUFFER_START + (OLED_WIDTH * 2);
|
const int len = FRAMEBUFFER_START + (OLED_WIDTH * 2);
|
||||||
I2C_CLASS::Transmit(DEVICEADDR_OLED, screenBuffer, len);
|
I2C_CLASS::Transmit(DEVICEADDR_OLED, screenBuffer, len);
|
||||||
osDelay(TICKS_10MS);
|
osDelay(TICKS_10MS);
|
||||||
|
checkDisplayBufferChecksum();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OLED::setBrightness(uint8_t contrast) {
|
void OLED::setBrightness(uint8_t contrast) {
|
||||||
|
|||||||
@@ -51,13 +51,9 @@ public:
|
|||||||
static bool isInitDone();
|
static bool isInitDone();
|
||||||
// Draw the buffer out to the LCD if any content has changed.
|
// Draw the buffer out to the LCD if any content has changed.
|
||||||
static void refresh() {
|
static void refresh() {
|
||||||
uint32_t hash = 0;
|
|
||||||
const int len = FRAMEBUFFER_START + (OLED_WIDTH * 2);
|
if (checkDisplayBufferChecksum()) {
|
||||||
for (int i = 0; i < len; i++) {
|
const int len = FRAMEBUFFER_START + (OLED_WIDTH * 2);
|
||||||
hash += (i * screenBuffer[i]);
|
|
||||||
}
|
|
||||||
if (hash != displayChecksum) {
|
|
||||||
displayChecksum = hash;
|
|
||||||
I2C_CLASS::Transmit(DEVICEADDR_OLED, screenBuffer, len);
|
I2C_CLASS::Transmit(DEVICEADDR_OLED, screenBuffer, len);
|
||||||
// DMA tx time is ~ 20mS Ensure after calling this you delay for at least 25ms
|
// DMA tx time is ~ 20mS Ensure after calling this you delay for at least 25ms
|
||||||
// or we need to goto double buffering
|
// or we need to goto double buffering
|
||||||
@@ -118,6 +114,17 @@ public:
|
|||||||
static void transitionScrollDown();
|
static void transitionScrollDown();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
static bool checkDisplayBufferChecksum(){
|
||||||
|
uint32_t hash = 0;
|
||||||
|
const int len = FRAMEBUFFER_START + (OLED_WIDTH * 2);
|
||||||
|
for (int i = 0; i < len; i++) {
|
||||||
|
hash += (i * screenBuffer[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool result = hash!=displayChecksum;
|
||||||
|
displayChecksum= hash;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
static void drawChar(uint16_t charCode, FontStyle fontStyle); // Draw a character to the current cursor location
|
static void drawChar(uint16_t charCode, FontStyle fontStyle); // Draw a character to the current cursor location
|
||||||
static void setFramebuffer(uint8_t *buffer);
|
static void setFramebuffer(uint8_t *buffer);
|
||||||
static uint8_t *firstStripPtr; // Pointers to the strips to allow for buffer having extra content
|
static uint8_t *firstStripPtr; // Pointers to the strips to allow for buffer having extra content
|
||||||
|
|||||||
Reference in New Issue
Block a user