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;
}
相关推荐
闲云自留地3 分钟前
Neutron 实战教程:物理 vs 虚拟网络,OVN 环境创建网络与安全策略
服务器·网络·openstack
为思念酝酿的痛8 分钟前
传输层协议UDP
linux·网络·udp
Elnaij11 分钟前
Linux系统与系统编程(16)——日志、线程池的实现与线程安全
linux
szarron22 分钟前
HTOOL‑SA12 + HT06 近场探头组合实操|手持设备工位 EMI 预兼容排查完整流程
运维·服务器·开发语言·网络·射频工程·频谱仪
杨云龙UP23 分钟前
DB2 HADR 主备架构活动日志参数优化操作手册
linux·运维·服务器·数据库·db2·db2 hadr·日志参数调整
我是大猴子27 分钟前
MyBatis‑Plus & MyBatis‑Flex 区别
java·服务器·数据库
csdn_aspnet34 分钟前
如何从电脑主机拷东西到VWmare虚拟机
linux·运维·服务器·windows·vmware·虚拟机
码农幻想梦41 分钟前
“找不到 www.bilibili.com 的服务器 IP 地址”解决办法
运维·服务器·tcp/ip
Vcaker1 小时前
Linux学习28-Kubernetes service
linux·运维·学习
gf13211111 小时前
python_调用远程服务器上的openclaw
服务器·python·php