STM32之LCD_ShowString()函数

LCD_ShowString(10,50,260,16,16,"Love")
10:表示字符在LCD显示的横轴x的起始坐标

50:表示字符在LCD显示的纵轴y的起始坐标

260:表示显示的字符串的长度设置

16,16:表示显示字符串字体的大小,可设置为12/16/24

  • 24
    点赞
  • 71
    收藏
    觉得还不错? 一键收藏
  • 6
    评论
#include "led.h" #include "delay.h" #include "key.h" #include "sys.h" #include "lcd.h" #include "usart.h" #include "dht11.h" uint32_t length; // 存储距离的变量 float leng; // 存储距离的变量(浮点数) u8 temp,humi; // 存储温度和湿度的变量 u8 bufe[5]; int main(void) { u8 x=0; u32 lcd_id[12]; //存放LCD ID字符串 delay_init(); //延时函数初始化 //NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2); //设置NVIC中断分组2:2位抢占优先级,2位响应优先级 uart_init(115200); //串口初始化为115200 LED_Init(); //LED端口初始化 LCD_Init(); POINT_COLOR=RED; sprintf((char*)lcd_id,"LCD ID:%04X",lcddev.id);//将LCD ID打印到lcd_id数组。 while(1) { // // leng = Hcsr04GetLength(); // 获取距离 DHT11_Read_Data(&temp,&humi); // 获取温湿度数据 bufe[0] = temp; // 保存温度数据 bufe[1] = humi; // 保存湿度数据 bufe[2] = 45; // 保存固定值 length = leng * 100; // 将距离转换为整型 POINT_COLOR=RED; LCD_ShowString(30,70,200,16,16,"wen:"); LCD_ShowString(30,90,200,16,16,"shi:"); LCD_ShowString(30,110,200,16,16,"length/1000"); LCD_ShowString(30,130,200,16,16,"length%1000/100"); LCD_ShowString(170,130,210,16,16,":"); LCD_ShowString(30,170,200,16,16,"length%100/10"); LCD_ShowString(30,190,200,16,16,"length%10/1"); LCD_ShowxNum(60,70,bufe[0],4,16,1); LCD_ShowString(100,70,200,16,16,"C"); LCD_ShowxNum(60,90,bufe[1],4,16,1); LCD_ShowString(100,90,200,16,16,"%"); x++; if(x==12)x=0; LED0=!LED0; delay_ms(1000); } }加注释
06-12
这是一段使用了多个外设的 STM32F4 程序,主要实现了通过超声波测距、DHT11 温湿度传感器获取环境数据,并在 LCD 上显示。下面是代码的注释: ```c #include "led.h" // LED 相关函数库 #include "delay.h" // 延时函数库 #include "key.h" // 按键函数库 #include "sys.h" // 系统函数库 #include "lcd.h" // LCD 相关函数库 #include "usart.h" // 串口函数库 #include "dht11.h" // DHT11 温湿度传感器函数库 uint32_t length; // 存储距离的变量 float leng; // 存储距离的变量(浮点数) u8 temp,humi; // 存储温度和湿度的变量 u8 bufe[5]; // 存储传感器数据的数组 int main(void) { u8 x=0; u32 lcd_id[12]; // 存放 LCD ID 字符串 delay_init(); // 延时函数初始化 uart_init(115200); // 串口初始化为 115200 LED_Init(); // LED 端口初始化 LCD_Init(); // LCD 初始化 POINT_COLOR=RED; // 设置字体颜色为红色 sprintf((char*)lcd_id,"LCD ID:%04X",lcddev.id); // 将 LCD ID 打印到 lcd_id 数组 while(1) { leng = Hcsr04GetLength(); // 获取距离 DHT11_Read_Data(&temp,&humi); // 获取温湿度数据 bufe[0] = temp; // 保存温度数据 bufe[1] = humi; // 保存湿度数据 bufe[2] = 45; // 保存固定值 length = leng * 100; // 将距离转换为整型 // 在 LCD 上显示各项数据 POINT_COLOR=RED; LCD_ShowString(30,70,200,16,16,"wen:"); LCD_ShowString(30,90,200,16,16,"shi:"); LCD_ShowString(30,110,200,16,16,"length/1000"); LCD_ShowString(30,130,200,16,16,"length%1000/100"); LCD_ShowString(170,130,210,16,16,":"); LCD_ShowString(30,170,200,16,16,"length%100/10"); LCD_ShowString(30,190,200,16,16,"length%10/1"); LCD_ShowxNum(60,70,bufe[0],4,16,1); LCD_ShowString(100,70,200,16,16,"C"); LCD_ShowxNum(60,90,bufe[1],4,16,1); LCD_ShowString(100,90,200,16,16,"%"); x++; // 控制 LED 闪烁 if(x==12)x=0; LED0=!LED0; delay_ms(1000); // 延时 1 秒 } } ```
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值