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;
}
相关推荐
jiayi_199918 分钟前
Linux 容器安装 conda 和 pip
linux·conda·pip
半夏知半秋40 分钟前
mongodb的复制集整理
服务器·开发语言·数据库·后端·学习·mongodb
一周困⁸天.1 小时前
Redis 主从复制
linux·redis
ayaya_mana1 小时前
CentOS 7/8/9 一键安装 Python 3.10+ 并配置默认版本
linux·python·centos
The Chosen One9851 小时前
【Linux】Linux权限讲解 :写给文件的一封情书
linux·运维·服务器
IT 小阿姨(数据库)2 小时前
PostgreSQL pg_stat_bgwriter 视图各个字段详解
linux·数据库·sql·postgresql·centos
风语者日志2 小时前
[LitCTF 2023]Vim yyds
linux·编辑器·vim
Thexhy2 小时前
在centos 7上配置FIP服务器的详细教程!!!
linux·运维·centos
chao1898443 小时前
C 文件操作全解速览
服务器·c语言·c#
FJW0208143 小时前
DevOps——CI/CD持续集成与持续交付/部署的理解与部署
运维·ci/cd·devops