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;
}
相关推荐
AlfredZhao3 分钟前
用脚本按顺序执行初始化 DB 的 SQL 文件
linux
瑞克-桑切斯1 小时前
企业生产环境:https部署+nginx高可用(业务不中断)
linux·服务器·数据库
非凡ghost4 小时前
视频剪辑不用等渲染,这款开源工具让切分合并秒级完成
运维·电脑·软件需求
FII工业富联科技服务6 小时前
Omniverse 数字孪生与柔性自动化,如何破解产能与交付、设备与空间的双重困境?
运维·自动化·devops
润滑卫士6 小时前
油液介电常数在线监测:测量原理与油液老化状态评估方法
运维
Rock Chin6977 小时前
把 n8n 接进 Slack:在对话里 @机器人 触发自动化工作流
运维·机器人·自动化
浩浩测试一下8 小时前
Linux 底层知识点 1
linux·运维·服务器
Eloudy8 小时前
全文 - IMEX 第01节 -IMEX overview
运维·服务器·网络
物联网软硬件开发-轨物科技9 小时前
【技术白皮书】光伏清检一体化机器人系统解决方案技术白皮书
大数据·运维·网络·人工智能·机器人
Escalating_xu9 小时前
【Linux 网络编程】TCP 跨平台实战:用 Windows 客户端访问 Linux 服务器
linux·服务器·网络