Fahrudin Brbutovic Adnan Mehanovic

Dependencies:   N5110 mbed

Committer:
tim007
Date:
Mon Apr 28 09:59:14 2014 +0000
Revision:
0:d5dd28d4a7e3
PAI_LV7_Grupa2_Tim007

Who changed what in which revision?

UserRevisionLine numberNew contents of line
tim007 0:d5dd28d4a7e3 1 #include "mbed.h"
tim007 0:d5dd28d4a7e3 2 #include "N5110.h"
tim007 0:d5dd28d4a7e3 3
tim007 0:d5dd28d4a7e3 4 AnalogIn VRx (dp11);
tim007 0:d5dd28d4a7e3 5 AnalogIn VRy (dp10);
tim007 0:d5dd28d4a7e3 6 N5110 lcd (dp13 ,dp24 ,dp23 ,dp25 ,dp2 ,dp6 , dp18);
tim007 0:d5dd28d4a7e3 7
tim007 0:d5dd28d4a7e3 8 int mainPixelX, mainPixelY, previousMainPixelX, previousMainPixelY;
tim007 0:d5dd28d4a7e3 9
tim007 0:d5dd28d4a7e3 10 DigitalOut enable(dp14);
tim007 0:d5dd28d4a7e3 11
tim007 0:d5dd28d4a7e3 12 void move()
tim007 0:d5dd28d4a7e3 13 {
tim007 0:d5dd28d4a7e3 14 lcd.clearPixel(previousMainPixelX, previousMainPixelY);
tim007 0:d5dd28d4a7e3 15 lcd.clearPixel(previousMainPixelX - 1, previousMainPixelY);
tim007 0:d5dd28d4a7e3 16 lcd.clearPixel(previousMainPixelX - 2, previousMainPixelY);
tim007 0:d5dd28d4a7e3 17 lcd.clearPixel(previousMainPixelX + 1, previousMainPixelY);
tim007 0:d5dd28d4a7e3 18 lcd.clearPixel(previousMainPixelX + 2, previousMainPixelY);
tim007 0:d5dd28d4a7e3 19 lcd.clearPixel(previousMainPixelX, previousMainPixelY - 1);
tim007 0:d5dd28d4a7e3 20 lcd.clearPixel(previousMainPixelX, previousMainPixelY - 2);
tim007 0:d5dd28d4a7e3 21 lcd.clearPixel(previousMainPixelX, previousMainPixelY + 1);
tim007 0:d5dd28d4a7e3 22 lcd.clearPixel(previousMainPixelX, previousMainPixelY + 2);
tim007 0:d5dd28d4a7e3 23 lcd.clearPixel(previousMainPixelX - 1, previousMainPixelY - 1);
tim007 0:d5dd28d4a7e3 24 lcd.clearPixel(previousMainPixelX - 1, previousMainPixelY + 1);
tim007 0:d5dd28d4a7e3 25 lcd.clearPixel(previousMainPixelX + 1, previousMainPixelY - 1);
tim007 0:d5dd28d4a7e3 26 lcd.clearPixel(previousMainPixelX + 1, previousMainPixelY + 1);
tim007 0:d5dd28d4a7e3 27 lcd.setPixel(mainPixelX, mainPixelY);
tim007 0:d5dd28d4a7e3 28 lcd.setPixel(mainPixelX - 1, mainPixelY);
tim007 0:d5dd28d4a7e3 29 lcd.setPixel(mainPixelX - 2, mainPixelY);
tim007 0:d5dd28d4a7e3 30 lcd.setPixel(mainPixelX + 1, mainPixelY);
tim007 0:d5dd28d4a7e3 31 lcd.setPixel(mainPixelX + 2, mainPixelY);
tim007 0:d5dd28d4a7e3 32 lcd.setPixel(mainPixelX, mainPixelY - 1);
tim007 0:d5dd28d4a7e3 33 lcd.setPixel(mainPixelX, mainPixelY - 2);
tim007 0:d5dd28d4a7e3 34 lcd.setPixel(mainPixelX, mainPixelY + 1);
tim007 0:d5dd28d4a7e3 35 lcd.setPixel(mainPixelX, mainPixelY + 2);
tim007 0:d5dd28d4a7e3 36 lcd.setPixel(mainPixelX - 1, mainPixelY - 1);
tim007 0:d5dd28d4a7e3 37 lcd.setPixel(mainPixelX - 1, mainPixelY + 1);
tim007 0:d5dd28d4a7e3 38 lcd.setPixel(mainPixelX + 1, mainPixelY - 1);
tim007 0:d5dd28d4a7e3 39 lcd.setPixel(mainPixelX + 1, mainPixelY + 1);
tim007 0:d5dd28d4a7e3 40 lcd.refresh();
tim007 0:d5dd28d4a7e3 41 wait(0.5);
tim007 0:d5dd28d4a7e3 42 lcd.clearPixel(previousMainPixelX + 2, previousMainPixelY + 3);
tim007 0:d5dd28d4a7e3 43 lcd.clearPixel(previousMainPixelX + 4, previousMainPixelY + 3);
tim007 0:d5dd28d4a7e3 44 lcd.clearPixel(previousMainPixelX + 6, previousMainPixelY + 3);
tim007 0:d5dd28d4a7e3 45 lcd.clearPixel(previousMainPixelX + 3, previousMainPixelY + 4);
tim007 0:d5dd28d4a7e3 46 lcd.clearPixel(previousMainPixelX + 5, previousMainPixelY + 4);
tim007 0:d5dd28d4a7e3 47 lcd.clearPixel(previousMainPixelX + 7, previousMainPixelY + 4);
tim007 0:d5dd28d4a7e3 48 lcd.clearPixel(previousMainPixelX + 4, previousMainPixelY + 5);
tim007 0:d5dd28d4a7e3 49 lcd.clearPixel(previousMainPixelX + 6, previousMainPixelY + 5);
tim007 0:d5dd28d4a7e3 50 lcd.clearPixel(previousMainPixelX + 8, previousMainPixelY + 5);
tim007 0:d5dd28d4a7e3 51 lcd.clearPixel(previousMainPixelX + 5, previousMainPixelY + 6);
tim007 0:d5dd28d4a7e3 52 lcd.clearPixel(previousMainPixelX + 7, previousMainPixelY + 6);
tim007 0:d5dd28d4a7e3 53 lcd.clearPixel(previousMainPixelX + 9, previousMainPixelY + 6);
tim007 0:d5dd28d4a7e3 54 lcd.clearPixel(previousMainPixelX + 6, previousMainPixelY + 7);
tim007 0:d5dd28d4a7e3 55 lcd.clearPixel(previousMainPixelX + 7, previousMainPixelY + 7);
tim007 0:d5dd28d4a7e3 56 lcd.clearPixel(previousMainPixelX + 8, previousMainPixelY + 7);
tim007 0:d5dd28d4a7e3 57 lcd.clearPixel(previousMainPixelX + 9, previousMainPixelY + 7);
tim007 0:d5dd28d4a7e3 58 lcd.clearPixel(previousMainPixelX + 10, previousMainPixelY + 7);
tim007 0:d5dd28d4a7e3 59 lcd.clearPixel(previousMainPixelX + 7, previousMainPixelY + 8);
tim007 0:d5dd28d4a7e3 60 lcd.clearPixel(previousMainPixelX + 8, previousMainPixelY + 8);
tim007 0:d5dd28d4a7e3 61 lcd.clearPixel(previousMainPixelX + 9, previousMainPixelY + 8);
tim007 0:d5dd28d4a7e3 62 lcd.clearPixel(previousMainPixelX + 10, previousMainPixelY + 8);
tim007 0:d5dd28d4a7e3 63 lcd.clearPixel(previousMainPixelX + 11, previousMainPixelY + 8);
tim007 0:d5dd28d4a7e3 64 lcd.clearPixel(previousMainPixelX + 9, previousMainPixelY + 9);
tim007 0:d5dd28d4a7e3 65 lcd.clearPixel(previousMainPixelX + 10, previousMainPixelY + 10);
tim007 0:d5dd28d4a7e3 66 lcd.clearPixel(previousMainPixelX + 11, previousMainPixelY + 11);
tim007 0:d5dd28d4a7e3 67 lcd.clearPixel(previousMainPixelX + 12, previousMainPixelY + 12);
tim007 0:d5dd28d4a7e3 68 lcd.clearPixel(previousMainPixelX + 13, previousMainPixelY + 13);
tim007 0:d5dd28d4a7e3 69 lcd.clearPixel(previousMainPixelX + 14, previousMainPixelY + 14);
tim007 0:d5dd28d4a7e3 70 lcd.clearPixel(previousMainPixelX + 15, previousMainPixelY + 15);
tim007 0:d5dd28d4a7e3 71 lcd.clearPixel(previousMainPixelX + 16, previousMainPixelY + 16);
tim007 0:d5dd28d4a7e3 72 lcd.setPixel(mainPixelX + 2, mainPixelY + 3);
tim007 0:d5dd28d4a7e3 73 lcd.setPixel(mainPixelX + 4, mainPixelY + 3);
tim007 0:d5dd28d4a7e3 74 lcd.setPixel(mainPixelX + 6, mainPixelY + 3);
tim007 0:d5dd28d4a7e3 75 lcd.setPixel(mainPixelX + 3, mainPixelY + 4);
tim007 0:d5dd28d4a7e3 76 lcd.setPixel(mainPixelX + 5, mainPixelY + 4);
tim007 0:d5dd28d4a7e3 77 lcd.setPixel(mainPixelX + 7, mainPixelY + 4);
tim007 0:d5dd28d4a7e3 78 lcd.setPixel(mainPixelX + 4, mainPixelY + 5);
tim007 0:d5dd28d4a7e3 79 lcd.setPixel(mainPixelX + 6, mainPixelY + 5);
tim007 0:d5dd28d4a7e3 80 lcd.setPixel(mainPixelX + 8, mainPixelY + 5);
tim007 0:d5dd28d4a7e3 81 lcd.setPixel(mainPixelX + 5, mainPixelY + 6);
tim007 0:d5dd28d4a7e3 82 lcd.setPixel(mainPixelX + 7, mainPixelY + 6);
tim007 0:d5dd28d4a7e3 83 lcd.setPixel(mainPixelX + 9, mainPixelY + 6);
tim007 0:d5dd28d4a7e3 84 lcd.setPixel(mainPixelX + 6, mainPixelY + 7);
tim007 0:d5dd28d4a7e3 85 lcd.setPixel(mainPixelX + 7, mainPixelY + 7);
tim007 0:d5dd28d4a7e3 86 lcd.setPixel(mainPixelX + 8, mainPixelY + 7);
tim007 0:d5dd28d4a7e3 87 lcd.setPixel(mainPixelX + 9, mainPixelY + 7);
tim007 0:d5dd28d4a7e3 88 lcd.setPixel(mainPixelX + 10, mainPixelY + 7);
tim007 0:d5dd28d4a7e3 89 lcd.setPixel(mainPixelX + 7, mainPixelY + 8);
tim007 0:d5dd28d4a7e3 90 lcd.setPixel(mainPixelX + 8, mainPixelY + 8);
tim007 0:d5dd28d4a7e3 91 lcd.setPixel(mainPixelX + 9, mainPixelY + 8);
tim007 0:d5dd28d4a7e3 92 lcd.setPixel(mainPixelX + 10, mainPixelY + 8);
tim007 0:d5dd28d4a7e3 93 lcd.setPixel(mainPixelX + 11, mainPixelY + 8);
tim007 0:d5dd28d4a7e3 94 lcd.setPixel(mainPixelX + 9, mainPixelY + 9);
tim007 0:d5dd28d4a7e3 95 lcd.setPixel(mainPixelX + 10, mainPixelY + 10);
tim007 0:d5dd28d4a7e3 96 lcd.setPixel(mainPixelX + 11, mainPixelY + 11);
tim007 0:d5dd28d4a7e3 97 lcd.setPixel(mainPixelX + 12, mainPixelY + 12);
tim007 0:d5dd28d4a7e3 98 lcd.setPixel(mainPixelX + 13, mainPixelY + 13);
tim007 0:d5dd28d4a7e3 99 lcd.setPixel(mainPixelX + 14, mainPixelY + 14);
tim007 0:d5dd28d4a7e3 100 lcd.setPixel(mainPixelX + 15, mainPixelY + 15);
tim007 0:d5dd28d4a7e3 101 lcd.setPixel(mainPixelX + 16, mainPixelY + 16);
tim007 0:d5dd28d4a7e3 102 lcd.refresh();
tim007 0:d5dd28d4a7e3 103 }
tim007 0:d5dd28d4a7e3 104
tim007 0:d5dd28d4a7e3 105 int main()
tim007 0:d5dd28d4a7e3 106 {
tim007 0:d5dd28d4a7e3 107 enable = 1;
tim007 0:d5dd28d4a7e3 108 lcd.init();
tim007 0:d5dd28d4a7e3 109 lcd.clear();
tim007 0:d5dd28d4a7e3 110 while(1) {
tim007 0:d5dd28d4a7e3 111 previousMainPixelX = mainPixelX;
tim007 0:d5dd28d4a7e3 112 previousMainPixelY = mainPixelY;
tim007 0:d5dd28d4a7e3 113 mainPixelX = int(VRx * 67);
tim007 0:d5dd28d4a7e3 114 mainPixelY = int(VRy * 47);
tim007 0:d5dd28d4a7e3 115 move();
tim007 0:d5dd28d4a7e3 116 }
tim007 0:d5dd28d4a7e3 117 }