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;
}
相关推荐
RH2312112 分钟前
2026.5.12 Linux
java·linux·数据结构
cen__y16 分钟前
Linux11(网络编程)
linux·运维·服务器·c语言·网络·网络协议·tcp/ip
ITKEY_25 分钟前
archlinux x11桌面 部分程序识别成Wayland
linux
CableTech_SQH40 分钟前
商业地产和高端酒店该怎么选综合布线解决方案?
运维·服务器·网络
Y\43 分钟前
VMware虚拟机已断开连接解决方法(二)
服务器
isyangli_blog1 小时前
vmware 安装 Windows Server 2012
服务器
怀旧,1 小时前
【Linux网络编程】9. 数据链路层
linux·服务器·网络
QotomPC1 小时前
Qotom Q30900GP多网口Mini PC:16网口设计在pfSense与工业网络中的应用
服务器·网络·边缘计算
用户2367829801681 小时前
Linux watch 命令深度解析:从实时监控到变化检测的完整实现
linux
xingyuzhisuan2 小时前
哪里可以一键部署Stable Diffusion XL的GPU云环境?(2026实测指南)
运维·人工智能·stable diffusion·gpu算力