longan-movie-player/gd32v_lcd/include/lcd/lcd.h
2019-10-05 20:44:28 +08:00

146 lines
3.9 KiB
C

#ifndef __LCD_H
#define __LCD_H
#include "systick.h"
#include "stdlib.h"
#include "gd32vf103_gpio.h"
#define USE_HORIZONTAL 2 //设置横屏或者竖屏显示 0或1为竖屏 2或3为横屏
#define HAS_BLK_CNTL 0
#if USE_HORIZONTAL==0||USE_HORIZONTAL==1
#define LCD_W 80
#define LCD_H 160
#else
#define LCD_W 160
#define LCD_H 80
#endif
typedef unsigned char u8;
typedef unsigned int u16;
typedef unsigned long u32;
// #define LED_ON gpio_bit_reset(GPIOC,GPIO_PIN_13)
// #define LED_OFF gpio_bit_set(GPIOC,GPIO_PIN_13)
#define LED_ON
#define LED_OFF
#define SPI0_CFG 1 //hardware spi
// #define SPI0_CFG 2 //hardware spi dma
// #define SPI0_CFG 3 //software spi
#define FRAME_SIZE 25600
//-----------------OLED端口定义----------------
#if SPI0_CFG == 1
#define OLED_SCLK_Clr()
#define OLED_SCLK_Set()
#define OLED_SDIN_Clr()
#define OLED_SDIN_Set()
#define OLED_CS_Clr() gpio_bit_reset(GPIOB,GPIO_PIN_2) //CS PB2
#define OLED_CS_Set() gpio_bit_set(GPIOB,GPIO_PIN_2)
#elif SPI0_CFG == 2
#define OLED_SCLK_Clr()
#define OLED_SCLK_Set()
#define OLED_SDIN_Clr()
#define OLED_SDIN_Set()
#define OLED_CS_Clr()
#define OLED_CS_Set()
#else /* SPI0_CFG */
#define OLED_SCLK_Clr() gpio_bit_reset(GPIOA,GPIO_PIN_5) //CLK PA5
#define OLED_SCLK_Set() gpio_bit_set(GPIOA,GPIO_PIN_5)
#define OLED_SDIN_Clr() gpio_bit_reset(GPIOA,GPIO_PIN_7) //DIN PA7
#define OLED_SDIN_Set() gpio_bit_set(GPIOA,GPIO_PIN_7)
#define OLED_CS_Clr() gpio_bit_reset(GPIOB,GPIO_PIN_2) //CS PB2
#define OLED_CS_Set() gpio_bit_set(GPIOB,GPIO_PIN_2)
#endif /* SPI0_CFG */
#define OLED_RST_Clr() gpio_bit_reset(GPIOB,GPIO_PIN_1) //RES PB1
#define OLED_RST_Set() gpio_bit_set(GPIOB,GPIO_PIN_1)
#define OLED_DC_Clr() gpio_bit_reset(GPIOB,GPIO_PIN_0) //DC PB0
#define OLED_DC_Set() gpio_bit_set(GPIOB,GPIO_PIN_0)
#if HAS_BLK_CNTL
#define OLED_BLK_Clr() gpio_bit_reset(GPIOA,GPIO_PIN_5)//BLK
#define OLED_BLK_Set() gpio_bit_set(GPIOA,GPIO_PIN_5)
#else
#define OLED_BLK_Clr()
#define OLED_BLK_Set()
#endif
#define OLED_CMD 0 //写命令
#define OLED_DATA 1 //写数据
extern u16 BACK_COLOR; //背景色
extern unsigned char image[12800];
void LCD_Writ_Bus(u8 dat);
void LCD_WR_DATA8(u8 dat);
void LCD_WR_DATA(u16 dat);
void LCD_WR_REG(u8 dat);
void LCD_Address_Set(u16 x1,u16 y1,u16 x2,u16 y2);
void Lcd_Init(void);
void LCD_Clear(u16 Color);
void LCD_ShowChinese(u16 x,u16 y,u8 index,u8 size,u16 color);
void LCD_DrawPoint(u16 x,u16 y,u16 color);
void LCD_DrawPoint_big(u16 x,u16 y,u16 color);
void LCD_Fill(u16 xsta,u16 ysta,u16 xend,u16 yend,u16 color);
void LCD_DrawLine(u16 x1,u16 y1,u16 x2,u16 y2,u16 color);
void LCD_DrawRectangle(u16 x1, u16 y1, u16 x2, u16 y2,u16 color);
void Draw_Circle(u16 x0,u16 y0,u8 r,u16 color);
void LCD_ShowChar(u16 x,u16 y,u8 num,u8 mode,u16 color);
void LCD_ShowString(u16 x,u16 y,const u8 *p,u16 color);
u32 mypow(u8 m,u8 n);
void LCD_ShowNum(u16 x,u16 y,u16 num,u8 len,u16 color);
void LCD_ShowNum1(u16 x,u16 y,float num,u8 len,u16 color);
void LCD_ShowPicture(u16 x1,u16 y1,u16 x2,u16 y2);
void LCD_ShowLogo(void);
//画笔颜色
#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 //棕色
#define BRRED 0XFC07 //棕红色
#define GRAY 0X8430 //灰色
//GUI颜色
#define DARKBLUE 0X01CF //深蓝色
#define LIGHTBLUE 0X7D7C //浅蓝色
#define GRAYBLUE 0X5458 //灰蓝色
//以上三色为PANEL的颜色
#define LIGHTGREEN 0X841F //浅绿色
#define LGRAY 0XC618 //浅灰色(PANNEL),窗体背景色
#define LGRAYBLUE 0XA651 //浅灰蓝色(中间层颜色)
#define LBBLUE 0X2B12 //浅棕蓝色(选择条目的反色)
#endif