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;
}
相关推荐
悟空码字30 分钟前
部署Spring Boot项目到Linux服务器数据盘
linux·spring boot·部署·数据盘
Once_day2 小时前
Linux之rsyslog(6)RainerScript
linux·服务器·syslog
Shylock_Mister3 小时前
Linux C线程编程全指南
linux·运维·c语言
心灵宝贝3 小时前
CentOS 7 安装 unzip-6.0-21.el7.x86_64.rpm 步骤详解(附安装包)
linux·服务器·centos
q***13343 小时前
在linux(Centos)中Mysql的端口修改保姆级教程
linux·mysql·centos
Autism....4 小时前
服务器理解
运维·服务器
Starry_hello world4 小时前
Linux 文件缓冲区
linux
天亮之前_ict4 小时前
【故障排查】intel 服务器安装Win server 2019蓝屏解决方法
运维·服务器
牢七4 小时前
操作系统。
linux
SongYuLong的博客4 小时前
openwrt源码编译环境搭建-安装Luci
linux·嵌入式硬件