WIP
This commit is contained in:
parent
49383b1b32
commit
229846fe6d
5 changed files with 79 additions and 42 deletions
332
components/f4ll_cpp/ili9341.cpp
Normal file
332
components/f4ll_cpp/ili9341.cpp
Normal file
|
@ -0,0 +1,332 @@
|
|||
#include <f4ll_cpp/ili9341.h>
|
||||
#include <platform/core_ll.h>
|
||||
#include <inttypes.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#define LCD_L 320
|
||||
#define LCD_S 240
|
||||
|
||||
#define LCD_W LCD_L
|
||||
#define LCD_H LCD_S
|
||||
|
||||
#define LCD_REG (*((volatile unsigned short *) 0x60000000)) /* DC = 0 */
|
||||
#define LCD_RAM (*((volatile unsigned short *) 0x60080000)) /* DC = 1 */
|
||||
|
||||
|
||||
Ili9341Fsmc::Ili9341Fsmc(volatile uint16_t *reg, volatile uint16_t *ram,
|
||||
DMA_TypeDef *dma, uint32_t dmaStream,
|
||||
bool horizontal)
|
||||
: DmaHelper(dma, dmaStream)
|
||||
, m_reg(reg ? reg : (volatile unsigned short *) 0x60000000)
|
||||
, m_ram(ram ? ram : (volatile unsigned short *) 0x60080000)
|
||||
, m_width(horizontal ? LCD_L : LCD_S)
|
||||
, m_height(horizontal ? LCD_S : LCD_L)
|
||||
, m_rectX(0)
|
||||
, m_rectY(0)
|
||||
, m_rectWidth(m_width)
|
||||
, m_rectHeight(m_height)
|
||||
{
|
||||
LL_DMA_EnableIT_TC(GetDma(), GetStream());
|
||||
LL_DMA_EnableIT_TE(GetDma(), GetStream());
|
||||
|
||||
WriteCmd(ILI9341_RESET);
|
||||
LL_mDelay(10);
|
||||
WriteCmd(ILI9341_DISPLAY_OFF);
|
||||
WriteCmd(ILI9341_POWERA, {0x39, 0x2C, 0x00, 0x34, 0x02});
|
||||
WriteCmd(ILI9341_POWERB, {0x00, 0xC1, 0x30});
|
||||
WriteCmd(ILI9341_DTCA, {0x85, 0x00, 0x78});
|
||||
WriteCmd(ILI9341_DTCB, {0x00, 0x00});
|
||||
WriteCmd(ILI9341_POWER_SEQ, {0x64, 0x03, 0x12, 0x81});
|
||||
WriteCmd(ILI9341_PRC, 0x20);
|
||||
WriteCmd(ILI9341_POWER1, 0x23);
|
||||
WriteCmd(ILI9341_POWER2, 0x10);
|
||||
WriteCmd(ILI9341_VCOM1, {0x3E, 0x28});
|
||||
WriteCmd(ILI9341_VCOM2, 0x86);
|
||||
WriteCmd(ILI9341_MAC, horizontal ? 0xe8 : 0x48);
|
||||
WriteCmd(ILI9341_PIXEL_FORMAT, 0x55);
|
||||
WriteCmd(ILI9341_FRC, {0x00, 0x18});
|
||||
WriteCmd(ILI9341_DFC, {0x08, 0x82, 0x27});
|
||||
WriteCmd(ILI9341_3GAMMA_EN, 0x00);
|
||||
WriteCmd(ILI9341_COLUMN_ADDR, {0x00, 0x00, (uint16_t)((m_width-1) >> 8), (uint16_t)((m_width-1) & 0x00ff)});
|
||||
WriteCmd(ILI9341_PAGE_ADDR, {0x00, 0x00, (uint16_t)((m_height-1) >> 8), (uint16_t)((m_height-1) & 0x00ff)});
|
||||
WriteCmd(ILI9341_GAMMA, 0x01);
|
||||
WriteCmd(ILI9341_PGAMMA, {0x0F, 0x31, 0x2B, 0x0C, 0x0E, 0x08, 0x4E, 0xF1, 0x37, 0x07, 0x10, 0x03, 0x0E, 0x09, 0x00});
|
||||
WriteCmd(ILI9341_NGAMMA, {0x00, 0x0E, 0x14, 0x03, 0x11, 0x07, 0x31, 0xC1, 0x48, 0x08, 0x0F, 0x0C, 0x31, 0x36, 0x0F});
|
||||
WriteCmd(ILI9341_SLEEP_OUT);
|
||||
LL_mDelay(100);
|
||||
WriteCmd(ILI9341_DISPLAY_ON);
|
||||
}
|
||||
|
||||
void Ili9341Fsmc::WriteCmd(uint16_t cmd, std::initializer_list<const uint16_t> params)
|
||||
{
|
||||
*m_reg = cmd;
|
||||
for(uint16_t param : params)
|
||||
*m_ram = param;
|
||||
}
|
||||
|
||||
void Ili9341Fsmc::WriteCmd_(uint16_t cmd, uint16_t cnt, ...)
|
||||
{
|
||||
va_list argp;
|
||||
va_start(argp, cnt);
|
||||
|
||||
*m_reg = cmd;
|
||||
for(uint16_t n = 0; n < cnt; ++n) {
|
||||
*m_ram = (uint16_t) va_arg(argp, uint32_t);
|
||||
}
|
||||
va_end(argp);
|
||||
}
|
||||
|
||||
void Ili9341Fsmc::SetRect(uint16_t x, uint16_t y, uint16_t width, uint16_t height)
|
||||
{
|
||||
if(x > m_width || y > m_height || !width || !height )
|
||||
return;
|
||||
|
||||
WaitDmaIdle();
|
||||
|
||||
m_rectX = x;
|
||||
m_rectY = y;
|
||||
m_rectWidth = x + width > m_width ? m_width - x : width;
|
||||
m_rectHeight = y + height > m_height ? m_height - x : height;
|
||||
|
||||
uint16_t right = x + m_rectWidth - 1;
|
||||
uint16_t bottom = y + m_rectHeight - 1;
|
||||
|
||||
WriteCmd(ILI9341_COLUMN_ADDR, {(uint16_t)(x >> 8), (uint16_t)(x & 0xff), (uint16_t)(right >> 8), (uint16_t)(right & 0xff)});
|
||||
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, bool async)
|
||||
{
|
||||
uint32_t count = m_rectWidth * m_rectHeight;
|
||||
WaitDmaIdle();
|
||||
m_dmaColor = color;
|
||||
WriteCmd(ILI9341_GRAM);
|
||||
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(GetDma(), GetStream());
|
||||
if(!async)
|
||||
WaitDmaIdle();
|
||||
}
|
||||
|
||||
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, async);
|
||||
}
|
||||
|
||||
void Ili9341Fsmc::SetupDmaSize(uint32_t size)
|
||||
{
|
||||
if(size > 0xffff) {
|
||||
LL_DMA_SetDataLength(GetDma(), GetStream(), 0xffff);
|
||||
m_dmaRemainingPixels = size - 0xffff;
|
||||
} else {
|
||||
LL_DMA_SetDataLength(GetDma(), GetStream(), size);
|
||||
m_dmaRemainingPixels = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void Ili9341Fsmc::HandleDmaIrq()
|
||||
{
|
||||
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::SetCursor(uint16_t x, uint16_t y, uint16_t fgColor, uint16_t bgColor)
|
||||
{
|
||||
m_xPos = x;
|
||||
m_yPos = y;
|
||||
m_fgColor = fgColor;
|
||||
m_bgColor = bgColor;
|
||||
}
|
||||
|
||||
void Ili9341Fsmc::PrintChar(char c, bool transparent)
|
||||
{
|
||||
// fonts are rotated, one byte representing one column
|
||||
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);
|
||||
if(transparent) {
|
||||
WaitDmaIdle();
|
||||
WriteCmd(ILI9341_MEMORY_READ);
|
||||
*m_ram;
|
||||
LL_DMA_SetM2MSrcAddress(GetDma(), GetStream(), reinterpret_cast<uint32_t>(m_ram));
|
||||
LL_DMA_SetPeriphIncMode(GetDma(), GetStream(), LL_DMA_PERIPH_NOINCREMENT);
|
||||
LL_DMA_SetM2MDstAddress(GetDma(), GetStream(), reinterpret_cast<uint32_t>(m_fontBuffer));
|
||||
LL_DMA_SetMemoryIncMode(GetDma(), GetStream(), LL_DMA_MEMORY_INCREMENT);
|
||||
SetupDmaSize(sizeof(m_fontBuffer)/sizeof(m_fontBuffer[0][0]));
|
||||
m_dmaEngineBusy = true;
|
||||
LL_DMA_EnableStream(GetDma(), GetStream());
|
||||
}
|
||||
WaitDmaIdle();
|
||||
WriteCmd(ILI9341_GRAM);
|
||||
for(uint8_t y = 0; y < CHRHEIGHT; ++y ) {
|
||||
uint8_t mask = 1 << y;
|
||||
for(uint8_t x = 0; x < CHRWIDTH; ++x) {
|
||||
*m_ram = (chrPtr[x] & mask) ? m_fgColor : (transparent ? m_fontBuffer[y][x] : m_bgColor);
|
||||
}
|
||||
}
|
||||
m_xPos += CHRWIDTH;
|
||||
}
|
||||
|
||||
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--) {
|
||||
if(*str == '\r')
|
||||
m_xPos = 0;
|
||||
else if(*str == '\n')
|
||||
m_yPos += CHRHEIGHT;
|
||||
else
|
||||
PrintChar(*str, false);
|
||||
++str;
|
||||
}
|
||||
}
|
||||
|
||||
void Ili9341Fsmc::Test()
|
||||
{
|
||||
static uint16_t linebuf[320];
|
||||
uint16_t x;
|
||||
|
||||
WriteCmd(ILI9341_READ_ID4);
|
||||
for( x= 0; x < 4; ++x)
|
||||
linebuf[x] = *m_ram;
|
||||
|
||||
// uint16_t *bufptr = linebuf;
|
||||
// WriteCmd(ILI9341_MEMORY_READ);
|
||||
// for(x = 0; x < m_width; ++x)
|
||||
// *bufptr++ = *m_ram;
|
||||
|
||||
|
||||
WriteCmd(ILI9341_GRAM);
|
||||
uint16_t fillers[4] = { 0xf800, 0x7e0, 0x1f, 0xffff };
|
||||
for(uint32_t y = 0; y < m_height; ++y) {
|
||||
for(x = 0; x < m_width / 2; ++x)
|
||||
*m_ram = fillers[ (x&0x18) >> 3 ];
|
||||
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}
|
||||
};
|
170
components/f4ll_cpp/ili9341.h
Normal file
170
components/f4ll_cpp/ili9341.h
Normal file
|
@ -0,0 +1,170 @@
|
|||
#ifndef __ili9341_H
|
||||
#define __ili9341_H
|
||||
|
||||
#include <f4ll_cpp/singleton.h>
|
||||
#include <f4ll_cpp/dmahelper.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
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, 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, bool transparent = false);
|
||||
void Print(char const *str, uint8_t len = 0);
|
||||
|
||||
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; }
|
||||
inline void WriteCmd(uint16_t cmd, uint16_t param) { *m_reg = cmd; *m_ram = param; }
|
||||
void WriteCmd(uint16_t cmd, std::initializer_list<const 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;
|
||||
|
||||
void HandleDmaIrq();
|
||||
void SetupDmaSize(uint32_t size);
|
||||
volatile 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;
|
||||
|
||||
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,
|
||||
ILI9341_READ_DISPLAY_IDENTIFICATION_INFORMATION = 0x04,
|
||||
ILI9341_READ_DISPLAY_STATUS = 0x09,
|
||||
ILI9341_READ_DISPLAY_POWER_MODE = 0x0A,
|
||||
ILI9341_READ_DISPLAY_MADCTL = 0x0B,
|
||||
ILI9341_READ_DISPLAY_PIXEL_FORMAT = 0x0C,
|
||||
ILI9341_READ_DISPLAY_IMAGE_FORMAT = 0x0D,
|
||||
ILI9341_READ_DISPLAY_SIGNAL_MODE = 0x0E,
|
||||
ILI9341_READ_DISPLAY_SELF_DIAGNOSTIC_RESULT = 0x0F,
|
||||
ILI9341_ENTER_SLEEP_MODE = 0x10,
|
||||
ILI9341_SLEEP_OUT = 0x11,
|
||||
ILI9341_PARTIAL_MODE_ON = 0x12,
|
||||
ILI9341_NORMAL_DISPLAY_MODE_ON = 0x13,
|
||||
ILI9341_DISPLAY_INVERSION_OFF = 0x20,
|
||||
ILI9341_DISPLAY_INVERSION_ON = 0x21,
|
||||
ILI9341_GAMMA = 0x26,
|
||||
ILI9341_DISPLAY_OFF = 0x28,
|
||||
ILI9341_DISPLAY_ON = 0x29,
|
||||
ILI9341_COLUMN_ADDR = 0x2A,
|
||||
ILI9341_PAGE_ADDR = 0x2B,
|
||||
ILI9341_GRAM = 0x2C,
|
||||
ILI9341_COLOR_SET = 0x2D,
|
||||
ILI9341_MEMORY_READ = 0x2E,
|
||||
ILI9341_PARTIAL_AREA = 0x30,
|
||||
ILI9341_VERTICAL_SCROLLING_DEFINITION = 0x33,
|
||||
ILI9341_TEARING_EFFECT_LINE_OFF = 0x34,
|
||||
ILI9341_TEARING_EFFECT_LINE_ON = 0x35,
|
||||
ILI9341_MAC = 0x36,
|
||||
ILI9341_VERTICAL_SCROLLING_START_ADDRESS = 0x37,
|
||||
ILI9341_IDLE_MODE_OFF = 0x38,
|
||||
ILI9341_IDLE_MODE_ON = 0x39,
|
||||
ILI9341_PIXEL_FORMAT = 0x3A,
|
||||
ILI9341_WMC = 0x3C,
|
||||
ILI9341_RMC = 0x3E,
|
||||
ILI9341_SET_TEAR_SCANLINE = 0x44,
|
||||
ILI9341_WDB = 0x51,
|
||||
ILI9341_READ_DISPLAY_BRIGHTNESS = 0x52,
|
||||
ILI9341_WCD = 0x53,
|
||||
ILI9341_READ_CTRL_DISPLAY = 0x54,
|
||||
ILI9341_WCABC = 0x55,
|
||||
ILI9341_RCABC = 0x56,
|
||||
ILI9341_WCABCMB = 0x5E,
|
||||
ILI9341_RCABCMB = 0x5F,
|
||||
ILI9341_RGB_INTERFACE = 0xB0,
|
||||
ILI9341_FRC = 0xB1,
|
||||
ILI9341_FRAME_CTRL_NM = 0xB2,
|
||||
ILI9341_FRAME_CTRL_IM = 0xB3,
|
||||
ILI9341_FRAME_CTRL_PM = 0xB4,
|
||||
ILI9341_BPC = 0xB5,
|
||||
ILI9341_DFC = 0xB6,
|
||||
ILI9341_ENTRY_MODE_SET = 0xB7,
|
||||
ILI9341_BACKLIGHT_CONTROL_1 = 0xB8,
|
||||
ILI9341_BACKLIGHT_CONTROL_2 = 0xB9,
|
||||
ILI9341_BACKLIGHT_CONTROL_3 = 0xBA,
|
||||
ILI9341_BACKLIGHT_CONTROL_4 = 0xBB,
|
||||
ILI9341_BACKLIGHT_CONTROL_5 = 0xBC,
|
||||
ILI9341_BACKLIGHT_CONTROL_6 = 0xBD,
|
||||
ILI9341_BACKLIGHT_CONTROL_7 = 0xBE,
|
||||
ILI9341_BACKLIGHT_CONTROL_8 = 0xBF,
|
||||
ILI9341_POWER1 = 0xC0,
|
||||
ILI9341_POWER2 = 0xC1,
|
||||
ILI9341_VCOM1 = 0xC5,
|
||||
ILI9341_VCOM2 = 0xC7,
|
||||
ILI9341_POWERA = 0xCB,
|
||||
ILI9341_POWERB = 0xCF,
|
||||
ILI9341_READ_ID1 = 0xDA,
|
||||
ILI9341_READ_ID2 = 0xDB,
|
||||
ILI9341_READ_ID3 = 0xDC,
|
||||
ILI9341_READ_ID4 = 0xD3,
|
||||
ILI9341_PGAMMA = 0xE0,
|
||||
ILI9341_NGAMMA = 0xE1,
|
||||
ILI9341_DTCA = 0xE8,
|
||||
ILI9341_DTCB = 0xEA,
|
||||
ILI9341_POWER_SEQ = 0xED,
|
||||
ILI9341_3GAMMA_EN = 0xF2,
|
||||
ILI9341_INTERFACE = 0xF6,
|
||||
ILI9341_PRC = 0xF7,
|
||||
};
|
||||
|
||||
static const uint8_t CHRHEIGHT = 8; // SHOULD BE 8
|
||||
static const uint8_t CHRWIDTH = 6;
|
||||
static const uint8_t CHRCOUNT = 96;
|
||||
static const uint8_t m_font[CHRCOUNT][CHRWIDTH];
|
||||
uint16_t m_fontBuffer[CHRHEIGHT][CHRWIDTH];
|
||||
|
||||
public:
|
||||
enum Colors {
|
||||
ILI9341_BLACK = 0x0000, /* 0, 0, 0 */
|
||||
ILI9341_NAVY = 0x000F, /* 0, 0, 128 */
|
||||
ILI9341_DARKGREEN = 0x03E0, /* 0, 128, 0 */
|
||||
ILI9341_DARKCYAN = 0x03EF, /* 0, 128, 128 */
|
||||
ILI9341_MAROON = 0x7800, /* 128, 0, 0 */
|
||||
ILI9341_PURPLE = 0x780F, /* 128, 0, 128 */
|
||||
ILI9341_OLIVE = 0x7BE0, /* 128, 128, 0 */
|
||||
ILI9341_LIGHTGREY = 0xC618, /* 192, 192, 192 */
|
||||
ILI9341_DARKGREY = 0x7BEF, /* 128, 128, 128 */
|
||||
ILI9341_BLUE = 0x001F, /* 0, 0, 255 */
|
||||
ILI9341_GREEN = 0x07E0, /* 0, 255, 0 */
|
||||
ILI9341_CYAN = 0x07FF, /* 0, 255, 255 */
|
||||
ILI9341_RED = 0xF800, /* 255, 0, 0 */
|
||||
ILI9341_MAGENTA = 0xF81F, /* 255, 0, 255 */
|
||||
ILI9341_YELLOW = 0xFFE0, /* 255, 255, 0 */
|
||||
ILI9341_WHITE = 0xFFFF, /* 255, 255, 255 */
|
||||
ILI9341_ORANGE = 0xFD20, /* 255, 165, 0 */
|
||||
ILI9341_GREENYELLOW = 0xAFE5, /* 173, 255, 47 */
|
||||
ILI9341_PINK = 0xF81F,
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue