Linux Oled显示字符

cpp 复制代码
/*
 * Copyright (c) 2015, Vladimir Komendantskiy
 * MIT License
 *
 * SSD1306 demo of block and font drawing.
 */

//
// fixed for OrangePiZero by HypHop
//

#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, "LiNan:");
	disp->font = font2;

	oled_putstrto(disp, 20, 9+10, "May your birthday   ");
    disp->font = font2;

	oled_putstrto(disp, 0, 9+20, "be full of laughter. ");
	disp->font = font2;

	oled_putstrto(disp,50,9+30,"---2025.1.16");

	oled_send_buffer(disp);

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_show(&disp);

	return 0;
}
相关推荐
木白CPP26 分钟前
USB(一): USB 概述&&介绍
linux·网络·嵌入式硬件
熬夜敲代码的猫27 分钟前
Linux:进程概念
linux
刘胡子大叔31 分钟前
1Panel 部署 ThinkPHP8 踩坑实录
linux·ubuntu
anew___37 分钟前
《从零手写操作系统 (21):用户态C运行时——从裸ELF到printf》
linux·服务器·c语言
吴声子夜歌1 小时前
Nginx应用与运维——Nginx编译及部署(部署)
java·运维·nginx
帷幕落秋1 小时前
Redis主从复制
运维·数据库
帷幕落秋1 小时前
Mysql主从复制
运维·数据库
暖核1 小时前
MySQL 高级运维核心:备份恢复、主从复制与 MHA 高可用复习总结
运维·数据库·mysql
jackletter1 小时前
linux:systemd之守护进程
linux·运维·服务器·systemd
用户4107192013251 小时前
VMware 虚拟机 Ubuntu 无法连接网络
linux