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;
}
相关推荐
沫璃染墨几秒前
《从零入门Linux系统篇(五十一):线程篇·四——pthread线程库详解:从线程创建到终止与分离》
linux·运维·服务器·开发语言·c++·系统架构·线程
YYRAN_ZZU3 分钟前
GMSL开发加解串配置介绍
linux·嵌入式硬件
墨家前任巨子11 分钟前
定时关机脚本
运维
云计算练习生12 分钟前
什么是上下文切换?进程切换时 CPU 到底在保存什么
linux·服务器·操作系统·进程切换
用户05101225729613 分钟前
RGA(二)——RK3588 的核拓扑与能力差异
linux·嵌入式
ESDWAN14 分钟前
企业组网后网络频繁掉线,常见故障排查指南
运维·网络·架构
用户05101225729614 分钟前
RGA(一)——基础知识
linux·嵌入式
qetfw18 分钟前
Debian 综合服务实训:Apache2、Samba、LDAP、vsftpd 与 OpenVPN
linux·服务器·debian
用户05101225729619 分钟前
RGA(三)——实宽高、虚宽高与对齐约束
linux·嵌入式
fastjson_28 分钟前
帆软看板 - 问题收集
linux·前端·javascript