From 5d04df39e0aab47334486cc72be5c5c88ecdb259 Mon Sep 17 00:00:00 2001 From: "Ben V. Brown" Date: Tue, 27 Jun 2023 20:52:17 +1000 Subject: [PATCH 1/5] Adjust divider Update OLED.cpp --- source/Core/Drivers/OLED.cpp | 2 +- source/Core/Drivers/OLED.hpp | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/source/Core/Drivers/OLED.cpp b/source/Core/Drivers/OLED.cpp index 71603b84..90dcc4d5 100644 --- a/source/Core/Drivers/OLED.cpp +++ b/source/Core/Drivers/OLED.cpp @@ -32,7 +32,7 @@ uint32_t OLED::displayChecksum; I2C_CLASS::I2C_REG OLED_Setup_Array[] = { /**/ {0x80, 0xAE, 0}, /*Display off*/ - {0x80, 0xD3, 0}, /*Set display clock divide ratio / osc freq*/ + {0x80, OLED_DIVIDER, 0}, /*Set display clock divide ratio / osc freq*/ {0x80, 0x52, 0}, /*Divide ratios*/ {0x80, 0xA8, 0}, /*Set Multiplex Ratio*/ {0x80, OLED_HEIGHT - 1, 0}, /*Multiplex ratio adjusts how far down the matrix it scans*/ diff --git a/source/Core/Drivers/OLED.hpp b/source/Core/Drivers/OLED.hpp index eb71b86a..cfe47eb6 100644 --- a/source/Core/Drivers/OLED.hpp +++ b/source/Core/Drivers/OLED.hpp @@ -46,6 +46,7 @@ extern "C" { #define OLED_VCOM_LAYOUT 0x12 #define OLED_SEGMENT_MAP_REVERSED +#define OLED_DIVIDER 0xD3 #else #define OLED_WIDTH 96 #define OLED_HEIGHT 16 @@ -55,8 +56,8 @@ extern "C" { #define OLED_GRAM_END 0x7F #define OLED_GRAM_START_FLIP 0 #define OLED_GRAM_END_FLIP 95 - -#define OLED_SEGMENT_MAP 0xA0 +#define OLED_DIVIDER 0xD5 +#define OLED_SEGMENT_MAP 0xA0 #endif #define FRAMEBUFFER_START 17 From 159555f299981293e05479157d2d788884ace90d Mon Sep 17 00:00:00 2001 From: "Ben V. Brown" Date: Wed, 28 Jun 2023 19:13:03 +1000 Subject: [PATCH 2/5] Update OLED.cpp --- source/Core/Drivers/OLED.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/Core/Drivers/OLED.cpp b/source/Core/Drivers/OLED.cpp index 90dcc4d5..295a249e 100644 --- a/source/Core/Drivers/OLED.cpp +++ b/source/Core/Drivers/OLED.cpp @@ -90,7 +90,7 @@ const uint8_t REFRESH_COMMANDS[17] = { 0x80, 0x00, // A 0x80, - (OLED_HEIGHT / 8), // B + (OLED_HEIGHT / 8) - 1, // B // Start of data 0x40, From 803d75cd9d2995002c6dab01f292580950d4f819 Mon Sep 17 00:00:00 2001 From: "Ben V. Brown" Date: Wed, 28 Jun 2023 19:14:08 +1000 Subject: [PATCH 3/5] Init startup to both buffers Just in case --- source/Core/Drivers/OLED.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/source/Core/Drivers/OLED.cpp b/source/Core/Drivers/OLED.cpp index 295a249e..1233209f 100644 --- a/source/Core/Drivers/OLED.cpp +++ b/source/Core/Drivers/OLED.cpp @@ -127,6 +127,7 @@ void OLED::initialize() { #endif displayOffset = 0; memcpy(&screenBuffer[0], &REFRESH_COMMANDS[0], sizeof(REFRESH_COMMANDS)); + memcpy(&secondFrameBuffer[0], &REFRESH_COMMANDS[0], sizeof(REFRESH_COMMANDS)); // Set the display to be ON once the settings block is sent and send the // initialisation data to the OLED. From 43094b2222556d35316bed01f8e409c948bc9d88 Mon Sep 17 00:00:00 2001 From: "Ben V. Brown" Date: Thu, 29 Jun 2023 18:52:53 +1000 Subject: [PATCH 4/5] Revert to slower software I2C --- source/Core/BSP/Miniware/Software_I2C.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/Core/BSP/Miniware/Software_I2C.h b/source/Core/BSP/Miniware/Software_I2C.h index 3b40f517..e3a95a71 100644 --- a/source/Core/BSP/Miniware/Software_I2C.h +++ b/source/Core/BSP/Miniware/Software_I2C.h @@ -33,7 +33,7 @@ #define SOFT_I2C_DELAY() \ { \ - for (int xx = 0; xx < 10; xx++) { \ + for (int xx = 0; xx < 15; xx++) { \ asm("nop"); \ } \ } From c43063ee8c0ccb5b7d80f7dbfc04e46ea12df509 Mon Sep 17 00:00:00 2001 From: "Ben V. Brown" Date: Thu, 29 Jun 2023 18:58:14 +1000 Subject: [PATCH 5/5] Fixup overlapping variables on oled draw --- source/Core/Drivers/OLED.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/source/Core/Drivers/OLED.cpp b/source/Core/Drivers/OLED.cpp index 1233209f..cb9f6327 100644 --- a/source/Core/Drivers/OLED.cpp +++ b/source/Core/Drivers/OLED.cpp @@ -272,7 +272,7 @@ void OLED::transitionSecondaryFramebuffer(bool forwardNavigation) { TickType_t duration = 0; TickType_t start = xTaskGetTickCount(); uint8_t offset = 0; - + TickType_t startDraw = xTaskGetTickCount(); while (duration <= totalDuration) { duration = xTaskGetTickCount() - start; uint16_t progress = ((duration * 100) / totalDuration); // Percentage of the period we are through for animation @@ -309,9 +309,8 @@ void OLED::transitionSecondaryFramebuffer(bool forwardNavigation) { memmove(&stripPointers[3][newStart], &stripBackPointers[3][newEnd], progress); #endif - TickType_t start = xTaskGetTickCount(); refresh(); // Now refresh to write out the contents to the new page - vTaskDelayUntil(&start, TICKS_100MS / 7); + vTaskDelayUntil(&startDraw, TICKS_100MS / 7); if (getButtonState() != BUTTON_NONE) { return; } @@ -333,6 +332,7 @@ void OLED::useSecondaryFramebuffer(bool useSecondary) { * **This function blocks until the transition has completed or user presses button** */ void OLED::transitionScrollDown() { + TickType_t startDraw = xTaskGetTickCount(); for (uint8_t heightPos = 0; heightPos < OLED_HEIGHT; heightPos++) { // For each line, we shuffle all bits up a row @@ -375,9 +375,8 @@ void OLED::transitionScrollDown() { refresh(); // Now refresh to write out the contents to the new page return; } - TickType_t start = xTaskGetTickCount(); refresh(); // Now refresh to write out the contents to the new page - vTaskDelayUntil(&start, TICKS_100MS / 7); + vTaskDelayUntil(&startDraw, TICKS_100MS / 7); } }