#include "tftlcd.h"
#include "stdlib.h"
#include "font.h"
#include "usart.h"
#include "SysTick.h"
//LCD的画笔颜色和背景色
u16 FRONT_COLOR=BLACK; //画笔颜色
u16 BACK_COLOR=WHITE; //背景色
_tftlcd_data tftlcd_data;
//写寄存器函数
//cmd:寄存器值
void LCD_WriteCmd(u16 cmd)
{
#ifdef TFTLCD_HX8357D
TFTLCD->LCD_CMD=cmd;//写入要写的寄存器序号
#endif
#ifdef TFTLCD_HX8357DN
TFTLCD->LCD_CMD=cmd;
#endif
#ifdef TFTLCD_R61509V
TFTLCD->LCD_CMD=cmd;//写入要写的寄存器序号
#endif
#ifdef TFTLCD_R61509VN
TFTLCD->LCD_CMD=(cmd>>8)<<1;
TFTLCD->LCD_CMD=(cmd&0xff)<<1;
#endif
#ifdef TFTLCD_R61509V3
TFTLCD->LCD_CMD=cmd;//写入要写的寄存器序号
#endif
#ifdef TFTLCD_HX8352C
TFTLCD->LCD_CMD=cmd<<8;
#endif
#ifdef TFTLCD_ILI9341
TFTLCD->LCD_CMD=cmd<<8;
#endif
#ifdef TFTLCD_ILI9327
TFTLCD->LCD_CMD=cmd;
#endif
#ifdef TFTLCD_ILI9325
TFTLCD->LCD_CMD=cmd;
#endif
#ifdef TFTLCD_ILI9486
TFTLCD->LCD_CMD=cmd;
#endif
#ifdef TFTLCD_ST7793
TFTLCD->LCD_CMD=cmd>>8;
TFTLCD->LCD_CMD=cmd&0xff;
#endif
#ifdef TFTLCD_SSD1963
TFTLCD->LCD_CMD=cmd;
#endif
#ifdef TFTLCD_NT35510
TFTLCD->LCD_CMD=cmd;
#endif
#ifdef TFTLCD_ILI9481
TFTLCD->LCD_CMD=cmd;
#endif
#ifdef TFTLCD_R61509VE
TFTLCD->LCD_CMD=cmd;
#endif
#ifdef TFTLCD_SSD1963N
TFTLCD->LCD_CMD=cmd;
#endif
#ifdef TFTLCD_ILI9488
TFTLCD->LCD_CMD=cmd;
#endif
#ifdef TFTLCD_ILI9806
TFTLCD->LCD_CMD=cmd;
#endif
}
//写数据
//data:要写入的值
void LCD_WriteData(u16 data)
{
#ifdef TFTLCD_HX8357D
TFTLCD->LCD_DATA=data;//写入要写的寄存器序号
#endif
#ifdef TFTLCD_HX8357DN
TFTLCD->LCD_DATA=data;
#endif
#ifdef TFTLCD_R61509V
TFTLCD->LCD_DATA=data;//写入要写的寄存器序号
#endif
#ifdef TFTLCD_R61509VN
TFTLCD->LCD_DATA=(data>>8)<<1;
TFTLCD->LCD_DATA=(data&0xff)<<1;
#endif
#ifdef TFTLCD_R61509V3
TFTLCD->LCD_DATA=data;//写入要写的寄存器序号
#endif
#ifdef TFTLCD_HX8352C
TFTLCD->LCD_DATA=data<<8;
#endif
#ifdef TFTLCD_ILI9341
TFTLCD->LCD_DATA=data<<8;
#endif
#ifdef TFTLCD_ILI9327
TFTLCD->LCD_DATA=data;
#endif
#ifdef TFTLCD_ILI9325
TFTLCD->LCD_DATA=data;
#endif
#ifdef TFTLCD_ILI9486
TFTLCD->LCD_DATA=data;
#endif
#ifdef TFTLCD_ST7793
TFTLCD->LCD_DATA=data>>8;
TFTLCD->LCD_DATA=data&0xff;
#endif
#ifdef TFTLCD_SSD1963
TFTLCD->LCD_DATA=data;
#endif
#ifdef TFTLCD_NT35510
TFTLCD->LCD_DATA=data;
#endif
#ifdef TFTLCD_ILI9481
TFTLCD->LCD_DATA=data;
#endif
#ifdef TFTLCD_R61509VE
TFTLCD->LCD_DATA=data;
#endif
#ifdef TFTLCD_SSD1963N
TFTLCD->LCD_DATA=data;
#endif
#ifdef TFTLCD_ILI9488
TFTLCD->LCD_DATA=data;
#endif
#ifdef TFTLCD_ILI9806
TFTLCD->LCD_DATA=data;
#endif
}
void LCD_WriteCmdData(u16 cmd,u16 data)
{
LCD_WriteCmd(cmd);
LCD_WriteData(data);
}
u32 LCD_RGBColor_Change(u16 color)
{
u8 r,g,b=0;
r=(color>>11)&0x1f;
g=(color>>5)&0x3f;
b=color&0x1f;
return ((r<<13)|(g<<6)|(b<<1));
}
void LCD_WriteData_Color(u16 color)
{
#ifdef TFTLCD_HX8357D
TFTLCD->LCD_DATA=color;
#endif
#ifdef TFTLCD_HX8357DN
TFTLCD->LCD_DATA=color>>8;
TFTLCD->LCD_DATA=color&0xff;
#endif
#ifdef TFTLCD_R61509V
TFTLCD->LCD_DATA=color;
#endif
#ifdef TFTLCD_R61509VN
u32 recolor=0;
recolor=LCD_RGBColor_Change(color);
TFTLCD->LCD_DATA=(recolor>>9);
TFTLCD->LCD_DATA=recolor;
#endif
#ifdef TFTLCD_R61509V3
TFTLCD->LCD_DATA=color;
#endif
#ifdef TFTLCD_HX8352C
TFTLCD->LCD_DATA=color&0xff00;
TFTLCD->LCD_DATA=color<<8;
#endif
#ifdef TFTLCD_ILI9341
TFTLCD->LCD_DATA=color&0xff00;
TFTLCD->LCD_DATA=color<<8;
#endif
#ifdef TFTLCD_ILI9327
TFTLCD->LCD_DATA=color>>8;
TFTLCD->LCD_DATA=color&0xff;
#endif
#ifdef TFTLCD_ILI9325
TFTLCD->LCD_DATA=color;
#endif
#ifdef TFTLCD_ILI9486
TFTLCD->LCD_DATA=color;
#endif
#ifdef TFTLCD_ST7793
TFTLCD->LCD_DATA=color>>8;
TFTLCD->LCD_DATA=color&0xff;
#endif
#ifdef TFTLCD_SSD1963
TFTLCD->LCD_DATA=color;
#endif
#ifdef TFTLCD_NT35510
TFTLCD->LCD_DATA=color;
#endif
#ifdef TFTLCD_ILI9481
TFTLCD->LCD_DATA=color;
#endif
#ifdef TFTLCD_R61509VE
TFTLCD->LCD_DATA=color;
#endif
#ifdef TFTLCD_SSD1963N
TFTLCD->LCD_DATA=color;
#endif
#ifdef TFTLCD_ILI9488
TFTLCD->LCD_DATA=color>>8;
TFTLCD->LCD_DATA=color&0xff;
#endif
#ifdef TFTLCD_ILI9806
TFTLCD->LCD_DATA=color;
#endif
}
//读数据
//返回值:读到的值
u16 LCD_ReadData(void)
{
#ifdef TFTLCD_HX8357D
return TFTLCD->LCD_DATA;
#endif
#ifdef TFTLCD_HX8357DN
// u16 ram1,ram2;
// ram1=TFTLCD->LCD_DATA;
// printf("ram1=%x ",ram1);
// ram2=TFTLCD->LCD_DATA;
// printf("ram2=%x \r\n",ram2);
// ram2=ram2<<8|ram1;
// return ram2;
return TFTLCD->LCD_DATA;
// return ((TFTLCD->LCD_DATA<<8)|(TFTLCD->LCD_DATA));
#endif
#ifdef TFTLCD_R61509V
return TFTLCD->LCD_DATA;
#endif
#ifdef TFTLCD_R61509VN
// return TFTLCD->LCD_DATA;
u16 ram;
ram=(TFTLCD->LCD_DATA)>>1;
ram=ram<<8;
ram|=(TFTLCD->LCD_DATA)>>1;
return ram;
#endif
#ifdef TFTLCD_R61509V3
return TFTLCD->LCD_DATA;
#endif
#ifdef TFTLCD_HX8352C
return ((TFTLCD->LCD_DATA<<8)|(TFTLCD->LCD_DATA));
#endif
#ifdef TFTLCD_ILI9341
return TFTLCD->LCD_DATA;
#endif
#ifdef TFTLCD_ILI9327
u16 ram;
ram=TFTLCD->LCD_DATA;
ram=ram<<8;
ram|=TFTLCD->LCD_DATA;
return ram;
#endif
#ifdef TFTLCD_ILI9325
return TFTLCD->LCD_DATA;
#endif
#ifdef TFTLCD_ILI9486
return TFTLCD->LCD_DATA;
#endif
#ifdef TFTLCD_ST7793
u16 ram;
ram=TFTLCD->LCD_DATA;
ram=ram<<8;
ram|=TFTLCD->LCD_DATA;
return ram;
#endif
#ifdef TFTLCD_SSD1963
return TFTLCD->LCD_DATA;
#endif
#ifdef TFTLCD_NT35510
return TFTLCD->LCD_DATA;
#endif
#ifdef TFTLCD_ILI9481
return TFTLCD->LCD_DATA;
#endif
#ifdef TFTLCD_R61509VE
return TFTLCD->LCD_DATA;
#endif
#ifdef TFTLCD_SSD1963N
return TFTLCD->LCD_DATA;
#endif
#ifdef TFTLCD_ILI9488
u16 ram;
ram=TFTLCD->LCD_DATA;
ram=ram<<8;
ram|=TFTLCD->LCD_DATA;
return ram;
#endif
#ifdef TFTLCD_ILI9806
return TFTLCD->LCD_DATA;
#endif
}
//设置LCD显示方向
//dir:0,竖屏;1,横屏
void LCD_Display_Dir(u8 dir)
{
tftlcd_data.dir=dir; //横屏/竖屏
if(dir==0) //默认竖屏方向
{
#ifdef TFTLCD_HX8357D
LCD_WriteCmd(0x36); //设置彩屏显示方向的寄存器
LCD_WriteData(0x4c);
tftlcd_data.height=480;
tftlcd_data.width=320;
#endif
#ifdef TFTLCD_HX8357DN
LCD_WriteCmd(0x36); //设置彩屏显示方向的寄存器
LCD_WriteData(0x4c);
tftlcd_data.height=480;
tftlcd_data.width=320;
#endif
#ifdef TFTLCD_R61509V
LCD_WriteCmd(0x0001);
LCD_WriteData(0x0100);
LCD_WriteCmd(0x0003);
LCD_WriteData(0x1030);
tftlcd_data.height=400;
tftlcd_data.width=240;
#endif
#ifdef TFTLCD_R61509VN
LCD_WriteCmd(0x0001);
LCD_WriteData(0x0100);
LCD_WriteCmd(0x0003);
LCD_WriteData(0x1030);
tftlcd_data.height=400;
tftlcd_data.width=240;
#endif
#ifdef TFTLCD_R61509V3
LCD_WriteCmd(0x0001);
LCD_WriteData(0x0100);
LCD_WriteCmd(0x0003);
LCD_WriteData(0x1030);
tftlcd_data.height=400;
tftlcd_data.width=240;
#endif
#ifdef TFTLCD_HX8352C
LCD_WriteCmd(0x36); //设置彩屏显示方向的寄存器
LCD_WriteData(0x03); //03:U-D,L-R; 06:D-U,R-L;
tftlcd_data.height=400;
tftlcd_data.width=240;
#endif
#ifdef TFTLCD_ILI9341
LCD_WriteCmd(0x36); //设置彩屏显示方向的寄存器
LCD_WriteData(0x08);
tftlcd_data.height=320;
tftlcd_data.width=240;
#endif
#ifdef TFTLCD_ILI9327
LCD_WriteCmd(0x36); //设置彩屏显示方向的寄存器
LCD_WriteData(0x48);
tftlcd_data.height=400;
tftlcd_data.width=240;
#endif
#ifdef TFTLCD_ILI9325
LCD_WriteCmd(0x0001);
LCD_WriteData(0x0100);
LCD_WriteCmd(0x0003); //设置彩屏显示方向的寄存器
LCD_WriteData(0x1030);
tftlcd_data.height=320;
tftlcd_data.width=240;
#endif
#ifdef TFTLCD_ILI9486
LCD_W
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
STM32单片机原理及应用课程设计-俄罗斯方块游戏 (181个子文件)
Template.uvguix.Administrator 136KB
Template.axf 538KB
keilkilll.bat 399B
tftlcd.c 115KB
stm32f10x_tim.c 107KB
stm32f10x_flash.c 61KB
stm32f10x_rcc.c 50KB
stm32f10x_adc.c 46KB
stm32f10x_i2c.c 45KB
stm32f10x_can.c 44KB
stm32f10x_usart.c 37KB
system_stm32f10x.c 36KB
stm32f10x_fsmc.c 35KB
stm32f10x_spi.c 30KB
stm32f10x_dma.c 29KB
stm32f10x_sdio.c 28KB
stm32f10x_gpio.c 23KB
stm32f10x_dac.c 19KB
core_cm3.c 17KB
stm32f10x_cec.c 11KB
tetris.c 11KB
stm32f10x_pwr.c 9KB
stm32f10x_rtc.c 8KB
stm32f10x_bkp.c 8KB
misc.c 7KB
stm32f10x_exti.c 7KB
stm32f10x_wwdg.c 6KB
stm32f10x_dbgmcu.c 5KB
stm32f10x_iwdg.c 5KB
stm32f10x_it.c 4KB
usart.c 4KB
stm32f10x_crc.c 3KB
time.c 3KB
key.c 2KB
main.c 2KB
SysTick.c 1KB
led.c 980B
system.c 29B
tftlcd.crf 366KB
stm32f10x_tim.crf 363KB
tetris.crf 357KB
main.crf 354KB
stm32f10x_can.crf 350KB
time.crf 350KB
stm32f10x_adc.crf 348KB
stm32f10x_rcc.crf 348KB
usart.crf 347KB
stm32f10x_usart.crf 347KB
stm32f10x_fsmc.crf 347KB
stm32f10x_spi.crf 345KB
stm32f10x_gpio.crf 345KB
stm32f10x_dma.crf 344KB
stm32f10x_dac.crf 343KB
key.crf 343KB
system_stm32f10x.crf 342KB
stm32f10x_bkp.crf 342KB
stm32f10x_pwr.crf 342KB
stm32f10x_rtc.crf 342KB
systick.crf 342KB
led.crf 342KB
stm32f10x_exti.crf 342KB
stm32f10x_wwdg.crf 341KB
misc.crf 341KB
system.crf 341KB
stm32f10x_iwdg.crf 341KB
stm32f10x_it.crf 341KB
core_cm3.crf 4KB
stm32f10x_usart.d 2KB
stm32f10x_fsmc.d 2KB
stm32f10x_iwdg.d 2KB
stm32f10x_gpio.d 2KB
stm32f10x_exti.d 2KB
stm32f10x_wwdg.d 2KB
stm32f10x_rcc.d 2KB
stm32f10x_dac.d 2KB
stm32f10x_adc.d 2KB
stm32f10x_pwr.d 2KB
stm32f10x_can.d 2KB
stm32f10x_rtc.d 2KB
stm32f10x_bkp.d 2KB
stm32f10x_tim.d 2KB
stm32f10x_spi.d 2KB
stm32f10x_dma.d 2KB
system_stm32f10x.d 2KB
tftlcd.d 2KB
main.d 2KB
tetris.d 2KB
stm32f10x_it.d 2KB
time.d 2KB
systick.d 2KB
usart.d 2KB
misc.d 2KB
system.d 2KB
key.d 2KB
led.d 2KB
core_cm3.d 110B
startup_stm32f10x_hd.d 70B
Target_1_STM32F103ZE_1.0.0.dbgconf 7KB
Template_Target 1.dep 83KB
picture.h 1.69MB
共 181 条
- 1
- 2
资源评论
茜茜西西CeCe
- 粉丝: 991
- 资源: 14
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功