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;
}
相关推荐
IP搭子来一个24 分钟前
2026年动态IP代理怎么选:共享好还是独享好?
服务器·网络协议·tcp/ip
比奇堡派星星1 小时前
awk命令
linux·运维·服务器
WW、forever1 小时前
【服务器】上传百度网盘数据至服务器
运维·服务器
清水白石0081 小时前
Python 柯里化完全指南:从函数式思想到工程实践
linux·服务器·python
m0_694845571 小时前
netcut 是什么?简单安全的在线剪贴板搭建与使用教程
运维·服务器·安全·开源·云计算·github
女王大人万岁2 小时前
Golang标准库 CGO 介绍与使用指南
服务器·开发语言·后端·golang
宸迪2 小时前
【python】使用uv管理项目包依赖
linux·python·uv
网云工程师手记3 小时前
DDNS-Go部署与使用体验:动态公网IP远程访问不再断
运维·服务器·网络·网络协议·网络安全
HalvmånEver3 小时前
Linux:基于信号量的环形队列与生产者消费者模型(一)
linux·运维·服务器·信号量
海兰4 小时前
手把手elasticsearch学习增删改查之“增”
运维·jenkins