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;
}
相关推荐
w***Q3502 小时前
Git工作流自动化
运维·git·自动化
qq_401700412 小时前
嵌入式用Unix时间的优势及其C语言转换
服务器·c语言·unix
xu_yule4 小时前
Linux_12(进程信号)内核态和用户态+处理信号+不可重入函数+volatile
linux·运维·服务器
虾..5 小时前
Linux 环境变量&&进程优先级
linux·运维·服务器
i***t9195 小时前
Linux下MySQL的简单使用
linux·mysql·adb
偶像你挑的噻5 小时前
11-Linux驱动开发-I2C子系统–mpu6050简单数据透传驱动
linux·驱动开发·stm32·嵌入式硬件
稚辉君.MCA_P8_Java6 小时前
DeepSeek 插入排序
linux·后端·算法·架构·排序算法
数据库学啊6 小时前
团队小希望运维简单,时序数据库选型有什么推荐?
运维·数据库·时序数据库
霍格沃兹软件测试开发7 小时前
Playwright MCP浏览器自动化指南:让AI精准理解你的命令
运维·人工智能·自动化
郝学胜-神的一滴7 小时前
Linux命名管道:创建与原理详解
linux·运维·服务器·开发语言·c++·程序人生·个人开发