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;
}
相关推荐
进击的荆棘11 分钟前
Linux——基础指令(中)
linux·服务器·linux基础指令
b1305381004924 分钟前
鸿蒙应用开发实战【41】— 登录页面LoginPage完整开发
服务器·华为·harmonyos·鸿蒙系统
zt1985q31 分钟前
本地部署开源轻量级监控平台 Beszel 并实现外部访问
运维·服务器·网络协议·开源
BerryS3N35 分钟前
GitHub Actions自动化运维实战:从CI/CD到云端部署的完整指南
运维·自动化·github
L-影35 分钟前
Server-Sent Events (SSE):让服务器“主动开口”的实时推送技术
运维·服务器·sse
不能跑的代码不是好代码9 小时前
Linux系统常用命令中文速查表
linux·运维·服务器
石一峰69910 小时前
深入理解 Linux 中断三层机制与 1-Wire 时序锁原理
linux·运维·服务器
运维老郭10 小时前
PostgreSQL编译安装实战
运维·postgresql
无限码农11 小时前
Linux上通过cmake编译uchardet
linux·运维·服务器
运维大师12 小时前
【Linux运维极简教程】06-网络配置与管理
linux·运维