a sample program to use oled_i2c library, to display float number on the OLED screen.
Dependencies: eeprom mbed oled_i2c
main.cpp@0:c35f30fe243b, 2018-06-19 (annotated)
- Committer:
- poushen
- Date:
- Tue Jun 19 05:27:24 2018 +0000
- Revision:
- 0:c35f30fe243b
add code to display float to OLED screen
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
poushen | 0:c35f30fe243b | 1 | #include "mbed.h" |
poushen | 0:c35f30fe243b | 2 | #include "oled_i2c.h" |
poushen | 0:c35f30fe243b | 3 | #include "oled_font.h" |
poushen | 0:c35f30fe243b | 4 | |
poushen | 0:c35f30fe243b | 5 | DigitalOut myled(LED2); |
poushen | 0:c35f30fe243b | 6 | |
poushen | 0:c35f30fe243b | 7 | // make oled_i2c instance using I2C object. |
poushen | 0:c35f30fe243b | 8 | // with default slave address 0x78 (0x3C in 7bit format) |
poushen | 0:c35f30fe243b | 9 | // test ok with SSD1306 I2C 128*64 oled screen |
poushen | 0:c35f30fe243b | 10 | I2C i2c(dp5,dp27); // for LPC1114 or LPC1115 |
poushen | 0:c35f30fe243b | 11 | oled_i2c oled(i2c); |
poushen | 0:c35f30fe243b | 12 | |
poushen | 0:c35f30fe243b | 13 | int main() |
poushen | 0:c35f30fe243b | 14 | { |
poushen | 0:c35f30fe243b | 15 | myled = 1; |
poushen | 0:c35f30fe243b | 16 | printf("LPC1114 demo \r\n"); |
poushen | 0:c35f30fe243b | 17 | |
poushen | 0:c35f30fe243b | 18 | i2c.frequency(1000 * 1000); |
poushen | 0:c35f30fe243b | 19 | oled.init_oled(); |
poushen | 0:c35f30fe243b | 20 | |
poushen | 0:c35f30fe243b | 21 | oled.setFont(BigNumbers); |
poushen | 0:c35f30fe243b | 22 | //oled.print("27", 20, 10); |
poushen | 0:c35f30fe243b | 23 | //oled.printNumI(27, 0, 0); |
poushen | 0:c35f30fe243b | 24 | oled.printNumF(27.45, 2, 0, 0); |
poushen | 0:c35f30fe243b | 25 | oled.setFont(SmallFont); |
poushen | 0:c35f30fe243b | 26 | oled.print("~c", 60, 30); |
poushen | 0:c35f30fe243b | 27 | oled.update(); |
poushen | 0:c35f30fe243b | 28 | |
poushen | 0:c35f30fe243b | 29 | myled = 0; |
poushen | 0:c35f30fe243b | 30 | while(1); |
poushen | 0:c35f30fe243b | 31 | } |