#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];
//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结构体中
disp->font = font1;//设置字体
oled_putstrto(disp,0,20,"-----MR.YU-----");
disp->font=font1;
oled_send_buffer(disp);//把缓存拷贝到oled屏幕
//oled_putpixel(disp, 60, 45);
//oled_putstr(disp, 1, "hello");
return 0;
}
void show_error(int err, int add) {//在运行时必须打开相关的设备驱动 否则出错
//const gchar* errmsg;
//errmsg = g_strerror(errno);
printf("\nERROR: %i, %i\n\n", err, add);
//printf("\nERROR\n");
}
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
oled_show(&disp);//显示
return 0;
}
orangepiZero2 最简单的oled开发
最新推荐文章于 2024-05-28 17:23:14 发布