国产免费AV|泡泡玛特欧洲总部将设在伦敦|中文天堂网www新版资源在线|一本久道综合在线中文|国精产品一二三产区的使用方法|香蕉鱼在线观看|www.27eee

ELEOK

標(biāo)題: stm32 0.96寸OLED時(shí)鐘程序,萬(wàn)年歷,大字體 [打印本頁(yè)]

作者: 路漫漫    時(shí)間: 2020-5-24 01:10
標(biāo)題: stm32 0.96寸OLED時(shí)鐘程序,萬(wàn)年歷,大字體
stm32自帶的RTC時(shí)鐘。硬件連接很簡(jiǎn)單,當(dāng)然程序也是比較簡(jiǎn)單的,只寫了溫度(DS18B20),stm32自帶RTC和OLED顯示,大家可自行刪改功能。
硬件連接:
      SDA --》PB13
      SCL --》PB12
DS18B20----》PA15
OLED和DS18B20直接5V供電就成,代碼和工具都在最后,需要的小伙伴自行下載吧。
程序代碼.7z (227.01 KB, 售價(jià): 1 E幣)
取模教程.zip (1.25 MB, 售價(jià): 1 E幣)

效果如下:


部分代碼:
  1. #include "sys.h"
  2. #include "usart.h"               
  3. #include "delay.h"        
  4. #include "led.h"
  5. #include "key.h"
  6. #include "oled.h"
  7. #include "beep.h"
  8. #include "rtc.h"
  9. #include "ds18b20.h"

  10. u8 year_buf[4];
  11. u8 month_buf[2];
  12. u8 day_buf[2];
  13. u8 temp_buf[4];

  14. int main(void)
  15. {               
  16.         u16 temp;
  17.         delay_init();             //延時(shí)初始化
  18.         NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);//設(shè)置中斷優(yōu)先級(jí)分組為組2:2位搶占優(yōu)先級(jí),2位響應(yīng)優(yōu)先級(jí)
  19.     Gpio_IIC_Init();
  20.         RTC_Init();                                  //RTC初始化
  21.         DS18B20_Init();
  22.         OLED_Init();
  23.         delay_ms(200);
  24.         OLED_CLS();
  25.         OLED_P16x16Ch(40,0,36);//第一行第三列顯示年
  26.         OLED_P16x16Ch(72,0,37);        //顯示月
  27.         OLED_P16x16Ch(106,0,38);        //顯示日
  28.         OLED_P16x16Ch(0,6,39);//星
  29.         OLED_P16x16Ch(16,6,41);//期
  30.         OLED_P16x16Ch(32,2,34);
  31.         OLED_P16x16Ch(32,4,35);//:
  32.         OLED_P16x16Ch(80,2,34);
  33.         OLED_P16x16Ch(80,4,35);//:
  34.         while(1)
  35.         {
  36.                 sprintf((char *)year_buf,"%04d",calendar.w_year);
  37.                 OLED_P8x16Str(8,0,year_buf);
  38.                 sprintf((char *)month_buf,"%02d",calendar.w_month);
  39.                 OLED_P8x16Str(58,0,month_buf);
  40.                 sprintf((char *)day_buf,"%02d",calendar.w_date);
  41.                 OLED_P8x16Str(90,0,day_buf);
  42.                
  43.                 OLED_P16x16Ch(0,2,calendar.hour/10*2);
  44.                 OLED_P16x16Ch(0,4,calendar.hour/10*2+1); //
  45.                 OLED_P16x16Ch(16,2,calendar.hour%10*2);
  46.                 OLED_P16x16Ch(16,4,calendar.hour%10*2+1);//
  47.                
  48.                 OLED_P16x16Ch(48,2,calendar.min/10*2);
  49.                 OLED_P16x16Ch(48,4,calendar.min/10*2+1);//
  50.                 OLED_P16x16Ch(64,2,calendar.min%10*2);
  51.                 OLED_P16x16Ch(64,4,calendar.min%10*2+1);//
  52.                
  53.                 OLED_P16x16Ch(95,2,calendar.sec/10*2);
  54.                 OLED_P16x16Ch(95,4,calendar.sec/10*2+1);//
  55.                 OLED_P16x16Ch(111,2,calendar.sec%10*2);
  56.                 OLED_P16x16Ch(111,4,calendar.sec%10*2+1);//

  57.                 OLED_P16x16Ch(32,6,calendar.week+20);//
  58.                
  59.                 temp = DS18B20_Get_Temp();
  60.                 OLED_P16x16str(64,6,11);
  61.                 OLED_P16x16str(80,6,12);
  62.                 OLED_P16x16str(96,6,temp%1000/100);
  63.                 OLED_P16x16str(112,6,temp%100/10);

  64.         }
  65. }
復(fù)制代碼



作者: mini10000    時(shí)間: 2022-10-3 09:18
牛牛牛!!!!!!





歡迎光臨 ELEOK (http://m.afoofa.cn/) Powered by Discuz! X5.0