mbed menu system
console.cpp@2:5c4911aba273, 2013-02-28 (annotated)
- Committer:
- mbedDevLondon
- Date:
- Thu Feb 28 03:33:50 2013 +0000
- Revision:
- 2:5c4911aba273
- Parent:
- 0:a5ece7312edc
formatting in menuIDs.h
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbedDevLondon | 0:a5ece7312edc | 1 | // console.cpp |
mbedDevLondon | 0:a5ece7312edc | 2 | // |
mbedDevLondon | 0:a5ece7312edc | 3 | |
mbedDevLondon | 0:a5ece7312edc | 4 | #include "console.h" |
mbedDevLondon | 0:a5ece7312edc | 5 | #include "ANSITerm.h" |
mbedDevLondon | 0:a5ece7312edc | 6 | |
mbedDevLondon | 0:a5ece7312edc | 7 | using namespace std; |
mbedDevLondon | 0:a5ece7312edc | 8 | |
mbedDevLondon | 0:a5ece7312edc | 9 | |
mbedDevLondon | 0:a5ece7312edc | 10 | extern ANSITerm pc; |
mbedDevLondon | 0:a5ece7312edc | 11 | |
mbedDevLondon | 0:a5ece7312edc | 12 | // |
mbedDevLondon | 0:a5ece7312edc | 13 | // Clears the screen |
mbedDevLondon | 0:a5ece7312edc | 14 | // |
mbedDevLondon | 0:a5ece7312edc | 15 | void clrscr() |
mbedDevLondon | 0:a5ece7312edc | 16 | { |
mbedDevLondon | 0:a5ece7312edc | 17 | pc.clear_screen(); |
mbedDevLondon | 0:a5ece7312edc | 18 | } |
mbedDevLondon | 0:a5ece7312edc | 19 | |
mbedDevLondon | 0:a5ece7312edc | 20 | // |
mbedDevLondon | 0:a5ece7312edc | 21 | // Moves the cursor to x, y in console window |
mbedDevLondon | 0:a5ece7312edc | 22 | // ie x=left\right y=top\bottom |
mbedDevLondon | 0:a5ece7312edc | 23 | // |
mbedDevLondon | 0:a5ece7312edc | 24 | void gotoxy(int x, int y) |
mbedDevLondon | 0:a5ece7312edc | 25 | { |
mbedDevLondon | 0:a5ece7312edc | 26 | pc.set_cursor_position(x,y); |
mbedDevLondon | 0:a5ece7312edc | 27 | } |
mbedDevLondon | 0:a5ece7312edc | 28 | |
mbedDevLondon | 0:a5ece7312edc | 29 | void printXY( char * text, int x, int y) |
mbedDevLondon | 0:a5ece7312edc | 30 | { |
mbedDevLondon | 0:a5ece7312edc | 31 | static bool runOnce = false; |
mbedDevLondon | 0:a5ece7312edc | 32 | if (runOnce == false){ |
mbedDevLondon | 0:a5ece7312edc | 33 | clrscr(); |
mbedDevLondon | 0:a5ece7312edc | 34 | runOnce = true; |
mbedDevLondon | 0:a5ece7312edc | 35 | } |
mbedDevLondon | 0:a5ece7312edc | 36 | |
mbedDevLondon | 0:a5ece7312edc | 37 | gotoxy( x, y); |
mbedDevLondon | 0:a5ece7312edc | 38 | pc.printf("%s", text); |
mbedDevLondon | 0:a5ece7312edc | 39 | } |
mbedDevLondon | 0:a5ece7312edc | 40 | |
mbedDevLondon | 0:a5ece7312edc | 41 | // |
mbedDevLondon | 0:a5ece7312edc | 42 | // Set text and background colors |
mbedDevLondon | 0:a5ece7312edc | 43 | // |
mbedDevLondon | 0:a5ece7312edc | 44 | void setrgb(int color) |
mbedDevLondon | 0:a5ece7312edc | 45 | { |
mbedDevLondon | 0:a5ece7312edc | 46 | switch (color) |
mbedDevLondon | 0:a5ece7312edc | 47 | { |
mbedDevLondon | 0:a5ece7312edc | 48 | case 0: // White on Black |
mbedDevLondon | 0:a5ece7312edc | 49 | |
mbedDevLondon | 0:a5ece7312edc | 50 | break; |
mbedDevLondon | 0:a5ece7312edc | 51 | case 1: // Red on Black |
mbedDevLondon | 0:a5ece7312edc | 52 | |
mbedDevLondon | 0:a5ece7312edc | 53 | break; |
mbedDevLondon | 0:a5ece7312edc | 54 | case 2: // Green on Black |
mbedDevLondon | 0:a5ece7312edc | 55 | |
mbedDevLondon | 0:a5ece7312edc | 56 | break; |
mbedDevLondon | 0:a5ece7312edc | 57 | case 3: // Yellow on Black |
mbedDevLondon | 0:a5ece7312edc | 58 | |
mbedDevLondon | 0:a5ece7312edc | 59 | break; |
mbedDevLondon | 0:a5ece7312edc | 60 | case 4: // Blue on Black |
mbedDevLondon | 0:a5ece7312edc | 61 | |
mbedDevLondon | 0:a5ece7312edc | 62 | break; |
mbedDevLondon | 0:a5ece7312edc | 63 | case 5: // Magenta on Black |
mbedDevLondon | 0:a5ece7312edc | 64 | |
mbedDevLondon | 0:a5ece7312edc | 65 | break; |
mbedDevLondon | 0:a5ece7312edc | 66 | case 6: // Cyan on Black |
mbedDevLondon | 0:a5ece7312edc | 67 | |
mbedDevLondon | 0:a5ece7312edc | 68 | break; |
mbedDevLondon | 0:a5ece7312edc | 69 | case 7: // Black on Gray |
mbedDevLondon | 0:a5ece7312edc | 70 | |
mbedDevLondon | 0:a5ece7312edc | 71 | break; |
mbedDevLondon | 0:a5ece7312edc | 72 | case 8: // Black on White |
mbedDevLondon | 0:a5ece7312edc | 73 | |
mbedDevLondon | 0:a5ece7312edc | 74 | break; |
mbedDevLondon | 0:a5ece7312edc | 75 | case 9: // Red on White |
mbedDevLondon | 0:a5ece7312edc | 76 | |
mbedDevLondon | 0:a5ece7312edc | 77 | break; |
mbedDevLondon | 0:a5ece7312edc | 78 | case 10: // Green on White |
mbedDevLondon | 0:a5ece7312edc | 79 | |
mbedDevLondon | 0:a5ece7312edc | 80 | break; |
mbedDevLondon | 0:a5ece7312edc | 81 | case 11: // Yellow on White |
mbedDevLondon | 0:a5ece7312edc | 82 | |
mbedDevLondon | 0:a5ece7312edc | 83 | break; |
mbedDevLondon | 0:a5ece7312edc | 84 | case 12: // Blue on White |
mbedDevLondon | 0:a5ece7312edc | 85 | |
mbedDevLondon | 0:a5ece7312edc | 86 | break; |
mbedDevLondon | 0:a5ece7312edc | 87 | case 13: // Magenta on White |
mbedDevLondon | 0:a5ece7312edc | 88 | |
mbedDevLondon | 0:a5ece7312edc | 89 | break; |
mbedDevLondon | 0:a5ece7312edc | 90 | case 14: // Cyan on White |
mbedDevLondon | 0:a5ece7312edc | 91 | |
mbedDevLondon | 0:a5ece7312edc | 92 | break; |
mbedDevLondon | 0:a5ece7312edc | 93 | case 15: // White on White |
mbedDevLondon | 0:a5ece7312edc | 94 | |
mbedDevLondon | 0:a5ece7312edc | 95 | break; |
mbedDevLondon | 0:a5ece7312edc | 96 | default : // White on Black |
mbedDevLondon | 0:a5ece7312edc | 97 | |
mbedDevLondon | 0:a5ece7312edc | 98 | break; |
mbedDevLondon | 0:a5ece7312edc | 99 | } |
mbedDevLondon | 0:a5ece7312edc | 100 | } |
mbedDevLondon | 0:a5ece7312edc | 101 |