DonghunKang
Dependencies: mbed Adafruit_GFX
main.cpp@0:46005cfeedb5, 2018-10-29 (annotated)
- Committer:
- eins
- Date:
- Mon Oct 29 10:44:31 2018 +0000
- Revision:
- 0:46005cfeedb5
- Child:
- 1:ae0b11ca17d1
first ver.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
eins | 0:46005cfeedb5 | 1 | #include "mbed.h" |
eins | 0:46005cfeedb5 | 2 | #include "Adafruit_SSD1306.h" // Adafruit_GFX library |
eins | 0:46005cfeedb5 | 3 | |
eins | 0:46005cfeedb5 | 4 | DigitalOut myled(LED1); |
eins | 0:46005cfeedb5 | 5 | |
eins | 0:46005cfeedb5 | 6 | int main() |
eins | 0:46005cfeedb5 | 7 | { |
eins | 0:46005cfeedb5 | 8 | I2C I2C_Oled(PB_9, PB_8); // SDA, SCL |
eins | 0:46005cfeedb5 | 9 | I2C_Oled.frequency(400000); // 400kHz clock |
eins | 0:46005cfeedb5 | 10 | |
eins | 0:46005cfeedb5 | 11 | Adafruit_SSD1306_I2c myOled(I2C_Oled, PC_4); // D2 |
eins | 0:46005cfeedb5 | 12 | |
eins | 0:46005cfeedb5 | 13 | myOled.splash(); // logo output |
eins | 0:46005cfeedb5 | 14 | myOled.display(); |
eins | 0:46005cfeedb5 | 15 | wait(0.5); |
eins | 0:46005cfeedb5 | 16 | |
eins | 0:46005cfeedb5 | 17 | myOled.clearDisplay(); // clear buffer |
eins | 0:46005cfeedb5 | 18 | myOled.printf("%u x %u OLED Display\r\n", myOled.width(), myOled.height()); |
eins | 0:46005cfeedb5 | 19 | myOled.display(); // show a image on the OLED |
eins | 0:46005cfeedb5 | 20 | wait(1); |
eins | 0:46005cfeedb5 | 21 | |
eins | 0:46005cfeedb5 | 22 | uint16_t n = 0; |
eins | 0:46005cfeedb5 | 23 | |
eins | 0:46005cfeedb5 | 24 | while(1) |
eins | 0:46005cfeedb5 | 25 | { |
eins | 0:46005cfeedb5 | 26 | myled = !myled; |
eins | 0:46005cfeedb5 | 27 | |
eins | 0:46005cfeedb5 | 28 | myOled.clearDisplay(); |
eins | 0:46005cfeedb5 | 29 | myOled.setTextCursor(1, 5); |
eins | 0:46005cfeedb5 | 30 | myOled.printf("<<< UNIST DHE: %u >>>",n++); |
eins | 0:46005cfeedb5 | 31 | myOled.display(); |
eins | 0:46005cfeedb5 | 32 | wait(0.1); |
eins | 0:46005cfeedb5 | 33 | } |
eins | 0:46005cfeedb5 | 34 | } |