83 lines
2.8 KiB
C++
83 lines
2.8 KiB
C++
#ifndef __ili9341_H
|
|
#define __ili9341_H
|
|
|
|
#include "singleton.h"
|
|
#include <inttypes.h>
|
|
#include <initializer_list>
|
|
#include "main.h"
|
|
|
|
// Color definitions
|
|
#define ILI9341_BLACK 0x0000 /* 0, 0, 0 */
|
|
#define ILI9341_NAVY 0x000F /* 0, 0, 128 */
|
|
#define ILI9341_DARKGREEN 0x03E0 /* 0, 128, 0 */
|
|
#define ILI9341_DARKCYAN 0x03EF /* 0, 128, 128 */
|
|
#define ILI9341_MAROON 0x7800 /* 128, 0, 0 */
|
|
#define ILI9341_PURPLE 0x780F /* 128, 0, 128 */
|
|
#define ILI9341_OLIVE 0x7BE0 /* 128, 128, 0 */
|
|
#define ILI9341_LIGHTGREY 0xC618 /* 192, 192, 192 */
|
|
#define ILI9341_DARKGREY 0x7BEF /* 128, 128, 128 */
|
|
#define ILI9341_BLUE 0x001F /* 0, 0, 255 */
|
|
#define ILI9341_GREEN 0x07E0 /* 0, 255, 0 */
|
|
#define ILI9341_CYAN 0x07FF /* 0, 255, 255 */
|
|
#define ILI9341_RED 0xF800 /* 255, 0, 0 */
|
|
#define ILI9341_MAGENTA 0xF81F /* 255, 0, 255 */
|
|
#define ILI9341_YELLOW 0xFFE0 /* 255, 255, 0 */
|
|
#define ILI9341_WHITE 0xFFFF /* 255, 255, 255 */
|
|
#define ILI9341_ORANGE 0xFD20 /* 255, 165, 0 */
|
|
#define ILI9341_GREENYELLOW 0xAFE5 /* 173, 255, 47 */
|
|
#define ILI9341_PINK 0xF81F
|
|
|
|
|
|
class Ili9341Fsmc : public Singleton<Ili9341Fsmc>
|
|
{
|
|
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);
|
|
uint16_t Width() { return m_width; }
|
|
uint16_t Height() { return m_height; }
|
|
|
|
inline void WaitDmaIddle() { while(m_dmaEngineBusy); }
|
|
|
|
void Test();
|
|
|
|
|
|
private:
|
|
inline void WriteCmd(uint16_t cmd) { *m_reg = cmd; }
|
|
inline void WriteCmd(uint16_t cmd, uint16_t param) { *m_reg = cmd; *m_ram = param; }
|
|
void WriteCmd(uint16_t cmd, std::initializer_list<uint16_t> params);
|
|
void WriteCmd_(uint16_t cmd, uint16_t cnt, ...);
|
|
void SetRect(uint16_t x, uint16_t y, uint16_t width, uint16_t height);
|
|
|
|
volatile uint16_t * const m_reg;
|
|
volatile uint16_t * const m_ram;
|
|
|
|
DMA_TypeDef *m_dma;
|
|
uint32_t m_dmaStream;
|
|
friend void HandleLcdDmaIrq();
|
|
void SetupDmaSize(uint32_t size);
|
|
void DmaTransferComplete();
|
|
bool m_dmaEngineBusy = false;
|
|
uint32_t m_dmaRemainingPixels = 0;
|
|
uint16_t m_dmaColor = 0;
|
|
|
|
uint16_t const m_width;
|
|
uint16_t const m_height;
|
|
|
|
uint16_t m_rectX;
|
|
uint16_t m_rectY;
|
|
uint16_t m_rectWidth;
|
|
uint16_t m_rectHeight;
|
|
};
|
|
|
|
|
|
/* Includes ------------------------------------------------------------------*/
|
|
void ili9341_Reset(void);
|
|
void ili9341_writeData(char Data);
|
|
void ili9341_writeCommand(char Command);
|
|
void ili9341_init(void);
|
|
|
|
#endif
|