
5. OLED 屏应用 -IIC 协议
5.1 OLED 屏幕

5.2 Orangepi 的 IIC 接口
由 26pin 的原理图可知, Orange Pi Zero 2 可用的 i2c 为 i2c3

启动 linux 系统后, 先确认下 /dev 下存在 i2c-3 的设备节点
从命令运行结果能观察到系统支持 I2C-3 和 I2C-5 的驱动,而 H616 的外设我们看到只有一个 IIC 接口,用的是IIC-3Linux一切皆文件,每个硬件设备 “ 对应 ” 一个文件,由驱动程序提供映射

开始测试 i2c , 首先安装 i2c-tools
sudo apt-get install i2c-tools

4.2 OLED 功能代码阅读
sourceInsight ,SN 码: SI3US-361500-17409 支持正版,如果这个码不能用,自行百度
#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_demo(struct display_info *disp) {
int i;
char buf[100];
//putstrto(disp, 0, 0, "Spnd spd 2468 rpm");
// oled_putstrto(disp, 0, 9+1, "Spnd cur 0.46 A");
oled_putstrto(disp, 0, 9+1, "Welcome to");
disp->font = font1;
// oled_putstrto(disp, 0, 18+2, "Spnd tmp 53 C");
oled_putstrto(disp, 0, 18+2, "----OrangePi----");
disp->font = font2;
// oled_putstrto(disp, 0, 27+3, "DrvX tmp 64 C");
oled_putstrto(disp, 0, 27+3, "This is 0.96OLED");
oled_putstrto(disp, 0, 36+4, "");
oled_putstrto(disp, 0, 45+5, "");
disp->font = font1;
// oled_putstrto(disp, 0, 54, "Total cur 2.36 A");
oled_putstrto(disp, 0, 54, "*****************");
oled_send_buffer(disp);
disp->font = font3;
for (i=0; i<100; i++) {
sprintf(buf, "Spnd spd %d rpm", i);
oled_putstrto(disp, 0, 0, buf);
oled_putstrto(disp, 135-i, 36+4, "===");
oled_putstrto(disp,