![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
display code
Dependencies: mbed Adafruit_GFX
main.cpp@8:e61e86355653, 2015-07-24 (annotated)
- Committer:
- IOP
- Date:
- Fri Jul 24 01:20:00 2015 +0000
- Revision:
- 8:e61e86355653
- Parent:
- 7:4ab5e8203b1d
- Child:
- 9:a6021ca48d2e
run with easy module shield
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" |
IOP | 8:e61e86355653 | 3 | |
IOP | 8:e61e86355653 | 4 | DigitalOut shield_led_off(D10); |
IOP | 8:e61e86355653 | 5 | DigitalOut myled_R(LED1); |
kaizen | 0:81a58b2fb28e | 6 | |
kaizen | 0:81a58b2fb28e | 7 | |
kaizen | 0:81a58b2fb28e | 8 | // an SPI sub-class that provides a constructed default |
kaizen | 0:81a58b2fb28e | 9 | class I2CPreInit : public I2C |
kaizen | 0:81a58b2fb28e | 10 | { |
kaizen | 0:81a58b2fb28e | 11 | public: |
kaizen | 0:81a58b2fb28e | 12 | I2CPreInit(PinName sda, PinName scl) : I2C(sda, scl) |
kaizen | 0:81a58b2fb28e | 13 | { |
kaizen | 0:81a58b2fb28e | 14 | frequency(100000); |
kaizen | 0:81a58b2fb28e | 15 | start(); |
kaizen | 0:81a58b2fb28e | 16 | }; |
kaizen | 0:81a58b2fb28e | 17 | }; |
kaizen | 0:81a58b2fb28e | 18 | |
kaizen | 0:81a58b2fb28e | 19 | I2CPreInit gI2C(PA_10,PA_9); |
kaizen | 0:81a58b2fb28e | 20 | Adafruit_SSD1306_I2c gOled(gI2C,NC,0x78,64,128); |
kaizen | 0:81a58b2fb28e | 21 | Serial pc(USBTX,USBRX); |
kaizen | 0:81a58b2fb28e | 22 | |
kaizen | 0:81a58b2fb28e | 23 | int main() |
kaizen | 1:6b03b9f64311 | 24 | { uint16_t x=0; |
IOP | 8:e61e86355653 | 25 | |
IOP | 8:e61e86355653 | 26 | shield_led_off = 0; // turn off Green LED on shield |
kaizen | 0:81a58b2fb28e | 27 | |
kaizen | 0:81a58b2fb28e | 28 | gOled.begin(); |
eunkyoungkim | 7:4ab5e8203b1d | 29 | gOled.printf("%ux%u Hellow World\r\n", gOled.width(), gOled.height()); |
kaizen | 0:81a58b2fb28e | 30 | gOled.display(); |
kaizen | 0:81a58b2fb28e | 31 | |
kaizen | 0:81a58b2fb28e | 32 | |
kaizen | 0:81a58b2fb28e | 33 | while(1) |
kaizen | 0:81a58b2fb28e | 34 | { |
IOP | 8:e61e86355653 | 35 | myled_R = !myled_R; |
kaizen | 0:81a58b2fb28e | 36 | gOled.printf("%u\r",x); |
kaizen | 0:81a58b2fb28e | 37 | gOled.display(); |
kaizen | 0:81a58b2fb28e | 38 | x = x + 1; |
kaizen | 0:81a58b2fb28e | 39 | wait(1); |
kaizen | 0:81a58b2fb28e | 40 | } |
kaizen | 0:81a58b2fb28e | 41 | } |