DMA based FillRect works
This commit is contained in:
parent
d8ee389442
commit
98aacc5c47
22 changed files with 821 additions and 200 deletions
57
App/mainloop.cpp
Normal file
57
App/mainloop.cpp
Normal file
|
@ -0,0 +1,57 @@
|
|||
/*
|
||||
* mainloop.cpp
|
||||
*
|
||||
* Created on: Sep 11, 2019
|
||||
* Author: abody
|
||||
*/
|
||||
|
||||
#include <ili9341.h>
|
||||
#include "main.h"
|
||||
#include <mainloop.h>
|
||||
#include <initializer_list>
|
||||
|
||||
#define LCD_REG 0x60000000 /* DC = 0 */
|
||||
#define LCD_RAM 0x60080000 /* DC = 1 */
|
||||
#define BORDER 60
|
||||
#define BARWIDTH 2
|
||||
|
||||
void MainLoop()
|
||||
{
|
||||
uint16_t colors[] = {
|
||||
ILI9341_RED, ILI9341_ORANGE, ILI9341_YELLOW, ILI9341_GREENYELLOW,
|
||||
ILI9341_GREEN, ILI9341_CYAN, ILI9341_BLUE, ILI9341_MAGENTA
|
||||
};
|
||||
static uint16_t const colorCount = sizeof(colors)/sizeof(colors[0]);
|
||||
uint32_t lastTick = 0;
|
||||
uint32_t tmpTick;
|
||||
uint32_t lastDiff;
|
||||
|
||||
//LL_SYSTICK_EnableIT();
|
||||
|
||||
Ili9341Fsmc &lcd(Ili9341Fsmc::Instance((volatile unsigned short *) LCD_REG, (volatile unsigned short *) LCD_RAM, DMA2, LL_DMA_STREAM_4, true));
|
||||
|
||||
lcd.FillRect(ILI9341_WHITE);
|
||||
lcd.FillRect(BORDER, BORDER, lcd.Width()- BORDER * 2, lcd.Height()-BORDER * 2, ILI9341_BLACK);
|
||||
uint16_t offset = 0;
|
||||
uint16_t maxidx = (lcd.Width() - BARWIDTH) / BARWIDTH;
|
||||
for(;;) {
|
||||
uint16_t idx = 0;
|
||||
while(idx <= maxidx ) {
|
||||
lcd.FillRect(idx * BARWIDTH, 0, BARWIDTH, lcd.Height(), colors[(idx+offset) % colorCount]);
|
||||
++idx;
|
||||
}
|
||||
offset = (offset+1)%colorCount;
|
||||
tmpTick = HAL_GetTick();
|
||||
lastDiff = tmpTick - lastTick;
|
||||
do tmpTick = HAL_GetTick(); while(tmpTick - lastTick < 20);
|
||||
lastTick = tmpTick;
|
||||
// LL_GPIO_TogglePin(LED1_GPIO_Port, LED1_Pin);
|
||||
// LL_GPIO_TogglePin(LED2_GPIO_Port, LED2_Pin);
|
||||
// LL_mDelay(25);
|
||||
}
|
||||
}
|
||||
|
||||
MainLoop::MainLoop()
|
||||
{
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue