Fix whitespaces

This commit is contained in:
Patrick Horlebein
2020-04-17 09:46:01 +02:00
parent c851554d3e
commit 3d33a6ea57
3 changed files with 86 additions and 86 deletions

View File

@@ -101,8 +101,8 @@ public:
bool clear); bool clear);
static void drawHeatSymbol(uint8_t state); static void drawHeatSymbol(uint8_t state);
static void drawScrollIndicator(uint8_t p, uint8_t h); // Draws a scrolling position indicator static void drawScrollIndicator(uint8_t p, uint8_t h); // Draws a scrolling position indicator
static void transitionToContents(uint8_t *framebuffer, bool forwardNavigation); static void transitionToContents(uint8_t *framebuffer, bool forwardNavigation);
static void set_framebuffer(uint8_t *buffer); static void set_framebuffer(uint8_t *buffer);
private: private:
static void drawChar(char c); // Draw a character to a specific location static void drawChar(char c); // Draw a character to a specific location
static const uint8_t* currentFont;// Pointer to the current font used for rendering to the buffer static const uint8_t* currentFont;// Pointer to the current font used for rendering to the buffer

View File

@@ -63,11 +63,11 @@ const uint8_t REFRESH_COMMANDS[17] = { 0x80, 0xAF, 0x80, 0x21, 0x80, 0x20, 0x80,
0x7F, 0x80, 0xC0, 0x80, 0x22, 0x80, 0x00, 0x80, 0x01, 0x40 }; 0x7F, 0x80, 0xC0, 0x80, 0x22, 0x80, 0x00, 0x80, 0x01, 0x40 };
static uint8_t easeInOutTiming(uint8_t t) { static uint8_t easeInOutTiming(uint8_t t) {
return t * t * (300 - 2 * t) / 10000; return t * t * (300 - 2 * t) / 10000;
} }
static uint8_t lerp(uint8_t a, uint8_t b, uint8_t t) { static uint8_t lerp(uint8_t a, uint8_t b, uint8_t t) {
return a + t * (b - a) / 100; return a + t * (b - a) / 100;
} }
void OLED::initialize() { void OLED::initialize() {
@@ -94,14 +94,14 @@ void OLED::initialize() {
} }
void OLED::set_framebuffer(uint8_t *buffer) { void OLED::set_framebuffer(uint8_t *buffer) {
if (buffer == NULL) { if (buffer == NULL) {
firstStripPtr = &screenBuffer[FRAMEBUFFER_START]; firstStripPtr = &screenBuffer[FRAMEBUFFER_START];
secondStripPtr = &screenBuffer[FRAMEBUFFER_START + OLED_WIDTH]; secondStripPtr = &screenBuffer[FRAMEBUFFER_START + OLED_WIDTH];
return; return;
} }
firstStripPtr = &buffer[0]; firstStripPtr = &buffer[0];
secondStripPtr = &buffer[OLED_WIDTH]; secondStripPtr = &buffer[OLED_WIDTH];
} }
/* /*
@@ -153,44 +153,44 @@ void OLED::drawScrollIndicator(uint8_t y, uint8_t height) {
* Otherwise a rewinding navigation animation is shown to the second framebuffer contents. * Otherwise a rewinding navigation animation is shown to the second framebuffer contents.
*/ */
void OLED::transitionToContents(uint8_t *framebuffer, bool forwardNavigation) { void OLED::transitionToContents(uint8_t *framebuffer, bool forwardNavigation) {
uint8_t *firstBackStripPtr = &framebuffer[0]; uint8_t *firstBackStripPtr = &framebuffer[0];
uint8_t *secondBackStripPtr = &framebuffer[OLED_WIDTH]; uint8_t *secondBackStripPtr = &framebuffer[OLED_WIDTH];
uint32_t totalDuration = 50; // 500ms uint32_t totalDuration = 50; // 500ms
uint32_t duration = 0; uint32_t duration = 0;
uint32_t start = xTaskGetTickCount(); uint32_t start = xTaskGetTickCount();
uint8_t offset = 0; uint8_t offset = 0;
while (duration <= totalDuration) { while (duration <= totalDuration) {
duration = xTaskGetTickCount() - start; duration = xTaskGetTickCount() - start;
uint8_t progress = duration * 100 / totalDuration; uint8_t progress = duration * 100 / totalDuration;
progress = easeInOutTiming(progress); progress = easeInOutTiming(progress);
progress = lerp(0, OLED_WIDTH, progress); progress = lerp(0, OLED_WIDTH, progress);
if (progress > OLED_WIDTH) { if (progress > OLED_WIDTH) {
progress = OLED_WIDTH; progress = OLED_WIDTH;
} }
// When forward, current contents move to the left out. // When forward, current contents move to the left out.
// Otherwise the contents move to the right out. // Otherwise the contents move to the right out.
uint8_t oldStart = forwardNavigation ? 0 : progress; uint8_t oldStart = forwardNavigation ? 0 : progress;
uint8_t oldPrevious = forwardNavigation ? progress - offset : offset; uint8_t oldPrevious = forwardNavigation ? progress - offset : offset;
// Content from the second framebuffer moves in from the right (forward) // Content from the second framebuffer moves in from the right (forward)
// or from the left (not forward). // or from the left (not forward).
uint8_t newStart = forwardNavigation ? OLED_WIDTH - progress : 0; uint8_t newStart = forwardNavigation ? OLED_WIDTH - progress : 0;
uint8_t newEnd = forwardNavigation ? 0 : OLED_WIDTH - progress; uint8_t newEnd = forwardNavigation ? 0 : OLED_WIDTH - progress;
offset = progress; offset = progress;
memmove(&firstStripPtr[oldStart], &firstStripPtr[oldPrevious], OLED_WIDTH - progress); memmove(&firstStripPtr[oldStart], &firstStripPtr[oldPrevious], OLED_WIDTH - progress);
memmove(&secondStripPtr[oldStart], &secondStripPtr[oldPrevious], OLED_WIDTH - progress); memmove(&secondStripPtr[oldStart], &secondStripPtr[oldPrevious], OLED_WIDTH - progress);
memmove(&firstStripPtr[newStart], &firstBackStripPtr[newEnd], progress); memmove(&firstStripPtr[newStart], &firstBackStripPtr[newEnd], progress);
memmove(&secondStripPtr[newStart], &secondBackStripPtr[newEnd], progress); memmove(&secondStripPtr[newStart], &secondBackStripPtr[newEnd], progress);
refresh(); refresh();
osDelay(40); osDelay(40);
} }
} }
void OLED::setRotation(bool leftHanded) { void OLED::setRotation(bool leftHanded) {

View File

@@ -826,29 +826,29 @@ void gui_Menu(const menuitem *menu) {
int16_t lastOffset = -1; int16_t lastOffset = -1;
bool lcdRefresh = true; bool lcdRefresh = true;
ButtonState lastButtonState = BUTTON_NONE; ButtonState lastButtonState = BUTTON_NONE;
static bool enterGUIMenu = true; static bool enterGUIMenu = true;
enterGUIMenu = true; enterGUIMenu = true;
uint8_t scrollContentSize = 0; uint8_t scrollContentSize = 0;
for (uint8_t i = 0; menu[i].draw.func != NULL; i++) { for (uint8_t i = 0; menu[i].draw.func != NULL; i++) {
scrollContentSize += 1; scrollContentSize += 1;
} }
// Animated menu opening. // Animated menu opening.
if (menu[currentScreen].draw.func != NULL) { if (menu[currentScreen].draw.func != NULL) {
// This menu is drawn in a secondary framebuffer. // This menu is drawn in a secondary framebuffer.
// Then we play a transition from the current primary // Then we play a transition from the current primary
// framebuffer to the new buffer. // framebuffer to the new buffer.
// The extra buffer is discarded at the end of the transition. // The extra buffer is discarded at the end of the transition.
uint8_t secondaryFrameBuffer[OLED_WIDTH * 2]; uint8_t secondaryFrameBuffer[OLED_WIDTH * 2];
OLED::set_framebuffer(secondaryFrameBuffer); OLED::set_framebuffer(secondaryFrameBuffer);
OLED::setFont(0); OLED::setFont(0);
OLED::setCursor(0, 0); OLED::setCursor(0, 0);
OLED::clearScreen(); OLED::clearScreen();
menu[currentScreen].draw.func(); menu[currentScreen].draw.func();
OLED::set_framebuffer(NULL); OLED::set_framebuffer(NULL);
OLED::transitionToContents(secondaryFrameBuffer, true); OLED::transitionToContents(secondaryFrameBuffer, true);
} }
while ((menu[currentScreen].draw.func != NULL) && earlyExit == false) { while ((menu[currentScreen].draw.func != NULL) && earlyExit == false) {
OLED::setFont(0); OLED::setFont(0);
@@ -900,24 +900,24 @@ void gui_Menu(const menuitem *menu) {
case BUTTON_F_SHORT: case BUTTON_F_SHORT:
// increment // increment
if (descriptionStart == 0) { if (descriptionStart == 0) {
if (menu[currentScreen].incrementHandler.func != NULL) { if (menu[currentScreen].incrementHandler.func != NULL) {
enterGUIMenu = false; enterGUIMenu = false;
menu[currentScreen].incrementHandler.func(); menu[currentScreen].incrementHandler.func();
if (enterGUIMenu) { if (enterGUIMenu) {
uint8_t secondaryFrameBuffer[OLED_WIDTH * 2]; uint8_t secondaryFrameBuffer[OLED_WIDTH * 2];
OLED::set_framebuffer(secondaryFrameBuffer); OLED::set_framebuffer(secondaryFrameBuffer);
OLED::setFont(0); OLED::setFont(0);
OLED::setCursor(0, 0); OLED::setCursor(0, 0);
OLED::clearScreen(); OLED::clearScreen();
menu[currentScreen].draw.func(); menu[currentScreen].draw.func();
OLED::set_framebuffer(NULL); OLED::set_framebuffer(NULL);
OLED::transitionToContents(secondaryFrameBuffer, false); OLED::transitionToContents(secondaryFrameBuffer, false);
} }
enterGUIMenu = true; enterGUIMenu = true;
} else { } else {
earlyExit = true; earlyExit = true;
} }
} else } else
descriptionStart = 0; descriptionStart = 0;
break; break;