芯片解密|单片机解密|IC解密|芯片破解|芯片复制| PCB抄板|软件开发

飞芯科技-芯片解密|单片机解密|IC解密|芯片破解|芯片复制| PCB抄板|软件开发

单片机解密STM32HAL库软件IO口模拟IIC驱动OLED显示温湿度及RTC时间

单片机解密#include "sys.h"
单片机解密#include "delay.h"
单片机解密#include "usart.h"

#include "dht11.h"
#include "led.h"
//#include "lcd.h"
#include "soft_iic_oled.h"
#include "soft_iic.h"

#include "rtc.h"
//#include "usmart.h"

#include "stdio.h"     //printf函数头文件,将浮点数转换为字符串
//#include "sdio_sdcard.h"
//#include "text.h"
//#include "exfuns.h"
extern const uint8_t BMP1[];

uint8_t temperature;
uint8_t humidity;

char temp[6]={0};     //读出的温度暂存寄存器
char humi[6]={0};     //读出的湿度暂存寄存器

void dat_dis()        //温湿度数据处理转为字符串
{
     //humi[0]='R';
     //humi[1]=':';
     humi[0]=humidity/10+0x30;
     humi[1]=humidity%10+0x30;
     //humi[4]='%';   
     //humi[5]='\0';  //结束符,如果不要则后面会继续写数据

     //temp[0]='T';
     //temp[1]=':';
     temp[0]=temperature/10+0x30;
     temp[1]=temperature%10+0x30;
     //temp[4]='C';   
     //temp[5]='\0';  
}

int main(void)
{
                uint8_t t;
          /************************程序必备4项****************************/
          HAL_Init();                            /* 初始化HAL库 */
    sys_stm32_clock_init(RCC_PLL_MUL9);    /* 设置时钟, 72Mhz */
    delay_init(72);                        /* 延时初始化  */
    usart_init(115200);                    /* 串口初始化为115200 */
         /***********************所有外设初始化***************************/
          led_init();
          iic_init();
                oled_init();                                //OLED初始化
          //lcd_init();
        
                OLED_ShowPicture(0,0,128,64,BMP1,1);
          oled_refresh_gram();                 /*更新显示到OLED,只有此语句才会有显示*/
        
                rtc_init();                          //TRC初始化
        
          //exfuns_init();                       /* 为fatfs相关变量申请内存,必须初始化否则无汉字显示 */
    //f_mount(fs[0], "0:", 1);             /* 挂载SD卡 */
    //f_mount(fs[1], "1:", 1);             /* 挂载FLASH,必须挂载否则无汉字显示 */
//          while (fonts_init())                 /* 检查字库,必须初始化字库否则无汉字显示 */
//    {
//       lcd_clear(WHITE);                 /* 清屏 */
//                }
        
          rtc_set_alarm(2025, 6, 11, 12, 0, 0);  /* 设置一次闹钟12;0;0 */
        
        
    rtc_set_time(2025,6,11,11,50,42);       /* 2025-06-11; 11-50-42 */
        
          while (DHT11_Init())                   /* DHT11初始化 */
    {
        oled_show_string(10, 16, "DHT11 Error",16);
        delay_ms(200);  
    }
                        
                delay_ms(1000);                   //延时
                OLED_ColorTurn(0);                //0正常显示,1 反色显示
                OLED_DisplayTurn(0);              //0正常显示 1 屏幕翻转显示
                oled_clear();                     //清屏
                //OLCD显示时间
                /**************************************************/               
                OLED_ShowChinese(45,0,9,16);      //年,16X16字体显示        
          OLED_ShowChinese(70,0,10,16);     //月        
          OLED_ShowChinese(96,0,2,16);      //日        
          OLED_ShowChinese(0,48,11,16);     //温
          OLED_ShowChinese(13,48,13,16);    //度
          OLED_ShowChinese(69,48,12,16);    //湿
          OLED_ShowChinese(82,48,13,16);    //度
          OLED_ShowChinese(48,48,14,16);    //℃        
          OLED_ShowChinese(116,48,15,16);   //%               
          oled_refresh_gram();              /*更新显示到OLED,只有此语句才会有显示*/        
                /**************************************************/        
               
                //TFTLCD显示时间
        /**************************************************/               
//                text_show_string(10+4*16,    30, 200, 24, "年", 24, 0, RED);//“年”字前面4个数字,若显示24大小,则像素为12X24
//                text_show_string(10+6*16+32, 30, 200, 24, "月", 24, 0, RED);
//                text_show_string(10+8*16+64, 30, 200, 24, "日", 24, 0, RED);
//               
//                text_show_string(10+4*16,    80, 200, 24, "时", 24, 0, RED);
//                text_show_string(10+6*16+32, 80, 200, 24, "分", 24, 0, RED);
//                text_show_string(10+8*16+64, 80, 200, 24, "秒", 24, 0, RED);
//               
//                text_show_string(10,        120, 200, 24, "温度:   ℃", 24, 0, RED);
//                text_show_string(10,        160, 200, 24, "湿度:    %", 24, 0, RED);
                /**************************************************/               
                while(1)
          {               
                  delay_ms(10);
      DHT11_Read_Data(&temperature, &humidity);   /*读取温湿度值 */
      dat_dis();
                        //OLED显示温湿度
                        /**************************************************/
                  oled_show_string(32,51,temp,12);
                  oled_show_string(100,51,humi,12);
                        //oled_show_num(32,51,temp[0],1,12);
      //oled_show_num(40,51,temp[1],1,12);
      //oled_show_num(100,51,humi[0],1,12);
      //oled_show_num(108,51,humi[1],1,12);
                         oled_refresh_gram();     /*更新显示到OLED,只有此语句才会有显示*/        
                        /**************************************************/
                        
                        //TFTLCD显示温湿度


联系方式

地址:石家庄市新华区民族路77号华强广场D座2009
电话:0311-88816616/87087811
手机:13315190088
传真:0311-67901001
联系人:张工
网址:www.feixindz.com
邮箱:feixindz@163.com
微信:xinpianjiemi
QQ:527263666/568069805

在线客服
热线电话

企业微信