找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 6210|回复: 5
收起左侧

1.8寸 lcd tft显示屏stm32显示源码

[复制链接]
ID:141183 发表于 2018-4-24 11:22 | 显示全部楼层 |阅读模式
1.8寸 lcd tft显示屏 显示模块。

单片机源程序如下:
  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. /*Voltage[4]:电压
  6. *I_current[4]:电流
  7. *direction[4]:方向
  8. *speed[4]:速度
  9. *temperature[4]:温度*/
  10. /* Includes ------------------------------------------------------------------*/
  11. #include "stm32f10x.h"
  12. #include "Lcd_Driver.h"
  13. #include "LCD_Config.h"
  14. #include "GUI.h"
  15. #include "delay.h"
  16. #include "Picture.h"
  17. #define  uint   unsigned int
  18. #define  uchar  unsigned char


  19. GPIO_InitTypeDef GPIO_InitStructure;
  20. void RCC_Configuration(void);
  21. void Delayms(__IO uint32_t nCount);
  22. uchar Num[10]={0,1,2,3,4,5,6,7,8,9};
  23. uchar number[4],nnn=100;
  24. uchar Voltage[4],I_current[4],direction[4],speed[4],temperature[4];

  25. void Redraw_Mainmenu(void)
  26. {

  27.         Lcd_Clear(GRAY0);
  28.         
  29.         Gui_DrawFont_GBK16(16,2,BLUE,GRAY0,"后备保护系统");

  30.         DisplayButtonUp(15,26,113,50); //x1,y1,x2,y2        
  31.         Gui_DrawFont_GBK16(15,30,RED,GRAY0,"电流:");
  32.         sprintf(I_current ,"%d",nnn);
  33.   Gui_DrawFont_GBK16(54, 30, RED, GRAY0,I_current);
  34.                 Gui_DrawFont_GBK16(92,30,RED,GRAY0,"A");
  35.         
  36.         DisplayButtonUp(15,51,113,75); //x1,y1,x2,y2
  37.         Gui_DrawFont_GBK16(16,55,RED,GRAY0,"电压:");
  38.         sprintf(Voltage,"%d",nnn);
  39.   Gui_DrawFont_GBK16(54, 55, RED, GRAY0,Voltage);
  40.         Gui_DrawFont_GBK16(92,55,RED,GRAY0,"V");
  41.         
  42.         DisplayButtonUp(15,76,113,100); //x1,y1,x2,y2
  43.         Gui_DrawFont_GBK16(16,80,RED,GRAY0,"方向:");
  44.         Gui_DrawFont_GBK16(54,80,RED,GRAY0,"上行");
  45.         
  46.         DisplayButtonUp(15,101,113,125); //x1,y1,x2,y2
  47.         Gui_DrawFont_GBK16(16,105,RED,GRAY0,"转速:");
  48.         sprintf(speed,"%d",nnn);
  49.   Gui_DrawFont_GBK16(54, 105, RED, GRAY0,speed);
  50.         Gui_DrawFont_GBK16(84,105,RED,GRAY0,"m/s");
  51.         
  52.         DisplayButtonUp(15,126,113,150); //x1,y1,x2,y2
  53.         Gui_DrawFont_GBK16(16,130,RED,GRAY0,"温度:");
  54.         sprintf(temperature,"%d",nnn);
  55.   Gui_DrawFont_GBK16(54, 130, RED, GRAY0,temperature);        
  56.         Gui_DrawFont_GBK16(92,130,RED,GRAY0,"度");        
  57. }


  58. //u16 ID=0;

  59. int main(void)
  60. {
  61.   SystemInit();
  62.   delay_init(72);//延时初始化
  63.   Lcd_Init();//初始化硬件SPI
  64.         
  65.         Redraw_Mainmenu();        
  66.         
  67.         
  68.   while(1)
  69.   {  

  70.   }

  71. }


  72. //void RCC_Configuration(void)
  73. //{   
  74. //  /* 设置微控制器系统,初始化嵌入式FLASH接口,初始化PLL并更新系统频率变量 */
  75. //  SystemInit();
  76. //}


  77. void Delayms(__IO uint32_t nCount)
  78. {
  79.   for(; nCount != 0; nCount--);
  80. }

  81. #ifdef  USE_FULL_ASSERT
  82. /**
  83.   * @brief  Reports the name of the source file and the source line number
  84.   *   where the assert_param error has occurred.
  85.   * @param file: pointer to the source file name
  86.   * @param line: assert_param error line source number
  87.   * @retval : None
  88.   */



  89. void assert_failed(uint8_t* file, uint32_t line)
  90. ……………………

  91. …………限于本文篇幅 余下代码请从51黑下载附件…………
复制代码

所有资料51hei提供下载:
显示.rar (368.75 KB, 下载次数: 171)

评分

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

查看全部评分

回复

使用道具 举报

ID:214152 发表于 2018-7-4 13:58 | 显示全部楼层
看看,感谢分享
回复

使用道具 举报

ID:413217 发表于 2018-10-22 10:28 | 显示全部楼层
你好,能告诉下怎么接线吗
回复

使用道具 举报

ID:141183 发表于 2019-2-23 10:52 | 显示全部楼层
411706683 发表于 2018-10-22 10:28
你好,能告诉下怎么接线吗

//±¾2aêÔ3ìDòê1óÃμÄêÇÄ£ÄaSPI½ó¿úÇy¶ˉ
//¿é×Ôóé¸ü¸Ä½ó¿úIOÅäÖã¬ê1óÃèÎòa×îéù4 IO¼′¿éíê3é±¾¿îòo¾§Çy¶ˉÏÔê¾
/******************************************************************************
½ó¿ú¶¨òåÔúLcd_Driver.hÄú¶¨ò壬Çë¸ù¾Y½óÏßDT¸Ä2¢DT¸ÄÏàó|IO3õê¼»ˉLCD_GPIO_Init()
#define LCD_CTRL                     GPIOB                     //¶¨òåTFTêy¾Y¶Ë¿ú
#define LCD_LED                             //2»ê1óñ31a¿ØÖÆ
#define LCD_RS                 GPIO_Pin_1         //PB1--->>TFT --RS/DC
#define LCD_CS                GPIO_Pin_12  //PB11--->>TFT --CS/CE
#define LCD_RST                                        //¸′λòy½Å½óμ½Ïμí3¸′λéÏ
#define LCD_SCL                GPIO_Pin_13         //PB13--->>TFT --SCL/SCK
#define LCD_SDA                GPIO_Pin_15         //PB15 MOSI--->>TFT --SDA/DIN
*******************************************************************************/
回复

使用道具 举报

ID:688355 发表于 2020-2-20 15:06 | 显示全部楼层
非常感谢,下来试试学习一下
回复

使用道具 举报

ID:74868 发表于 2021-1-14 09:15 | 显示全部楼层
分享快乐
回复

使用道具 举报

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

本版积分规则

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

Powered by 单片机教程网

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