找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 2544|回復: 1
打印 上一主題 下一主題
收起左側

stm32驅動1.80寸tft源碼

[復制鏈接]
跳轉到指定樓層
樓主
ID:459211 發(fā)表于 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,"嵌入式開發(fā)網");
  79.         Gui_DrawFont_GBK16(32,36,BLACK,GRAY0,"中文測試");
  80.         Gui_DrawFont_GBK16(16,52,BLUE,GRAY0,"專注液晶批發(fā)");
  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, 下載次數(shù): 34)



評分

參與人數(shù) 1黑幣 +50 收起 理由
admin + 50 共享資料的黑幣獎勵!

查看全部評分

分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏 分享淘帖 頂 踩
回復

使用道具 舉報

沙發(fā)
ID:651491 發(fā)表于 2019-12-18 17:12 | 只看該作者
我想知道爲什麼加上ucosii系統(tǒng)后就會出現(xiàn)白屏的現(xiàn)象
回復

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規(guī)則

小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術交流QQ群281945664

Powered by 單片機教程網

快速回復 返回頂部 返回列表