PR_2 DonghunKang
Dependencies: mbed Adafruit_GFX
main.cpp@0:5241b121daec, 2019-10-15 (annotated)
- Committer:
- Donghun
- Date:
- Tue Oct 15 13:36:45 2019 +0000
- Revision:
- 0:5241b121daec
Pr_2
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Donghun | 0:5241b121daec | 1 | #include "mbed.h" |
Donghun | 0:5241b121daec | 2 | #include "Adafruit_SSD1306.h" |
Donghun | 0:5241b121daec | 3 | |
Donghun | 0:5241b121daec | 4 | DigitalOut myled(LED1); |
Donghun | 0:5241b121daec | 5 | |
Donghun | 0:5241b121daec | 6 | #define PR_3 |
Donghun | 0:5241b121daec | 7 | |
Donghun | 0:5241b121daec | 8 | #ifdef Test |
Donghun | 0:5241b121daec | 9 | int main() |
Donghun | 0:5241b121daec | 10 | { |
Donghun | 0:5241b121daec | 11 | I2C I2C_Oled(PB_7, PA_15); |
Donghun | 0:5241b121daec | 12 | I2C_Oled.frequency(400000); |
Donghun | 0:5241b121daec | 13 | |
Donghun | 0:5241b121daec | 14 | Adafruit_SSD1306_I2c myOled(I2C_Oled, PA_1); |
Donghun | 0:5241b121daec | 15 | myOled.splash(); |
Donghun | 0:5241b121daec | 16 | myOled.display(); |
Donghun | 0:5241b121daec | 17 | wait(0.5); |
Donghun | 0:5241b121daec | 18 | |
Donghun | 0:5241b121daec | 19 | myOled.clearDisplay(); |
Donghun | 0:5241b121daec | 20 | myOled.printf("%u x %u OLED Display\r\n", myOled.width(), myOled.height()); |
Donghun | 0:5241b121daec | 21 | myOled.display(); |
Donghun | 0:5241b121daec | 22 | wait(1); |
Donghun | 0:5241b121daec | 23 | |
Donghun | 0:5241b121daec | 24 | uint16_t n = 0; |
Donghun | 0:5241b121daec | 25 | |
Donghun | 0:5241b121daec | 26 | while(1) |
Donghun | 0:5241b121daec | 27 | { |
Donghun | 0:5241b121daec | 28 | myled = !myled; |
Donghun | 0:5241b121daec | 29 | myOled.clearDisplay(); |
Donghun | 0:5241b121daec | 30 | myOled.setTextCursor(1,5); |
Donghun | 0:5241b121daec | 31 | myOled.printf("<<< UNIST DHE: %u >>>", n++); |
Donghun | 0:5241b121daec | 32 | myOled.display(); |
Donghun | 0:5241b121daec | 33 | wait(0.1); |
Donghun | 0:5241b121daec | 34 | } |
Donghun | 0:5241b121daec | 35 | } |
Donghun | 0:5241b121daec | 36 | #endif |
Donghun | 0:5241b121daec | 37 | |
Donghun | 0:5241b121daec | 38 | #ifdef PR_1 |
Donghun | 0:5241b121daec | 39 | int main() |
Donghun | 0:5241b121daec | 40 | { |
Donghun | 0:5241b121daec | 41 | I2C I2C_Oled(PB_7, PA_15); |
Donghun | 0:5241b121daec | 42 | I2C_Oled.frequency(400000); |
Donghun | 0:5241b121daec | 43 | |
Donghun | 0:5241b121daec | 44 | Adafruit_SSD1306_I2c myOled(I2C_Oled, PA_1); |
Donghun | 0:5241b121daec | 45 | myOled.splash(); |
Donghun | 0:5241b121daec | 46 | myOled.display(); |
Donghun | 0:5241b121daec | 47 | wait(0.5); |
Donghun | 0:5241b121daec | 48 | |
Donghun | 0:5241b121daec | 49 | myOled.clearDisplay(); |
Donghun | 0:5241b121daec | 50 | myOled.printf("%u x %u OLED Display\r\n", myOled.width(), myOled.height()); |
Donghun | 0:5241b121daec | 51 | myOled.display(); |
Donghun | 0:5241b121daec | 52 | wait(1); |
Donghun | 0:5241b121daec | 53 | |
Donghun | 0:5241b121daec | 54 | while(1) |
Donghun | 0:5241b121daec | 55 | { |
Donghun | 0:5241b121daec | 56 | myOled.clearDisplay(); |
Donghun | 0:5241b121daec | 57 | myOled.setTextCursor(1,5); |
Donghun | 0:5241b121daec | 58 | myled = !myled; |
Donghun | 0:5241b121daec | 59 | |
Donghun | 0:5241b121daec | 60 | myOled.display(); |
Donghun | 0:5241b121daec | 61 | } |
Donghun | 0:5241b121daec | 62 | } |
Donghun | 0:5241b121daec | 63 | #endif |
Donghun | 0:5241b121daec | 64 | |
Donghun | 0:5241b121daec | 65 | #ifdef PR_2 |
Donghun | 0:5241b121daec | 66 | int main() |
Donghun | 0:5241b121daec | 67 | { |
Donghun | 0:5241b121daec | 68 | I2C I2C_Oled(PB_7, PA_15); |
Donghun | 0:5241b121daec | 69 | I2C_Oled.frequency(400000); |
Donghun | 0:5241b121daec | 70 | |
Donghun | 0:5241b121daec | 71 | Adafruit_SSD1306_I2c myOled(I2C_Oled, PA_1); |
Donghun | 0:5241b121daec | 72 | myOled.splash(); |
Donghun | 0:5241b121daec | 73 | myOled.display(); |
Donghun | 0:5241b121daec | 74 | wait(0.5); |
Donghun | 0:5241b121daec | 75 | |
Donghun | 0:5241b121daec | 76 | myOled.clearDisplay(); |
Donghun | 0:5241b121daec | 77 | myOled.printf("%u x %u OLED Display\r\n", myOled.width(), myOled.height()); |
Donghun | 0:5241b121daec | 78 | myOled.display(); |
Donghun | 0:5241b121daec | 79 | wait(1); |
Donghun | 0:5241b121daec | 80 | |
Donghun | 0:5241b121daec | 81 | while(1) |
Donghun | 0:5241b121daec | 82 | { |
Donghun | 0:5241b121daec | 83 | myOled.clearDisplay(); |
Donghun | 0:5241b121daec | 84 | myOled.setTextSize(3); |
Donghun | 0:5241b121daec | 85 | myOled.setTextColor(BLACK, WHITE); |
Donghun | 0:5241b121daec | 86 | myOled.setTextCursor(1,1); |
Donghun | 0:5241b121daec | 87 | myOled.printf("Read This?"); |
Donghun | 0:5241b121daec | 88 | myOled.display(); |
Donghun | 0:5241b121daec | 89 | wait(1); |
Donghun | 0:5241b121daec | 90 | myOled.clearDisplay(); |
Donghun | 0:5241b121daec | 91 | myOled.setTextSize(2); |
Donghun | 0:5241b121daec | 92 | myOled.setTextColor(BLACK, WHITE); |
Donghun | 0:5241b121daec | 93 | myOled.setTextCursor(1,1); |
Donghun | 0:5241b121daec | 94 | myOled.printf("How About This?"); |
Donghun | 0:5241b121daec | 95 | myOled.display(); |
Donghun | 0:5241b121daec | 96 | wait(1); |
Donghun | 0:5241b121daec | 97 | myOled.clearDisplay(); |
Donghun | 0:5241b121daec | 98 | myOled.setTextSize(1); |
Donghun | 0:5241b121daec | 99 | myOled.setTextColor(BLACK, WHITE); |
Donghun | 0:5241b121daec | 100 | myOled.setTextCursor(1,1); |
Donghun | 0:5241b121daec | 101 | myOled.printf("Really?"); |
Donghun | 0:5241b121daec | 102 | myOled.display(); |
Donghun | 0:5241b121daec | 103 | wait(1); |
Donghun | 0:5241b121daec | 104 | myOled.clearDisplay(); |
Donghun | 0:5241b121daec | 105 | myOled.setTextColor(WHITE); |
Donghun | 0:5241b121daec | 106 | myOled.setTextCursor(0,0); |
Donghun | 0:5241b121daec | 107 | myOled.setTextSize(1); |
Donghun | 0:5241b121daec | 108 | myOled.printf("A"); |
Donghun | 0:5241b121daec | 109 | myOled.setTextSize(2); |
Donghun | 0:5241b121daec | 110 | myOled.printf("A"); |
Donghun | 0:5241b121daec | 111 | myOled.setTextSize(3); |
Donghun | 0:5241b121daec | 112 | myOled.printf("A"); |
Donghun | 0:5241b121daec | 113 | myOled.setTextSize(4); |
Donghun | 0:5241b121daec | 114 | myOled.printf("A"); |
Donghun | 0:5241b121daec | 115 | myOled.setTextSize(5); |
Donghun | 0:5241b121daec | 116 | myOled.printf("A"); |
Donghun | 0:5241b121daec | 117 | myOled.setTextSize(6); |
Donghun | 0:5241b121daec | 118 | myOled.printf("A"); |
Donghun | 0:5241b121daec | 119 | myOled.display(); |
Donghun | 0:5241b121daec | 120 | wait(1); |
Donghun | 0:5241b121daec | 121 | myOled.clearDisplay(); |
Donghun | 0:5241b121daec | 122 | myOled.clearDisplay(); |
Donghun | 0:5241b121daec | 123 | myOled.drawRect(100, 10, 20, 20, WHITE); |
Donghun | 0:5241b121daec | 124 | myOled.display(); |
Donghun | 0:5241b121daec | 125 | wait(1); |
Donghun | 0:5241b121daec | 126 | myOled.fillRect(10, 10, 45, 15, WHITE); |
Donghun | 0:5241b121daec | 127 | myOled.display(); |
Donghun | 0:5241b121daec | 128 | wait(1); |
Donghun | 0:5241b121daec | 129 | myOled.drawRoundRect(60, 20, 35, 35, 8, WHITE); |
Donghun | 0:5241b121daec | 130 | myOled.display(); |
Donghun | 0:5241b121daec | 131 | wait(1); |
Donghun | 0:5241b121daec | 132 | myOled.drawCircle(60, 30, 30, WHITE); |
Donghun | 0:5241b121daec | 133 | myOled.display(); |
Donghun | 0:5241b121daec | 134 | wait(1); |
Donghun | 0:5241b121daec | 135 | myOled.fillCircle(100, 20, 5, WHITE); |
Donghun | 0:5241b121daec | 136 | myOled.display(); |
Donghun | 0:5241b121daec | 137 | wait(1); |
Donghun | 0:5241b121daec | 138 | myOled.fillCircle(70, 20, 5, WHITE); |
Donghun | 0:5241b121daec | 139 | myOled.display(); |
Donghun | 0:5241b121daec | 140 | wait(1); |
Donghun | 0:5241b121daec | 141 | myOled.drawTriangle(24, 1, 3, 55, 45, 55, WHITE); |
Donghun | 0:5241b121daec | 142 | myOled.display(); |
Donghun | 0:5241b121daec | 143 | wait(1); |
Donghun | 0:5241b121daec | 144 | myOled.fillTriangle(104, 62, 125, 9, 83, 9, WHITE); |
Donghun | 0:5241b121daec | 145 | myOled.display(); |
Donghun | 0:5241b121daec | 146 | wait(1); |
Donghun | 0:5241b121daec | 147 | } |
Donghun | 0:5241b121daec | 148 | } |
Donghun | 0:5241b121daec | 149 | #endif |
Donghun | 0:5241b121daec | 150 | |
Donghun | 0:5241b121daec | 151 | #ifdef PR_3 |
Donghun | 0:5241b121daec | 152 | int main() |
Donghun | 0:5241b121daec | 153 | { |
Donghun | 0:5241b121daec | 154 | I2C I2C_Oled(PB_7, PA_15); |
Donghun | 0:5241b121daec | 155 | I2C_Oled.frequency(400000); |
Donghun | 0:5241b121daec | 156 | |
Donghun | 0:5241b121daec | 157 | Adafruit_SSD1306_I2c myOled(I2C_Oled, PA_1); |
Donghun | 0:5241b121daec | 158 | myOled.splash(); |
Donghun | 0:5241b121daec | 159 | myOled.display(); |
Donghun | 0:5241b121daec | 160 | wait(0.5); |
Donghun | 0:5241b121daec | 161 | |
Donghun | 0:5241b121daec | 162 | myOled.clearDisplay(); |
Donghun | 0:5241b121daec | 163 | myOled.printf("%u x %u OLED Display\r\n", myOled.width(), myOled.height()); |
Donghun | 0:5241b121daec | 164 | myOled.display(); |
Donghun | 0:5241b121daec | 165 | wait(1); |
Donghun | 0:5241b121daec | 166 | |
Donghun | 0:5241b121daec | 167 | static const unsigned char panda[] = |
Donghun | 0:5241b121daec | 168 | { |
Donghun | 0:5241b121daec | 169 | |
Donghun | 0:5241b121daec | 170 | }; |
Donghun | 0:5241b121daec | 171 | while(1) |
Donghun | 0:5241b121daec | 172 | { |
Donghun | 0:5241b121daec | 173 | myOled.clearDisplay(); |
Donghun | 0:5241b121daec | 174 | myOled.drawBitmap(32,16,panda, 64, 32, WHITE); |
Donghun | 0:5241b121daec | 175 | myOled.display(); |
Donghun | 0:5241b121daec | 176 | wait(0.5); |
Donghun | 0:5241b121daec | 177 | } |
Donghun | 0:5241b121daec | 178 | } |
Donghun | 0:5241b121daec | 179 | #endif |