display i2c
Dependencies: mbed SSD1308_128x64_I2C USBDevice
main.cpp@7:ae282775cbcc, 2015-01-01 (annotated)
- Committer:
- wim
- Date:
- Thu Jan 01 17:54:33 2015 +0000
- Revision:
- 7:ae282775cbcc
- Parent:
- 6:44256b0b5d18
- Child:
- 8:8d49c965b3ec
Added option to select optimisation using low level I2C methods. Testing on F401 and LPC1768.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
wim | 1:00053cb70ac5 | 1 | /* mbed Seeed 128x64 OLED Test |
wim | 1:00053cb70ac5 | 2 | * http://www.seeedstudio.com/depot/grove-oled-display-12864-p-781.html?cPath=163_167 |
wim | 1:00053cb70ac5 | 3 | * |
wim | 1:00053cb70ac5 | 4 | * Copyright (c) 2012 Wim Huiskamp |
wim | 1:00053cb70ac5 | 5 | * Released under the MIT License: http://mbed.org/license/mit |
wim | 1:00053cb70ac5 | 6 | * |
wim | 1:00053cb70ac5 | 7 | * version 0.2 Initial Release |
wim | 1:00053cb70ac5 | 8 | */ |
wim | 1:00053cb70ac5 | 9 | #include "mbed.h" |
wim | 1:00053cb70ac5 | 10 | #include "mbed_logo.h" |
wim | 1:00053cb70ac5 | 11 | #include "SSD1308.h" |
wim | 1:00053cb70ac5 | 12 | |
wim | 7:ae282775cbcc | 13 | #if defined(TARGET_LPC1768) |
wim | 1:00053cb70ac5 | 14 | //Pin Defines for I2C Bus |
wim | 1:00053cb70ac5 | 15 | //#define D_SDA p9 |
wim | 1:00053cb70ac5 | 16 | //#define D_SCL p10 |
wim | 1:00053cb70ac5 | 17 | #define D_SDA p28 |
wim | 1:00053cb70ac5 | 18 | #define D_SCL p27 |
wim | 7:ae282775cbcc | 19 | #endif |
wim | 7:ae282775cbcc | 20 | |
wim | 7:ae282775cbcc | 21 | #if defined(TARGET_NUCLEO_F401RE) |
wim | 7:ae282775cbcc | 22 | #define D_SDA PB_9 |
wim | 7:ae282775cbcc | 23 | #define D_SCL PB_8 |
wim | 7:ae282775cbcc | 24 | #endif |
wim | 7:ae282775cbcc | 25 | |
wim | 7:ae282775cbcc | 26 | #if defined(TARGET_KL25Z) |
wim | 7:ae282775cbcc | 27 | // I2C for KL25Z |
wim | 7:ae282775cbcc | 28 | #define D_SCL PTE1 |
wim | 7:ae282775cbcc | 29 | #define D_SDA PTE0 |
wim | 7:ae282775cbcc | 30 | #endif |
wim | 7:ae282775cbcc | 31 | |
wim | 1:00053cb70ac5 | 32 | I2C i2c(D_SDA, D_SCL); |
wim | 1:00053cb70ac5 | 33 | |
wim | 1:00053cb70ac5 | 34 | //Host PC Baudrate (Virtual Com Port on USB) |
wim | 1:00053cb70ac5 | 35 | #define D_BAUDRATE 9600 |
wim | 1:00053cb70ac5 | 36 | //#define D_BAUDRATE 57600 |
wim | 1:00053cb70ac5 | 37 | |
wim | 1:00053cb70ac5 | 38 | // mbed Interface Hardware definitions |
wim | 1:00053cb70ac5 | 39 | DigitalOut myled1(LED1); |
wim | 1:00053cb70ac5 | 40 | DigitalOut myled2(LED2); |
wim | 1:00053cb70ac5 | 41 | DigitalOut myled3(LED3); |
wim | 1:00053cb70ac5 | 42 | DigitalOut heartbeatLED(LED4); |
wim | 1:00053cb70ac5 | 43 | |
wim | 1:00053cb70ac5 | 44 | // Host PC Communication channels |
wim | 1:00053cb70ac5 | 45 | Serial pc(USBTX, USBRX); // tx, rx |
wim | 1:00053cb70ac5 | 46 | |
wim | 1:00053cb70ac5 | 47 | // Instantiate OLED |
wim | 1:00053cb70ac5 | 48 | SSD1308 oled = SSD1308(i2c, SSD1308_SA0); |
wim | 1:00053cb70ac5 | 49 | |
wim | 1:00053cb70ac5 | 50 | void show_menu() { |
wim | 3:1337e3d65ed0 | 51 | pc.printf("0: Exit\r"); |
wim | 3:1337e3d65ed0 | 52 | pc.printf("1: Show Menu\r"); |
wim | 3:1337e3d65ed0 | 53 | pc.printf("2: Send Message\r"); |
wim | 3:1337e3d65ed0 | 54 | pc.printf("3: Fill Display\r"); |
wim | 3:1337e3d65ed0 | 55 | pc.printf("4: Display cleared\r"); |
wim | 3:1337e3d65ed0 | 56 | pc.printf("5: Display off\r"); |
wim | 3:1337e3d65ed0 | 57 | pc.printf("6: Display on\r"); |
wim | 3:1337e3d65ed0 | 58 | pc.printf("7: Display Invert\r"); |
wim | 3:1337e3d65ed0 | 59 | pc.printf("8: Display Normal\r"); |
wim | 3:1337e3d65ed0 | 60 | pc.printf("9: Display Bitmap\r"); |
wim | 3:1337e3d65ed0 | 61 | pc.printf("A: Brightness Ramp\r"); |
wim | 3:1337e3d65ed0 | 62 | pc.printf("B: Send Inverted Message\r"); |
wim | 3:1337e3d65ed0 | 63 | pc.printf("C: Flip and Mirror\r"); |
wim | 3:1337e3d65ed0 | 64 | pc.printf("D: Blink\r"); |
wim | 3:1337e3d65ed0 | 65 | pc.printf("E: Big Chars\r"); |
wim | 5:dff410a009c5 | 66 | pc.printf("F: Progress Scale\r"); |
wim | 6:44256b0b5d18 | 67 | pc.printf("G: Scroll\r"); |
wim | 6:44256b0b5d18 | 68 | pc.printf("H: Hor Scroll\r"); |
wim | 6:44256b0b5d18 | 69 | pc.printf("V: Ver and Hor Scroll\r"); |
wim | 1:00053cb70ac5 | 70 | // pc.printf("\n\r"); |
wim | 1:00053cb70ac5 | 71 | |
wim | 1:00053cb70ac5 | 72 | } |
wim | 1:00053cb70ac5 | 73 | |
wim | 1:00053cb70ac5 | 74 | |
wim | 1:00053cb70ac5 | 75 | void oled_Test() { |
wim | 7:ae282775cbcc | 76 | pc.printf("OLED test start\r"); |
wim | 7:ae282775cbcc | 77 | |
wim | 7:ae282775cbcc | 78 | #if defined(TARGET_LPC1768) |
wim | 7:ae282775cbcc | 79 | pc.printf("\r\nHello World from LPC1768\r\n"); |
wim | 7:ae282775cbcc | 80 | #endif |
wim | 7:ae282775cbcc | 81 | #if defined(TARGET_KL25Z) |
wim | 7:ae282775cbcc | 82 | pc.printf("\r\nHello World from KL25Z\r\n"); |
wim | 7:ae282775cbcc | 83 | #endif |
wim | 7:ae282775cbcc | 84 | #if defined(TARGET_LPC812) |
wim | 7:ae282775cbcc | 85 | pc.printf("\r\nHello World from LPC812\r\n"); |
wim | 7:ae282775cbcc | 86 | #endif |
wim | 7:ae282775cbcc | 87 | #if defined(TARGET_LPC1549) |
wim | 7:ae282775cbcc | 88 | pc.printf("Hello World from LPC1549\n\r"); |
wim | 7:ae282775cbcc | 89 | #endif |
wim | 7:ae282775cbcc | 90 | #if defined(TARGET_NUCLEO_F401RE) |
wim | 7:ae282775cbcc | 91 | pc.printf("Hello World from ST32F401RE\n\r"); |
wim | 7:ae282775cbcc | 92 | #endif |
wim | 7:ae282775cbcc | 93 | #if defined(TARGET_NUCLEO_F103RB) |
wim | 7:ae282775cbcc | 94 | pc.printf("Hello World from ST32F103RB\n\r"); |
wim | 7:ae282775cbcc | 95 | #endif |
wim | 7:ae282775cbcc | 96 | |
wim | 1:00053cb70ac5 | 97 | |
wim | 6:44256b0b5d18 | 98 | // oled.writeString(0, 0, 13, "Hello World !"); |
wim | 6:44256b0b5d18 | 99 | oled.writeString(0, 0, "Hello World !"); |
wim | 6:44256b0b5d18 | 100 | pc.printf("Printed something\r"); |
wim | 1:00053cb70ac5 | 101 | wait(3); |
wim | 1:00053cb70ac5 | 102 | |
wim | 6:44256b0b5d18 | 103 | // oled.writeString(1, 0, 8, "baz quux"); |
wim | 6:44256b0b5d18 | 104 | oled.writeString(1, 0, "baz quux"); |
wim | 6:44256b0b5d18 | 105 | pc.printf("Printed something\r"); |
wim | 1:00053cb70ac5 | 106 | wait(3); |
wim | 1:00053cb70ac5 | 107 | |
wim | 1:00053cb70ac5 | 108 | // oled.writeString(4, 0, 272, "a long, rather lengthy, extended string passage thing, eh, that just goes on, and on, and on, and on, and on, and on, and on, yes, further, continuing, extending, expanding beyond all reason or sanity!!!!! and yet, there's more! so much more! for ever and ever, oh yeah"); |
wim | 6:44256b0b5d18 | 109 | // pc.printf("Printed something\r"); |
wim | 1:00053cb70ac5 | 110 | // wait(3); |
wim | 1:00053cb70ac5 | 111 | |
wim | 1:00053cb70ac5 | 112 | oled.fillDisplay(0xAA); |
wim | 6:44256b0b5d18 | 113 | pc.printf("Display filled\r"); |
wim | 1:00053cb70ac5 | 114 | wait(3); |
wim | 1:00053cb70ac5 | 115 | |
wim | 1:00053cb70ac5 | 116 | oled.setDisplayOff(); |
wim | 6:44256b0b5d18 | 117 | pc.printf("Display off\r"); |
wim | 1:00053cb70ac5 | 118 | wait(0.5); |
wim | 1:00053cb70ac5 | 119 | |
wim | 1:00053cb70ac5 | 120 | oled.setDisplayOn(); |
wim | 6:44256b0b5d18 | 121 | pc.printf("Display on\r"); |
wim | 1:00053cb70ac5 | 122 | wait(0.5); |
wim | 1:00053cb70ac5 | 123 | |
wim | 1:00053cb70ac5 | 124 | oled.clearDisplay(); |
wim | 6:44256b0b5d18 | 125 | pc.printf("Display cleared\r"); |
wim | 1:00053cb70ac5 | 126 | wait(0.5); |
wim | 1:00053cb70ac5 | 127 | |
wim | 6:44256b0b5d18 | 128 | // oled.writeString(0, 0, 11, "Bye World !"); |
wim | 6:44256b0b5d18 | 129 | oled.writeString(0, 0, "Bye World !"); |
wim | 6:44256b0b5d18 | 130 | pc.printf("Printed something\r"); |
wim | 1:00053cb70ac5 | 131 | wait(3); |
wim | 1:00053cb70ac5 | 132 | |
wim | 6:44256b0b5d18 | 133 | pc.printf("OLED test done\r"); |
wim | 1:00053cb70ac5 | 134 | } |
wim | 1:00053cb70ac5 | 135 | |
wim | 1:00053cb70ac5 | 136 | // Variables for Heartbeat and Status monitoring |
wim | 1:00053cb70ac5 | 137 | Ticker heartbeat; |
wim | 1:00053cb70ac5 | 138 | bool heartbeatflag=false; |
wim | 1:00053cb70ac5 | 139 | |
wim | 1:00053cb70ac5 | 140 | // Local functions |
wim | 1:00053cb70ac5 | 141 | void clear_screen() { |
wim | 1:00053cb70ac5 | 142 | //ANSI Terminal Commands |
wim | 1:00053cb70ac5 | 143 | pc.printf("\x1B[2J"); |
wim | 1:00053cb70ac5 | 144 | pc.printf("\x1B[H"); |
wim | 1:00053cb70ac5 | 145 | } |
wim | 1:00053cb70ac5 | 146 | |
wim | 1:00053cb70ac5 | 147 | |
wim | 1:00053cb70ac5 | 148 | void init_interfaces() { |
wim | 1:00053cb70ac5 | 149 | // Init Host PC communication, default is 9600 |
wim | 1:00053cb70ac5 | 150 | pc.baud(D_BAUDRATE); |
wim | 1:00053cb70ac5 | 151 | |
wim | 1:00053cb70ac5 | 152 | // Init I/F hardware |
wim | 1:00053cb70ac5 | 153 | // i2c.frequency(100000); |
wim | 1:00053cb70ac5 | 154 | i2c.frequency(400000); // according to the spec the max bitrate for the SSD1308 is 400 kbit/s |
wim | 1:00053cb70ac5 | 155 | } |
wim | 1:00053cb70ac5 | 156 | |
wim | 1:00053cb70ac5 | 157 | |
wim | 1:00053cb70ac5 | 158 | // Heartbeat monitor |
wim | 1:00053cb70ac5 | 159 | void pulse() { |
wim | 1:00053cb70ac5 | 160 | heartbeatLED = !heartbeatLED; |
wim | 1:00053cb70ac5 | 161 | } |
wim | 1:00053cb70ac5 | 162 | |
wim | 1:00053cb70ac5 | 163 | void heartbeat_start() { |
wim | 1:00053cb70ac5 | 164 | heartbeat.attach(&pulse, 0.5); |
wim | 1:00053cb70ac5 | 165 | } |
wim | 1:00053cb70ac5 | 166 | |
wim | 1:00053cb70ac5 | 167 | void heartbeat_stop() { |
wim | 1:00053cb70ac5 | 168 | heartbeat.detach(); |
wim | 1:00053cb70ac5 | 169 | } |
wim | 1:00053cb70ac5 | 170 | |
wim | 1:00053cb70ac5 | 171 | |
wim | 1:00053cb70ac5 | 172 | int main() { |
wim | 1:00053cb70ac5 | 173 | bool running=true; |
wim | 2:d86478c0f5da | 174 | bool left = true; |
wim | 2:d86478c0f5da | 175 | bool down = true; |
wim | 2:d86478c0f5da | 176 | |
wim | 1:00053cb70ac5 | 177 | char command; |
wim | 1:00053cb70ac5 | 178 | |
wim | 1:00053cb70ac5 | 179 | init_interfaces(); |
wim | 1:00053cb70ac5 | 180 | |
wim | 1:00053cb70ac5 | 181 | heartbeat_start(); |
wim | 1:00053cb70ac5 | 182 | |
wim | 1:00053cb70ac5 | 183 | clear_screen(); |
wim | 1:00053cb70ac5 | 184 | |
wim | 6:44256b0b5d18 | 185 | pc.printf("Hello World!\r"); |
wim | 1:00053cb70ac5 | 186 | |
wim | 1:00053cb70ac5 | 187 | #if(0) |
wim | 1:00053cb70ac5 | 188 | // Quick test |
wim | 1:00053cb70ac5 | 189 | oled_Test(); |
wim | 1:00053cb70ac5 | 190 | |
wim | 1:00053cb70ac5 | 191 | while(1) { |
wim | 1:00053cb70ac5 | 192 | myled1 = 1; |
wim | 1:00053cb70ac5 | 193 | wait(0.2); |
wim | 1:00053cb70ac5 | 194 | |
wim | 1:00053cb70ac5 | 195 | myled1 = 0; |
wim | 1:00053cb70ac5 | 196 | wait(0.2); |
wim | 1:00053cb70ac5 | 197 | pc.printf("*"); |
wim | 1:00053cb70ac5 | 198 | } |
wim | 1:00053cb70ac5 | 199 | #else |
wim | 1:00053cb70ac5 | 200 | // Interactive Test |
wim | 1:00053cb70ac5 | 201 | show_menu(); |
wim | 1:00053cb70ac5 | 202 | |
wim | 1:00053cb70ac5 | 203 | while(running) { |
wim | 1:00053cb70ac5 | 204 | |
wim | 1:00053cb70ac5 | 205 | if(pc.readable()) { |
wim | 1:00053cb70ac5 | 206 | command = pc.getc(); |
wim | 3:1337e3d65ed0 | 207 | //pc.printf("command= %c \n\r", command); |
wim | 3:1337e3d65ed0 | 208 | pc.printf("\r"); |
wim | 3:1337e3d65ed0 | 209 | |
wim | 1:00053cb70ac5 | 210 | switch (command) { |
wim | 1:00053cb70ac5 | 211 | case '0' : |
wim | 6:44256b0b5d18 | 212 | pc.printf("Done\r"); |
wim | 1:00053cb70ac5 | 213 | running = false; |
wim | 1:00053cb70ac5 | 214 | break; |
wim | 1:00053cb70ac5 | 215 | |
wim | 1:00053cb70ac5 | 216 | case '1' : |
wim | 1:00053cb70ac5 | 217 | show_menu(); |
wim | 1:00053cb70ac5 | 218 | break; |
wim | 1:00053cb70ac5 | 219 | |
wim | 1:00053cb70ac5 | 220 | case '2' : |
wim | 6:44256b0b5d18 | 221 | pc.printf("Hello World!\r"); |
wim | 7:ae282775cbcc | 222 | oled.writeString(0, 0, "Hello World !"); |
wim | 1:00053cb70ac5 | 223 | break; |
wim | 1:00053cb70ac5 | 224 | |
wim | 1:00053cb70ac5 | 225 | case '3' : |
wim | 6:44256b0b5d18 | 226 | pc.printf("Fill part of Display 0xA5\r"); |
wim | 3:1337e3d65ed0 | 227 | // oled.fillDisplay(0xA5); |
wim | 3:1337e3d65ed0 | 228 | |
wim | 3:1337e3d65ed0 | 229 | oled.fillDisplay(0xA5, 2, 5, 0, 63); |
wim | 1:00053cb70ac5 | 230 | break; |
wim | 1:00053cb70ac5 | 231 | |
wim | 1:00053cb70ac5 | 232 | case '4' : |
wim | 6:44256b0b5d18 | 233 | pc.printf("Display cleared\r"); |
wim | 1:00053cb70ac5 | 234 | oled.clearDisplay(); |
wim | 1:00053cb70ac5 | 235 | break; |
wim | 1:00053cb70ac5 | 236 | |
wim | 1:00053cb70ac5 | 237 | case '5' : |
wim | 6:44256b0b5d18 | 238 | pc.printf("Display off\r"); |
wim | 1:00053cb70ac5 | 239 | oled.setDisplayOff(); |
wim | 1:00053cb70ac5 | 240 | break; |
wim | 1:00053cb70ac5 | 241 | case '6' : |
wim | 6:44256b0b5d18 | 242 | pc.printf("Display on\r"); |
wim | 1:00053cb70ac5 | 243 | oled.setDisplayOn(); |
wim | 1:00053cb70ac5 | 244 | break; |
wim | 1:00053cb70ac5 | 245 | |
wim | 1:00053cb70ac5 | 246 | case '7' : |
wim | 6:44256b0b5d18 | 247 | pc.printf("Display Invert\r"); |
wim | 1:00053cb70ac5 | 248 | oled.setDisplayInverse(); |
wim | 1:00053cb70ac5 | 249 | break; |
wim | 1:00053cb70ac5 | 250 | |
wim | 1:00053cb70ac5 | 251 | case '8' : |
wim | 6:44256b0b5d18 | 252 | pc.printf("Display Normal\r"); |
wim | 1:00053cb70ac5 | 253 | oled.setDisplayNormal(); |
wim | 1:00053cb70ac5 | 254 | break; |
wim | 1:00053cb70ac5 | 255 | |
wim | 1:00053cb70ac5 | 256 | case '9' : |
wim | 6:44256b0b5d18 | 257 | pc.printf("Display bitmap\r"); |
wim | 3:1337e3d65ed0 | 258 | oled.writeBitmap((uint8_t*) mbed_logo); |
wim | 3:1337e3d65ed0 | 259 | |
wim | 1:00053cb70ac5 | 260 | break; |
wim | 1:00053cb70ac5 | 261 | |
wim | 1:00053cb70ac5 | 262 | case 'A' : |
wim | 6:44256b0b5d18 | 263 | pc.printf("Brightness Ramp Down\r"); |
wim | 3:1337e3d65ed0 | 264 | for (int contrast=0x7F; contrast >= 0x10; contrast--) { |
wim | 2:d86478c0f5da | 265 | oled.setContrastControl(contrast); |
wim | 2:d86478c0f5da | 266 | wait(0.05); |
wim | 2:d86478c0f5da | 267 | } |
wim | 2:d86478c0f5da | 268 | |
wim | 2:d86478c0f5da | 269 | wait(1); |
wim | 3:1337e3d65ed0 | 270 | |
wim | 6:44256b0b5d18 | 271 | pc.printf("Brightness Ramp Up\r"); |
wim | 3:1337e3d65ed0 | 272 | for (int contrast=0x10; contrast <= 0x7F; contrast++) { |
wim | 2:d86478c0f5da | 273 | oled.setContrastControl(contrast); |
wim | 2:d86478c0f5da | 274 | wait(0.05); |
wim | 2:d86478c0f5da | 275 | } |
wim | 2:d86478c0f5da | 276 | |
wim | 6:44256b0b5d18 | 277 | pc.printf("Brightness Ramp Done\r"); |
wim | 3:1337e3d65ed0 | 278 | |
wim | 1:00053cb70ac5 | 279 | break; |
wim | 1:00053cb70ac5 | 280 | |
wim | 1:00053cb70ac5 | 281 | case 'B' : |
wim | 6:44256b0b5d18 | 282 | pc.printf("Send Inverted Message\r"); |
wim | 3:1337e3d65ed0 | 283 | oled.setInverted(true); |
wim | 6:44256b0b5d18 | 284 | // oled.writeString(0, 0, 13, "Hello World !"); |
wim | 6:44256b0b5d18 | 285 | oled.writeString(0, 0, "Hello World !"); |
wim | 3:1337e3d65ed0 | 286 | oled.setInverted(false); |
wim | 3:1337e3d65ed0 | 287 | |
wim | 3:1337e3d65ed0 | 288 | oled.printf(" Result is %d", 12345); |
wim | 3:1337e3d65ed0 | 289 | |
wim | 2:d86478c0f5da | 290 | break; |
wim | 2:d86478c0f5da | 291 | |
wim | 2:d86478c0f5da | 292 | case 'C' : |
wim | 6:44256b0b5d18 | 293 | pc.printf("Flip and Mirror (Rewrite display to show horizontal effect)\r"); |
wim | 2:d86478c0f5da | 294 | left = !left; |
wim | 2:d86478c0f5da | 295 | down = !down; |
wim | 2:d86478c0f5da | 296 | oled.setDisplayFlip(left, down); |
wim | 3:1337e3d65ed0 | 297 | break; |
wim | 3:1337e3d65ed0 | 298 | |
wim | 3:1337e3d65ed0 | 299 | case 'D' : |
wim | 6:44256b0b5d18 | 300 | pc.printf("D: Blink and Fade (not supported)\r"); |
wim | 3:1337e3d65ed0 | 301 | |
wim | 3:1337e3d65ed0 | 302 | // oled.setDisplayBlink(true); |
wim | 3:1337e3d65ed0 | 303 | // wait(4); |
wim | 3:1337e3d65ed0 | 304 | // oled.setDisplayBlink(false); |
wim | 3:1337e3d65ed0 | 305 | |
wim | 3:1337e3d65ed0 | 306 | oled.setDisplayFade(true); |
wim | 3:1337e3d65ed0 | 307 | wait(4); |
wim | 3:1337e3d65ed0 | 308 | oled.setDisplayFade(false); |
wim | 3:1337e3d65ed0 | 309 | |
wim | 6:44256b0b5d18 | 310 | pc.printf("D: Blink done\r"); |
wim | 6:44256b0b5d18 | 311 | break; |
wim | 3:1337e3d65ed0 | 312 | |
wim | 3:1337e3d65ed0 | 313 | case 'E' : |
wim | 6:44256b0b5d18 | 314 | pc.printf("E: Big Chars\r"); |
wim | 3:1337e3d65ed0 | 315 | |
wim | 3:1337e3d65ed0 | 316 | oled.writeBigChar(0, 0, '+'); |
wim | 3:1337e3d65ed0 | 317 | oled.writeBigChar(0, 16, '7'); |
wim | 3:1337e3d65ed0 | 318 | oled.writeBigChar(0, 32, '8'); |
wim | 3:1337e3d65ed0 | 319 | oled.writeBigChar(0, 48, '9'); |
wim | 3:1337e3d65ed0 | 320 | |
wim | 6:44256b0b5d18 | 321 | pc.printf("E: Big Chars done\r"); |
wim | 3:1337e3d65ed0 | 322 | break; |
wim | 5:dff410a009c5 | 323 | |
wim | 5:dff410a009c5 | 324 | case 'F' : |
wim | 6:44256b0b5d18 | 325 | pc.printf("F: Progress Scale\r"); |
wim | 5:dff410a009c5 | 326 | |
wim | 5:dff410a009c5 | 327 | for (int percentage=0; percentage <= 100; percentage++) { |
wim | 5:dff410a009c5 | 328 | oled.writeProgressBar(2, 0, percentage); |
wim | 6:44256b0b5d18 | 329 | oled.printf(" %3d%%", percentage); |
wim | 5:dff410a009c5 | 330 | |
wim | 5:dff410a009c5 | 331 | oled.writeProgressBar(4, 0, 100 - percentage); |
wim | 6:44256b0b5d18 | 332 | oled.printf(" %3d%%", 100 - percentage); |
wim | 6:44256b0b5d18 | 333 | |
wim | 6:44256b0b5d18 | 334 | oled.writeLevelBar(6, 0, percentage); |
wim | 6:44256b0b5d18 | 335 | oled.printf(" %3dmV", percentage); |
wim | 6:44256b0b5d18 | 336 | |
wim | 5:dff410a009c5 | 337 | wait(0.05); |
wim | 5:dff410a009c5 | 338 | } |
wim | 6:44256b0b5d18 | 339 | |
wim | 6:44256b0b5d18 | 340 | pc.printf("F: Progress Scale done\r"); |
wim | 6:44256b0b5d18 | 341 | break; |
wim | 6:44256b0b5d18 | 342 | |
wim | 6:44256b0b5d18 | 343 | case 'G' : |
wim | 6:44256b0b5d18 | 344 | pc.printf("G: Scroll\r"); |
wim | 5:dff410a009c5 | 345 | |
wim | 6:44256b0b5d18 | 346 | for (int line=0; line < ROWS; line++) { |
wim | 6:44256b0b5d18 | 347 | oled.setDisplayStartLine(line); |
wim | 6:44256b0b5d18 | 348 | wait(0.05); |
wim | 6:44256b0b5d18 | 349 | } |
wim | 6:44256b0b5d18 | 350 | |
wim | 6:44256b0b5d18 | 351 | oled.setDisplayStartLine(0); |
wim | 6:44256b0b5d18 | 352 | |
wim | 6:44256b0b5d18 | 353 | pc.printf("G: Scroll done\r"); |
wim | 5:dff410a009c5 | 354 | break; |
wim | 5:dff410a009c5 | 355 | |
wim | 5:dff410a009c5 | 356 | |
wim | 6:44256b0b5d18 | 357 | case 'H' : |
wim | 6:44256b0b5d18 | 358 | // pc.printf("H: Hor Scroll\r"); |
wim | 6:44256b0b5d18 | 359 | pc.printf("H: Hor Scroll (Page 0-3)\r"); |
wim | 6:44256b0b5d18 | 360 | // oled.setContinuousHorizontalScroll(true, PAGE0, PAGE7, SCROLL_INTERVAL_25_FRAMES); |
wim | 6:44256b0b5d18 | 361 | oled.setContinuousHorizontalScroll(true, PAGE0, PAGE3, SCROLL_INTERVAL_25_FRAMES); |
wim | 6:44256b0b5d18 | 362 | oled.setDisplayScroll(true); |
wim | 6:44256b0b5d18 | 363 | |
wim | 6:44256b0b5d18 | 364 | wait(5); |
wim | 6:44256b0b5d18 | 365 | |
wim | 6:44256b0b5d18 | 366 | oled.setDisplayScroll(false); |
wim | 6:44256b0b5d18 | 367 | |
wim | 6:44256b0b5d18 | 368 | pc.printf("H: Hor Scroll done\r"); |
wim | 6:44256b0b5d18 | 369 | break; |
wim | 6:44256b0b5d18 | 370 | |
wim | 6:44256b0b5d18 | 371 | |
wim | 6:44256b0b5d18 | 372 | case 'V' : |
wim | 6:44256b0b5d18 | 373 | pc.printf("V: Ver and Hor Scroll (Page 0-7)\r"); |
wim | 6:44256b0b5d18 | 374 | |
wim | 6:44256b0b5d18 | 375 | |
wim | 6:44256b0b5d18 | 376 | oled.setContinuousVerticalAndHorizontalScroll(true, PAGE0, PAGE7, 0x01, SCROLL_INTERVAL_25_FRAMES); |
wim | 6:44256b0b5d18 | 377 | oled.setVerticalScrollArea(20, 20); |
wim | 6:44256b0b5d18 | 378 | |
wim | 6:44256b0b5d18 | 379 | oled.setDisplayScroll(true); |
wim | 6:44256b0b5d18 | 380 | |
wim | 6:44256b0b5d18 | 381 | |
wim | 6:44256b0b5d18 | 382 | wait(5); |
wim | 6:44256b0b5d18 | 383 | |
wim | 6:44256b0b5d18 | 384 | oled.setDisplayScroll(false); |
wim | 6:44256b0b5d18 | 385 | |
wim | 6:44256b0b5d18 | 386 | pc.printf("V: Ver and Hor Scroll done\r"); |
wim | 6:44256b0b5d18 | 387 | break; |
wim | 6:44256b0b5d18 | 388 | |
wim | 6:44256b0b5d18 | 389 | |
wim | 1:00053cb70ac5 | 390 | } //switch |
wim | 1:00053cb70ac5 | 391 | }//if |
wim | 1:00053cb70ac5 | 392 | }//while |
wim | 1:00053cb70ac5 | 393 | #endif |
wim | 1:00053cb70ac5 | 394 | |
wim | 1:00053cb70ac5 | 395 | pc.printf("Bye World!\n\r"); |
wim | 1:00053cb70ac5 | 396 | }//main |
wim | 1:00053cb70ac5 | 397 |