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;
}
相关推荐
GL_Rain4 分钟前
快速搭建Halo博客 + 崩溃秒恢复方案(Docker极简部署)
运维·docker·容器
不做无法实现的梦~8 分钟前
Linux 上使用 CLion 开发嵌入式,并用 Codex CLI
linux·运维·服务器
张32326 分钟前
Ansible拆分大型Playbook
linux·ansible
被摘下的星星1 小时前
以太网技术
服务器·网络
卓豪终端管理1 小时前
两种终端数据清除策略的技术笔记:企业定向清除 vs 完全擦除
运维·自动化
lulukanshijie2 小时前
Packer 入门:自动化镜像构建工具
运维·其他·自动化
苦逼大学生被编程薄纱2 小时前
Ext 文件系统基础:Linux 存储基石入门(下)
linux·运维·服务器
Lumos_7772 小时前
Linux -- 进程
linux·运维·服务器
南境十里·墨染春水2 小时前
linux学习进展 进程间通讯——共享内存
linux·数据库·学习
李白你好2 小时前
RedTeam-Agent无需手动操作,AI 接管所有渗透工具,让安全测试真正自动化
运维·人工智能·自动化