K1Guitar/device/LCD_ILI9341/Drv_ILI9341_Lcd_Init.h

114 lines
4.8 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* @Author: CTW
* @Date: 2025-11-07 14:37:14
* @FilePath: \PhoenixSMGT_Testproject\Drivers\LCD_ILI9341\Drv_ILI9341_Lcd_Init.h
*/
#ifndef __DRV_ILI9341_LCD_INIT_H
#define __DRV_ILI9341_LCD_INIT_H
#include "includes.h"
//#include "spi.h"
#define USE_HORIZONTAL 0 //设置横屏或者竖屏显示 0或1为竖屏 2或3为横屏
#if USE_HORIZONTAL==0||USE_HORIZONTAL==1
#define LCD_W 240
#define LCD_H 320
#else
#define LCD_W 320
#define LCD_H 240
#endif
//电阻屏芯片连接引脚
// SPI2引脚复用功能
#define LCD_SCK_PIN GPIO_PINS_13
#define LCD_SCK_PORT GPIOB
#define LCD_MOSI_PIN GPIO_PINS_15
#define LCD_MOSI_PORT GPIOB
#define LCD_MISO_PIN GPIO_PINS_14
#define LCD_MISO_PORT GPIOB
#define LCD_NSS_PIN GPIO_PINS_12
#define LCD_NSS_PORT GPIOB
// LCD控制引脚
#define LCD_DC_PIN GPIO_PINS_8 // TFT_RS
#define LCD_DC_PORT GPIOA
#define LCD_BLK_PIN GPIO_PINS_9 // TFT_BL
#define LCD_BLK_PORT GPIOC
#define LCD_RES_PIN GPIO_PINS_10 // TFT_RESET
#define LCD_RES_PORT GPIOA
// SPI句柄使用SPI2
//extern SPI_HandleTypeDef hspi2;
// 引脚电平操作宏
#define LCD_CS_Clr() HAL_GPIO_WritePin(LCD_NSS_PORT, LCD_NSS_PIN, GPIO_PIN_RESET)
#define LCD_CS_Set() HAL_GPIO_WritePin(LCD_NSS_PORT, LCD_NSS_PIN, GPIO_PIN_SET)
#define LCD_DC_Clr() HAL_GPIO_WritePin(LCD_DC_PORT, LCD_DC_PIN, GPIO_PIN_RESET)
#define LCD_DC_Set() HAL_GPIO_WritePin(LCD_DC_PORT, LCD_DC_PIN, GPIO_PIN_SET)
#define LCD_BLK_Clr() HAL_GPIO_WritePin(LCD_BLK_PORT, LCD_BLK_PIN, GPIO_PIN_RESET)
#define LCD_BLK_Set() HAL_GPIO_WritePin(LCD_BLK_PORT, LCD_BLK_PIN, GPIO_PIN_SET)
#define LCD_RES_Clr() HAL_GPIO_WritePin(LCD_RES_PORT, LCD_RES_PIN, GPIO_PIN_RESET)
#define LCD_RES_Set() HAL_GPIO_WritePin(LCD_RES_PORT, LCD_RES_PIN, GPIO_PIN_SET)
//画笔颜色
#define WHITE 0xFFFF
#define BLACK 0x0000
#define BLUE 0x001F
#define COLOR_PRIMARY 0x1B9F // #1D73FF MiSans UI 主色
#define COLOR_GRAD_START 0x01D5 // #003AAE 规范渐变起始(深蓝)
#define COLOR_GRAD_MID 0x029A // #034FD6 规范渐变中间
#define COLOR_GRAD_END 0x431E // #4161F8 规范渐变结束(中蓝)
#define COLOR_BG_START 0x10A6 // #0E1535 屏幕背景渐变顶
#define COLOR_BG_END 0x31A9 // #2F3647 屏幕背景渐变底
#define COLOR_MIXER_RED 0xF2E9 // #F85E4B 弦音色槽位红
#define COLOR_MIXER_ORANGE 0xF4C5 // #F59C2C 伴奏槽位橙
#define COLOR_MIXER_YELLOW 0xF6C7 // #F3D939 导奏槽位黄
#define COLOR_MIXER_GREEN 0x170F // #13E17F 鼓音槽位绿
#define BRED 0XF81F
#define GRED 0XFFE0
#define GBLUE 0X07FF
#define RED 0xF800
#define MAGENTA 0xF81F
#define GREEN 0x07E0
#define CYAN 0x7FFF
#define YELLOW 0xFFE0
#define BROWN 0XBC40 //棕色
#define BRRED 0XFC07 //棕红色
#define GRAY 0X8430 //灰色
#define DARKBLUE 0X01CF //深蓝色
#define LIGHTBLUE 0X7D7C //浅蓝色
#define GRAYBLUE 0X5458 //灰蓝色
#define LIGHTGREEN 0X841F //浅绿色
#define LGRAY 0XC618 //浅灰色(PANNEL),窗体背景色
#define LGRAYBLUE 0XA651 //浅灰蓝色(中间层颜色)
#define LBBLUE 0X2B12 //浅棕蓝色(选择条目的反色)
#define DARKLGRAY 0x2968 // #292C42 控件未选中(暗蓝灰,对应规范非焦点背景)
#define COLOR_NORMAL_BG DARKLGRAY /* 控件普通状态背景 */
#define BUTTON_COLOR /*0x5AEB*/BLACK
#define START_COLOR COLOR_GRAD_START
#define END_COLOR COLOR_GRAD_END
extern void LCD_GPIO_Init(void); //初始化GPIO
extern void LCD_WR_DATA8(uint8_t data); //写入一个字节
extern void LCD_WR_DATA16(uint16_t data); //写入两个字节
extern void LCD_WR_REG(uint8_t reg); //写入一个指令
extern void LCD_SetWindow(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2); //设置坐标函数
extern void LCD_Init(void); //LCD初始化
extern void LCD_SPI_DMA_Send(const uint8_t *data, uint32_t len); //SPI2 DMA批量发送
extern void LCD_DrawChevron_Right(uint16_t x, uint16_t y, uint8_t size, uint8_t thick, uint16_t color); //向右空心尖括号
// 渐变背景文字显示(先画垂直渐变底,再叠加文字笔画)
extern uint32_t LCD_ShowChinese_AutoAlign_Gradient(uint16_t x1, uint16_t x2, uint16_t y,
const uint8_t *p, uint8_t align, uint16_t fc,
uint16_t color_top, uint16_t color_bottom, uint8_t size);
extern uint16_t LCD_ShowString_AutoAlign_Gradient(uint16_t x1, uint16_t x2, uint16_t y,
const uint8_t *p, uint8_t align, uint16_t fc,
uint16_t color_top, uint16_t color_bottom, uint8_t size);
#endif