DonghunKang
Dependencies: mbed Adafruit_GFX
main.cpp@1:ae0b11ca17d1, 2019-10-16 (annotated)
- Committer:
- eins
- Date:
- Wed Oct 16 04:48:38 2019 +0000
- Revision:
- 1:ae0b11ca17d1
- Parent:
- 0:46005cfeedb5
- Child:
- 2:3061fe655b7d
modifying for F303RE.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
eins | 0:46005cfeedb5 | 1 | #include "mbed.h" |
eins | 0:46005cfeedb5 | 2 | #include "Adafruit_SSD1306.h" // Adafruit_GFX library |
eins | 0:46005cfeedb5 | 3 | |
eins | 1:ae0b11ca17d1 | 4 | Serial pc(SERIAL_TX, SERIAL_RX); |
eins | 1:ae0b11ca17d1 | 5 | DigitalOut myled(LED1); |
eins | 1:ae0b11ca17d1 | 6 | DigitalOut redLed(PA_12); |
eins | 1:ae0b11ca17d1 | 7 | DigitalIn myButton(PC_13); |
eins | 1:ae0b11ca17d1 | 8 | DigitalIn exButton(PC_11); |
eins | 1:ae0b11ca17d1 | 9 | |
eins | 1:ae0b11ca17d1 | 10 | BusOut my7Seg(PA_8, PA_9, PA_10, PC_9, PC_8, PC_7, PC_6, PA_11); // 8bit data |
eins | 1:ae0b11ca17d1 | 11 | // LSB, , MSB |
eins | 1:ae0b11ca17d1 | 12 | char val7Seg[16] = {0x3F, 0x06, 0x5B, 0x4F, 0x66, 0x6D, 0x7D, 0x07, 0x7F, 0x6F, |
eins | 1:ae0b11ca17d1 | 13 | 0x77, 0x7C, 0x39, 0x5E, 0x79, 0x71}; |
eins | 1:ae0b11ca17d1 | 14 | |
eins | 1:ae0b11ca17d1 | 15 | char rxData[5]; |
eins | 1:ae0b11ca17d1 | 16 | bool flagRx = 0; |
eins | 0:46005cfeedb5 | 17 | |
eins | 0:46005cfeedb5 | 18 | int main() |
eins | 0:46005cfeedb5 | 19 | { |
eins | 1:ae0b11ca17d1 | 20 | I2C I2C_Oled(PB_7, PA_15); // SDA, SCL |
eins | 0:46005cfeedb5 | 21 | I2C_Oled.frequency(400000); // 400kHz clock |
eins | 0:46005cfeedb5 | 22 | |
eins | 1:ae0b11ca17d1 | 23 | Adafruit_SSD1306_I2c myOled(I2C_Oled, PA_1); // D2 |
eins | 0:46005cfeedb5 | 24 | |
eins | 0:46005cfeedb5 | 25 | myOled.splash(); // logo output |
eins | 0:46005cfeedb5 | 26 | myOled.display(); |
eins | 0:46005cfeedb5 | 27 | wait(0.5); |
eins | 0:46005cfeedb5 | 28 | |
eins | 0:46005cfeedb5 | 29 | myOled.clearDisplay(); // clear buffer |
eins | 0:46005cfeedb5 | 30 | myOled.printf("%u x %u OLED Display\r\n", myOled.width(), myOled.height()); |
eins | 0:46005cfeedb5 | 31 | myOled.display(); // show a image on the OLED |
eins | 0:46005cfeedb5 | 32 | wait(1); |
eins | 0:46005cfeedb5 | 33 | |
eins | 0:46005cfeedb5 | 34 | uint16_t n = 0; |
eins | 0:46005cfeedb5 | 35 | |
eins | 0:46005cfeedb5 | 36 | while(1) |
eins | 0:46005cfeedb5 | 37 | { |
eins | 0:46005cfeedb5 | 38 | myled = !myled; |
eins | 0:46005cfeedb5 | 39 | |
eins | 0:46005cfeedb5 | 40 | myOled.clearDisplay(); |
eins | 0:46005cfeedb5 | 41 | myOled.setTextCursor(1, 5); |
eins | 0:46005cfeedb5 | 42 | myOled.printf("<<< UNIST DHE: %u >>>",n++); |
eins | 0:46005cfeedb5 | 43 | myOled.display(); |
eins | 0:46005cfeedb5 | 44 | wait(0.1); |
eins | 0:46005cfeedb5 | 45 | } |
eins | 0:46005cfeedb5 | 46 | } |