tim003 tim003
/
PAI_Grupa1_Tim003_Projekat1
Tarik Demirović Aida Pločo
Revision 0:3c24a8a80614, committed 2014-05-19
- Comitter:
- tim003
- Date:
- Mon May 19 07:57:55 2014 +0000
- Commit message:
- PAI-Grupa1-Tim003-Projekat1
Changed in this revision
diff -r 000000000000 -r 3c24a8a80614 N5110.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/N5110.lib Mon May 19 07:57:55 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/eencae/code/N5110/#adb79338d40f
diff -r 000000000000 -r 3c24a8a80614 Reket.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Reket.cpp Mon May 19 07:57:55 2014 +0000 @@ -0,0 +1,47 @@ +#include "Reket.h" + +void Reket::crtajReket(N5110 &display) +{ + for(int i = y1; i <= y2; i++) + { + display.setPixel(x1, i); + display.setPixel(x2, i); + } + + display.refresh(); +} + +void Reket::brisiReket(N5110 &display) +{ + for(int i = y1; i <= y2; i++) + { + display.clearPixel(x1, i); + display.clearPixel(x2, i); + } + + display.refresh(); +} + +void Reket::osvjeziPoziciju(AnalogIn &p1) +{ + if (p1 < 1.0/3.0) + { + y1--; + y2--; + if(y1 < 0 or y2 < 7){ + y1 = 0; + y2 = 7; + } + } + + if (p1 > 2.0/3.0) + { + y1++; + y2++; + if(y2 > 47 or y1 > 40) + { + y2 = 47; + y1 = 40; + } + } +}
diff -r 000000000000 -r 3c24a8a80614 Reket.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Reket.h Mon May 19 07:57:55 2014 +0000 @@ -0,0 +1,16 @@ +#ifndef REKET_H +#define REKET_H + +#include "mbed.h" +#include "N5110.h" + +class Reket { + int x1, x2, y1, y2; +public: + Reket(int x_1, int x_2, int y_1, int y_2) : x1(x_1), x2(x_2), y1(y_1), y2(y_2) {} + void crtajReket(N5110 &display); + void brisiReket(N5110 &display); + void osvjeziPoziciju(AnalogIn &p1); +}; + +#endif \ No newline at end of file
diff -r 000000000000 -r 3c24a8a80614 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon May 19 07:57:55 2014 +0000 @@ -0,0 +1,64 @@ +#include "mbed.h" +#include "N5110.h" +#include "Reket.h" + + +Reket rLijevi (1, 2, 5, 12); +Reket rDesni (81, 82, 10, 17); + +char skor1[1]; +char skor2[1]; + +N5110 display(dp4,dp24,dp23,dp25,dp2,dp6,dp18); +DigitalOut enable (dp14); + +AnalogIn P1(dp9); +AnalogIn P2(dp10); + +void cifre(int cifra) +{ + if(cifra == 0) + { + for(int i = 0; i < 4; i++) + display.setPixel(31 + i, 1); + + for(int i = 0; i < 5; i++) + display.setPixel(34, 1 + i); + + for(int i = 0; i < 4; i++) + display.setPixel(31 + i, 6); + + for(int i = 0; i <= 5; i++) + display.setPixel(30, 1 + i); + } + + display.refresh(); +} + +int main() { + skor1[0] = '4'; + skor2[0] = '0'; + enable = 1; + display.init(); + display.setXYAddress(0, 0); + + while(1) + { + for(int i = 0; i < 47; i++) + display.setPixel(41, i); + + display.refresh(); + + rLijevi.brisiReket(display); + rLijevi.osvjeziPoziciju(P1); + rLijevi.crtajReket(display); + + rDesni.brisiReket(display); + rDesni.osvjeziPoziciju(P2); + rDesni.crtajReket(display); + + cifre(0); + + wait(0.05); + } +}
diff -r 000000000000 -r 3c24a8a80614 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Mon May 19 07:57:55 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/8a40adfe8776 \ No newline at end of file