Skip to content

Commit

Permalink
Fix OLED display scroll speed being painfully slow + junk on ease in/out
Browse files Browse the repository at this point in the history
  • Loading branch information
Ralim committed Jun 19, 2023
1 parent 9b5d155 commit 691abd5
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 13 deletions.
2 changes: 1 addition & 1 deletion source/Core/BSP/MHP30/FreeRTOSConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ extern uint32_t SystemCoreClock;
#define INCLUDE_vTaskDelete 0
#define INCLUDE_vTaskCleanUpResources 0
#define INCLUDE_vTaskSuspend 0
#define INCLUDE_vTaskDelayUntil 0
#define INCLUDE_vTaskDelayUntil 1
#define INCLUDE_vTaskDelay 1
#define INCLUDE_xTaskGetSchedulerState 1
#define INCLUDE_uxTaskGetStackHighWaterMark 1
Expand Down
2 changes: 1 addition & 1 deletion source/Core/BSP/Miniware/FreeRTOSConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ extern uint32_t SystemCoreClock;
#define INCLUDE_vTaskDelete 0
#define INCLUDE_vTaskCleanUpResources 0
#define INCLUDE_vTaskSuspend 0
#define INCLUDE_vTaskDelayUntil 0
#define INCLUDE_vTaskDelayUntil 1
#define INCLUDE_vTaskDelay 1
#define INCLUDE_xTaskGetSchedulerState 1
#define INCLUDE_uxTaskGetStackHighWaterMark 1
Expand Down
2 changes: 1 addition & 1 deletion source/Core/BSP/Sequre_S60/FreeRTOSConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ extern uint32_t SystemCoreClock;
#define INCLUDE_vTaskDelete 0
#define INCLUDE_vTaskCleanUpResources 0
#define INCLUDE_vTaskSuspend 0
#define INCLUDE_vTaskDelayUntil 0
#define INCLUDE_vTaskDelayUntil 1
#define INCLUDE_vTaskDelay 1
#define INCLUDE_xTaskGetSchedulerState 1
#define INCLUDE_uxTaskGetStackHighWaterMark 1
Expand Down
22 changes: 12 additions & 10 deletions source/Core/Drivers/OLED.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ const uint8_t REFRESH_COMMANDS[17] = {
* Returns a new percentage value with ease in and ease out.
* Original floating point formula: t * t * (3.0f - 2.0f * t);
*/
static uint8_t easeInOutTiming(uint8_t t) { return t * t * (300 - 2 * t) / 10000; }
static uint16_t easeInOutTiming(uint16_t t) { return t * t * (300 - 2 * t) / 10000; }

/*
* Returns the value between a and b, using a percentage value t.
Expand Down Expand Up @@ -259,8 +259,8 @@ void OLED::maskScrollIndicatorOnOLED() {
*/
void OLED::transitionSecondaryFramebuffer(bool forwardNavigation) {
uint8_t *stripBackPointers[4];
stripBackPointers[0] = &secondFrameBuffer[0];
stripBackPointers[1] = &secondFrameBuffer[OLED_WIDTH];
stripBackPointers[0] = &secondFrameBuffer[FRAMEBUFFER_START + 0];
stripBackPointers[1] = &secondFrameBuffer[FRAMEBUFFER_START + OLED_WIDTH];

#ifdef OLED_128x32
stripBackPointers[2] = &secondFrameBuffer[OLED_WIDTH * 2];
Expand All @@ -273,10 +273,10 @@ void OLED::transitionSecondaryFramebuffer(bool forwardNavigation) {
uint8_t offset = 0;

while (duration <= totalDuration) {
duration = xTaskGetTickCount() - start;
uint8_t progress = ((duration * 100) / totalDuration); // Percentage of the period we are through for animation
progress = easeInOutTiming(progress);
progress = lerp(0, OLED_WIDTH, progress);
duration = xTaskGetTickCount() - start;
uint16_t progress = ((duration * 100) / totalDuration); // Percentage of the period we are through for animation
progress = easeInOutTiming(progress);
progress = lerp(0, OLED_WIDTH, progress);
// Constrain
if (progress > OLED_WIDTH) {
progress = OLED_WIDTH;
Expand Down Expand Up @@ -308,8 +308,9 @@ void OLED::transitionSecondaryFramebuffer(bool forwardNavigation) {
memmove(&stripPointers[3][newStart], &stripBackPointers[3][newEnd], progress);
#endif

refresh();
osDelay(TICKS_100MS / 7);
TickType_t start = xTaskGetTickCount();
refresh(); // Now refresh to write out the contents to the new page
vTaskDelayUntil(&start, TICKS_100MS / 7);
if (getButtonState() != BUTTON_NONE) {
return;
}
Expand Down Expand Up @@ -373,8 +374,9 @@ 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
osDelay(TICKS_100MS / 7);
vTaskDelayUntil(&start, TICKS_100MS / 7);
}
}

Expand Down

1 comment on commit 691abd5

@discip
Copy link
Collaborator

@discip discip commented on 691abd5 Jun 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Ralim
Unfortunately the instability I mentioned here: c691809#commitcomment-118816126 is still present.

This popped up in addition to those mentioned in the link above:
artifacts_4

For Pinecil_V2 and TS80P this (everything I reported regarding the artifacts on the OLED) only occurs on the latter device after flashing, manually resetting to factory defaults and going through the menu setting up everything as needed.

Please sign in to comment.