Program to display a ruuning pole across the screen
pole.cpp@0:fa28b1f22307, 2019-05-11 (annotated)
- Committer:
- sreepada
- Date:
- Sat May 11 15:18:00 2019 +0000
- Revision:
- 0:fa28b1f22307
Program to display a running pole across the screen.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sreepada | 0:fa28b1f22307 | 1 | // RUNNING VERTICAL POLE |
sreepada | 0:fa28b1f22307 | 2 | |
sreepada | 0:fa28b1f22307 | 3 | |
sreepada | 0:fa28b1f22307 | 4 | #include "mbed.h" |
sreepada | 0:fa28b1f22307 | 5 | #include "N5110.h" |
sreepada | 0:fa28b1f22307 | 6 | |
sreepada | 0:fa28b1f22307 | 7 | N5110 lcd(p8,p9,p10,p11,p13,p21); |
sreepada | 0:fa28b1f22307 | 8 | |
sreepada | 0:fa28b1f22307 | 9 | int main() |
sreepada | 0:fa28b1f22307 | 10 | { |
sreepada | 0:fa28b1f22307 | 11 | lcd.init(); // LCD initialization |
sreepada | 0:fa28b1f22307 | 12 | |
sreepada | 0:fa28b1f22307 | 13 | int x = 0; // starting position-x |
sreepada | 0:fa28b1f22307 | 14 | int y = 0; // starting position-y |
sreepada | 0:fa28b1f22307 | 15 | |
sreepada | 0:fa28b1f22307 | 16 | while(1) |
sreepada | 0:fa28b1f22307 | 17 | { |
sreepada | 0:fa28b1f22307 | 18 | |
sreepada | 0:fa28b1f22307 | 19 | lcd.clear(); // clear LCD before starting new line |
sreepada | 0:fa28b1f22307 | 20 | |
sreepada | 0:fa28b1f22307 | 21 | lcd.drawLine(x,y,x,47,1); // (x-coordinate of start positin, y-coordinate of start position, |
sreepada | 0:fa28b1f22307 | 22 | // x-coordinate of end positin, y-coordinate of end positin, |
sreepada | 0:fa28b1f22307 | 23 | // 1-black pixel, 0-white pixel |
sreepada | 0:fa28b1f22307 | 24 | |
sreepada | 0:fa28b1f22307 | 25 | x=x+1; // increment x -position for next line |
sreepada | 0:fa28b1f22307 | 26 | // need not worry about y-position because starting poisition y-coordinate is always zero |
sreepada | 0:fa28b1f22307 | 27 | |
sreepada | 0:fa28b1f22307 | 28 | if (x>83) // test if line reached end of screen |
sreepada | 0:fa28b1f22307 | 29 | { |
sreepada | 0:fa28b1f22307 | 30 | x=0; // if true restart |
sreepada | 0:fa28b1f22307 | 31 | } |
sreepada | 0:fa28b1f22307 | 32 | |
sreepada | 0:fa28b1f22307 | 33 | |
sreepada | 0:fa28b1f22307 | 34 | lcd.refresh(); // refresh the LCD before |
sreepada | 0:fa28b1f22307 | 35 | wait_ms(1000/10); // 10 frames |
sreepada | 0:fa28b1f22307 | 36 | |
sreepada | 0:fa28b1f22307 | 37 | } |
sreepada | 0:fa28b1f22307 | 38 | } |
sreepada | 0:fa28b1f22307 | 39 | |
sreepada | 0:fa28b1f22307 | 40 |