香橙派开发板Orange Pi 5在Linux系统下如何使用I2C点亮OLED屏幕

安装wiringOP库

我们找一个目录

git clone https://github.com/orangepi-xunlong/wiringOP.git
cd wiringOP/
./build

这样你就把wiringOP库安装好了

常用命令
gpio readall 查看引脚

检测i2c有没有开启/打开

我们首先看看OrangePi_5_RK3588S_用户手册_v2.0,这里面有不同的引脚功能图,文件在最后可下载

我们可以 orangepi-config -> System -> Hardware -> save -> 重启

我在16 18引脚插入了一个设备 运行i2cdetect -y 1 可以看到地址

这个1是/dev/i2c-1

我在16 18引脚插入了一个设备 运行i2cdetect -y 1 可以看到地址

这个1是/dev/i2c-1

后面测试i2c参考这学习笔记4 orangepi的i2c和oled屏幕显示_orange pi zero3 oled scl-CSDN博客

#include <errno.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <stdint.h>
 
#include "oled.h"
#include "font.h"
 
int oled_show(struct display_info *disp) {
	int i;
	char buf[100];
 
	oled_putstrto(disp, 0, 9+1, "Welcome       to");
	disp->font = font1;
 
	oled_putstrto(disp, 0, 9+9, "orangepi i2c oled");
	disp->font = font3;
 
	oled_send_buffer(disp);
 
return 0;
}
 
void show_usage(char *progname) {
	printf("\nUsage:\n%s <I2C bus device node >\n", progname);
}
 
int main(int argc, char **argv) {
	int e;
	char filename[32];
	struct display_info disp;
 
	if (argc < 2) {
		show_usage(argv[0]);
		
		return -1;
	}
 
	memset(&disp, 0, sizeof(disp));
	sprintf(filename, "%s", argv[1]);
	disp.address = OLED_I2C_ADDR;
	disp.font = font2;
 
	e = oled_open(&disp, filename);
 
		e = oled_init(&disp);
	oled_show(&disp);
	return 0;
}

OrangePi_5_RK3588S_用户手册_v2.0

链接: https://pan.baidu.com/s/1X2uWDIXXJJvcGogtrqby2Q?pwd=u4xf 提取码: u4xf

详情移步到我的个人网站phlqj.top

 香橙派每秒刷新一次OLED屏幕,显示CPU温度、CPU使用率、GPU使用率和NPU使用率

  • 10
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值