![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
1.3''OLED
Dependencies: mbed QEI OLED_SSD1306_SH1106 I2C_SSD1306_nucleo_l432KC
main.cpp@1:6b03b9f64311, 2015-06-25 (annotated)
- Committer:
- kaizen
- Date:
- Thu Jun 25 05:29:49 2015 +0000
- Revision:
- 1:6b03b9f64311
- Parent:
- 0:81a58b2fb28e
- Child:
- 3:847c4451cc97
First Release SSD1306_LCD-HelloWorld
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 | #if defined(TARGET_WIZwiki_W7500) |
kaizen | 0:81a58b2fb28e | 7 | #define SDA PA_10 |
kaizen | 0:81a58b2fb28e | 8 | #define SCL PA_9 |
kaizen | 0:81a58b2fb28e | 9 | #endif |
kaizen | 0:81a58b2fb28e | 10 | |
kaizen | 0:81a58b2fb28e | 11 | // an SPI sub-class that provides a constructed default |
kaizen | 0:81a58b2fb28e | 12 | class I2CPreInit : public I2C |
kaizen | 0:81a58b2fb28e | 13 | { |
kaizen | 0:81a58b2fb28e | 14 | public: |
kaizen | 0:81a58b2fb28e | 15 | I2CPreInit(PinName sda, PinName scl) : I2C(sda, scl) |
kaizen | 0:81a58b2fb28e | 16 | { |
kaizen | 0:81a58b2fb28e | 17 | frequency(100000); |
kaizen | 0:81a58b2fb28e | 18 | start(); |
kaizen | 0:81a58b2fb28e | 19 | }; |
kaizen | 0:81a58b2fb28e | 20 | }; |
kaizen | 0:81a58b2fb28e | 21 | |
kaizen | 0:81a58b2fb28e | 22 | I2CPreInit gI2C(PA_10,PA_9); |
kaizen | 0:81a58b2fb28e | 23 | Adafruit_SSD1306_I2c gOled(gI2C,NC,0x78,64,128); |
kaizen | 0:81a58b2fb28e | 24 | Serial pc(USBTX,USBRX); |
kaizen | 0:81a58b2fb28e | 25 | |
kaizen | 0:81a58b2fb28e | 26 | int main() |
kaizen | 1:6b03b9f64311 | 27 | { uint16_t x=0; |
kaizen | 0:81a58b2fb28e | 28 | |
kaizen | 0:81a58b2fb28e | 29 | gOled.begin(); |
kaizen | 0:81a58b2fb28e | 30 | gOled.printf("%ux%u OLED Display\r\n", gOled.width(), gOled.height()); |
kaizen | 0:81a58b2fb28e | 31 | gOled.display(); |
kaizen | 0:81a58b2fb28e | 32 | |
kaizen | 0:81a58b2fb28e | 33 | |
kaizen | 0:81a58b2fb28e | 34 | while(1) |
kaizen | 0:81a58b2fb28e | 35 | { |
kaizen | 0:81a58b2fb28e | 36 | myled = !myled; |
kaizen | 0:81a58b2fb28e | 37 | gOled.printf("%u\r",x); |
kaizen | 0:81a58b2fb28e | 38 | gOled.display(); |
kaizen | 0:81a58b2fb28e | 39 | x = x + 1; |
kaizen | 0:81a58b2fb28e | 40 | wait(1); |
kaizen | 0:81a58b2fb28e | 41 | } |
kaizen | 0:81a58b2fb28e | 42 | } |