找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 2495|回复: 1
打印 上一主题 下一主题
收起左侧

stm32驱动1.80寸tft源码

[复制链接]
跳转到指定楼层
楼主
ID:459211 发表于 2019-1-1 03:00 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
给各位参考下

单片机源程序如下:
  1. //==================================如何切换横竖屏显示=======================================//
  2. //打开Lcd_Driver.h头文件,修改宏#define USE_HORIZONTAL 值为0使用竖屏模式.1,使用横屏模式
  3. //===========================如何切换模拟SPI总线驱动和硬件SPI总线驱动=========================//
  4. //打开Lcd_Driver.h头文件,修改宏#define USE_HARDWARE_SPI  值为0使用模拟SPI总线.1,使用硬件SPI总线


  5. /* Includes ------------------------------------------------------------------*/
  6. #include "stm32f10x.h"
  7. #include "Lcd_Driver.h"
  8. #include "LCD_Config.h"
  9. #include "GUI.h"
  10. #include "delay.h"
  11. #include "Picture.h"

  12. GPIO_InitTypeDef GPIO_InitStructure;


  13. void RCC_Configuration(void);

  14. void Delayms(__IO uint32_t nCount);

  15. unsigned char Num[10]={0,1,2,3,4,5,6,7,8,9};



  16. void Redraw_Mainmenu(void)
  17. {

  18.         Lcd_Clear(GRAY0);
  19.        
  20.         Gui_DrawFont_GBK16(8,2,BLUE,GRAY0,"Mcudev电子技术");
  21.         Gui_DrawFont_GBK16(32,20,BLUE,GRAY0,"液晶测试");

  22.         DisplayButtonUp(15,38,113,58); //x1,y1,x2,y2
  23.         Gui_DrawFont_GBK16(16,40,GREEN,GRAY0,"颜色填充测试");

  24.         DisplayButtonUp(15,68,113,88); //x1,y1,x2,y2
  25.         Gui_DrawFont_GBK16(16,70,BLUE,GRAY0,"文字显示测试");

  26.         DisplayButtonUp(15,98,113,118); //x1,y1,x2,y2
  27.         Gui_DrawFont_GBK16(16,100,RED,GRAY0,"图片显示测试");

  28.          #if USE_HORIZONTAL==1        //使用横屏       
  29.        
  30.                 Gui_DrawFont_Num32(125,90,RED,GRAY0,Num[5]);
  31.                 delay_ms(1000);
  32.                 Gui_DrawFont_Num32(125,90,RED,GRAY0,Num[4]);
  33.                 delay_ms(1000);
  34.                 Gui_DrawFont_Num32(125,90,RED,GRAY0,Num[3]);
  35.                 delay_ms(1000);
  36.                 Gui_DrawFont_Num32(125,90,RED,GRAY0,Num[2]);
  37.                 delay_ms(1000);
  38.                 Gui_DrawFont_Num32(125,90,RED,GRAY0,Num[1]);
  39.                 delay_ms(1000);
  40.                 Gui_DrawFont_Num32(125,90,RED,GRAY0,Num[0]);       
  41.        
  42.         #else       
  43.        
  44.                 Gui_DrawFont_Num32(100,125,RED,GRAY0,Num[5]);
  45.                 delay_ms(1000);
  46.                 Gui_DrawFont_Num32(100,125,RED,GRAY0,Num[4]);
  47.                 delay_ms(1000);
  48.                 Gui_DrawFont_Num32(100,125,RED,GRAY0,Num[3]);
  49.                 delay_ms(1000);
  50.                 Gui_DrawFont_Num32(100,125,RED,GRAY0,Num[2]);
  51.                 delay_ms(1000);
  52.                 Gui_DrawFont_Num32(100,125,RED,GRAY0,Num[1]);
  53.                 delay_ms(1000);
  54.                 Gui_DrawFont_Num32(100,125,RED,GRAY0,Num[0]);       
  55.        
  56.         #endif

  57. }

  58. void Num_Test(void)
  59. {
  60.         u8 i=0;
  61.         Lcd_Clear(GRAY0);
  62.         Gui_DrawFont_GBK16(16,20,RED,GRAY0,"Num Test");
  63.         delay_ms(1000);
  64.         Lcd_Clear(GRAY0);

  65.         for(i=0;i<10;i++)
  66.         {
  67.         Gui_DrawFont_Num32((i%3)*40,32*(i/3),RED,GRAY0,Num[i+1]);
  68.         delay_ms(100);
  69.         }
  70.        
  71. }

  72. void Font_Test(void)
  73. {
  74.         Lcd_Clear(GRAY0);
  75.         Gui_DrawFont_GBK16(16,10,BLUE,GRAY0,"文字显示测试");

  76.         delay_ms(1000);
  77.         Lcd_Clear(GRAY0);
  78.         Gui_DrawFont_GBK16(16,16,BLACK,GRAY0,"嵌入式开发网");
  79.         Gui_DrawFont_GBK16(32,36,BLACK,GRAY0,"中文测试");
  80.         Gui_DrawFont_GBK16(16,52,BLUE,GRAY0,"专注液晶批发");
  81.         Gui_DrawFont_GBK16(16,70,RED,GRAY0, "全程技术支持");
  82.         Gui_DrawFont_GBK16(16,100,GREEN,GRAY0,"mcudev.taobao");

  83.         delay_ms(1800);       
  84. }

  85. void Color_Test(void)
  86. {
  87.         u8 i=1;
  88.         Lcd_Clear(GRAY0);
  89.        
  90.         Gui_DrawFont_GBK16(20,10,BLUE,GRAY0,"Color Test");
  91.         delay_ms(200);

  92.         while(i--)
  93.         {
  94.         Lcd_Clear(WHITE);
  95.         Lcd_Clear(BLACK);
  96.         Lcd_Clear(RED);
  97.   Lcd_Clear(GREEN);
  98.   Lcd_Clear(BLUE);
  99.         }               
  100. }
  101. //16位 垂直扫描  右到左  高位在前
  102. void show_pic(void)
  103. {
  104.         int i,j,k;
  105.         unsigned char picH,picL;
  106.        
  107.         Lcd_Clear(GRAY0);
  108.        
  109.         Gui_DrawFont_GBK16(16,10,BLUE,GRAY0,"图片显示测试");
  110.        
  111.         delay_ms(1000);
  112.        
  113.         Lcd_Clear(GRAY0);
  114.        
  115.         #if USE_HORIZONTAL==1        //使用横屏       

  116.         {
  117.                         k=0;
  118.                         for(i=0;i<128;i++)
  119.                         for(j=0;j<160;j++)
  120.                         {
  121.                                 picH=gImage_1234[k++];
  122.                                 picL=gImage_1234[k++];
  123.                                 Lcd_WriteData(picH);
  124.                                 Lcd_WriteData(picL);
  125.                                
  126.                                
  127.                         }                       
  128.         }       

  129.                
  130.         #else       
  131.         {
  132.                 k=0;
  133.                 for(i=0;i<160;i++)
  134.                 for(j=0;j<128;j++)
  135.                 {
  136.                         picH=gImage_123[k++];
  137.                         picL=gImage_123[k++];
  138.                         Lcd_WriteData(picH);
  139.                         Lcd_WriteData(picL);
  140.                 }       
  141.         }               
  142.         #endif
  143. }

  144. //画圆 划线  算法演示
  145. void show_Circle(void)
  146. {

  147.         Lcd_Clear(GRAY0);
  148.        
  149.         Gui_DrawFont_GBK16(8,10,BLUE,GRAY0,"Circle显示测试");
  150.        
  151.         delay_ms(1000);
  152.        
  153.         Lcd_Clear(GRAY0);
  154.        
  155. #if USE_HORIZONTAL==1        //使用横屏       

  156.         Gui_DrawLine(0, 0,159,0,RED);//画一条直径线
  157.         Gui_DrawLine(0, 1,159,1,RED);//画一条直径线
  158.        
  159.         Gui_DrawLine(159, 0,159,127,RED);//画一条直径线
  160.         Gui_DrawLine(158, 0,158,127,RED);//画一条直径线
  161.        
  162.         Gui_DrawLine(0, 127,159,127,RED);//画一条直径线
  163.         Gui_DrawLine(0, 126,159,126,RED);//画一条直径线
  164.        
  165.         Gui_DrawLine(0, 0,0, 127,RED);//画一条直径线
  166.         Gui_DrawLine(1, 0,1, 127,RED);//画一条直径线
  167.        
  168. #else                //竖屏显示
  169.                
  170.         Gui_DrawLine(0, 0,127,0,RED);//画一条直径线
  171.         Gui_DrawLine(0, 1,127,1,RED);//画一条直径线
  172.        
  173.         Gui_DrawLine(127, 0,127,159,RED);//画一条直径线
  174.         Gui_DrawLine(126, 0,126,159,RED);//画一条直径线
  175.        
  176.         Gui_DrawLine(0, 159,127,159,RED);//画一条直径线
  177.         Gui_DrawLine(0, 158,127,158,RED);//画一条直径线
  178.        
  179.         Gui_DrawLine(0, 0,0, 159,RED);//画一条直径线
  180.         Gui_DrawLine(1, 0,1, 159,RED);//画一条直径线

  181.         #endif
  182.        
  183.         Gui_Circle(64,64,50,RED);//画一个圆形
  184.         Gui_Circle(64,64,40,GREEN);
  185.         Gui_Circle(64,64,30,BLUE);
  186.        
  187.        
  188.         Gui_DrawLine(10, 79,110, 79,BLACK);//画一条黑色的直径线
  189.         Gui_DrawLine(10, 80,110, 80,BLACK);//画一条黑色的直径线
  190.         Gui_DrawLine(10, 81,110, 81,BLACK);//画一条黑色的直径线
  191. }


  192. u16 ID=0;

  193. int main(void)
  194. {
  195.   SystemInit();
  196.   delay_init(72);//延时初始化
  197.   Lcd_Init();//初始化硬件SPI
  198.        
  199.   while(1)
  200.   {  
  201.                
  202. //                LCD_LED_SET;//通过IO控制背光亮
  203.                 Redraw_Mainmenu();
  204.                 Color_Test();//简单纯色填充测试
  205.                 Num_Test();
  206.                 Font_Test();//中英文显示测试               
  207.                 show_pic();//图片显示示例
  208.                 delay_ms(1200);
  209.                 show_Circle();//绘图算法显示---画圆
  210.                 delay_ms(2000);
  211.                
  212. //                LCD_LED_CLR;//IO控制背光灭               
  213.   }

  214. }


  215. void RCC_Configuration(void)
  216. {   
  217.   /* Setup the microcontroller system. Initialize the Embedded Flash Interface,  
  218.      initialize the PLL and update the SystemFrequency variable. */
  219.   SystemInit();
  220. }

  221. ……………………

  222. …………限于本文篇幅 余下代码请从51黑下载附件…………
复制代码
全部资料51hei下载地址:
1.80寸tft.7z (475.5 KB, 下载次数: 34)



评分

参与人数 1黑币 +50 收起 理由
admin + 50 共享资料的黑币奖励!

查看全部评分

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖 顶 踩
回复

使用道具 举报

沙发
ID:651491 发表于 2019-12-18 17:12 | 只看该作者
我想知道爲什麽加上ucosii系統后就會出現白屏的現象
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表