Touch pt. 1
This commit is contained in:
parent
22982db966
commit
46a5748e75
22 changed files with 3528 additions and 613 deletions
|
@ -14,7 +14,7 @@
|
|||
#define LCD_RAM (*((volatile unsigned short *) 0x60080000)) /* DC = 1 */
|
||||
|
||||
#define RGB2U16(R,G,B) ((R & 0xf8) << 8 | (G & 0xfc) << 3 | (B & 0xf8) >> 3)
|
||||
#define SPLIT(x) ((uint8_t)(x >> 8)), ((uint8_t)x)
|
||||
#define MSBSPLIT(x) ((uint8_t)(x >> 8)), ((uint8_t)x)
|
||||
|
||||
Ili9341Fsmc::Ili9341Fsmc(volatile uint16_t *reg, volatile uint16_t *ram,
|
||||
DMA_TypeDef *dma, uint32_t dmaStream,
|
||||
|
@ -58,7 +58,6 @@ Ili9341Fsmc::Ili9341Fsmc(volatile uint16_t *reg, volatile uint16_t *ram,
|
|||
WriteCmd(ILI9341_SLEEP_OUT);
|
||||
LL_mDelay(100);
|
||||
WriteCmd(ILI9341_DISPLAY_ON);
|
||||
WriteCmd(ILI9341_VERTICAL_SCROLLING_DEFINITION, {0x00, 0x00, SPLIT(m_height), 0x00, 0x00});
|
||||
}
|
||||
|
||||
void Ili9341Fsmc::WriteCmd(uint16_t cmd, std::initializer_list<const uint16_t> params)
|
||||
|
@ -80,6 +79,17 @@ void Ili9341Fsmc::WriteCmd_(uint16_t cmd, uint16_t cnt, ...)
|
|||
va_end(argp);
|
||||
}
|
||||
|
||||
void Ili9341Fsmc::SetScrollMode(bool on)
|
||||
{
|
||||
if(on != m_scrollMode) {
|
||||
if(on)
|
||||
WriteCmd(ILI9341_VERTICAL_SCROLLING_DEFINITION, {0x00, 0x00, MSBSPLIT(m_height), 0x00, 0x00});
|
||||
else
|
||||
WriteCmd(ILI9341_NORMAL_DISPLAY_MODE_ON);
|
||||
m_scrollMode = on;
|
||||
}
|
||||
}
|
||||
|
||||
void Ili9341Fsmc::WritePixels(void *src, uint32_t count, bool increment, bool async)
|
||||
{
|
||||
WriteCmd(ILI9341_GRAM);
|
||||
|
@ -130,7 +140,7 @@ void Ili9341Fsmc::ReadPixels(uint16_t *dst, uint32_t count)
|
|||
|
||||
void Ili9341Fsmc::SetScrollOffset()
|
||||
{
|
||||
uint16_t offsetData[2] = { SPLIT(m_scrollOffset) };
|
||||
uint16_t offsetData[2] = { MSBSPLIT(m_scrollOffset) };
|
||||
WriteCmd(ILI9341_VERTICAL_SCROLLING_START_ADDRESS);
|
||||
*m_ram = offsetData[0];
|
||||
*m_ram = offsetData[1];
|
||||
|
@ -151,8 +161,8 @@ void Ili9341Fsmc::SetRect(uint16_t x, uint16_t y, uint16_t width, uint16_t heigh
|
|||
uint16_t right = x + m_rectWidth - 1;
|
||||
uint16_t bottom = y + m_rectHeight - 1;
|
||||
|
||||
WriteCmd(ILI9341_COLUMN_ADDR, { SPLIT(x), SPLIT(right) });
|
||||
WriteCmd(ILI9341_PAGE_ADDR, { SPLIT(y), SPLIT(bottom) });
|
||||
WriteCmd(ILI9341_COLUMN_ADDR, { MSBSPLIT(x), MSBSPLIT(right) });
|
||||
WriteCmd(ILI9341_PAGE_ADDR, { MSBSPLIT(y), MSBSPLIT(bottom) });
|
||||
}
|
||||
|
||||
void Ili9341Fsmc::FillRect(uint16_t color, bool async)
|
||||
|
@ -237,7 +247,7 @@ void Ili9341Fsmc::PrintChar(char c, uint16_t x, uint16_t y, uint16_t fgColor, ui
|
|||
PrintChar(c);
|
||||
}
|
||||
|
||||
void Ili9341Fsmc::Print(char const *str, uint8_t len)
|
||||
void Ili9341Fsmc::Print(char const *str, uint8_t len, bool transparent)
|
||||
{
|
||||
if(!len)
|
||||
len = strlen(str);
|
||||
|
@ -253,11 +263,12 @@ void Ili9341Fsmc::Print(char const *str, uint8_t len)
|
|||
m_scrollOffset -= m_height;
|
||||
WaitDmaIdle();
|
||||
SetScrollOffset();
|
||||
FillRect(0, AdjustY(m_yPos), m_width, CHRHEIGHT, m_bgColor);
|
||||
if(!transparent)
|
||||
FillRect(0, AdjustY(m_yPos), m_width, CHRHEIGHT, m_bgColor);
|
||||
}
|
||||
}
|
||||
else
|
||||
PrintChar(*str, false);
|
||||
PrintChar(*str, transparent);
|
||||
++str;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue