mbed menu system
Diff: console.cpp
- Revision:
- 0:a5ece7312edc
diff -r 000000000000 -r a5ece7312edc console.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/console.cpp Thu Feb 28 00:38:31 2013 +0000 @@ -0,0 +1,101 @@ +// console.cpp +// + +#include "console.h" +#include "ANSITerm.h" + +using namespace std; + + +extern ANSITerm pc; + +// +// Clears the screen +// +void clrscr() +{ + pc.clear_screen(); +} + +// +// Moves the cursor to x, y in console window +// ie x=left\right y=top\bottom +// +void gotoxy(int x, int y) +{ + pc.set_cursor_position(x,y); +} + +void printXY( char * text, int x, int y) +{ + static bool runOnce = false; + if (runOnce == false){ + clrscr(); + runOnce = true; + } + + gotoxy( x, y); + pc.printf("%s", text); +} + +// +// Set text and background colors +// +void setrgb(int color) +{ + switch (color) + { + case 0: // White on Black + + break; + case 1: // Red on Black + + break; + case 2: // Green on Black + + break; + case 3: // Yellow on Black + + break; + case 4: // Blue on Black + + break; + case 5: // Magenta on Black + + break; + case 6: // Cyan on Black + + break; + case 7: // Black on Gray + + break; + case 8: // Black on White + + break; + case 9: // Red on White + + break; + case 10: // Green on White + + break; + case 11: // Yellow on White + + break; + case 12: // Blue on White + + break; + case 13: // Magenta on White + + break; + case 14: // Cyan on White + + break; + case 15: // White on White + + break; + default : // White on Black + + break; + } +} +