找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 2634|回复: 2
收起左侧

STM32F103汉字、图片、时钟显示源程序

[复制链接]
ID:372936 发表于 2019-6-18 22:17 | 显示全部楼层 |阅读模式
最小系统板开发板STM32F103无SD卡用片内flash显示汉字、图片、时钟

单片机源程序如下:
  1. #include "led.h"
  2. #include "delay.h"
  3. #include "key.h"
  4. #include "sys.h"
  5. #include "lcd.h"
  6. #include "usart.h"
  7. #include "image2lcd.h"
  8. #include "stdlib.h"
  9. #include "text.h"
  10. #include "usmart.h"         
  11. #include "rtc.h"

  12.        
  13. extern const u8 gImage_image1[];//图片数据(包含信息头),存储在image1.c里面.

  14. int main(void)
  15. {
  16.         u8 t=0;       
  17.         u8 i=0;
  18.         NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);//设置中断优先级分组为组2:2位抢占优先级,2位响应优先级
  19.         LED_Init();                             //LED端口初始化
  20.         usmart_dev.init(SystemCoreClock/1000000);        //初始化USMART       
  21.         RTC_Init();                
  22.         delay_init();             //延时初始化
  23.         NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);// 设置中断优先级分组2
  24.         LED_Init();                          //初始化与LED连接的硬件接口
  25.         uart_init(115200);
  26.         LCD_Init();
  27. //        LCD_Clear(GRAY);

  28.          
  29.         POINT_COLOR=RED;
  30.         LCD_Show_Font(20,10,0);              //显示智能螃蟹投食器     
  31.         LCD_Show_Font(50,10,1);
  32.         LCD_Show_Font(80,10,2);
  33.         LCD_Show_Font(110,10,3);
  34.         LCD_Show_Font(140,10,4);
  35.         LCD_Show_Font(170,10,5);
  36.         LCD_Show_Font(200,10,6);

  37.         POINT_COLOR=BLACK;
  38.         LCD_Show_Font(30,45,7);         //饲料重量:
  39.         LCD_Show_Font(50,45,8);
  40.         LCD_Show_Font(70,45,9);
  41.         LCD_Show_Font(90,45,10);
  42.         LCD_Show_Font(110,45,11);
  43.          
  44.         LCD_Show_Font(30,70,12);                //出料速度:
  45.         LCD_Show_Font(50,70,13);
  46.         LCD_Show_Font(70,70,14);         
  47.         LCD_Show_Font(90,70,15);
  48.         LCD_Show_Font(110,70,16);
  49.        
  50.         LCD_Show_Font(30,95,17);                //预计投喂时长:
  51.         LCD_Show_Font(50,95,18);
  52.         LCD_Show_Font(70,95,19);
  53.         LCD_Show_Font(90,95,20);
  54.         LCD_Show_Font(110,95,21);         
  55.         LCD_Show_Font(130,95,22);
  56.         LCD_Show_Font(150,95,23);
  57.          

  58.         POINT_COLOR=BLUE;
  59.         LCD_Show_Font(75,265,24);                //显示上海海洋大学
  60.         LCD_Show_Font(100,265,25);
  61.         LCD_Show_Font(125,265,26);
  62.         LCD_Show_Font(150,265,27);
  63.         LCD_Show_Font(175,265,28);
  64.         LCD_Show_Font(200,265,29);
  65.        
  66.         POINT_COLOR=BLUE;
  67.         LCD_ShowString(72,295,150,12,12,"Shanghai Ocean University");         

  68.         POINT_COLOR=BLUE;          
  69.         LCD_ShowString(120,49,200,16,16," 50Kg");                //数据
  70.         LCD_ShowString(120,74,200,16,16," 10g/s");
  71.         LCD_ShowString(160,99,200,16,16," 1-1.5h");
  72.          
  73.                   
  74. ///////////////////////////////////////////////////////////////////////////////////////////////////         
  75.             POINT_COLOR=RED;          
  76.                 LCD_ShowString(180,55,200,24,24,"^_^");                //显示字符串(x,y,长度,大小,大小,字符串)
  77. //                LCD_ShowString(60,80,200,16,16,"Shanghai");
  78. //                LCD_ShowString(60,100,200,16,16,"Ocean University");
  79.                 POINT_COLOR=BLACK;
  80. //                LCD_ShowString(32,120,200,12,12,"2019/6/10");
  81.                
  82.                 LCD_Fill(20,200,110,220,999);     //颜色块1 (x1,y1, x2,y2, cplor)
  83.                 LCD_Fill(110,200,220,220,777);    //颜色块2
  84.                 LCD_Fill(20,221,110,240,555);     //颜色块3
  85.                 LCD_Fill(110,221,220,240,333);    //颜色块4
  86.                
  87.                
  88.                 POINT_COLOR=GREEN;
  89.                 LCD_DrawLine(0,  37,238,37);      //画绿线1  (x1,y1, x2,y2)
  90. //                LCD_DrawLine(0,140,240,140);          //画绿线2
  91.                 POINT_COLOR=BLUE;
  92.                 LCD_DrawLine(65,258,240,258);     //画蓝线
  93.                
  94. /*                POINT_COLOR=BLUE;
  95.                 LCD_DrawRectangle(30, 150, 60, 180);     //画矩形  (x1,y1, x4,y4)
  96.                 LCD_Draw_Circle(85,165,15);       //画圆        (x1,y1,r)
  97.                 LCD_ShowxNum(29,188,888888888,9,12,0x80);   //显示数字        (x1,y1,数字,字数,大小,方式)
  98.                 LCD_Color_Fill(110,150,150,190,(u16*)1234);        //填充彩色块
  99. */               
  100.                 POINT_COLOR=BLUE;
  101.                 LCD_DrawLine(165,158,215,158);          //画五角星
  102.                 LCD_DrawLine(190,140,170,180);          
  103.                 LCD_DrawLine(190,140,210,180);     
  104.                 LCD_DrawLine(165,158,210,180);          
  105.                 LCD_DrawLine(215,158,170,180);     


  106. //显示时间
  107.         POINT_COLOR=BLACK;//设置字体为颜色
  108.         LCD_ShowString(30,130,200,16,16,"    -  -  ");         //年:月:日  
  109.         LCD_ShowString(30,165,200,16,16,"  :  :  ");         //时:分:秒                   
  110.          while(1)
  111.         {                                                                    
  112.                 if(t!=calendar.sec)
  113.                 {
  114.                         t=calendar.sec;
  115.                         LCD_ShowNum(30,130,calendar.w_year,4,16);                        //显示年                                                  
  116.                         LCD_ShowxNum(70,130,calendar.w_month,2,16,0x80);        //显示月                                                  
  117.                         LCD_ShowxNum(94,130,calendar.w_date,2,16,0x80);        //显示日
  118.                         switch(calendar.week)                                                                //显示星期
  119.                         {
  120.                                 case 0:
  121.                                         LCD_ShowString(30,148,200,16,16,"Sunday   ");
  122.                                         break;
  123.                                 case 1:
  124.                                         LCD_ShowString(30,148,200,16,16,"Monday   ");
  125.                                         break;
  126.                                 case 2:
  127.                                         LCD_ShowString(30,148,200,16,16,"Tuesday  ");
  128.                                         break;
  129.                                 case 3:
  130.                                         LCD_ShowString(30,148,200,16,16,"Wednesday");
  131.                                         break;
  132.                                 case 4:
  133.                                         LCD_ShowString(30,148,200,16,16,"Thursday ");
  134.                                         break;
  135.                                 case 5:
  136.                                         LCD_ShowString(30,148,200,16,16,"Friday   ");
  137.                                         break;
  138.                                 case 6:
  139.                                         LCD_ShowString(30,148,200,16,16,"Saturday ");
  140.                                         break;  
  141.                         }
  142.                         LCD_ShowxNum(30,165,calendar.hour,2,16,0x80);                //显示时                                                          
  143.                         LCD_ShowxNum(54,165,calendar.min,2,16,0x80);                //显示分                                                          
  144.                         LCD_ShowxNum(78,165,calendar.sec,2,16,0x80);                //显示秒
  145.                         LED0=!LED0;
  146.                 }       
  147.                 delay_ms(10);
  148.                
  149. //显示图片
  150.                 while(1)
  151.                 {                  
  152.                         if(i==0)
  153.                         {
  154.                                 image_display(5,255,(u8*)gImage_image1);//在指定地址显示图片
  155.                         }
  156.                         i++;
  157.                         if(i>10)i=0;
  158.                         LED0=!LED0;       
  159.                         break;       
  160.                 }
  161.        
  162.         };


  163.                
  164. }
复制代码

所有资料51hei提供下载:
修改TFT图文显示.7z (308.98 KB, 下载次数: 52)

评分

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

查看全部评分

回复

使用道具 举报

ID:611378 发表于 2020-5-7 19:38 | 显示全部楼层
顶,好,可以 完美
回复

使用道具 举报

ID:918601 发表于 2021-5-10 16:20 来自手机 | 显示全部楼层
我买了stm32开发板,准备试试。
回复

使用道具 举报

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

本版积分规则

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

Powered by 单片机教程网

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