This commit is contained in:
Attila Body 2020-02-10 15:06:45 +01:00
parent 90d89c7fbe
commit 49383b1b32
68 changed files with 3385 additions and 610 deletions

66
App/application.cpp Normal file
View file

@ -0,0 +1,66 @@
/*
* mainloop.cpp
*
* Created on: Sep 11, 2019
* Author: abody
*/
#include <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()
{
//LL_SYSTICK_EnableIT();
Ili9341Fsmc &lcd(Ili9341Fsmc::Init(nullptr, nullptr, DMA2, LL_DMA_STREAM_4, false));
lcd.FillRect(Ili9341Fsmc::ILI9341_BLACK, false);
//lcd.Test();
lcd.SetCursor( 10, 10, Ili9341Fsmc::ILI9341_WHITE, Ili9341Fsmc::ILI9341_BLACK);
lcd.Print("Baszod");
for(;;) {
if(m_received && m_transmitted) {
m_transmitted = false;
m_console.SendLine(reinterpret_cast<char*>(const_cast<char*>(m_rcvdBuffer->buffer)), m_rcvdBuffer->len);
m_received = false;
m_rcvdBuffer->busy = false;
}
}
//LL_GPIO_TogglePin(LED1_GPIO_Port, LED1_Pin);
//LL_GPIO_TogglePin(LED2_GPIO_Port, LED2_Pin);
//LL_mDelay(25);
}
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;
}

49
App/application.h Normal file
View file

@ -0,0 +1,49 @@
/*
* mainloop.h
*
* Created on: Sep 11, 2019
* Author: abody
*/
#ifndef MAINLOOP_H_
#define MAINLOOP_H_
#if defined(__cplusplus)
extern "C" {
#endif
void MainLoop();
#if defined(__cplusplus)
}
#endif
#if defined(__cplusplus)
#include <f4ll_cpp/serialconsole.h>
#include "globals.h"
struct GlobalsInitializer {
GlobalsInitializer(SerialConsole<257> *console) {
g_console = console;
}
};
class Application : public GlobalsInitializer, public SerialConsole<257>::ISerialConsoleCallback {
public:
Application();
void Loop();
private:
virtual void LineReceived(void *userParam, SerialConsole<257>::Buffer *buffer);
virtual void TransmissionComplete(void *userParam, SerialConsole<257>::Buffer *buffer);
SerialConsole<257> m_console;
volatile bool m_received = false;
volatile SerialConsole<257>::Buffer *m_rcvdBuffer;
volatile bool m_transmitted = true;
};
#endif // __cplusplus
#endif /* MAINLOOP_H_ */

View file

@ -7,3 +7,4 @@
#include "globals.h"
SerialConsole<257> *g_console = nullptr;

View file

@ -7,5 +7,12 @@
#ifndef GLOBALS_H_
#define GLOBALS_H_
#include <f4ll_cpp/serialconsole.h>
#if defined(__cplusplus)
extern SerialConsole<257> *g_console;
#endif // __cplusplus
#endif /* GLOBALS_H_ */

View file

@ -18,10 +18,9 @@
Ili9341Fsmc::Ili9341Fsmc(volatile uint16_t *reg, volatile uint16_t *ram,
DMA_TypeDef *dma, uint32_t dmaStream,
bool horizontal)
: m_reg(reg ? reg : (volatile unsigned short *) 0x60000000)
: DmaHelper(dma, dmaStream)
, m_reg(reg ? reg : (volatile unsigned short *) 0x60000000)
, m_ram(ram ? ram : (volatile unsigned short *) 0x60080000)
, m_dma(dma)
, m_dmaStream(dmaStream)
, m_width(horizontal ? LCD_L : LCD_S)
, m_height(horizontal ? LCD_S : LCD_L)
, m_rectX(0)
@ -29,8 +28,8 @@ Ili9341Fsmc::Ili9341Fsmc(volatile uint16_t *reg, volatile uint16_t *ram,
, m_rectWidth(m_width)
, m_rectHeight(m_height)
{
LL_DMA_EnableIT_TC(m_dma, m_dmaStream);
LL_DMA_EnableIT_TE(m_dma, m_dmaStream);
LL_DMA_EnableIT_TC(GetDma(), GetStream());
LL_DMA_EnableIT_TE(GetDma(), GetStream());
WriteCmd(ILI9341_RESET);
HAL_Delay(10);
@ -84,7 +83,7 @@ void Ili9341Fsmc::SetRect(uint16_t x, uint16_t y, uint16_t width, uint16_t heigh
if(x > m_width || y > m_height || !width || !height )
return;
WaitDmaIddle();
WaitDmaIdle();
m_rectX = x;
m_rectY = y;
@ -98,66 +97,203 @@ void Ili9341Fsmc::SetRect(uint16_t x, uint16_t y, uint16_t width, uint16_t heigh
WriteCmd(ILI9341_PAGE_ADDR, {(uint16_t)(y >> 8), (uint16_t)(y & 0xff), (uint16_t)(bottom >> 8), (uint16_t)(bottom & 0xff)});
}
void Ili9341Fsmc::FillRect(uint16_t color)
void Ili9341Fsmc::FillRect(uint16_t color, bool async)
{
uint32_t count = m_rectWidth * m_rectHeight;
WaitDmaIddle();
WaitDmaIdle();
m_dmaColor = color;
WriteCmd(ILI9341_GRAM);
LL_DMA_SetM2MDstAddress(m_dma, m_dmaStream, (uint32_t)m_ram);
LL_DMA_SetM2MSrcAddress(m_dma, m_dmaStream, (uint32_t) &m_dmaColor);
LL_DMA_SetMemoryIncMode(m_dma, m_dmaStream, LL_DMA_MEMORY_NOINCREMENT);
LL_DMA_SetPeriphIncMode(m_dma, m_dmaStream, LL_DMA_PERIPH_NOINCREMENT);
LL_DMA_SetM2MDstAddress(GetDma(), GetStream(), (uint32_t)m_ram);
LL_DMA_SetM2MSrcAddress(GetDma(), GetStream(), (uint32_t) &m_dmaColor);
LL_DMA_SetMemoryIncMode(GetDma(), GetStream(), LL_DMA_MEMORY_NOINCREMENT);
LL_DMA_SetPeriphIncMode(GetDma(), GetStream(), LL_DMA_PERIPH_NOINCREMENT);
SetupDmaSize(count);
m_dmaEngineBusy = true;
LL_DMA_EnableStream(m_dma, m_dmaStream);
// for(uint32_t pix = 0; pix < count; ++pix)
// *m_ram = color;
LL_DMA_EnableStream(GetDma(), GetStream());
if(!async)
WaitDmaIdle();
}
void Ili9341Fsmc::FillRect(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint16_t color)
void Ili9341Fsmc::FillRect(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint16_t color, bool async)
{
SetRect(x, y, width, height);
FillRect(color);
FillRect(color, async);
}
void Ili9341Fsmc::SetupDmaSize(uint32_t size)
{
if(size > 0xffff) {
LL_DMA_SetDataLength(m_dma, m_dmaStream, 0xffff);
LL_DMA_SetDataLength(GetDma(), GetStream(), 0xffff);
m_dmaRemainingPixels = size - 0xffff;
} else {
LL_DMA_SetDataLength(m_dma, m_dmaStream, size);
LL_DMA_SetDataLength(GetDma(), GetStream(), size);
m_dmaRemainingPixels = 0;
}
}
void Ili9341Fsmc::DmaTransferComplete()
void Ili9341Fsmc::HandleDmaIrq()
{
if(!m_dmaRemainingPixels)
m_dmaEngineBusy = false;
else {
SetupDmaSize(m_dmaRemainingPixels);
LL_DMA_EnableStream(m_dma, m_dmaStream);
}
if(*GetIsReg() & GetTcMask()) { //LL_DMA_IsActiveFlag_TC4(DMA2)) {
*GetIfcReg() = GetTcMask(); //LL_DMA_ClearFlag_TC4(DMA2);
LL_DMA_DisableStream(GetDma(), GetStream());
if(!m_dmaRemainingPixels)
m_dmaEngineBusy = false;
else {
SetupDmaSize(m_dmaRemainingPixels);
LL_DMA_EnableStream(GetDma(), GetStream());
}
} else if(*GetIsReg() & GetTeMask())
*GetIfcReg() = GetTeMask();
}
void Ili9341Fsmc::Test()
void Ili9341Fsmc::SetCursor(uint16_t x, uint16_t y, uint16_t fgColor, uint16_t bgColor)
{
FillRect(ILI9341_PINK);
WaitDmaIddle();
m_xPos = x;
m_yPos = y;
m_fgColor = fgColor;
m_bgColor = bgColor;
}
void Ili9341Fsmc::PrintChar(char c)
{
if(m_xPos >= m_width - CHRWIDTH || m_yPos >= m_height - CHRHEIGHT || c < ' ' || c >= '~')
return;
uint8_t const *chrPtr = m_font[c - 32];
SetRect(m_xPos, m_yPos, CHRWIDTH, CHRHEIGHT);
WriteCmd(ILI9341_GRAM);
for(uint8_t y = 0; y < CHRWIDTH; ++y ) {
uint8_t mask = 0x80;
for(uint8_t x = 0; x < CHRHEIGHT; ++x)
*m_ram = (chrPtr[x] & mask) ? m_fgColor : m_fgColor;
mask >>= 1;
}
m_xPos += CHRHEIGHT;
}
void Ili9341Fsmc::PrintChar(char c, uint16_t x, uint16_t y, uint16_t fgColor, uint16_t bgColor)
{
SetCursor(x, y, fgColor, bgColor);
PrintChar(c);
}
void Ili9341Fsmc::Print(char const *str, uint8_t len)
{
if(!len)
len = strlen(str);
while(len--)
PrintChar(*str++);
}
void Ili9341Fsmc::Test() {
FillRect(ILI9341_PINK, false);
WriteCmd(ILI9341_GRAM);
uint16_t fillers[4] = { 0xf800, 0x7e0, 0x1f, 0xffff };
for(uint32_t y = 0; y < m_height; ++y) {
uint32_t x;
for(x = 0; x < m_width / 2; ++x) {
for(x = 0; x < m_width / 2; ++x)
*m_ram = fillers[ (x&0x18) >> 3 ];
}
for( ; x < m_width; ++x) {
for( ; x < m_width; ++x)
*m_ram = 0;
}
}
}
const uint8_t Ili9341Fsmc::m_font[CHRCOUNT][CHRWIDTH] = {
{0x00,0x00,0x00,0x00,0x00,0x00}, //
{0x2f,0x00,0x00,0x00,0x00,0x00}, // !
{0x03,0x00,0x03,0x00,0x00,0x00}, // "
{0x12,0x3f,0x12,0x12,0x3f,0x12}, // #
{0x2e,0x2a,0x7f,0x2a,0x3a,0x00}, // $
{0x23,0x13,0x08,0x04,0x32,0x31}, // %
{0x10,0x2a,0x25,0x2a,0x10,0x20}, // &
{0x02,0x01,0x00,0x00,0x00,0x00}, // '
{0x1e,0x21,0x00,0x00,0x00,0x00}, // (
{0x21,0x1e,0x00,0x00,0x00,0x00}, // )
{0x08,0x2a,0x1c,0x2a,0x08,0x08}, // *
{0x08,0x08,0x3e,0x08,0x08,0x08}, // +
{0x80,0x60,0x00,0x00,0x00,0x00}, // ,
{0x08,0x08,0x08,0x08,0x08,0x00}, // -
{0x30,0x30,0x00,0x00,0x00,0x00}, // .
{0x20,0x10,0x08,0x04,0x02,0x00}, // /
{0x1e,0x31,0x29,0x25,0x23,0x1e}, // 0
{0x22,0x21,0x3f,0x20,0x20,0x20}, // 1
{0x32,0x29,0x29,0x29,0x29,0x26}, // 2
{0x12,0x21,0x21,0x25,0x25,0x1a}, // 3
{0x18,0x14,0x12,0x3f,0x10,0x10}, // 4
{0x17,0x25,0x25,0x25,0x25,0x19}, // 5
{0x1e,0x25,0x25,0x25,0x25,0x18}, // 6
{0x01,0x01,0x31,0x09,0x05,0x03}, // 7
{0x1a,0x25,0x25,0x25,0x25,0x1a}, // 8
{0x06,0x29,0x29,0x29,0x29,0x1e}, // 9
{0x24,0x00,0x00,0x00,0x00,0x00}, // :
{0x80,0x64,0x00,0x00,0x00,0x00}, // ;
{0x08,0x14,0x22,0x00,0x00,0x00}, // <
{0x14,0x14,0x14,0x14,0x14,0x00}, // =
{0x22,0x14,0x08,0x00,0x00,0x00}, // >
{0x02,0x01,0x01,0x29,0x05,0x02}, // ?
{0x1e,0x21,0x2d,0x2b,0x2d,0x0e}, // @
{0x3e,0x09,0x09,0x09,0x09,0x3e}, // A
{0x3f,0x25,0x25,0x25,0x25,0x1a}, // B
{0x1e,0x21,0x21,0x21,0x21,0x12}, // C
{0x3f,0x21,0x21,0x21,0x12,0x0c}, // D
{0x3f,0x25,0x25,0x25,0x25,0x21}, // E
{0x3f,0x05,0x05,0x05,0x05,0x01}, // F
{0x1e,0x21,0x21,0x21,0x29,0x1a}, // G
{0x3f,0x04,0x04,0x04,0x04,0x3f}, // H
{0x21,0x21,0x3f,0x21,0x21,0x21}, // I
{0x10,0x20,0x20,0x20,0x20,0x1f}, // J
{0x3f,0x04,0x0c,0x0a,0x11,0x20}, // K
{0x3f,0x20,0x20,0x20,0x20,0x20}, // L
{0x3f,0x02,0x04,0x04,0x02,0x3f}, // M
{0x3f,0x02,0x04,0x08,0x10,0x3f}, // N
{0x1e,0x21,0x21,0x21,0x21,0x1e}, // O
{0x3f,0x09,0x09,0x09,0x09,0x06}, // P
{0x1e,0x21,0x29,0x31,0x21,0x1e}, // Q
{0x3f,0x09,0x09,0x09,0x19,0x26}, // R
{0x12,0x25,0x25,0x25,0x25,0x18}, // S
{0x01,0x01,0x01,0x3f,0x01,0x01}, // T
{0x1f,0x20,0x20,0x20,0x20,0x1f}, // U
{0x0f,0x10,0x20,0x20,0x10,0x0f}, // V
{0x1f,0x20,0x10,0x10,0x20,0x1f}, // W
{0x21,0x12,0x0c,0x0c,0x12,0x21}, // X
{0x01,0x02,0x0c,0x38,0x04,0x02}, // Y
{0x21,0x31,0x29,0x25,0x23,0x21}, // Z
{0x3f,0x21,0x00,0x00,0x00,0x00}, // [
{0x02,0x04,0x08,0x10,0x20,0x00}, // "\"
{0x21,0x3f,0x00,0x00,0x00,0x00}, // ]
{0x04,0x02,0x3f,0x02,0x04,0x00}, // ^
{0x40,0x40,0x40,0x40,0x40,0x40}, // _
{0x01,0x02,0x00,0x00,0x00,0x00}, // `
{0x10,0x30,0x2a,0x2a,0x3c,0x00}, // a
{0x3f,0x24,0x24,0x24,0x18,0x00}, // b
{0x0c,0x14,0x22,0x22,0x00,0x00}, // c
{0x18,0x24,0x24,0x24,0x3f,0x00}, // d
{0x1c,0x2c,0x2a,0x2a,0x24,0x00}, // e
{0x3e,0x05,0x01,0x00,0x00,0x00}, // f
{0x18,0x28,0xa4,0xa4,0x7c,0x00}, // g
{0x3f,0x04,0x04,0x0c,0x30,0x00}, // h
{0x24,0x3d,0x20,0x00,0x00,0x00}, // i
{0x20,0x40,0x40,0x3d,0x00,0x00}, // j
{0x3f,0x0c,0x12,0x20,0x00,0x00}, // k
{0x1f,0x20,0x20,0x00,0x00,0x00}, // l
{0x3e,0x02,0x3c,0x02,0x3c,0x00}, // m
{0x3e,0x02,0x02,0x02,0x3c,0x00}, // n
{0x0c,0x14,0x22,0x32,0x0c,0x00}, // o
{0xfc,0x24,0x24,0x24,0x18,0x00}, // p
{0x18,0x24,0x24,0x24,0xfc,0x80}, // q
{0x3c,0x04,0x02,0x02,0x00,0x00}, // r
{0x24,0x2c,0x2a,0x2a,0x10,0x00}, // s
{0x02,0x1f,0x22,0x20,0x00,0x00}, // t
{0x1e,0x20,0x20,0x20,0x1e,0x00}, // u
{0x06,0x18,0x20,0x18,0x06,0x00}, // v
{0x1e,0x30,0x1c,0x30,0x0e,0x00}, // w
{0x22,0x14,0x08,0x14,0x22,0x00}, // x
{0x0c,0x10,0xa0,0xa0,0x7c,0x00}, // y
{0x22,0x32,0x2a,0x26,0x22,0x22}, // z
{0x0c,0x3f,0x21,0x00,0x00,0x00}, // {
{0x3f,0x00,0x00,0x00,0x00,0x00}, // |
{0x21,0x3f,0x0c,0x00,0x00,0x00}, // }
{0x02,0x01,0x02,0x01,0x00,0x00}, // ~
{0x00,0x00,0x00,0x00,0x00,0x00}
};

View file

@ -1,27 +1,33 @@
#ifndef __ili9341_H
#define __ili9341_H
#include "singleton.h"
#include <f4ll_cpp/singleton.h>
#include <f4ll_cpp/dmahelper.h>
#include <inttypes.h>
#include <initializer_list>
#include "main.h"
class Ili9341Fsmc : public Singleton<Ili9341Fsmc>
class Ili9341Fsmc : public Singleton<Ili9341Fsmc>, private DmaHelper
{
public:
Ili9341Fsmc(volatile uint16_t *reg, volatile uint16_t *ram,
DMA_TypeDef *dma, uint32_t dmaStream,
bool horizontal = true);
void FillRect(uint16_t color);
void FillRect(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint16_t color);
void FillRect(uint16_t color, bool async = true);
void FillRect(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint16_t color, bool async = true);
uint16_t Width() { return m_width; }
uint16_t Height() { return m_height; }
void SetCursor(uint16_t x, uint16_t y, uint16_t fgColor, uint16_t bgColor);
void PrintChar(char c, uint16_t x, uint16_t y, uint16_t fgColor, uint16_t bgColor);
void PrintChar(char c);
void Print(char const *str, uint8_t len = 0);
inline void WaitDmaIddle() { while(m_dmaEngineBusy); }
inline void WaitDmaIdle() { while(m_dmaEngineBusy); }
void Test();
static void HandleDmaIrq(Ili9341Fsmc *obj) { obj->HandleDmaIrq(); }
private:
inline void WriteCmd(uint16_t cmd) { *m_reg = cmd; }
@ -33,12 +39,9 @@ private:
volatile uint16_t * const m_reg;
volatile uint16_t * const m_ram;
DMA_TypeDef *m_dma;
uint32_t m_dmaStream;
friend void HandleLcdDmaIrq();
void HandleDmaIrq();
void SetupDmaSize(uint32_t size);
void DmaTransferComplete();
bool m_dmaEngineBusy = false;
volatile bool m_dmaEngineBusy = false;
uint32_t m_dmaRemainingPixels = 0;
uint16_t m_dmaColor = 0;
@ -50,6 +53,11 @@ private:
uint16_t m_rectWidth;
uint16_t m_rectHeight;
uint16_t m_xPos = 0;
uint16_t m_yPos = 0;
uint16_t m_fgColor = ILI9341_WHITE;
uint16_t m_bgColor = ILI9341_BLACK;
enum Commands {
ILI9341_NOP = 0x00,
ILI9341_RESET = 0x01,
@ -130,6 +138,11 @@ private:
ILI9341_PRC = 0xF7,
};
static const uint8_t CHRHEIGHT = 8;
static const uint8_t CHRWIDTH = 6;
static const uint8_t CHRCOUNT = 96;
static const uint8_t m_font[CHRCOUNT][CHRWIDTH];
public:
enum Colors {
ILI9341_BLACK = 0x0000, /* 0, 0, 0 */

View file

@ -12,10 +12,23 @@
void HandleLcdDmaIrq()
{
// DMA2 Stream4
if(LL_DMA_IsActiveFlag_TC4(DMA2)) {
LL_DMA_DisableStream(DMA2, LL_DMA_STREAM_4);
LL_DMA_ClearFlag_TC4(DMA2);
Ili9341Fsmc::Instance().DmaTransferComplete();
} else if(LL_DMA_IsActiveFlag_TE4(DMA2))
LL_DMA_ClearFlag_TE4(DMA2);
Ili9341Fsmc::HandleDmaIrq(&Ili9341Fsmc::Instance());
}
void HandleConsoleRxDmaIrq()
{
if(g_console)
g_console->HandleRxDmaIrq();
}
void HandleConsoleTxDmaIrq()
{
if(g_console)
g_console->HandleTxDmaIrq();
}
void HandleConsoleUsartIrq()
{
if(g_console)
g_console->HandleUsartIrq();
}

View file

@ -15,6 +15,10 @@ extern "C" {
void HandleLcdDmaIrq();
void HandleConsoleRxDmaIrq();
void HandleConsoleTxDmaIrq();
void HandleConsoleUsartIrq();
#ifdef __cplusplus
}
#endif

View file

@ -1,55 +0,0 @@
/*
* mainloop.cpp
*
* Created on: Sep 11, 2019
* Author: abody
*/
#include <ili9341.h>
#include "main.h"
#include <mainloop.h>
#include <initializer_list>
#define BORDER 60
#define BARWIDTH 2
void MainLoop()
{
uint16_t colors[] = {
Ili9341Fsmc::ILI9341_RED, Ili9341Fsmc::ILI9341_ORANGE, Ili9341Fsmc::ILI9341_YELLOW, Ili9341Fsmc::ILI9341_GREENYELLOW,
Ili9341Fsmc::ILI9341_GREEN, Ili9341Fsmc::ILI9341_CYAN, Ili9341Fsmc::ILI9341_BLUE, Ili9341Fsmc::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::Init(nullptr, nullptr, DMA2, LL_DMA_STREAM_4, true));
lcd.FillRect(Ili9341Fsmc::ILI9341_WHITE);
lcd.FillRect(BORDER, BORDER, lcd.Width()- BORDER * 2, lcd.Height()-BORDER * 2, Ili9341Fsmc::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()
{
}

View file

@ -1,27 +0,0 @@
/*
* mainloop.h
*
* Created on: Sep 11, 2019
* Author: abody
*/
#ifndef MAINLOOP_H_
#define MAINLOOP_H_
#if defined(__cplusplus)
extern "C" {
#endif
void MainLoop();
#if defined(__cplusplus)
class MainLoop {
MainLoop();
};
#endif // __cplusplus
#if defined(__cplusplus)
}
#endif
#endif /* MAINLOOP_H_ */

View file

@ -1,35 +0,0 @@
/*
* singleton.h
*
* Created on: Sep 11, 2019
* Author: compi
*/
#ifndef SINGLETON_H_
#define SINGLETON_H_
#include <utility>
template<typename T> class Singleton {
public:
static T &Instance() { return *m_instance; }
template<typename ... Args>
static T &Init(Args &&... args)
{
static T instance{ std::forward<Args>(args)... };
if(!m_instance)
m_instance = &instance;
return instance;
}
protected:
Singleton() = default;
Singleton(const Singleton &) = delete;
Singleton &operator=(const Singleton &) = delete;
virtual ~Singleton() = default;
static T *m_instance;
};
template<typename T> T* Singleton<T>::m_instance = nullptr;
#endif /* SINGLETON_H_ */