[136] | 1 | #ifndef ROBOTTEXTMANAGER_H
|
---|
| 2 | #define ROBOTTEXTMANAGER_H
|
---|
| 3 |
|
---|
| 4 | #define USERNAME 0
|
---|
| 5 | #define ROBOTNAME 1
|
---|
| 6 | #define CITYNAME 2
|
---|
| 7 | #define COUNTRYNAME 3
|
---|
| 8 | #define EMPTY 4
|
---|
| 9 |
|
---|
| 10 | class TextManager{
|
---|
| 11 | //The TextManager class is a collection of features specific for Hello
|
---|
| 12 | //User example.
|
---|
| 13 | //
|
---|
| 14 | //- It includes solution for setting text position based on
|
---|
| 15 | // line/column. The original Robot.text(), or the more low level
|
---|
| 16 | // print() function can only set text position on pixels from left,
|
---|
| 17 | // top.
|
---|
| 18 | //
|
---|
| 19 | //- The process of accepting input with the virtual keyboard, saving
|
---|
| 20 | // into or reading from EEPROM is delt with here.
|
---|
| 21 | //
|
---|
| 22 | //- A workflow for stop the music while displaying image. Trouble
|
---|
| 23 | // will happen otherwise.
|
---|
| 24 |
|
---|
| 25 | public:
|
---|
| 26 | //add some margin to the text, left side only atm.
|
---|
| 27 | void setMargin(int margin_left,int margin_top);
|
---|
| 28 |
|
---|
| 29 | //print text based on line, column.
|
---|
| 30 | void writeText(int lineNum, int colNum, char* txt, bool onOff=true);
|
---|
| 31 |
|
---|
| 32 | //print a script from the scripts library
|
---|
| 33 | void writeScript(int seq, int line, int col);
|
---|
| 34 |
|
---|
| 35 | //The whole process of getting input
|
---|
| 36 | void input(int lin,int col, int code);
|
---|
| 37 | //Print a cursor and virtual keyboard on screen, and save the user's input
|
---|
| 38 | void getInput(int lin, int col);
|
---|
| 39 | //Get user name, robot name, city name or country name from EEPROM
|
---|
| 40 | //and store in the input pool.
|
---|
| 41 | void setInputPool(int code);
|
---|
| 42 | //save user input to EEPROM
|
---|
| 43 | void pushInput(int code);
|
---|
| 44 |
|
---|
| 45 | //Replaces Robot.drawPicture(), as this one solves collision between
|
---|
| 46 | //image and music
|
---|
| 47 | void showPicture(char * filename, int posX, int posY);
|
---|
| 48 |
|
---|
| 49 | private:
|
---|
| 50 | int margin_left,margin_top;
|
---|
| 51 | int getLin(int lineNum); //Convert line to pixels from top
|
---|
| 52 | int getCol(int colNum); //Convert line to pixels from left
|
---|
| 53 |
|
---|
| 54 | static const int lineHeight;//8+2=10
|
---|
| 55 | static const int charWidth;//5+1=6
|
---|
| 56 |
|
---|
| 57 | int inputPos;
|
---|
| 58 | int inputLin;
|
---|
| 59 | int inputCol;
|
---|
| 60 |
|
---|
| 61 | void drawInput(bool onOff);
|
---|
| 62 | void mvInput(int dire);
|
---|
| 63 |
|
---|
| 64 | char selectLetter();
|
---|
| 65 | void refreshCurrentLetter(char letter);
|
---|
| 66 |
|
---|
| 67 | void getPGMtext(int seq);
|
---|
| 68 |
|
---|
| 69 | char PGMbuffer[85]; //the buffer for storing strings
|
---|
| 70 | char inputPool[18];
|
---|
| 71 | };
|
---|
| 72 |
|
---|
| 73 | //a trick for removing the need of creating an object of TextManager.
|
---|
| 74 | //So you can call me.somefunction() directly in the sketch.
|
---|
| 75 | extern TextManager textManager;
|
---|
| 76 |
|
---|
| 77 | #endif
|
---|