其实上一篇是补的作业,顺便鄙视卓大的帖子都是文字,没有图片,听说可以用屏幕,就翻箱倒柜,可以一块屏幕都没找到,最后找到一块OLED的屏幕,据说升值了,管他呢,IIC接口的,好了就是它了
【炫Q-STM32】NUCLEO L053R8 边玩边学(三)-点亮OLED
下边的代码稍做修改,只要是IIC的引脚要接对,没有RST随便写了一个
/* * Copyright (c) 2012 Neal Horman - http://www.wanlink.com * * License: MIT open source (http://opensource.org/licenses/MIT) * Summary; * Use / modify / distribute / publish it how you want and * if you use it, or don't, you can't hold me liable for how * it does or doesn't work. * If it doesn't work how you want, don't use it, or change * it so that it does work. */ #include "mbed.h" #include "Adafruit_SSD1306.h" DigitalOut myled(LED1); class I2CPreInit : public I2C { public: I2CPreInit(PinName sda, PinName scl) : I2C(sda, scl) { frequency(400000); start(); }; }; I2CPreInit gI2C(I2C_SDA, I2C_SCL); Adafruit_SSD1306_I2c gOled2(gI2C,D13,0x78,64,128); int main() { uint16_t x=0; gOled2.printf("%ux%u OLED Display\r\n", gOled2.width(), gOled2.height()); while(1) { myled = !myled; gOled2.printf("%u\r",x); gOled2.display(); x++; wait(1.0); } }
共9条 1/1
1
跳转至
页