![](/media/cache/profiles/17a98ed636b0294602e63e75d11339a2.jpg.50x50_q85.jpg)
read TI TMP102 temperature and display on SSD1306 OLED
Dependencies: Adafruit_GFX TMP102 mbed
Fork of DisplayOled by
main.cpp
- Committer:
- franni
- Date:
- 2017-05-16
- Revision:
- 0:3b87797f65fc
- Child:
- 1:c636842ce79c
File content as of revision 0:3b87797f65fc:
#include "mbed.h" #include "Adafruit_SSD1306.h" DigitalOut led1(LED_RED); // SPI sub-class that provides a constructed default class I2CPreInit : public I2C { public: I2CPreInit(PinName sda, PinName scl) : I2C(sda, scl) { //frequency(400000); frequency(100000); start(); }; }; I2CPreInit myI2C(PTE0,PTE1); Adafruit_SSD1306_I2c myOled(myI2C,NC,0x78,64,128); int main() { uint16_t x=0; myOled.begin(); myOled.printf("%ux%u Hellow World\r\n", myOled.width(), myOled.height()); myOled.display(); while(1) { led1 = !led1; myOled.printf("%u\r",x); myOled.display(); x = x + 1; wait(1.0); } } /* #include "mbed.h" #include "Adafruit_SSD1306.h" class I2CPreInit : public I2C { public: I2CPreInit(PinName sda, PinName scl) : I2C(sda, scl) { frequency(100000); start(); }; }; I2CPreInit myI2C(PTE0,PTE1); Adafruit_SSD1306_I2c myOled(myI2C,NC,0x78,64,128); int main() { uint16_t x=0; myOled.begin(); myOled.clearDisplay(); myOled.display(); wait(0.1); myOled.fillCircle(64, 42, 10, 1); myOled.display(); wait(1); myOled.fillCircle(64, 42, 5, 0); myOled.display(); wait(1); myOled.clearDisplay(); myOled.display(); wait(0.1); myOled.printf("\r\n OLED %ux%u \r\n\r\n Hello World\r\n\n", myOled.width(), myOled.height()); myOled.drawRect(0, 0, 128, 64,1); myOled.display(); wait(0.5); while(1) { myOled.printf("%u\r ",x); myOled.drawRect(0, 0, 128, 64,1); myOled.display(); x = x + 1; wait(0.01); } } */