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;
}
相关推荐
isyangli_blog6 分钟前
基于 OpenDaylight 的 SDN 负载均衡应用
运维·负载均衡
ICT系统集成阿祥16 分钟前
校园网络准入认证建设与运维经验
运维·网络·智慧校园·经验总结
颖火虫盟主18 分钟前
Linux USB 探测→枚举→RNDIS 驱动匹配 全流程笔记
linux·运维·笔记
liulilittle29 分钟前
甲骨文云中国大陆定向 QoS 原理及绕过解决方案
服务器·开发语言·网络·计算机网络·oracle·通信·qos
程序猿编码30 分钟前
子域猎手:一款高性能DNS枚举工具的设计与实现
linux·c++·python·c·dns
行走__Wz31 分钟前
【网工入门-eNSP模拟-02】dhcp动态主机配置ip地址
服务器·网络·tcp/ip
Full Stack Developme31 分钟前
Linux cd /abc 与 cd /abc/ 区别
linux·运维·服务器
想吃火锅100535 分钟前
【leetcode】20.有效的括号js
linux·javascript·leetcode
buhuizhiyuci43 分钟前
【Linux篇】数字世界程序运行寻找地址的指南针——环境变量的详解
linux·运维·服务器
Shadow(⊙o⊙)44 分钟前
信号1.0,信号概念、signal()处理、前后台进程、闹钟设置、初识信号三张表。
linux·运维·服务器·开发语言·c++