131 lines
4.9 KiB
C
131 lines
4.9 KiB
C
|
/****************************************************************************************************
|
|||
|
//=========================================<3D><>Դ<EFBFBD><D4B4><EFBFBD><EFBFBD>================================================//
|
|||
|
// LCDģ<44><C4A3> STM32<33><32>Ƭ<EFBFBD><C6AC>
|
|||
|
// VCC <20><> DC5V/3.3V //<2F><>Դ
|
|||
|
// GND <20><> GND //<2F><>Դ<EFBFBD><D4B4>
|
|||
|
//=======================================Һ<><D2BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߽<EFBFBD><DFBD><EFBFBD>==========================================//
|
|||
|
//<2F><>ģ<EFBFBD><C4A3>Ĭ<EFBFBD><C4AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ΪSPI<50><49><EFBFBD><EFBFBD>
|
|||
|
// LCDģ<44><C4A3> STM32<33><32>Ƭ<EFBFBD><C6AC>
|
|||
|
// SDA <20><> PB15 //Һ<><D2BA><EFBFBD><EFBFBD>SPI<50><49><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD>ź<EFBFBD>
|
|||
|
//=======================================Һ<><D2BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߽<EFBFBD><DFBD><EFBFBD>==========================================//
|
|||
|
// LCDģ<44><C4A3> STM32<33><32>Ƭ<EFBFBD><C6AC>
|
|||
|
// SCK <20><> PB13 //Һ<><D2BA><EFBFBD><EFBFBD>SPI<50><49><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>ź<EFBFBD>
|
|||
|
// A0 <20><> PB10 //Һ<><D2BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>/<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ź<EFBFBD>
|
|||
|
// RESET <20><> PB12 //Һ<><D2BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><EFBFBD>ź<EFBFBD>
|
|||
|
// CS <20><> PB11 //Һ<><D2BA><EFBFBD><EFBFBD>Ƭѡ<C6AC><D1A1><EFBFBD><EFBFBD><EFBFBD>ź<EFBFBD>
|
|||
|
**************************************************************************************************/
|
|||
|
/* @attention
|
|||
|
*
|
|||
|
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
|
|||
|
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
|
|||
|
* TIME. AS A RESULT, QD electronic SHALL NOT BE HELD LIABLE FOR ANY
|
|||
|
* DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
|
|||
|
* FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
|
|||
|
* CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
|
|||
|
**************************************************************************************************/
|
|||
|
#ifndef __LCD_H
|
|||
|
#define __LCD_H
|
|||
|
#include "main.h"
|
|||
|
#include "stdlib.h"
|
|||
|
|
|||
|
//LCD<43><44>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
typedef struct
|
|||
|
{
|
|||
|
uint16_t width; //LCD <20><><EFBFBD><EFBFBD>
|
|||
|
uint16_t height; //LCD <20>߶<EFBFBD>
|
|||
|
uint16_t id; //LCD ID
|
|||
|
uint8_t dir; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƣ<EFBFBD>0<EFBFBD><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>1<EFBFBD><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
uint16_t wramcmd; //<2F><>ʼдgramָ<6D><D6B8>
|
|||
|
uint16_t setxcmd; //<2F><><EFBFBD><EFBFBD>x<EFBFBD><78><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8>
|
|||
|
uint16_t setycmd; //<2F><><EFBFBD><EFBFBD>y<EFBFBD><79><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8>
|
|||
|
}_lcd_dev;
|
|||
|
|
|||
|
//LCD<43><44><EFBFBD><EFBFBD>
|
|||
|
extern _lcd_dev lcddev; //<2F><><EFBFBD><EFBFBD>LCD<43><44>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>
|
|||
|
/////////////////////////////////////<2F>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>///////////////////////////////////
|
|||
|
#define USE_HORIZONTAL 0 //<2F><><EFBFBD><EFBFBD>Һ<EFBFBD><D2BA><EFBFBD><EFBFBD>˳ʱ<CBB3><CAB1><EFBFBD><EFBFBD>ת<EFBFBD><D7AA><EFBFBD><EFBFBD> 0-0<><30><EFBFBD><EFBFBD>ת<EFBFBD><D7AA>1-90<39><30><EFBFBD><EFBFBD>ת<EFBFBD><D7AA>2-180<38><30><EFBFBD><EFBFBD>ת<EFBFBD><D7AA>3-270<37><30><EFBFBD><EFBFBD>ת
|
|||
|
|
|||
|
//////////////////////////////////////////////////////////////////////////////////
|
|||
|
//<2F><><EFBFBD><EFBFBD>LCD<43>ijߴ<C4B3>
|
|||
|
#define LCD_W 128
|
|||
|
#define LCD_H 160
|
|||
|
|
|||
|
//TFTLCD<43><44><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD>õĺ<C3B5><C4BA><EFBFBD>
|
|||
|
extern uint16_t POINT_COLOR;//Ĭ<>Ϻ<EFBFBD>ɫ
|
|||
|
extern uint16_t BACK_COLOR; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ.Ĭ<><C4AC>Ϊ<EFBFBD><CEAA>ɫ
|
|||
|
|
|||
|
////////////////////////////////////////////////////////////////////
|
|||
|
//-----------------LCD<43>˿ڶ<CBBF><DAB6><EFBFBD>----------------
|
|||
|
|
|||
|
|
|||
|
//GPIO<49><4F>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><EFBFBD>ߣ<EFBFBD>
|
|||
|
#define LCD_CS_SET LCD_CS_GPIO_Port->BSRR=LCD_CS_Pin //Ƭѡ<C6AC>˿<EFBFBD> PB12
|
|||
|
#define LCD_RS_SET LCD_RS_GPIO_Port->BSRR=LCD_RS_Pin //<2F><><EFBFBD><EFBFBD>/<2F><><EFBFBD><EFBFBD> PB14
|
|||
|
#define LCD_RST_SET LCD_RST_GPIO_Port->BSRR=LCD_RST_Pin //<2F><>λ PB11
|
|||
|
|
|||
|
//GPIO<49><4F>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><EFBFBD>ͣ<EFBFBD>
|
|||
|
#define LCD_CS_CLR LCD_CS_GPIO_Port->BRR=LCD_CS_Pin //Ƭѡ<C6AC>˿<EFBFBD> PB12
|
|||
|
#define LCD_RS_CLR LCD_RS_GPIO_Port->BRR=LCD_RS_Pin //<2F><><EFBFBD><EFBFBD>/<2F><><EFBFBD><EFBFBD> PB13
|
|||
|
#define LCD_RST_CLR LCD_RST_GPIO_Port->BRR=LCD_RST_Pin //<2F><>λ PB11
|
|||
|
|
|||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ
|
|||
|
#define WHITE 0xFFFF
|
|||
|
#define BLACK 0x0000
|
|||
|
#define BLUE 0x001F
|
|||
|
#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 //<2F><>ɫ
|
|||
|
#define BRRED 0XFC07 //<2F>غ<EFBFBD>ɫ
|
|||
|
#define GRAY 0X8430 //<2F><>ɫ
|
|||
|
//GUI<55><49>ɫ
|
|||
|
|
|||
|
#define DARKBLUE 0X01CF //<2F><><EFBFBD><EFBFBD>ɫ
|
|||
|
#define LIGHTBLUE 0X7D7C //dz<><C7B3>ɫ
|
|||
|
#define GRAYBLUE 0X5458 //<2F><><EFBFBD><EFBFBD>ɫ
|
|||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫΪPANEL<45><4C><EFBFBD><EFBFBD>ɫ
|
|||
|
|
|||
|
#define LIGHTGREEN 0X841F //dz<><C7B3>ɫ
|
|||
|
#define LIGHTGRAY 0XEF5B //dz<><C7B3>ɫ(PANNEL)
|
|||
|
#define LGRAY 0XC618 //dz<><C7B3>ɫ(PANNEL),<2C><><EFBFBD>屳<EFBFBD><E5B1B3>ɫ
|
|||
|
|
|||
|
#define LGRAYBLUE 0XA651 //dz<><C7B3><EFBFBD><EFBFBD>ɫ(<28>м<EFBFBD><D0BC><EFBFBD><EFBFBD><EFBFBD>ɫ)
|
|||
|
#define LBBLUE 0X2B12 //dz<><C7B3><EFBFBD><EFBFBD>ɫ(ѡ<><D1A1><EFBFBD><EFBFBD>Ŀ<EFBFBD>ķ<EFBFBD>ɫ)
|
|||
|
|
|||
|
void LCD_Init(void);
|
|||
|
void LCD_DisplayOn(void);
|
|||
|
void LCD_DisplayOff(void);
|
|||
|
void LCD_Clear(uint16_t Color);
|
|||
|
void LCD_SetCursor(uint16_t Xpos, uint16_t Ypos);
|
|||
|
void LCD_DrawPoint(uint16_t x,uint16_t y);//<2F><><EFBFBD><EFBFBD>
|
|||
|
uint16_t LCD_ReadPoint(uint16_t x,uint16_t y); //<2F><><EFBFBD><EFBFBD>
|
|||
|
void LCD_DrawLine(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2);
|
|||
|
void LCD_DrawRectangle(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2);
|
|||
|
void LCD_SetWindows(uint16_t xStar, uint16_t yStar,uint16_t xEnd,uint16_t yEnd);
|
|||
|
|
|||
|
uint16_t LCD_RD_DATA(void);//<2F><>ȡLCD<43><44><EFBFBD><EFBFBD>
|
|||
|
void LCD_WriteReg(uint8_t LCD_Reg, uint16_t LCD_RegValue);
|
|||
|
void LCD_WR_DATA(uint8_t data);
|
|||
|
uint16_t LCD_ReadReg(uint8_t LCD_Reg);
|
|||
|
void LCD_WriteRAM_Prepare(void);
|
|||
|
void LCD_WriteRAM(uint16_t RGB_Code);
|
|||
|
uint16_t LCD_ReadRAM(void);
|
|||
|
uint16_t LCD_BGR2RGB(uint16_t c);
|
|||
|
void LCD_SetParam(void);
|
|||
|
void Lcd_WriteData_16Bit(uint16_t Data);
|
|||
|
void LCD_direction(uint8_t direction );
|
|||
|
|
|||
|
|
|||
|
|
|||
|
#endif
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|