Commit f735d785 authored by Projects's avatar Projects

Faster LCD buffer clearing.

parent 522c8925
...@@ -126,6 +126,8 @@ void RTC_IRQHandler(void) ...@@ -126,6 +126,8 @@ void RTC_IRQHandler(void)
void lcd_init(void) void lcd_init(void)
{ {
uint16_t cmd;
timer_init(); timer_init();
spi_init(); spi_init();
// TODO I am pretty sure, it will be already initialized somewhere.. // TODO I am pretty sure, it will be already initialized somewhere..
...@@ -145,6 +147,17 @@ void lcd_init(void) ...@@ -145,6 +147,17 @@ void lcd_init(void)
rtc_setup(LCD_POL_INV_FREQ); rtc_setup(LCD_POL_INV_FREQ);
lcd_power(1); lcd_power(1);
// Send command to clear the display
GPIO_PinOutSet(LCD_PORT_SCS, LCD_PIN_SCS);
timer_delay(6);
cmd = LCD_CMD_ALL_CLEAR;
spi_transmit((uint8_t*) &cmd, 2);
timer_delay(2);
GPIO_PinOutClear(LCD_PORT_SCS, LCD_PIN_SCS);
lcd_clear(); lcd_clear();
lcd_enable(1); lcd_enable(1);
} }
...@@ -167,39 +180,26 @@ void lcd_power(uint8_t enable) ...@@ -167,39 +180,26 @@ void lcd_power(uint8_t enable)
void lcd_clear(void) void lcd_clear(void)
{ {
uint16_t cmd; // Using uint32_t instead of uint8_t reduces the number of writes 4 times
uint8_t *p = buffer; uint32_t *p = (uint32_t*)buffer;
#ifdef LCD_NODMA
uint16_t i; uint16_t i;
// Clear pixel buffer // Clear pixel buffer
for(i = 0; i < sizeof(buffer); ++i) for(i = 0; i < sizeof(buffer) / sizeof(uint32_t); ++i)
*p++ = 0x00; *p++ = 0x00;
#else
uint8_t x, y;
for(y = 0; y < LCD_HEIGHT; ++y) #ifndef LCD_NODMA
{ // Clear pixel buffer
// Clear framebuffer for(i = 0; i < sizeof(buffer) / sizeof(uint32_t); ++i)
for(x = 0; x < LCD_WIDTH / 8; ++x) *p++ = 0x00;
*p++ = 0x00;
for(i = 0; i < LCD_HEIGHT; ++i)
{
// Add control codes // Add control codes
*p++ = 0xff; // Dummy buffer[i * LCD_STRIDE - 2] = 0xff; // Dummy
*p++ = (y + 2); // Address of next line buffer[i * LCD_STRIDE - 1] = (i + 2); // Address of next line
} }
#endif #endif
// Send command to clear the display
GPIO_PinOutSet(LCD_PORT_SCS, LCD_PIN_SCS);
timer_delay(6);
cmd = LCD_CMD_ALL_CLEAR;
spi_transmit((uint8_t*) &cmd, 2);
timer_delay(2);
GPIO_PinOutClear(LCD_PORT_SCS, LCD_PIN_SCS);
} }
void lcd_update(void) void lcd_update(void)
...@@ -236,12 +236,8 @@ void lcd_update(void) ...@@ -236,12 +236,8 @@ void lcd_update(void)
spi_transmit((uint8_t*) &cmd, 2); spi_transmit((uint8_t*) &cmd, 2);
} }
#else #else
// TODO here the DMA transfer should run in the end
spi_transmit(p, LCD_STRIDE * LCD_HEIGHT); spi_transmit(p, LCD_STRIDE * LCD_HEIGHT);
/*for(i = 0; i < LCD_STRIDE * LCD_HEIGHT / 2; i += 2)
{
spi_transmit(p, 2);
p += 2;
}*/
#endif #endif
timer_delay(2); timer_delay(2);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment