标题: stm32f103显示温度到oled程序 [打印本页]

作者: Engou    时间: 2018-10-2 08:52
标题: stm32f103显示温度到oled程序
  1. #include "stm32f10x.h" //STM32头文件
  2. #include "sys.h"
  3. #include "delay.h"
  4. #include "lm75a.h"

  5. #include "oled0561.h"

  6. int main (void){//主程序
  7.         u8 buffer[3];
  8.         delay_ms(100); //上电时等待其他器件就绪
  9.         RCC_Configuration(); //系统时钟初始化

  10.         I2C_Configuration();//I2C初始化
  11.         LM75A_GetTemp(buffer); //读取LM75A的温度数据

  12.         OLED0561_Init(); //OLED初始化
  13.         OLED_DISPLAY_LIT(100);//亮度设置

  14.         OLED_DISPLAY_PIC1();//显示全屏图片
  15.         delay_ms(1000); //延时
  16.         OLED_DISPLAY_CLEAR();
  17.         OLED_DISPLAY_8x16_BUFFER(0,"   YoungTalk "); //显示字符串
  18.         OLED_DISPLAY_8x16_BUFFER(6,"  Temp:"); //显示字符串

  19.         OLED_DISPLAY_16x16(2,2*16,0);//汉字显示         测试成功
  20.         OLED_DISPLAY_16x16(2,3*16,1);
  21.         OLED_DISPLAY_16x16(2,4*16,2);
  22.         OLED_DISPLAY_16x16(2,5*16,3);

  23.         /*while(1){
  24.                 LM75A_GetTemp(buffer); //读取LM75A的温度数据
  25.                         
  26.                 if(buffer[0])OLED_DISPLAY_8x16(6,7*8,'-'); //如果第1组为1即是负温度
  27.                 OLED_DISPLAY_8x16(6,8*8,buffer[1]/10+0x30);//显示温度值
  28.                 OLED_DISPLAY_8x16(6,9*8,buffer[1]%10+0x30);//
  29.                 OLED_DISPLAY_8x16(6,10*8,'.');//
  30.                 OLED_DISPLAY_8x16(6,11*8,buffer[2]/10+0x30);//
  31.                 OLED_DISPLAY_8x16(6,12*8,buffer[2]%10+0x30);//
  32.                 OLED_DISPLAY_8x16(6,13*8,'C');//

  33.                 delay_ms(200); //延时
  34.         }*/
  35. }
复制代码

OLED屏汉字与图片显示程序.rar

338.03 KB, 下载次数: 103, 下载积分: 黑币 -5

源代码


作者: ebingyu    时间: 2018-10-11 15:59
学习了
作者: sucen    时间: 2020-5-4 10:51
真的很厉害很赞。学习了




欢迎光临 (http://www.51hei.com/bbs/) Powered by Discuz! X3.1