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;
}
相关推荐
幸福指北41 分钟前
🚀 开源了,一个人 + AI 肝出一个 AI 终端 | AShell 技术分享
运维·人工智能·ai·终端
肥胖小羊2 小时前
微信社群自动化管理与防骚扰系统的设计与实现
运维·自动化
AI办公探索者3 小时前
仓储物流AI任务执行的技术拆解:从WMS自动化到多设备协同的落地路径
运维·人工智能·ai·自动化
longerxin20204 小时前
nano编辑器插入、编辑完整操作教程(Linux日志/配置专用)
linux·运维·编辑器
cesium vue5 小时前
nginx 流媒体配置
运维·nginx
木心术15 小时前
GitHub Actions自动化运维实战:从CI/CD到全链路DevOps
运维·自动化·github
糯米导航5 小时前
实践教程|搭建电商 AI 无限画布,实现百款商品主图自动化批量生成
运维·人工智能·自动化
朴马丁5 小时前
从制造到智造:PLM如何赋能企业研发创新
大数据·运维·人工智能·食品行业·流程行业plm·化工新材料行业·新能源材料行业
爱小黄5 小时前
使用docker搭建集群-使用 Docker 搭建 KingbaseES 集群
运维·docker·容器
zhougl9966 小时前
Gateway 和 Nginx 路由区别
运维·nginx·gateway