最小系统板开发板STM32F103无SD卡用片内flash显示汉字、图片、时钟
单片机源程序如下:
- #include "led.h"
- #include "delay.h"
- #include "key.h"
- #include "sys.h"
- #include "lcd.h"
- #include "usart.h"
- #include "image2lcd.h"
- #include "stdlib.h"
- #include "text.h"
- #include "usmart.h"
- #include "rtc.h"
-
- extern const u8 gImage_image1[];//图片数据(包含信息头),存储在image1.c里面.
- int main(void)
- {
- u8 t=0;
- u8 i=0;
- NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);//设置中断优先级分组为组2:2位抢占优先级,2位响应优先级
- LED_Init(); //LED端口初始化
- usmart_dev.init(SystemCoreClock/1000000); //初始化USMART
- RTC_Init();
- delay_init(); //延时初始化
- NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);// 设置中断优先级分组2
- LED_Init(); //初始化与LED连接的硬件接口
- uart_init(115200);
- LCD_Init();
- // LCD_Clear(GRAY);
-
- POINT_COLOR=RED;
- LCD_Show_Font(20,10,0); //显示智能螃蟹投食器
- LCD_Show_Font(50,10,1);
- LCD_Show_Font(80,10,2);
- LCD_Show_Font(110,10,3);
- LCD_Show_Font(140,10,4);
- LCD_Show_Font(170,10,5);
- LCD_Show_Font(200,10,6);
- POINT_COLOR=BLACK;
- LCD_Show_Font(30,45,7); //饲料重量:
- LCD_Show_Font(50,45,8);
- LCD_Show_Font(70,45,9);
- LCD_Show_Font(90,45,10);
- LCD_Show_Font(110,45,11);
-
- LCD_Show_Font(30,70,12); //出料速度:
- LCD_Show_Font(50,70,13);
- LCD_Show_Font(70,70,14);
- LCD_Show_Font(90,70,15);
- LCD_Show_Font(110,70,16);
-
- LCD_Show_Font(30,95,17); //预计投喂时长:
- LCD_Show_Font(50,95,18);
- LCD_Show_Font(70,95,19);
- LCD_Show_Font(90,95,20);
- LCD_Show_Font(110,95,21);
- LCD_Show_Font(130,95,22);
- LCD_Show_Font(150,95,23);
-
- POINT_COLOR=BLUE;
- LCD_Show_Font(75,265,24); //显示上海海洋大学
- LCD_Show_Font(100,265,25);
- LCD_Show_Font(125,265,26);
- LCD_Show_Font(150,265,27);
- LCD_Show_Font(175,265,28);
- LCD_Show_Font(200,265,29);
-
- POINT_COLOR=BLUE;
- LCD_ShowString(72,295,150,12,12,"Shanghai Ocean University");
- POINT_COLOR=BLUE;
- LCD_ShowString(120,49,200,16,16," 50Kg"); //数据
- LCD_ShowString(120,74,200,16,16," 10g/s");
- LCD_ShowString(160,99,200,16,16," 1-1.5h");
-
-
- ///////////////////////////////////////////////////////////////////////////////////////////////////
- POINT_COLOR=RED;
- LCD_ShowString(180,55,200,24,24,"^_^"); //显示字符串(x,y,长度,大小,大小,字符串)
- // LCD_ShowString(60,80,200,16,16,"Shanghai");
- // LCD_ShowString(60,100,200,16,16,"Ocean University");
- POINT_COLOR=BLACK;
- // LCD_ShowString(32,120,200,12,12,"2019/6/10");
-
- LCD_Fill(20,200,110,220,999); //颜色块1 (x1,y1, x2,y2, cplor)
- LCD_Fill(110,200,220,220,777); //颜色块2
- LCD_Fill(20,221,110,240,555); //颜色块3
- LCD_Fill(110,221,220,240,333); //颜色块4
-
-
- POINT_COLOR=GREEN;
- LCD_DrawLine(0, 37,238,37); //画绿线1 (x1,y1, x2,y2)
- // LCD_DrawLine(0,140,240,140); //画绿线2
- POINT_COLOR=BLUE;
- LCD_DrawLine(65,258,240,258); //画蓝线
-
- /* POINT_COLOR=BLUE;
- LCD_DrawRectangle(30, 150, 60, 180); //画矩形 (x1,y1, x4,y4)
- LCD_Draw_Circle(85,165,15); //画圆 (x1,y1,r)
- LCD_ShowxNum(29,188,888888888,9,12,0x80); //显示数字 (x1,y1,数字,字数,大小,方式)
- LCD_Color_Fill(110,150,150,190,(u16*)1234); //填充彩色块
- */
- POINT_COLOR=BLUE;
- LCD_DrawLine(165,158,215,158); //画五角星
- LCD_DrawLine(190,140,170,180);
- LCD_DrawLine(190,140,210,180);
- LCD_DrawLine(165,158,210,180);
- LCD_DrawLine(215,158,170,180);
- //显示时间
- POINT_COLOR=BLACK;//设置字体为颜色
- LCD_ShowString(30,130,200,16,16," - - "); //年:月:日
- LCD_ShowString(30,165,200,16,16," : : "); //时:分:秒
- while(1)
- {
- if(t!=calendar.sec)
- {
- t=calendar.sec;
- LCD_ShowNum(30,130,calendar.w_year,4,16); //显示年
- LCD_ShowxNum(70,130,calendar.w_month,2,16,0x80); //显示月
- LCD_ShowxNum(94,130,calendar.w_date,2,16,0x80); //显示日
- switch(calendar.week) //显示星期
- {
- case 0:
- LCD_ShowString(30,148,200,16,16,"Sunday ");
- break;
- case 1:
- LCD_ShowString(30,148,200,16,16,"Monday ");
- break;
- case 2:
- LCD_ShowString(30,148,200,16,16,"Tuesday ");
- break;
- case 3:
- LCD_ShowString(30,148,200,16,16,"Wednesday");
- break;
- case 4:
- LCD_ShowString(30,148,200,16,16,"Thursday ");
- break;
- case 5:
- LCD_ShowString(30,148,200,16,16,"Friday ");
- break;
- case 6:
- LCD_ShowString(30,148,200,16,16,"Saturday ");
- break;
- }
- LCD_ShowxNum(30,165,calendar.hour,2,16,0x80); //显示时
- LCD_ShowxNum(54,165,calendar.min,2,16,0x80); //显示分
- LCD_ShowxNum(78,165,calendar.sec,2,16,0x80); //显示秒
- LED0=!LED0;
- }
- delay_ms(10);
-
- //显示图片
- while(1)
- {
- if(i==0)
- {
- image_display(5,255,(u8*)gImage_image1);//在指定地址显示图片
- }
- i++;
- if(i>10)i=0;
- LED0=!LED0;
- break;
- }
-
- };
-
- }
复制代码
所有资料51hei提供下载:
修改TFT图文显示.7z
(308.98 KB, 下载次数: 52)
|