1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-24 08:45:24 +03:00

Dual-buffer for LCD

This commit is contained in:
Damjan Adamic 2014-12-04 21:11:27 +01:00
parent e32da2ba4a
commit 0d1362e476
4 changed files with 27 additions and 7 deletions

View file

@ -678,11 +678,11 @@ ifeq ($(PCB), TARANIS)
CPPDEFS = -DREV4a CPPDEFS = -DREV4a
SWR = YES SWR = YES
else ifeq ($(PCBREV), REVPLUS) else ifeq ($(PCBREV), REVPLUS)
CPPDEFS = -DREVPLUS CPPDEFS = -DREVPLUS -DLCD_DUAL_BUFFER
HAPTIC = YES HAPTIC = YES
SWR = NO SWR = NO
else ifeq ($(PCBREV), REV9E) else ifeq ($(PCBREV), REV9E)
CPPDEFS = -DREVPLUS -DREV9E CPPDEFS = -DREVPLUS -DREV9E -DLCD_DUAL_BUFFER
HAPTIC = YES HAPTIC = YES
SWR = YES SWR = YES
else else

View file

@ -161,7 +161,13 @@
#define DISPLAY_BUF_SIZE (LCD_W*((LCD_H+7)/8)) #define DISPLAY_BUF_SIZE (LCD_W*((LCD_H+7)/8))
#endif #endif
#if defined(LCD_DUAL_BUFFER)
extern display_t displayBuf1[DISPLAY_BUF_SIZE];
extern display_t displayBuf2[DISPLAY_BUF_SIZE];
extern display_t * displayBuf;
#else
extern display_t displayBuf[DISPLAY_BUF_SIZE]; extern display_t displayBuf[DISPLAY_BUF_SIZE];
#endif
extern coord_t lcdLastPos; extern coord_t lcdLastPos;
extern coord_t lcdNextPos; extern coord_t lcdNextPos;

View file

@ -36,11 +36,20 @@
#include "opentx.h" #include "opentx.h"
#if defined(LCD_DUAL_BUFFER)
display_t displayBuf1[DISPLAY_BUF_SIZE];
display_t displayBuf2[DISPLAY_BUF_SIZE];
display_t * displayBuf = displayBuf1;
#define DISPLAY_BUFER_SIZE sizeof(displayBuf1)
#else
display_t displayBuf[DISPLAY_BUF_SIZE]; display_t displayBuf[DISPLAY_BUF_SIZE];
#define DISPLAY_BUFER_SIZE sizeof(displayBuf)
#endif
void lcd_clear() void lcd_clear()
{ {
memset(displayBuf, 0, sizeof(displayBuf)); memset(displayBuf, 0, DISPLAY_BUFER_SIZE);
} }
coord_t lcdLastPos; coord_t lcdLastPos;

View file

@ -193,11 +193,17 @@ void lcdRefresh(bool wait)
DMA1_Stream7->CR &= ~DMA_SxCR_EN ; // Disable DMA DMA1_Stream7->CR &= ~DMA_SxCR_EN ; // Disable DMA
DMA1->HIFCR = DMA_HIFCR_CTCIF7 | DMA_HIFCR_CHTIF7 | DMA_HIFCR_CTEIF7 | DMA_HIFCR_CDMEIF7 | DMA_HIFCR_CFEIF7 ; // Write ones to clear bits DMA1->HIFCR = DMA_HIFCR_CTCIF7 | DMA_HIFCR_CHTIF7 | DMA_HIFCR_CTEIF7 | DMA_HIFCR_CDMEIF7 | DMA_HIFCR_CFEIF7 ; // Write ones to clear bits
#if defined(LCD_DUAL_BUFFER)
//switch LCD buffer
DMA1_Stream7->M0AR = (uint32_t)displayBuf;
displayBuf = (displayBuf == displayBuf1) ? displayBuf2 : displayBuf1;
#endif
DMA1_Stream7->CR |= DMA_SxCR_EN | DMA_SxCR_TCIE; // Enable DMA & tXe interrupt DMA1_Stream7->CR |= DMA_SxCR_EN | DMA_SxCR_TCIE; // Enable DMA & tXe interrupt
SPI3->CR2 |= SPI_CR2_TXDMAEN ; SPI3->CR2 |= SPI_CR2_TXDMAEN ;
} }
// #if !defined(SIMU)
extern "C" void DMA1_Stream7_IRQHandler() extern "C" void DMA1_Stream7_IRQHandler()
{ {
//clear interrupt flag //clear interrupt flag
@ -207,15 +213,14 @@ extern "C" void DMA1_Stream7_IRQHandler()
DMA1_Stream7->CR &= ~DMA_SxCR_EN ; // Disable DMA DMA1_Stream7->CR &= ~DMA_SxCR_EN ; // Disable DMA
while ( SPI3->SR & SPI_SR_BSY ) { while ( SPI3->SR & SPI_SR_BSY ) {
/* Wait for SPI to finis sending data /* Wait for SPI to finish sending data
The DMA Tx End interrupt comes two bytes before the end of SPI transmission, The DMA TX End interrupt comes two bytes before the end of SPI transmission,
therefore we have to wait here. therefore we have to wait here.
*/ */
} }
LCD_NCS_HIGH(); LCD_NCS_HIGH();
lcd_busy = false; lcd_busy = false;
} }
// #endif // #if !defined(SIMU)
#else // #if defined(REVPLUS) #else // #if defined(REVPLUS)
void lcdRefresh() void lcdRefresh()