Ecran OLED du projet SmartCampus
Dependencies: SSD1308_128x64_I2C
Diff: main.cpp
- Revision:
- 3:1337e3d65ed0
- Parent:
- 2:d86478c0f5da
- Child:
- 4:83b4e905be5b
--- a/main.cpp Mon Jul 09 20:46:27 2012 +0000 +++ b/main.cpp Wed Jul 18 13:59:03 2012 +0000 @@ -7,7 +7,6 @@ * version 0.2 Initial Release */ #include "mbed.h" -//#include "FixedWidthFont.h" #include "mbed_logo.h" #include "SSD1308.h" @@ -36,21 +35,22 @@ SSD1308 oled = SSD1308(i2c, SSD1308_SA0); void show_menu() { - pc.printf("0: Exit\n\r"); - pc.printf("1: Show Menu\n\r"); - pc.printf("2: Send Message\n\r"); - pc.printf("3: Fill Display\n\r"); - pc.printf("4: Display cleared\n\r"); - pc.printf("5: Display off\n\r"); - pc.printf("6: Display on\n\r"); - pc.printf("7: Display Invert\n\r"); - pc.printf("8: Display Normal\n\r"); - pc.printf("9: Display Bitmap\n\r"); - pc.printf("A: Brightness Ramp\n\r"); - pc.printf("B: Send Inverted Message\n\r"); - pc.printf("C: Flip and Mirror\n\r"); + pc.printf("0: Exit\r"); + pc.printf("1: Show Menu\r"); + pc.printf("2: Send Message\r"); + pc.printf("3: Fill Display\r"); + pc.printf("4: Display cleared\r"); + pc.printf("5: Display off\r"); + pc.printf("6: Display on\r"); + pc.printf("7: Display Invert\r"); + pc.printf("8: Display Normal\r"); + pc.printf("9: Display Bitmap\r"); + pc.printf("A: Brightness Ramp\r"); + pc.printf("B: Send Inverted Message\r"); + pc.printf("C: Flip and Mirror\r"); + pc.printf("D: Blink\r"); + pc.printf("E: Big Chars\r"); -// pc.printf("D: \n\r"); // pc.printf("E: \n\r"); // pc.printf("F: \n\r"); // pc.printf("\n\r"); @@ -167,8 +167,9 @@ if(pc.readable()) { command = pc.getc(); - pc.printf("command= %c \n\r", command); - + //pc.printf("command= %c \n\r", command); + pc.printf("\r"); + switch (command) { case '0' : pc.printf("Done\n\r"); @@ -185,8 +186,10 @@ break; case '3' : - pc.printf("Fill Display 0xAA\n\r"); - oled.fillDisplay(0xA5); + pc.printf("Fill part of Display 0xA5\n\r"); +// oled.fillDisplay(0xA5); + + oled.fillDisplay(0xA5, 2, 5, 0, 63); break; case '4' : @@ -215,30 +218,39 @@ case '9' : pc.printf("Display bitmap\r\n"); - oled.writeBitmap((PAGES*COLUMNS), (uint8_t*) mbed_logo); - +// oled.writeBitmap((PAGES*COLUMNS), (uint8_t*) mbed_logo); + oled.writeBitmap((uint8_t*) mbed_logo); + break; case 'A' : + pc.printf("Brightness Ramp Down\r\n"); - for (int contrast=0x7F; contrast >= 0x00; contrast--) { + for (int contrast=0x7F; contrast >= 0x10; contrast--) { oled.setContrastControl(contrast); wait(0.05); } wait(1); - + pc.printf("Brightness Ramp Up\r\n"); - for (int contrast=0x00; contrast <= 0x7F; contrast++) { + for (int contrast=0x10; contrast <= 0x7F; contrast++) { oled.setContrastControl(contrast); wait(0.05); } + pc.printf("Brightness Ramp Done\r\n"); + break; case 'B' : pc.printf("Send Inverted Message\n\r"); - oled.writeString(0, 0, 13, "Hello World !", true); + oled.setInverted(true); + oled.writeString(0, 0, 13, "Hello World !"); + oled.setInverted(false); + + oled.printf(" Result is %d", 12345); + break; case 'C' : @@ -246,8 +258,34 @@ left = !left; down = !down; oled.setDisplayFlip(left, down); - break; - + break; + + case 'D' : + pc.printf("D: Blink and Fade (not supported) \n\r"); + +// oled.setDisplayBlink(true); +// wait(4); +// oled.setDisplayBlink(false); + + oled.setDisplayFade(true); + wait(4); + oled.setDisplayFade(false); + + pc.printf("D: Blink done\n\r"); + break; + + + case 'E' : + pc.printf("E: Big Chars\n\r"); + + oled.writeBigChar(0, 0, '+'); + oled.writeBigChar(0, 16, '7'); + oled.writeBigChar(0, 32, '8'); + oled.writeBigChar(0, 48, '9'); + + pc.printf("E: Big Chars done\n\r"); + break; + } //switch }//if }//while