tim007 tim007
/
Zadatak1_LV7
Fahrudin Brbutovic Adnan Mehanovic
Diff: main.cpp
- Revision:
- 0:d5dd28d4a7e3
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon Apr 28 09:59:14 2014 +0000 @@ -0,0 +1,117 @@ +#include "mbed.h" +#include "N5110.h" + +AnalogIn VRx (dp11); +AnalogIn VRy (dp10); +N5110 lcd (dp13 ,dp24 ,dp23 ,dp25 ,dp2 ,dp6 , dp18); + +int mainPixelX, mainPixelY, previousMainPixelX, previousMainPixelY; + +DigitalOut enable(dp14); + +void move() +{ + lcd.clearPixel(previousMainPixelX, previousMainPixelY); + lcd.clearPixel(previousMainPixelX - 1, previousMainPixelY); + lcd.clearPixel(previousMainPixelX - 2, previousMainPixelY); + lcd.clearPixel(previousMainPixelX + 1, previousMainPixelY); + lcd.clearPixel(previousMainPixelX + 2, previousMainPixelY); + lcd.clearPixel(previousMainPixelX, previousMainPixelY - 1); + lcd.clearPixel(previousMainPixelX, previousMainPixelY - 2); + lcd.clearPixel(previousMainPixelX, previousMainPixelY + 1); + lcd.clearPixel(previousMainPixelX, previousMainPixelY + 2); + lcd.clearPixel(previousMainPixelX - 1, previousMainPixelY - 1); + lcd.clearPixel(previousMainPixelX - 1, previousMainPixelY + 1); + lcd.clearPixel(previousMainPixelX + 1, previousMainPixelY - 1); + lcd.clearPixel(previousMainPixelX + 1, previousMainPixelY + 1); + lcd.setPixel(mainPixelX, mainPixelY); + lcd.setPixel(mainPixelX - 1, mainPixelY); + lcd.setPixel(mainPixelX - 2, mainPixelY); + lcd.setPixel(mainPixelX + 1, mainPixelY); + lcd.setPixel(mainPixelX + 2, mainPixelY); + lcd.setPixel(mainPixelX, mainPixelY - 1); + lcd.setPixel(mainPixelX, mainPixelY - 2); + lcd.setPixel(mainPixelX, mainPixelY + 1); + lcd.setPixel(mainPixelX, mainPixelY + 2); + lcd.setPixel(mainPixelX - 1, mainPixelY - 1); + lcd.setPixel(mainPixelX - 1, mainPixelY + 1); + lcd.setPixel(mainPixelX + 1, mainPixelY - 1); + lcd.setPixel(mainPixelX + 1, mainPixelY + 1); + lcd.refresh(); + wait(0.5); + lcd.clearPixel(previousMainPixelX + 2, previousMainPixelY + 3); + lcd.clearPixel(previousMainPixelX + 4, previousMainPixelY + 3); + lcd.clearPixel(previousMainPixelX + 6, previousMainPixelY + 3); + lcd.clearPixel(previousMainPixelX + 3, previousMainPixelY + 4); + lcd.clearPixel(previousMainPixelX + 5, previousMainPixelY + 4); + lcd.clearPixel(previousMainPixelX + 7, previousMainPixelY + 4); + lcd.clearPixel(previousMainPixelX + 4, previousMainPixelY + 5); + lcd.clearPixel(previousMainPixelX + 6, previousMainPixelY + 5); + lcd.clearPixel(previousMainPixelX + 8, previousMainPixelY + 5); + lcd.clearPixel(previousMainPixelX + 5, previousMainPixelY + 6); + lcd.clearPixel(previousMainPixelX + 7, previousMainPixelY + 6); + lcd.clearPixel(previousMainPixelX + 9, previousMainPixelY + 6); + lcd.clearPixel(previousMainPixelX + 6, previousMainPixelY + 7); + lcd.clearPixel(previousMainPixelX + 7, previousMainPixelY + 7); + lcd.clearPixel(previousMainPixelX + 8, previousMainPixelY + 7); + lcd.clearPixel(previousMainPixelX + 9, previousMainPixelY + 7); + lcd.clearPixel(previousMainPixelX + 10, previousMainPixelY + 7); + lcd.clearPixel(previousMainPixelX + 7, previousMainPixelY + 8); + lcd.clearPixel(previousMainPixelX + 8, previousMainPixelY + 8); + lcd.clearPixel(previousMainPixelX + 9, previousMainPixelY + 8); + lcd.clearPixel(previousMainPixelX + 10, previousMainPixelY + 8); + lcd.clearPixel(previousMainPixelX + 11, previousMainPixelY + 8); + lcd.clearPixel(previousMainPixelX + 9, previousMainPixelY + 9); + lcd.clearPixel(previousMainPixelX + 10, previousMainPixelY + 10); + lcd.clearPixel(previousMainPixelX + 11, previousMainPixelY + 11); + lcd.clearPixel(previousMainPixelX + 12, previousMainPixelY + 12); + lcd.clearPixel(previousMainPixelX + 13, previousMainPixelY + 13); + lcd.clearPixel(previousMainPixelX + 14, previousMainPixelY + 14); + lcd.clearPixel(previousMainPixelX + 15, previousMainPixelY + 15); + lcd.clearPixel(previousMainPixelX + 16, previousMainPixelY + 16); + lcd.setPixel(mainPixelX + 2, mainPixelY + 3); + lcd.setPixel(mainPixelX + 4, mainPixelY + 3); + lcd.setPixel(mainPixelX + 6, mainPixelY + 3); + lcd.setPixel(mainPixelX + 3, mainPixelY + 4); + lcd.setPixel(mainPixelX + 5, mainPixelY + 4); + lcd.setPixel(mainPixelX + 7, mainPixelY + 4); + lcd.setPixel(mainPixelX + 4, mainPixelY + 5); + lcd.setPixel(mainPixelX + 6, mainPixelY + 5); + lcd.setPixel(mainPixelX + 8, mainPixelY + 5); + lcd.setPixel(mainPixelX + 5, mainPixelY + 6); + lcd.setPixel(mainPixelX + 7, mainPixelY + 6); + lcd.setPixel(mainPixelX + 9, mainPixelY + 6); + lcd.setPixel(mainPixelX + 6, mainPixelY + 7); + lcd.setPixel(mainPixelX + 7, mainPixelY + 7); + lcd.setPixel(mainPixelX + 8, mainPixelY + 7); + lcd.setPixel(mainPixelX + 9, mainPixelY + 7); + lcd.setPixel(mainPixelX + 10, mainPixelY + 7); + lcd.setPixel(mainPixelX + 7, mainPixelY + 8); + lcd.setPixel(mainPixelX + 8, mainPixelY + 8); + lcd.setPixel(mainPixelX + 9, mainPixelY + 8); + lcd.setPixel(mainPixelX + 10, mainPixelY + 8); + lcd.setPixel(mainPixelX + 11, mainPixelY + 8); + lcd.setPixel(mainPixelX + 9, mainPixelY + 9); + lcd.setPixel(mainPixelX + 10, mainPixelY + 10); + lcd.setPixel(mainPixelX + 11, mainPixelY + 11); + lcd.setPixel(mainPixelX + 12, mainPixelY + 12); + lcd.setPixel(mainPixelX + 13, mainPixelY + 13); + lcd.setPixel(mainPixelX + 14, mainPixelY + 14); + lcd.setPixel(mainPixelX + 15, mainPixelY + 15); + lcd.setPixel(mainPixelX + 16, mainPixelY + 16); + lcd.refresh(); +} + +int main() +{ + enable = 1; + lcd.init(); + lcd.clear(); + while(1) { + previousMainPixelX = mainPixelX; + previousMainPixelY = mainPixelY; + mainPixelX = int(VRx * 67); + mainPixelY = int(VRy * 47); + move(); + } +} \ No newline at end of file