![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Write the OLED(using I2C) l432KC PIN sda scl reset
Dependencies: Adafruit_GFX mbed
Fork of I2C_SSD1306_nucleo_l432KCc by
main.cpp@7:4ab5e8203b1d, 2015-07-13 (annotated)
- Committer:
- eunkyoungkim
- Date:
- Mon Jul 13 07:23:06 2015 +0000
- Revision:
- 7:4ab5e8203b1d
- Parent:
- 3:847c4451cc97
- Child:
- 8:e61e86355653
modify mbed-src
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
kaizen | 0:81a58b2fb28e | 1 | #include "mbed.h" |
kaizen | 0:81a58b2fb28e | 2 | #include "Adafruit_SSD1306.h" |
kaizen | 0:81a58b2fb28e | 3 | |
kaizen | 0:81a58b2fb28e | 4 | DigitalOut myled(LED1); |
kaizen | 0:81a58b2fb28e | 5 | |
kaizen | 0:81a58b2fb28e | 6 | |
kaizen | 0:81a58b2fb28e | 7 | // an SPI sub-class that provides a constructed default |
kaizen | 0:81a58b2fb28e | 8 | class I2CPreInit : public I2C |
kaizen | 0:81a58b2fb28e | 9 | { |
kaizen | 0:81a58b2fb28e | 10 | public: |
kaizen | 0:81a58b2fb28e | 11 | I2CPreInit(PinName sda, PinName scl) : I2C(sda, scl) |
kaizen | 0:81a58b2fb28e | 12 | { |
kaizen | 0:81a58b2fb28e | 13 | frequency(100000); |
kaizen | 0:81a58b2fb28e | 14 | start(); |
kaizen | 0:81a58b2fb28e | 15 | }; |
kaizen | 0:81a58b2fb28e | 16 | }; |
kaizen | 0:81a58b2fb28e | 17 | |
kaizen | 0:81a58b2fb28e | 18 | I2CPreInit gI2C(PA_10,PA_9); |
kaizen | 0:81a58b2fb28e | 19 | Adafruit_SSD1306_I2c gOled(gI2C,NC,0x78,64,128); |
kaizen | 0:81a58b2fb28e | 20 | Serial pc(USBTX,USBRX); |
kaizen | 0:81a58b2fb28e | 21 | |
kaizen | 0:81a58b2fb28e | 22 | int main() |
kaizen | 1:6b03b9f64311 | 23 | { uint16_t x=0; |
kaizen | 0:81a58b2fb28e | 24 | |
kaizen | 0:81a58b2fb28e | 25 | gOled.begin(); |
eunkyoungkim | 7:4ab5e8203b1d | 26 | gOled.printf("%ux%u Hellow World\r\n", gOled.width(), gOled.height()); |
kaizen | 0:81a58b2fb28e | 27 | gOled.display(); |
kaizen | 0:81a58b2fb28e | 28 | |
kaizen | 0:81a58b2fb28e | 29 | |
kaizen | 0:81a58b2fb28e | 30 | while(1) |
kaizen | 0:81a58b2fb28e | 31 | { |
kaizen | 0:81a58b2fb28e | 32 | myled = !myled; |
kaizen | 0:81a58b2fb28e | 33 | gOled.printf("%u\r",x); |
kaizen | 0:81a58b2fb28e | 34 | gOled.display(); |
kaizen | 0:81a58b2fb28e | 35 | x = x + 1; |
kaizen | 0:81a58b2fb28e | 36 | wait(1); |
kaizen | 0:81a58b2fb28e | 37 | } |
kaizen | 0:81a58b2fb28e | 38 | } |