diff options
author | Ben V. Brown <[email protected]> | 2018-05-11 12:54:55 +1000 |
---|---|---|
committer | Ben V. Brown <[email protected]> | 2018-05-11 12:54:55 +1000 |
commit | b6b207568c4f5527bdb01ca09890f5b15cafbf65 (patch) | |
tree | b47f242c09a64a442a6bae1d5295f66284a3f2ad | |
parent | 8bf65351ea198049de9cb6f56abf67dc3eb0cf63 (diff) | |
download | IronOS-b6b207568c4f5527bdb01ca09890f5b15cafbf65.tar.gz IronOS-b6b207568c4f5527bdb01ca09890f5b15cafbf65.zip |
Delay I2C DMA thread on oled slightly
The flickering on the LCD screen was caused by the OLED DMA taking slightly longer than the delays, so the tail end would flicker if the buffer was cleared before it finished writing.
In future may want to double buffer the LCD.
Fixes #290
-rw-r--r-- | workspace/TS100/inc/OLED.hpp | 2 | ||||
-rw-r--r-- | workspace/TS100/src/gui.cpp | 6 | ||||
-rw-r--r-- | workspace/TS100/src/main.cpp | 21 |
3 files changed, 17 insertions, 12 deletions
diff --git a/workspace/TS100/inc/OLED.hpp b/workspace/TS100/inc/OLED.hpp index 66d3c93e..cbf3eecc 100644 --- a/workspace/TS100/inc/OLED.hpp +++ b/workspace/TS100/inc/OLED.hpp @@ -35,6 +35,8 @@ public: // Draw the buffer out to the LCD using the DMA Channel void refresh() { i2c->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 } void drawChar(char c, char preCursorCommand = '\0'); // Draw a character to a specific location diff --git a/workspace/TS100/src/gui.cpp b/workspace/TS100/src/gui.cpp index bb57ab87..63106688 100644 --- a/workspace/TS100/src/gui.cpp +++ b/workspace/TS100/src/gui.cpp @@ -279,7 +279,7 @@ static int userConfirmation(const char* message) { if (lcdRefresh) { lcd.refresh(); - osDelay(20); + osDelay(40); lcdRefresh = false; } } @@ -635,7 +635,7 @@ static void settings_setCalibrateVIN(void) { } lcd.refresh(); - osDelay(50); + osDelay(40); // Cap to sensible values if (systemSettings.voltageDiv < 90) { @@ -807,7 +807,7 @@ void gui_Menu(const menuitem* menu) { if (lcdRefresh) { lcd.refresh(); // update the LCD - osDelay(20); + osDelay(40); lcdRefresh = false; } } diff --git a/workspace/TS100/src/main.cpp b/workspace/TS100/src/main.cpp index 3ba2a409..34960634 100644 --- a/workspace/TS100/src/main.cpp +++ b/workspace/TS100/src/main.cpp @@ -97,7 +97,7 @@ void printVoltage() { lcd.printNumber(getInputVoltageX10(systemSettings.voltageDiv) % 10, 1); } void GUIDelay() { - osDelay(66); // 15Hz + osDelay(50); } void gui_drawTipTemp(bool symbol) { // Draw tip temp handling unit conversion & tolerance near setpoint @@ -193,13 +193,13 @@ static void waitForButtonPress() { ButtonState buttons = getButtonState(); while (buttons) { buttons = getButtonState(); - GUIDelay(); lcd.refresh(); + GUIDelay(); } while (!buttons) { buttons = getButtonState(); - GUIDelay(); lcd.refresh(); + GUIDelay(); } } @@ -603,6 +603,7 @@ void showVersion(void) { screen++; screen = screen % 7; } + GUIDelay(); } } @@ -812,7 +813,8 @@ void startPIDTask(void const *argument) { int32_t rawTempError = currentlyActiveTemperatureTarget - rawTemp; - int32_t ierror = (rawTempError / ((int32_t)systemSettings.PID_I)); + int32_t ierror = (rawTempError + / ((int32_t) systemSettings.PID_I)); integralCount += ierror; if (integralCount > (itermMax / 2)) integralCount = itermMax / 2; // prevent too much lead @@ -822,11 +824,12 @@ void startPIDTask(void const *argument) { int32_t dInput = (rawTemp - derivativeLastValue); /*Compute PID Output*/ - int32_t output = (rawTempError / ((int32_t)systemSettings.PID_P)); - if (((int32_t)systemSettings.PID_I)) + int32_t output = (rawTempError + / ((int32_t) systemSettings.PID_P)); + if (((int32_t) systemSettings.PID_I)) output += integralCount; - if (((int32_t)systemSettings.PID_D)) - output -= (dInput / ((int32_t)systemSettings.PID_D)); + if (((int32_t) systemSettings.PID_D)) + output -= (dInput / ((int32_t) systemSettings.PID_D)); if (output > 100) { output = 100; // saturate @@ -895,7 +898,7 @@ void startMOVTask(void const *argument) { } if (systemSettings.OrientationMode == 2) { if (rotation != ORIENTATION_FLAT) { - lcd.setRotation(rotation == ORIENTATION_LEFT_HAND); // link the data through + lcd.setRotation(rotation == ORIENTATION_LEFT_HAND); // link the data through } } datax[currentPointer] = (int32_t) tx; |