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;
}
相关推荐
还鮟29 分钟前
靶机远程控制实验命令与入门实践(Linux)
linux·网络·安全
TG:@yunlaoda360 云老大1 小时前
华为云国际站代理商备份策略设置过程中遇到问题如何解决?
服务器·数据库·华为云
手揽回忆怎么睡1 小时前
Alibaba Linux 8安装jdk25
linux·运维·服务器
❀͜͡傀儡师1 小时前
docker一键部署网页版Win11系统
运维·docker·容器
2301_800050992 小时前
华为云介绍
运维·华为云
爱潜水的小L2 小时前
自学嵌入式day39,抓包
linux
萌萌哒草头将军2 小时前
AudioDock:服务器和 NAS 音频播放最棒的软件!🚀🚀🚀
服务器·docker·node.js
lifewange3 小时前
测试场景 Linux 命令速查表
linux·运维·服务器
Vect__3 小时前
进程控制详解
linux·驱动开发
就叫飞六吧3 小时前
JSONPath“隔空取物”思想,直击JSON深处的目标字段
服务器·windows·json