![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
display code
Dependencies: mbed Adafruit_GFX
main.cpp@10:abbd34fe7ce1, 2016-01-06 (annotated)
- Committer:
- IOP
- Date:
- Wed Jan 06 23:59:45 2016 +0000
- Revision:
- 10:abbd34fe7ce1
- Parent:
- 9:a6021ca48d2e
- Child:
- 11:f4ecb5faeffe
update mbed lib
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 | 10:abbd34fe7ce1 | 4 | DigitalOut myled_R(LED_RED); |
kaizen | 0:81a58b2fb28e | 5 | |
kaizen | 0:81a58b2fb28e | 6 | // an SPI sub-class that provides a constructed default |
kaizen | 0:81a58b2fb28e | 7 | class I2CPreInit : public I2C |
kaizen | 0:81a58b2fb28e | 8 | { |
kaizen | 0:81a58b2fb28e | 9 | public: |
kaizen | 0:81a58b2fb28e | 10 | I2CPreInit(PinName sda, PinName scl) : I2C(sda, scl) |
kaizen | 0:81a58b2fb28e | 11 | { |
kaizen | 0:81a58b2fb28e | 12 | frequency(100000); |
kaizen | 0:81a58b2fb28e | 13 | start(); |
kaizen | 0:81a58b2fb28e | 14 | }; |
kaizen | 0:81a58b2fb28e | 15 | }; |
kaizen | 0:81a58b2fb28e | 16 | |
IOP | 9:a6021ca48d2e | 17 | I2CPreInit myI2C(PA_10,PA_9); |
IOP | 9:a6021ca48d2e | 18 | Adafruit_SSD1306_I2c myOled(myI2C,NC,0x78,64,128); |
kaizen | 0:81a58b2fb28e | 19 | |
kaizen | 0:81a58b2fb28e | 20 | int main() |
IOP | 9:a6021ca48d2e | 21 | { |
IOP | 9:a6021ca48d2e | 22 | uint16_t x=0; |
kaizen | 0:81a58b2fb28e | 23 | |
IOP | 9:a6021ca48d2e | 24 | myOled.begin(); |
IOP | 9:a6021ca48d2e | 25 | myOled.printf("%ux%u Hellow World\r\n", myOled.width(), myOled.height()); |
IOP | 9:a6021ca48d2e | 26 | myOled.display(); |
kaizen | 0:81a58b2fb28e | 27 | |
kaizen | 0:81a58b2fb28e | 28 | while(1) |
kaizen | 0:81a58b2fb28e | 29 | { |
IOP | 8:e61e86355653 | 30 | myled_R = !myled_R; |
IOP | 9:a6021ca48d2e | 31 | myOled.printf("%u\r",x); |
IOP | 9:a6021ca48d2e | 32 | myOled.display(); |
IOP | 9:a6021ca48d2e | 33 | x = x + 1; |
IOP | 9:a6021ca48d2e | 34 | wait(1.0); |
kaizen | 0:81a58b2fb28e | 35 | } |
kaizen | 0:81a58b2fb28e | 36 | } |