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;
}
相关推荐
12点一刻2 分钟前
搭建自动化工作流:探寻解放双手的有效方案(1)
运维·人工智能·自动化·deepseek
Hi202402172 分钟前
自动化Trae Apollo参数解释的批量获取
运维·自动化·trae
sky丶Mamba38 分钟前
CMD,PowerShell、Linux/MAC设置环境变量
linux·运维·macos
运维开发王义杰1 小时前
打破技术债困境:从“保持现状”到成为变革的推动者
运维·职场和发展
工藤新一¹1 小时前
Linux 开发工具
linux·运维·服务器
W111115_1 小时前
网络综合实验
linux·运维·服务器·网络
cui_win1 小时前
【网络】Linux 内核优化实战 - net.ipv4.tcp_sack
linux·网络·tcp/ip
x县豆瓣酱1 小时前
ubuntu server远程连接
linux·运维·ubuntu
0wioiw01 小时前
Ubuntu基础(Python虚拟环境和Vue)
linux·python·ubuntu
山川绿水1 小时前
Ubuntu22.04更新Openssh至9.9p2无法正常连接,报错解决
服务器·web安全·网络安全