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;
}
相关推荐
Aurora_Dawn_yy几秒前
单机部署数据同步_jdk,mysql,kafka,flink,zookeeper,达梦,starrocks
大数据·linux·starrocks·zookeeper·达梦
bush42 分钟前
嵌入式linux学习记录十三
linux·嵌入式
sbjdhjd3 分钟前
Tomcat(下) 集群高可用实战:反向代理・负载均衡・分布式 Session
运维·前端·云原生·开源·tomcat·负载均衡·memcached
xjxijd9 分钟前
行为感知算法赋能运维,提前预判硬件故障与异常访问
运维·算法
ai_coder_ai11 分钟前
如何使用adb实现自动化脚本?
运维·adb·自动化
Splashtop高性能远程控制软件11 分钟前
微软2026年6月补丁星期二技术分析:206个漏洞、3个已公开零日的分级修复方案
运维·安全·自动化·远程桌面·splashtop
陈猪的杰咪13 分钟前
【2026最新指南】AI大模型API中转站选型参考:国内稳定接入ChatGPT、Claude、Gemini等主流模型实践分享
运维·网络·人工智能·chatgpt·架构
毒爪的小新17 分钟前
Open WebUI 从零到一:打造属于你的私人ChatGPT
linux·ai·语言模型·chatgpt·openwebui
keyipatience21 分钟前
命名管道:跨进程通信的终极指南
linux·运维·服务器
AOwhisky9 小时前
Redis 学习笔记(第三期):持久化与主从复制
运维·数据库·redis·笔记·学习·云计算