Hadžić Muharem Josip Kvesić

Dependencies:   N5110 mbed

Committer:
tim010
Date:
Thu Apr 24 16:12:04 2014 +0000
Revision:
0:d490ddc21b56
PAI-LV7-Grupa6-tim010

Who changed what in which revision?

UserRevisionLine numberNew contents of line
tim010 0:d490ddc21b56 1 #include "mbed.h"
tim010 0:d490ddc21b56 2 #include "N5110.h"
tim010 0:d490ddc21b56 3
tim010 0:d490ddc21b56 4 //Deklaracija LCD objekta
tim010 0:d490ddc21b56 5 //N5110 lcd(VCC,SCE,RST,D/C,MOSI,SCLK,LED)
tim010 0:d490ddc21b56 6 N5110 lcd(dp4,dp24,dp23,dp25,dp2,dp6,dp18);
tim010 0:d490ddc21b56 7
tim010 0:d490ddc21b56 8 //Digitalni izlaz za deaktivaciju LED buffera
tim010 0:d490ddc21b56 9 DigitalOut enable(dp14);
tim010 0:d490ddc21b56 10
tim010 0:d490ddc21b56 11 //Analogni ulazi sa dzojstika
tim010 0:d490ddc21b56 12 AnalogIn VRx(dp11);
tim010 0:d490ddc21b56 13 AnalogIn VRy(dp10);
tim010 0:d490ddc21b56 14 //Taster sa dzojstika
tim010 0:d490ddc21b56 15 DigitalIn SW(dp9);
tim010 0:d490ddc21b56 16
tim010 0:d490ddc21b56 17 void krug(int a,int b) {
tim010 0:d490ddc21b56 18 if(a<3 || a>80 || b<3 || b>44) return;
tim010 0:d490ddc21b56 19 lcd.clear();
tim010 0:d490ddc21b56 20 lcd.refresh();
tim010 0:d490ddc21b56 21 lcd.setXYAddress(0,0);
tim010 0:d490ddc21b56 22
tim010 0:d490ddc21b56 23 lcd.setPixel(a,b); //nije potrebno
tim010 0:d490ddc21b56 24
tim010 0:d490ddc21b56 25 lcd.setPixel(a-3,b);
tim010 0:d490ddc21b56 26 lcd.setPixel(a-3,b+1);
tim010 0:d490ddc21b56 27 lcd.setPixel(a-3,b-1);
tim010 0:d490ddc21b56 28 lcd.setPixel(a+3,b-1);
tim010 0:d490ddc21b56 29 lcd.setPixel(a+3,b);
tim010 0:d490ddc21b56 30 lcd.setPixel(a+3,b+1);
tim010 0:d490ddc21b56 31 lcd.setPixel(a-2,b+2);
tim010 0:d490ddc21b56 32 lcd.setPixel(a-2,b-2);
tim010 0:d490ddc21b56 33 lcd.setPixel(a+2,b+2);
tim010 0:d490ddc21b56 34 lcd.setPixel(a+2,b-2);
tim010 0:d490ddc21b56 35 lcd.setPixel(a-1,b+3);
tim010 0:d490ddc21b56 36 lcd.setPixel(a,b+3);
tim010 0:d490ddc21b56 37 lcd.setPixel(a+1,b+3);
tim010 0:d490ddc21b56 38 lcd.setPixel(a-1,b-3);
tim010 0:d490ddc21b56 39 lcd.setPixel(a,b-3);
tim010 0:d490ddc21b56 40 lcd.setPixel(a+1,b-3);
tim010 0:d490ddc21b56 41
tim010 0:d490ddc21b56 42
tim010 0:d490ddc21b56 43 lcd.refresh();
tim010 0:d490ddc21b56 44
tim010 0:d490ddc21b56 45
tim010 0:d490ddc21b56 46 }
tim010 0:d490ddc21b56 47
tim010 0:d490ddc21b56 48
tim010 0:d490ddc21b56 49
tim010 0:d490ddc21b56 50
tim010 0:d490ddc21b56 51 int main() {
tim010 0:d490ddc21b56 52 enable=1;
tim010 0:d490ddc21b56 53 //Aktivacija pull-up otpornika
tim010 0:d490ddc21b56 54 SW.mode(PullUp);
tim010 0:d490ddc21b56 55 int x=42, y=24;
tim010 0:d490ddc21b56 56 lcd.init();
tim010 0:d490ddc21b56 57
tim010 0:d490ddc21b56 58 krug(x,y);
tim010 0:d490ddc21b56 59
tim010 0:d490ddc21b56 60 while(1) {
tim010 0:d490ddc21b56 61 if (VRx<1.0/3.0)
tim010 0:d490ddc21b56 62 {
tim010 0:d490ddc21b56 63 x=x-1;
tim010 0:d490ddc21b56 64
tim010 0:d490ddc21b56 65 krug(x,y);
tim010 0:d490ddc21b56 66 }
tim010 0:d490ddc21b56 67 else if (VRx<2.0/3.0)
tim010 0:d490ddc21b56 68 {
tim010 0:d490ddc21b56 69 krug(x,y);
tim010 0:d490ddc21b56 70 }
tim010 0:d490ddc21b56 71 else
tim010 0:d490ddc21b56 72 {x=x+1;
tim010 0:d490ddc21b56 73 krug(x,y); }
tim010 0:d490ddc21b56 74 wait(0.05);
tim010 0:d490ddc21b56 75
tim010 0:d490ddc21b56 76 if (VRy<1.0/3.0)
tim010 0:d490ddc21b56 77 {
tim010 0:d490ddc21b56 78 y=y-1;
tim010 0:d490ddc21b56 79 krug(x,y);
tim010 0:d490ddc21b56 80
tim010 0:d490ddc21b56 81 }
tim010 0:d490ddc21b56 82 else if (VRy<2.0/3.0)
tim010 0:d490ddc21b56 83 {
tim010 0:d490ddc21b56 84 krug(x,y);
tim010 0:d490ddc21b56 85
tim010 0:d490ddc21b56 86 }
tim010 0:d490ddc21b56 87 else
tim010 0:d490ddc21b56 88 {
tim010 0:d490ddc21b56 89 y=y+1;
tim010 0:d490ddc21b56 90 krug(x,y);
tim010 0:d490ddc21b56 91 }
tim010 0:d490ddc21b56 92 wait(0.05);
tim010 0:d490ddc21b56 93 }
tim010 0:d490ddc21b56 94
tim010 0:d490ddc21b56 95 if(SW==1) wait(5);
tim010 0:d490ddc21b56 96
tim010 0:d490ddc21b56 97
tim010 0:d490ddc21b56 98
tim010 0:d490ddc21b56 99
tim010 0:d490ddc21b56 100
tim010 0:d490ddc21b56 101 }