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;
}
相关推荐
别动我齐刘海2 分钟前
C++ 工程化学习
java·linux·前端·c++·学习·机器学习·机器人
wewowilling2 小时前
认识微服务
java·运维·微服务·springcloud
玖石书2 小时前
Ubuntu 24.04 UFW 全命令攻略:从入门到端口开放实战
linux·运维·ubuntu
xiaoqiMikko2 小时前
Linux 实战(七):useradd、sudoers、umask、SGID、软链 —— 三台真机实测
linux·centos
weifont4 小时前
自动化抓取和上架商品:能不动手,就少动手
运维·前端·自动化
拂拉氏4 小时前
【知识讲解】 Linux之动静态库的了解
linux·运维·服务器·动静态库
Fcy6484 小时前
Linux下 五种IO模型的认识与⾮阻塞IO的实现
linux·服务器·io
Mikko75 小时前
Linux 重启后日志没了?进程被 OOM 杀了去哪看?logrotate 之后日志还往旧文件写?三台真机实测日志与性能排查
linux·运维·centos
书生执笔画浮沉5 小时前
分享一个开源小工具CAdapt
linux·c·gnu·glibc·kernel·升级·灵感
光依旧5 小时前
发版就掉请求?Spring Boot优雅停机的四步
运维·spring boot·nginx·高可用·优雅停机·mcp server