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;
}
相关推荐
RisunJan4 小时前
Linux命令-talk(终端实时对话)
linux·运维·服务器
NeilYuen4 小时前
【vemory】高性能KV存储AOF方案设计
linux·c++·redis·缓存
整点bug4 小时前
AI 运维该不该自动执行命令?
运维·ssh·openai
Kurisu_红莉栖4 小时前
关于docker的使用心得
运维·docker·容器
三言老师5 小时前
Rocky Linux 8.6 整机系统备份与迁移方案文档文档用途
linux·运维·服务器·网络
「PlanA」5 小时前
自动化流水线CSDN自动发布文章
运维·自动化
daad7775 小时前
用 HackRF + GNU Radio 制作 FM 发射机:从 WAV 到 103 MHz 空中信号
服务器·gnu·fm
雾时之林5 小时前
Linux----防火墙
linux·运维·网络
海兰6 小时前
【开源工具】BlueKing Lite —— AI 原生的轻量运维平台(二)
运维·人工智能·开源
我星期八休息7 小时前
网络编程—NAT、代理服务与内网穿透
linux·服务器·网络·网络协议