这次采用U8X8的方式,不再采用u8g2,因为后者一直报内存问题。所以采用了不占内存的u8x8模式

同时u8g2库文件的示例代码也是很牛逼的,

里面还有message box 非常的可爱运行效果也非常棒!

代码如下

 #include <Arduino.h>
#include <U8x8lib.h> #ifdef U8X8_HAVE_HW_SPI
#include <SPI.h>
#endif
U8X8_SSD1306_128X64_NONAME_SW_I2C u8x8(/* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // OLEDs without Reset of the Display
void setup(void)
{
//u8x8.begin();//可以定义按键如下
u8x8.begin(/*Select=*/ , /*Right/Next=*/ A1, /*Left/Prev=*/ A2, /*Up=*/ A0, /*Down=*/ A3, /*Home/Cancel=*/ ); u8x8.setPowerSave();
}
void loop(void)
{
/*u8x8.setFont(u8x8_font_chroma48medium8_r);
u8x8.drawString(0,0,"Hello World!");
u8x8.refreshDisplay();
delay(2000);*/ uint8_t r;
u8x8.setFont(u8x8_font_chroma48medium8_r);
r = u8x8_UserInterfaceMessage(u8x8.getU8x8(), "Message", "Box", NULL, " Ok \n Cancel ");
if ( r == )
{
u8x8.userInterfaceMessage("You pressed the", "Home/Quit", "Button", " Ok ");
}
else if ( r == )
{
u8x8.userInterfaceMessage("You selected the", "Ok", "Button", " Ok ");
}
else if ( r == )
{
u8x8.userInterfaceMessage("You selected the", "Cancel", "Button", " Ok ");
}
}

再也没有出现之前的动不动就报内存不足的问题。

同时还可以自己生成位图进行显示,比如二维码,不过,识别起来很吃力

代码如下

 #include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h> #define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET); static const unsigned char PROGMEM logo[] =
{
0x9F,0xFE,0x6C,0x38,0xFF,0x6F,0xFF,0xFE,0xBF,0xFE,0x6C,0x38,0xFF,0x6F,0xFF,0xFE,
0xFF,0xFF,0xEF,0xB8,0xFF,0x7F,0xFF,0xFE,0xBF,0xFF,0xFF,0x9F,0xFF,0x7F,0x1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0xFF,0xFF,0xFE,
0xFF,0xFF,0x7F,0xFB,0xDB,0xFF,0xFF,0xF8,0xFF,0xFF,0x7F,0xC3,0xD8,0x07,0xFC,0xD8,
0xFF,0xFF,0x7F,0xC3,0xFB,0xFF,0xFF,0xF8,0xFF,0xFF,0x79,0x9B,0xFF,0xFC,0x7F,0xF8,
0xE0,0x7F,0x61,0x9B,0x9F,0x6C,0xFF,0xD8,0xF7,0xFF,0xFD,0x9B,0xDF,0xFC,0x7F,0xD8,
0xFF,0xE1,0xFC,0x00,0xC7,0xFC,0x00,0x00/*"C:\Users\Administrator\Desktop\6464qrco000000000de_15134800003995111111111111111827.bmp",0*/}; #if (SSD1306_LCDHEIGHT != 64)
#error("Height incorrect, please fix Adafruit_SSD1306.h!");
#endif void setup() {
Serial.begin();
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
display.clearDisplay();
display.drawBitmap(, , logo, , , );
} void loop() {
//display.drawBitmap(0, 0, logo, 64, 64, 1); //在坐标X0,Y0的位置开始显示图片
//128是取模软件显示的宽度
//64是取模软件显示的高度
// display.display(); //把缓存的都显示
//delay(1); // display.clearDisplay(); //清除屏幕
}

U8g2库I2C总线再次突破性调试成功的更多相关文章

  1. 自制单片机之六……串行I2C总线E2PROM AT24CXXX的应用

    这一篇介绍I2C存储器的使用.主要是介绍AT24CXX系列器件,它分为两类,主要是通过被存储容量地址来分的,一类是AT24C02-AT24C16,它的存储容量从256字节到2048字节.另一类是AT2 ...

  2. I2C总线信号时序总结

    I2C总线信号时序总结 总线空闲状态  I2C总线总线的SDA和SCL两条信号线同时处于高电平时,规定为总线的空闲状态.此时各个器件的输出级场效应管均处在截止状态,即释放总线,由两条信号线各自的上拉电 ...

  3. i2c总线驱动,总线设备(适配器),从设备,从设备驱动的注册以及匹配

    常用链接 我的随笔 我的评论 我的参与 最新评论 我的标签 随笔分类 ARM裸机(13) C(8) C++(8) GNU-ARM汇编 Linux驱动(24) Linux应用编程(5) Makefile ...

  4. 【转】I2C总线协议

    I2C总线(Inter Integrated-Circuit)是由PHILIPS公司在上世纪80年代发明的一种电路板级串行总线标准,通过两根信号线——时钟线SCL和数据线SDA——即可完成主从机的单工 ...

  5. I2C总线信号时序总结【转】

    本文转载自:https://i.cnblogs.com/EditPosts.aspx?opt=1 I2C总线信号时序总结 总线空闲状态  I2C总线总线的SDA和SCL两条信号线同时处于高电平时,规定 ...

  6. 【转】I2C总线相关知识

    1. I2C access 1.1. I2C introduction I2C(Inter-Integrated Circuit)总线是由NXP恩智浦半导体公司在80年代开发的两线式串行总线,用来进行 ...

  7. I2C总线完全版——I2C总线的结构、工作时序与模拟编程

    I2C总线的结构.工作时序与模拟编程 I2C总线的结构.工作时序与模拟编程I2C总线(Inter Integrated Circuit)是飞利浦公司于上个世纪80年代开发的一种"电路板级&q ...

  8. i2c总线,设备,驱动之间的关系

    ------ 总线上先添加好所有具体驱动,i2c.c遍历i2c_boardinfo链表,依次建立i2c_client, 并对每一个i2c_client与所有这个线上的驱动匹配,匹配上,就调用这个驱动的 ...

  9. [I2C]I2C总线协议图解

    转自:http://blog.csdn.net/w89436838/article/details/38660631 1  I2C总线物理拓扑结构      I2C 总线在物理连接上非常简单,分别由S ...

随机推荐

  1. IDEA第八章----远程调试

    大家有没有遇到相同分支的代码在本地就是没有问题的,但是到测试环境死活不能实现功能,且还不报错.通常我们的解决办法就是打日志,然后一点一点跟踪日志. 这时我们在想如果也可以按照本地一样能断点测试的程序就 ...

  2. Java多线程窥探

    1.程序,进程,线程 标准定义:

  3. 认证客户端的链接与socketserver实现并发

    from socket import * import hmac,os secret_key=b'linhaifeng bang bang bang' def conn_auth(conn): ''' ...

  4. Go 语言打包静态文件

    对于 Go 语言开发者来说,在享受语言便利性的同时,最终编译的单一可执行文件也是我们所热衷的.但是,一旦遇到我们需要分发的东西不只有可执行文件的时候,事情就变得稍微有点复杂了,例如,需要分发个默认的配 ...

  5. 【转载】从头编写 asp.net core 2.0 web api 基础框架 (5) EF CRUD

    Github源码地址:https://github.com/solenovex/Building-asp.net-core-2-web-api-starter-template-from-scratc ...

  6. org.springframework.expression.spel.SpelEvaluationException: EL1004E: Method call: Method service() cannot be found on com.my.blog.springboot.thymeleaf.util.MethodTest type

    前言 本文中提到的解决方案,源码地址在:springboot-thymeleaf,希望可以帮你解决问题. 至于为什么已经写了一篇文章thymeleaf模板引擎调用java类中的方法,又多此一举的单独整 ...

  7. ----------- Rootkit 核心技术之绕过 IopParseDevice() 调用源检测逻辑 ---------------

    ---------------------------------------------------------------- 在上一篇文章中,我们已经看到 IopParseDevice() 如何对 ...

  8. Javac编译时出现包不存在的报错的解决方案

    今天在学习包类调用时出现如下错误: packa包不存在,在C盘目录下应该有这个包啊 原因是在当前目录下没找到,因为packa存放在其它目录下 如何解决: 应该配置一个classpath,直接把包所在的 ...

  9. HDU 2503 a/b + c/d(最大公约数与最小公倍数,板子题)

    话不多说,日常一水题,水水更健康!┗|`O′|┛ 嗷~~ a/b + c/d Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768 ...

  10. 基于Windows环境下MyEclipse10快捷键总结

    ---------------------------------------------MyEclipse 快捷键1(CTRL)----------------------------------- ...