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;
}
相关推荐
!沧海@一粟!4 小时前
麒麟Zabbix Agent安装配置全攻略
linux·服务器·zabbix
鸠摩智首席音效师8 小时前
如何使用 docker exec 在容器中运行命令 ?
运维·docker·容器
似水এ᭄往昔8 小时前
【Linux】自动化构建-make/Makefile
linux·运维·服务器·ubuntu
顶点多余9 小时前
Linux“信号“从硬件到软件详解
linux·运维·服务器
勘察加熊人9 小时前
ai飞卢小说自动化处理工作流获得提问素材
运维·自动化
瀚高PG实验室10 小时前
rpm包安装报错:cannot open Packages index using db5 - Cannot allocate memory (12)
linux·运维·服务器·瀚高数据库
云计算老刘10 小时前
2. DNS 服务器
运维
水星灭绝10 小时前
win11+wsl2+docker
运维·docker·容器
追风少年王大爷丶10 小时前
nginx 配置无域名访问拒绝
运维·服务器·nginx
AI+程序员在路上10 小时前
嵌入式软件技术大全
linux·开发语言·arm开发·单片机