orangepi zero2 全志H616 SSD1306 OLED屏幕测试程序 (已附源码)

news/2025/2/19 8:29:54/

orangepi zero2 H616 SSD1306 OLED屏幕测试程序

orangepi zero2 配置wiringpi 库后,突发奇想构建一个测试oled屏幕的程序,放一个蜗牛每次移动一个像素点,实时显示蜗牛的步数,后面要显示其他内容在此代码上修改即可,如此一来,岂不妙哉!便捷型max!!

测试效果展示:(狂飙蜗牛128)

全志H616 编写SSD1306 OLED屏幕测试程序 已附源码 (orangepi zero2)

源码:(记着装wiringpi库)

/** SSD1306 demo of block and font drawing.* by @Ty * Create time:2023/11/04*/
//
//#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_demo(struct display_info *disp) {int i;char buf[100];	//第一行显示内容  disp是oled设备的识别信息	oled_putstrto(disp, 0, 10, "Welcome  Ty  demo");//使用字体1 即font1disp->font = font1;//下一行显示内容  disp是oled设备的识别信息oled_putstrto(disp, 0, 20, "----Test Snail----");//使用字体1 即font2disp->font = font2;//反复发送新的界面打印,达到动画效果for (i=0; i<129; i++) {	//显示蜗牛爬了多少步,一步一个像素点;	sprintf(buf, "Snail Steps: %d ", i);oled_putstrto(disp, 0, 0, buf);//打印空格实时清屏蜗牛残留内存oled_putstrto(disp, 120-i, 36+4, "       ");//打印移动蜗牛oled_putstrto(disp, 128-i, 36+4, "@..");//打印空格实时清屏蚂蚁残留内存oled_putstrto(disp, 120, 56-i/2, "       ");//打印移动蚂蚁oled_putstrto(disp, 120, 68-i/2, ".");// 将要显示内容发送到oledoled_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        (demo:/dev/i2c-3)\n", progname);
}int main(int argc, char **argv) {int e;char filename[32];struct display_info disp;//在运行时要输入驱动文件 /dev/i2c-3,缺少参数就报错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;//打开设备 并检测是否成功 &disp是oled设备的识别信息e = oled_open(&disp, filename);	if (e < 0) {show_error(1, e);} else {//成功则继续执行oled显示函数 并判断是否成功  e = oled_init(&disp);if (e < 0) {show_error(2, e);} else {//成功则继续,打印start标志printf("---------start--------\n");//当打印完ole显示内容后,打印end标志if (oled_demo(&disp) < 0)show_error(3, 777);printf("----------end---------\n");}}return 0;
}

http://www.ppmy.cn/news/1196809.html

相关文章

Python基础入门例程32-NP32 牛牛的加减器(运算符)

最近的博文&#xff1a; Python基础入门例程31-NP31 团队分组&#xff08;列表&#xff09;-CSDN博客 Python基础入门例程30-NP30 用列表实现队列&#xff08;列表&#xff09;-CSDN博客 Python基础入门例程29-NP29 用列表实现栈&#xff08;列表&#xff09;-CSDN博客 目录…

MyBatis 详解

目录 1.MyBatis 框架的搭建 1.1 创建数据库和表 1.2 添加 MyBatis 依赖 1.3 设置 MyBatis 配置 1.3.1 设置数据库的连接信息 1.3.2 设置 XML 保存路径和命名格式 1.4 根据 MyBatis 写法完成数据库得操作 1.4.1 定义接口 1.4.2 使用 XML 实现接口 2.MyBatis查询操作 …

配置Raspberry自动连接WIFI,在无法查看路由器的校园网情况下使用自己电脑热点

1、开启电脑热点&#xff0c;并共享电脑WLAN2 打开控制面板->网络和Internet->网络连接 选择自己的校园网&#xff0c;我这里是WLAN2&#xff0c;右键属性&#xff0c;如下操作&#xff1a; 如果没有看到 本地连接*10类似的图标 则按如下操作&#xff1a;winx键&#x…

Day13反转链表两两交换链表中的节点删除链表的倒数第N个节点链表相交环形链表II

反转链表 struct ListNode* reverseList(struct ListNode* head){struct ListNode* preNULL;while(head){struct ListNode* temphead->next;head->nextpre;prehead;headtemp;}return pre; }两两交换链表中的节点 struct ListNode* swapPairs(struct ListNode* head){st…

ConnectionError: HTTPSConnectionPool

ConnectionError: HTTPSConnectionPool(host‘zbbfxstatic.figtingdream.com’, port443): Max retries exceeded with url: /api/cache (Caused by NewConnectionError(‘<urllib3.connection.HTTPSConnection object at 0x00000249795AD9A0>: Failed to establish a ne…

21.合并两个有序链表

#include <iostream>struct ListNode {int val;ListNode* next;ListNode(int x) : val(x), next(nullptr) {} };class Solution { public:ListNode* mergeTwoLists(ListNode* l1, ListNode* l2) {ListNode dummy ListNode(-1); // 创建一个虚拟节点作为头节点ListNode* …

C#知识总结 基础篇(下)

目录 5类和继承 5.1类继承 5.2访问继承的成员 5.3屏蔽基类的成员 5.4访问基类的成员 5.5虚方法与覆写方法 5.6构造函数的执行顺序 5.7成员访问修饰符 5.8抽象类 5.9密封类与静态类 6.表达式与运算符 6.1运算符和重载 7.结构 7.1结构体的感念。 7.2结构构造函数与…

Rocky 安装jdk17

1&#xff09;检测jdk是否安装&#xff1a; #运行 java -version如果提示安装&#xff0c;则输入N&#xff0c;跳过 2&#xff09;检测cpu 类型 若未安装查看linux处理器架构&#xff1a; #运行 hostnamectl #或运行 arch 3&#xff09;去官网下载相应的编译版本的Jdk Or…