SSTV-Decoder/include/tftlcd.h

117 lines
3.4 KiB
C
Raw Normal View History

2023-04-27 01:30:27 +08:00
/*
TFT LCD Driver
Screen: Z280IT002
Driver: ILI9341
Commands: 8-bit
Arguments:
GRAM: 16-bit
Others: 8-bit
Memory: 320 * 240 * 18 / 8 = 172800 bytes
RGB Interface: (maunal p. 45, Chapter 7.2.1)
16 bit mode (RGB565):
D0: NC
D1 - D5: blue
D6 - D11: green
D12: NC
D13 - D17: red
Pins:
CS: Chip Selection
WR: WRite signal
RD: ReaD signal
RS: data or command
DB: Data (8 pin * 2)
only use 0-7 to send data
*/
#pragma once
#include "derivative.h"
typedef unsigned char uchar;
// LCD function 1 enable
#define USE_HORIZONTAL 0 // 横屏
2023-04-27 01:30:27 +08:00
#define LCD_FAST_IO 1 // 快速IO
// LCD size
#if USE_HORIZONTAL == 1
#define LCD_W 320
#define LCD_H 240
#else
#define LCD_W 240
#define LCD_H 320
#endif
/*
LCD Control Pins Definition
LCD_CS -> PTB9
LCD_RS -> PTB8 /
LCD_WR -> PTB11
LCD_RD -> PTB10
LCD_RST -> PTE31
LCD_BL -> PTA19
*/
#define LCD_CS_SET (GPIOB->PDOR |= BIT(9))
#define LCD_CS_CLR (GPIOB->PDOR &= ~BIT(9))
#define LCD_RS_SET (GPIOB->PDOR |= BIT(8))
#define LCD_RS_CLR (GPIOB->PDOR &= ~BIT(8))
#define LCD_WR_SET (GPIOB->PDOR |= BIT(11))
#define LCD_WR_CLR (GPIOB->PDOR &= ~BIT(11))
#define LCD_RD_SET (GPIOB->PDOR |= BIT(10))
#define LCD_RD_CLR (GPIOB->PDOR &= ~BIT(10))
#define LCD_RST_SET (GPIOE->PDOR |= BIT(31))
#define LCD_RST_CLR (GPIOE->PDOR &= ~BIT(31))
#define LCD_BL_SET (GPIOA->PDOR |= BIT(19))
#define LCD_BL_CLR (GPIOA->PDOR &= ~BIT(19))
// PTD 0~7 数据线
#define DATAOUT(x) GPIOD->PDOR = (x & 0xff) // 数据输出
#define DATAIN GPIOD->PDIR // 数据输入
// Commands
#define LCD_COL_WR 0x2A // write column address, maunal p. 110 (Chapter 8.2.20)
#define LCD_PAGE_WR 0x2B // write page address, maunal p. 112 (Chapter 8.2.21)
#define LCD_RAM_WR 0x2C // write RAM, maunal p. 114 (Chapter 8.2.22)
#define LCD_RAM_AC 0x36 // Memory Access Control, manual p. 127 (Chapter 8.2.29)
// 画笔颜色
#define RED 0xF800
#define GREEN 0x07E0
#define BLUE 0x001F
#define WHITE 0xFFFF
#define BLACK 0x0000
#define YELLOW 0xFFE0
#define BRED 0XF81F
#define GRED 0XFFE0
#define GBLUE 0X07FF
#define MAGENTA 0xF81F
#define CYAN 0x7FFF
#define BROWN 0XBC40 // 棕色
#define BRRED 0XFC07 // 棕红色
#define GRAY 0X8430 // 灰色
#define DARKBLUE 0X01CF // 深蓝色
#define LIGHTBLUE 0X7D7C // 浅蓝色
#define GRAYBLUE 0X5458 // 灰蓝色
#define LIGHTGREEN 0X841F // 浅绿色
#define LIGHTGRAY 0XEF5B // 浅灰色(PANNEL)
#define LGRAY 0XC618 // 浅灰色(PANNEL),窗体背景色
#define LGRAYBLUE 0XA651 // 浅灰蓝色(中间层颜色)
#define LBBLUE 0X2B12 // 浅棕蓝色(选择条目的反色)
void LCD_RESET();
void LCD_Init();
2023-04-27 02:09:34 +08:00
void LCD_SetColor(uint16_t color);
void LCD_SetBackColor(uint16_t color);
void LCD_SetXY(uint16_t x, uint16_t y);
void LCD_SetRec(uint16_t xs, uint16_t xe, uint16_t ys, uint16_t ye);
void LCD_DrawPoint(uint16_t x, uint16_t y, uint16_t color);
void LCD_Clear(uint16_t color);
void LCD_ShowChar(uint16_t x, uint16_t y, uint8_t num, uint8_t size, uint8_t mode);
void LCD_ShowNum(uint16_t x, uint16_t y, uint32_t num, uint8_t len, uint8_t size, uint8_t dir, uint8_t mode);
void LCD_ShowString(uint16_t x, uint16_t y, char *str, uint8_t size, uint8_t dir, uint8_t mode);