Ken Todotani
/
eDISP
eDisp library and sample code
main.cpp@1:134b6e987450, 2011-03-07 (annotated)
- Committer:
- todotani
- Date:
- Mon Mar 07 13:38:33 2011 +0000
- Revision:
- 1:134b6e987450
- Parent:
- 0:e86010984e9a
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
todotani | 0:e86010984e9a | 1 | /* Sample code for mbed eDISP Library |
todotani | 0:e86010984e9a | 2 | * Copyright (c) 2010 todotani |
todotani | 0:e86010984e9a | 3 | * Released under the MIT License: http://mbed.org/license/mit |
todotani | 0:e86010984e9a | 4 | */ |
todotani | 0:e86010984e9a | 5 | |
todotani | 0:e86010984e9a | 6 | #include "mbed.h" |
todotani | 0:e86010984e9a | 7 | #include "eDisp.h" |
todotani | 0:e86010984e9a | 8 | |
todotani | 0:e86010984e9a | 9 | // RGB color code table |
todotani | 0:e86010984e9a | 10 | int RGB_color[16] = { |
todotani | 0:e86010984e9a | 11 | RGB_Navy, |
todotani | 0:e86010984e9a | 12 | RGB_Silver, |
todotani | 0:e86010984e9a | 13 | RGB_Blue, |
todotani | 0:e86010984e9a | 14 | RGB_Maroon, |
todotani | 0:e86010984e9a | 15 | RGB_Purple, |
todotani | 0:e86010984e9a | 16 | RGB_Red, |
todotani | 0:e86010984e9a | 17 | RGB_Fuchsia, |
todotani | 0:e86010984e9a | 18 | RGB_Green, |
todotani | 0:e86010984e9a | 19 | RGB_Teal, |
todotani | 0:e86010984e9a | 20 | RGB_Lime, |
todotani | 0:e86010984e9a | 21 | RGB_Aqua, |
todotani | 0:e86010984e9a | 22 | RGB_Olive, |
todotani | 0:e86010984e9a | 23 | RGB_Gray, |
todotani | 0:e86010984e9a | 24 | RGB_Yellow, |
todotani | 0:e86010984e9a | 25 | RGB_White, |
todotani | 0:e86010984e9a | 26 | RGB_Black }; |
todotani | 0:e86010984e9a | 27 | |
todotani | 0:e86010984e9a | 28 | // RGB color name table |
todotani | 0:e86010984e9a | 29 | char* colorName[16] = { |
todotani | 0:e86010984e9a | 30 | "Navy", |
todotani | 0:e86010984e9a | 31 | "Silver", |
todotani | 0:e86010984e9a | 32 | "Blue", |
todotani | 0:e86010984e9a | 33 | "Maroon", |
todotani | 0:e86010984e9a | 34 | "Purple", |
todotani | 0:e86010984e9a | 35 | "Red", |
todotani | 0:e86010984e9a | 36 | "Fuchsia", |
todotani | 0:e86010984e9a | 37 | "Green", |
todotani | 0:e86010984e9a | 38 | "Teal", |
todotani | 0:e86010984e9a | 39 | "Lime", |
todotani | 0:e86010984e9a | 40 | "Aqua", |
todotani | 0:e86010984e9a | 41 | "Olive", |
todotani | 0:e86010984e9a | 42 | "Gray", |
todotani | 0:e86010984e9a | 43 | "Yellow", |
todotani | 0:e86010984e9a | 44 | "White", |
todotani | 0:e86010984e9a | 45 | "Black" }; |
todotani | 0:e86010984e9a | 46 | |
todotani | 0:e86010984e9a | 47 | |
todotani | 0:e86010984e9a | 48 | eDisp display(p9, p10, 19200); // tx, rx, baud |
todotani | 0:e86010984e9a | 49 | |
todotani | 0:e86010984e9a | 50 | int main() { |
todotani | 0:e86010984e9a | 51 | int i; |
todotani | 0:e86010984e9a | 52 | |
todotani | 1:134b6e987450 | 53 | wait(2); |
todotani | 0:e86010984e9a | 54 | while (1) { |
todotani | 0:e86010984e9a | 55 | // Test-1 |
todotani | 0:e86010984e9a | 56 | // clear graphics screen |
todotani | 0:e86010984e9a | 57 | display.fillRect(0, 320, 240, 0, 0, RGB_Black); |
todotani | 0:e86010984e9a | 58 | display.reset(); |
todotani | 0:e86010984e9a | 59 | for (i = 0; i < 15; i++) { |
todotani | 0:e86010984e9a | 60 | display.fillRect(0, 320, 16, 0, i*16, RGB_color[i]); |
todotani | 0:e86010984e9a | 61 | display.locate(0, i); |
todotani | 0:e86010984e9a | 62 | display.printf("%s", colorName[i] ); |
todotani | 0:e86010984e9a | 63 | } |
todotani | 0:e86010984e9a | 64 | wait(2); |
todotani | 0:e86010984e9a | 65 | |
todotani | 0:e86010984e9a | 66 | // Test-2 |
todotani | 0:e86010984e9a | 67 | display.fillRect(0, 320, 240, 0, 0, RGB_Black); |
todotani | 0:e86010984e9a | 68 | display.cls(); |
todotani | 0:e86010984e9a | 69 | for (i = 0; i < 15; i++) { |
todotani | 0:e86010984e9a | 70 | display.drawLine(0, 1, i*16+1, 319, i*16+1, RGB_color[i]); |
todotani | 0:e86010984e9a | 71 | display.drawLine(0, i*21+1, 0, i*21+1, 239, RGB_color[i]); |
todotani | 0:e86010984e9a | 72 | } |
todotani | 0:e86010984e9a | 73 | wait(2); |
todotani | 0:e86010984e9a | 74 | |
todotani | 0:e86010984e9a | 75 | // Test-3 |
todotani | 0:e86010984e9a | 76 | for (i = 0; i < 15; i++) { |
todotani | 0:e86010984e9a | 77 | display.fillRect(0, 320, 240, 0, 0, RGB_color[i]); |
todotani | 0:e86010984e9a | 78 | wait(0.2); // wait until completion of draw |
todotani | 0:e86010984e9a | 79 | } |
todotani | 0:e86010984e9a | 80 | wait(2); |
todotani | 0:e86010984e9a | 81 | |
todotani | 0:e86010984e9a | 82 | // Test-4 |
todotani | 0:e86010984e9a | 83 | display.fillRect(0, 320, 240, 0, 0, RGB_Black); |
todotani | 0:e86010984e9a | 84 | display.cls(); |
todotani | 0:e86010984e9a | 85 | for (i = 0; i < 15; i++) { |
todotani | 0:e86010984e9a | 86 | display.textColor(RED + i%7); |
todotani | 0:e86010984e9a | 87 | display.printf("漢字表示OK AABBCC\n"); |
todotani | 0:e86010984e9a | 88 | } |
todotani | 0:e86010984e9a | 89 | wait(2); |
todotani | 0:e86010984e9a | 90 | } |
todotani | 0:e86010984e9a | 91 | } |