mirror of
https://github.com/Ralim/IronOS.git
synced 2025-02-26 07:53:55 +00:00
Add secondary framebuffer, instead of allocating on stack
This commit is contained in:
@@ -101,10 +101,11 @@ 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 transitionSecondaryFramebuffer(bool forwardNavigation);
|
||||||
static void set_framebuffer(uint8_t *buffer);
|
static void useSecondaryFramebuffer(bool useSecondary);
|
||||||
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 void setFramebuffer(uint8_t *buffer);
|
||||||
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
|
||||||
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
|
||||||
static uint8_t* secondStripPtr; //Pointers to the strips
|
static uint8_t* secondStripPtr; //Pointers to the strips
|
||||||
@@ -114,6 +115,7 @@ private:
|
|||||||
static int16_t cursor_x, cursor_y;
|
static int16_t cursor_x, cursor_y;
|
||||||
static uint8_t displayOffset;
|
static uint8_t displayOffset;
|
||||||
static uint8_t screenBuffer[16 + (OLED_WIDTH * 2) + 10]; // The data buffer
|
static uint8_t screenBuffer[16 + (OLED_WIDTH * 2) + 10]; // The data buffer
|
||||||
|
static uint8_t secondFrameBuffer[OLED_WIDTH * 2];
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* OLED_HPP_ */
|
#endif /* OLED_HPP_ */
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ uint8_t OLED::fontWidth, OLED::fontHeight;
|
|||||||
int16_t OLED::cursor_x, OLED::cursor_y;
|
int16_t OLED::cursor_x, OLED::cursor_y;
|
||||||
uint8_t OLED::displayOffset;
|
uint8_t OLED::displayOffset;
|
||||||
uint8_t OLED::screenBuffer[16 + (OLED_WIDTH * 2) + 10]; // The data buffer
|
uint8_t OLED::screenBuffer[16 + (OLED_WIDTH * 2) + 10]; // The data buffer
|
||||||
|
uint8_t OLED::secondFrameBuffer[OLED_WIDTH * 2];
|
||||||
|
|
||||||
/*Setup params for the OLED screen*/
|
/*Setup params for the OLED screen*/
|
||||||
/*http://www.displayfuture.com/Display/datasheet/controller/SSD1307.pdf*/
|
/*http://www.displayfuture.com/Display/datasheet/controller/SSD1307.pdf*/
|
||||||
@@ -93,7 +94,7 @@ void OLED::initialize() {
|
|||||||
sizeof(OLED_Setup_Array));
|
sizeof(OLED_Setup_Array));
|
||||||
}
|
}
|
||||||
|
|
||||||
void OLED::set_framebuffer(uint8_t *buffer) {
|
void OLED::setFramebuffer(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];
|
||||||
@@ -146,15 +147,14 @@ void OLED::drawScrollIndicator(uint8_t y, uint8_t height) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Plays a transition animation between two framebuffers.
|
* Plays a transition animation between two framebuffers.
|
||||||
* @param framebuffer Second framebuffer to use for animation.
|
* @param forwardNavigation Direction of the navigation animation.
|
||||||
* @param forward Direction of the navigation animation.
|
|
||||||
*
|
*
|
||||||
* If forward is true, this displays a forward navigation to the second framebuffer contents.
|
* If forward is true, this displays a forward navigation to the second framebuffer contents.
|
||||||
* 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::transitionSecondaryFramebuffer(bool forwardNavigation) {
|
||||||
uint8_t *firstBackStripPtr = &framebuffer[0];
|
uint8_t *firstBackStripPtr = &secondFrameBuffer[0];
|
||||||
uint8_t *secondBackStripPtr = &framebuffer[OLED_WIDTH];
|
uint8_t *secondBackStripPtr = &secondFrameBuffer[OLED_WIDTH];
|
||||||
|
|
||||||
uint32_t totalDuration = 50; // 500ms
|
uint32_t totalDuration = 50; // 500ms
|
||||||
uint32_t duration = 0;
|
uint32_t duration = 0;
|
||||||
@@ -193,6 +193,14 @@ void OLED::transitionToContents(uint8_t *framebuffer, bool forwardNavigation) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OLED::useSecondaryFramebuffer(bool useSecondary) {
|
||||||
|
if (useSecondary) {
|
||||||
|
setFramebuffer(secondFrameBuffer);
|
||||||
|
} else {
|
||||||
|
setFramebuffer(NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void OLED::setRotation(bool leftHanded) {
|
void OLED::setRotation(bool leftHanded) {
|
||||||
#ifdef MODEL_TS80
|
#ifdef MODEL_TS80
|
||||||
leftHanded = !leftHanded;
|
leftHanded = !leftHanded;
|
||||||
|
|||||||
@@ -840,14 +840,13 @@ void gui_Menu(const menuitem *menu) {
|
|||||||
// 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];
|
OLED::useSecondaryFramebuffer(true);
|
||||||
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::useSecondaryFramebuffer(false);
|
||||||
OLED::transitionToContents(secondaryFrameBuffer, true);
|
OLED::transitionSecondaryFramebuffer(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
while ((menu[currentScreen].draw.func != NULL) && earlyExit == false) {
|
while ((menu[currentScreen].draw.func != NULL) && earlyExit == false) {
|
||||||
@@ -905,14 +904,13 @@ void gui_Menu(const menuitem *menu) {
|
|||||||
menu[currentScreen].incrementHandler.func();
|
menu[currentScreen].incrementHandler.func();
|
||||||
|
|
||||||
if (enterGUIMenu) {
|
if (enterGUIMenu) {
|
||||||
uint8_t secondaryFrameBuffer[OLED_WIDTH * 2];
|
OLED::useSecondaryFramebuffer(true);
|
||||||
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::useSecondaryFramebuffer(false);
|
||||||
OLED::transitionToContents(secondaryFrameBuffer, false);
|
OLED::transitionSecondaryFramebuffer(false);
|
||||||
}
|
}
|
||||||
enterGUIMenu = true;
|
enterGUIMenu = true;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user