GD32F103 — 13-硬件IIC在OLED上显示温度值

GD32F103 DRG GD-1 13-硬件IIC在OLED上显示温度值 示例

GD32F103 — 13-硬件IIC在OLED上显示温度值

来源: DRG GD-1 开发板例程
源文件: GD32/drg_gd_1_gd32f103c8t6-master/13-硬件IIC在OLED上显示温度值/test/APP/main.c

子模块

  • Firmware
  • test

关键代码

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <stdio.h>
#include "systick.h"
#include "usart_comm.h"
#include "i2c.h"
#include "lm75a_temp.h"
#include "oled_i2c.h"

int main(){
	float temp_result;
	char temp_string[80];

	systick_config();
	usart0_init(9600);
	i2c_init();
	
	oled_init();
	oled_clear_all();
	oled_show_string(24, 0, (uint8_t *)"genbotter", 16);

	while(1){
		temp_result = lm75a_get_temp();
		sprintf(temp_string, "temperature is: %.3f C.", temp_result);
		oled_show_string(0, 2, (uint8_t *)temp_string, 16);
		delay_1ms(1000);  //ȴ1s
	}
}
世界是你们
使用 Hugo 构建
主题 StackJimmy 设计