Next up... Duck.
Yes, all it is, is a duck. Just a duck.
Add to LCD prototype (begins at "// LCD prototype" near the top):
Code:
void initDuck();
void printDuck(byte pos);
Add "doDisplayDuck" to the list of "displayFuncs[]" containing all the other doDisplay's.
Add the line "displayFuncNames[x++] = PSTR("Duck.");" to the menu selections (big block of displayFuncNames[x++]).
Add the following function, I put it around all the other display functions (below doDisplaySystemInfo):
Code:
void doDisplayDuck(void) {
while (tmp1[0] > 6) {
tmp1[0]--;
tmp1[1] = 1;
}
LCD::printDuck(tmp1[0]);
if (tmp1[1]) tmp1[0]--;
else tmp1[0]++;
if (tmp1[0] == 0) {
tmp1[1] = 0;
}
}
Now, look for
"displayFuncs[screen](); //call the appropriate display routine". Look for the comment "//left is rotate through screeens to the left", and the misnomer "//right is rotate through screeens to the left", and just below each of those, add the line "
if (screen == displayFuncSize - 1) LCD::init();". At the bottom of each, under the "LCD:
rint" statement, add the line "
if (screen == displayFuncSize - 1) LCD::initDuck();". This ensures that the LCD is in the right state when both coming-from and going-to the Duck mode.
Finally, two LCD functions need to be added - initDuck and printDuck.
In the LCD section near the middle, add:
Code:
void LCD::initDuck() {
//creating the duck:
LcdCommandWrite(0b00001100); // display control:
LcdCommandWrite(0b00000110); // entry mode set: increment automatically, no display shift
LcdCommandWrite(0b01001000); // set cgram
static byte chars[] PROGMEM = {
B00001,B10000,B00000,B00000, B00000,B11111,B11111,B00110,
B00011,B11000,B00000,B00000, B00001,B11111,B11111,B11110,
B00010,B11100,B00000,B00000, B00011,B11111,B11111,B11100,
B01111,B11100,B00000,B00000, B00011,B11111,B11111,B11111,
B11111,B11100,B00000,B00000, B00011,B11111,B11111,B11110,
B00001,B11100,B00000,B00000, B00011,B11111,B11111,B11100,
B00000,B11000,B00000,B00000, B00001,B11111,B11111,B11000,
B00000,B11100,B01100,B00000, B00000,B11111,B11111,B10000};
for(byte x=0;x<LcdNewChars;x++)
for(byte y=0;y<LcdCharHeightPix;y++)
LcdDataWrite(pgm_read_byte(&chars[y*LcdNewChars+x]));
LcdCommandWrite(0b00000001); // clear display, set cursor position to zero
LcdCommandWrite(0b10000000); // set dram to zero
}
void LCD::printDuck(byte pos) {
char duckchars[]={ 1,2,3,4,4,0,5,6,7,8,4,0 };
LCD::gotoXY(0,0);
byte x=0;
for (x=0;x<pos;x++) {
LCD::print(" ");
}
LCD::print(duckchars);
LCD::gotoXY(0,1);
for (x=0;x<pos;x++) {
LCD::print(" ");
}
LCD::print(duckchars+6);
LCD::gotoXY(11,1);
LCD::print("Duck.");
}
Then, upload, rechip, and voila... you have a duck screen.