63 lines
1.2 KiB
C++
63 lines
1.2 KiB
C++
/*
|
|
* mainloop.cpp
|
|
*
|
|
* Created on: Sep 11, 2019
|
|
* Author: abody
|
|
*/
|
|
|
|
#include <f4ll_cpp/ili9341.h>
|
|
#include <application.h>
|
|
#include <initializer_list>
|
|
#include "main.h"
|
|
#include "globals.h"
|
|
|
|
#define BORDER 60
|
|
#define BARWIDTH 2
|
|
|
|
|
|
|
|
void MainLoop()
|
|
{
|
|
Application m;
|
|
|
|
m.Loop();
|
|
}
|
|
|
|
Application::Application()
|
|
: GlobalsInitializer(&m_console)
|
|
, m_console(USART1, DMA2, LL_DMA_STREAM_2, LL_DMA_STREAM_7, this, nullptr)
|
|
{
|
|
}
|
|
|
|
void Application::Loop()
|
|
{
|
|
Ili9341Fsmc &lcd(Ili9341Fsmc::Init(nullptr, nullptr, DMA2, LL_DMA_STREAM_4, false));
|
|
|
|
lcd.FillRect(Ili9341Fsmc::ILI9341_ORANGE, false);
|
|
lcd.Test();
|
|
lcd.Print("0 1 2 3 4 5 6 7 8 9 A B C D E F\r\n");
|
|
|
|
for(;;) {
|
|
if(m_received && m_transmitted) {
|
|
m_transmitted = false;
|
|
const char *line = const_cast<const char*>(m_rcvdBuffer->buffer);
|
|
m_console.SendLine(line, m_rcvdBuffer->len);
|
|
lcd.Print(line);
|
|
lcd.Print("\r\n", 2);
|
|
m_received = false;
|
|
m_rcvdBuffer->busy = false;
|
|
}
|
|
}
|
|
}
|
|
|
|
void Application::LineReceived(void *userParam, SerialConsole<257>::Buffer *buffer)
|
|
{
|
|
m_received = true;
|
|
m_rcvdBuffer = buffer;
|
|
}
|
|
|
|
void Application::TransmissionComplete(void *userParam, SerialConsole<257>::Buffer *buffer)
|
|
{
|
|
m_transmitted = true;
|
|
}
|
|
|