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;
}
相关推荐
Titan202435 分钟前
Linux网络基础知识
linux·服务器·网络·c++·学习
皮皮蟹虾饺43 分钟前
NCCL 源码解析:通信器从出生到消亡的完整一生
linux·人工智能·ubuntu·语言模型·kubernetes
Java&Develop1 小时前
QuantDinger 宝塔 Linux 部署完整指南
linux·运维·状态模式
RisunJan2 小时前
Linux命令-tcpdump(网络数据包捕获)
linux·网络·tcpdump
头茬韭菜2 小时前
第 9 篇:「Fluss 运维实战」—— 部署、监控与故障排查
运维·fluss
Titan20242 小时前
Linux网络学习:套接字、UDP的封装与应用
linux·服务器·开发语言·网络·c++
.冰块.2 小时前
两套完整 Linux 建站实战:Wordpress 博客(LAMP)+ECShop 电商(LNMP)全套手册
linux·运维·项目实战·lnmp·lamp·电商平台·博客平台
杨云龙UP2 小时前
生产环境MySQL多实例XtraBackup全量备份与rsync异地自动传输实践
linux·运维·数据库·mysql·xtrabackup·主从复制·备份恢复
XR1234567883 小时前
医院有线无线一体化运维选型指南
运维
拂拉氏3 小时前
【知识讲解】 Linux中vim编辑器的学习与使用
linux·编辑器·vim