github网址链接

https://github.com/olikraus/u8g2/wiki/u8x8reference#print

用到的库文件

#ifdef U8X8_HAVE_HW_SPI
#include <SPI.h>

引脚定义

U8X8_SSD1306_128X64_NONAME_SW_I2C u8x8(/* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // OLEDs without Reset of the Display

屏幕初始化

u8x8.begin();
u8x8.setPowerSave(0);

 

字体设置

 u8x8.setFont(u8x8_font_amstrad_cpc_extended_r);

字体列表在github网站可查:https://github.com/olikraus/u8g2/wiki/fntlist8x8

字体的显示有两种 

一是用drawstring显示,例如

u8x8.draw2x2String(3, 3, "Fisher");

这种直接设置了它的显示坐标。

二使用print输出

u8x8.setCursor(15,2);//这里设置显示的坐标
u8x8.print("m");//输出显示内容

同时这种可以输出传感器数据。

在GitHub网站里有很多资料的。有待学习!

 

相关文章:

  • 2021-08-03
  • 2022-02-18
  • 2022-12-23
  • 2021-07-31
  • 2021-04-28
  • 2021-12-22
  • 2021-08-25
  • 2022-12-23
猜你喜欢
  • 2021-05-25
  • 2021-11-29
  • 2021-08-22
  • 2021-05-28
相关资源
相似解决方案