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;
}
相关推荐
擎创夏洛克AIOps几秒前
智能运维的“地基革命”:数据治理如何支撑大模型智能体?
运维·人工智能·科技
SDAU20052 分钟前
ESP32C3在Arduino下的MQTT操作
linux·服务器·前端
恒创科技HK2 分钟前
新站起步,租用香港服务器适合不?
运维·服务器
梁正雄4 分钟前
linux服务-RabbitMQ 原理与安装
linux·rabbitmq·ruby
Henry Zhu1234 分钟前
VPP中的DPDK插件源码详解第三篇:DPDK插件的数据接收和发送
运维·服务器·网络·tcp/ip·计算机网络
骇客野人6 分钟前
Java @Mapper 使用注解的方式注入SQL
linux·服务器·windows
budingxiaomoli6 分钟前
初始网络原理
java·运维·服务器·网络
ZKNOW甄知科技13 分钟前
低代码 ITSM 知识管理平台:驱动企业数智化运维的新引擎
运维·服务器·人工智能·低代码·网络安全·自动化
TG:@yunlaoda360 云老大15 分钟前
腾讯云国际站代理商的EO服务可以应用于哪些行业?
大数据·运维·腾讯云
hazhanglvfang16 分钟前
liunx基础环境排查
linux·运维·服务器