tim004 tim004
/
bitmapaSelmaEmrah
Selma Tucak Emrah Dautbegović
main.cpp@0:e792bd7ebca3, 2014-06-09 (annotated)
- Committer:
- tim004
- Date:
- Mon Jun 09 15:55:03 2014 +0000
- Revision:
- 0:e792bd7ebca3
Pai-Projekat_grupa7_tim004_bitmapa
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
tim004 | 0:e792bd7ebca3 | 1 | #include "mbed.h" |
tim004 | 0:e792bd7ebca3 | 2 | #include "N5110.h" |
tim004 | 0:e792bd7ebca3 | 3 | |
tim004 | 0:e792bd7ebca3 | 4 | Serial pc(USBTX, USBRX); |
tim004 | 0:e792bd7ebca3 | 5 | DigitalOut enable(dp14); |
tim004 | 0:e792bd7ebca3 | 6 | AnalogIn VRx(dp11); |
tim004 | 0:e792bd7ebca3 | 7 | AnalogIn VRy(dp10); |
tim004 | 0:e792bd7ebca3 | 8 | DigitalIn SW(dp9); |
tim004 | 0:e792bd7ebca3 | 9 | N5110 lcd(dp4,dp24,dp23,dp25,dp2,dp6,dp18); |
tim004 | 0:e792bd7ebca3 | 10 | Ticker t; |
tim004 | 0:e792bd7ebca3 | 11 | int x=0, y=0; |
tim004 | 0:e792bd7ebca3 | 12 | char a; |
tim004 | 0:e792bd7ebca3 | 13 | void NacrtajCursor(int x, int y) { |
tim004 | 0:e792bd7ebca3 | 14 | lcd.setPixel(x-1,y+1); |
tim004 | 0:e792bd7ebca3 | 15 | lcd.setPixel(x,y+1); |
tim004 | 0:e792bd7ebca3 | 16 | lcd.setPixel(x+1,y+1); |
tim004 | 0:e792bd7ebca3 | 17 | lcd.setPixel(x-1,y); |
tim004 | 0:e792bd7ebca3 | 18 | lcd.setPixel(x+1,y); |
tim004 | 0:e792bd7ebca3 | 19 | lcd.setPixel(x-1,y-1); |
tim004 | 0:e792bd7ebca3 | 20 | lcd.setPixel(x,y-1); |
tim004 | 0:e792bd7ebca3 | 21 | lcd.setPixel(x+1,y-1); |
tim004 | 0:e792bd7ebca3 | 22 | } |
tim004 | 0:e792bd7ebca3 | 23 | |
tim004 | 0:e792bd7ebca3 | 24 | void ObrisiCursor(int x, int y) { |
tim004 | 0:e792bd7ebca3 | 25 | lcd.clearPixel(x-1,y+1); |
tim004 | 0:e792bd7ebca3 | 26 | lcd.clearPixel(x,y+1); |
tim004 | 0:e792bd7ebca3 | 27 | lcd.clearPixel(x+1,y+1); |
tim004 | 0:e792bd7ebca3 | 28 | lcd.clearPixel(x-1,y); |
tim004 | 0:e792bd7ebca3 | 29 | lcd.clearPixel(x+1,y); |
tim004 | 0:e792bd7ebca3 | 30 | lcd.clearPixel(x-1,y-1); |
tim004 | 0:e792bd7ebca3 | 31 | lcd.clearPixel(x,y-1); |
tim004 | 0:e792bd7ebca3 | 32 | lcd.clearPixel(x+1,y-1); |
tim004 | 0:e792bd7ebca3 | 33 | } |
tim004 | 0:e792bd7ebca3 | 34 | void trepci() |
tim004 | 0:e792bd7ebca3 | 35 | { |
tim004 | 0:e792bd7ebca3 | 36 | NacrtajCursor(x,y); |
tim004 | 0:e792bd7ebca3 | 37 | ObrisiCursor(x,y); |
tim004 | 0:e792bd7ebca3 | 38 | } |
tim004 | 0:e792bd7ebca3 | 39 | |
tim004 | 0:e792bd7ebca3 | 40 | int main() { |
tim004 | 0:e792bd7ebca3 | 41 | enable = 1; |
tim004 | 0:e792bd7ebca3 | 42 | pc.baud(115200); |
tim004 | 0:e792bd7ebca3 | 43 | lcd.init(); |
tim004 | 0:e792bd7ebca3 | 44 | lcd.setXYAddress(0,0); |
tim004 | 0:e792bd7ebca3 | 45 | for(int i=0; i<84; i++) { |
tim004 | 0:e792bd7ebca3 | 46 | for(int j=0; j<48; j++) { |
tim004 | 0:e792bd7ebca3 | 47 | a= pc.getc(); |
tim004 | 0:e792bd7ebca3 | 48 | if (a=='1') lcd.setPixel(i,j); |
tim004 | 0:e792bd7ebca3 | 49 | else lcd.clearPixel(i,j); |
tim004 | 0:e792bd7ebca3 | 50 | } |
tim004 | 0:e792bd7ebca3 | 51 | } |
tim004 | 0:e792bd7ebca3 | 52 | lcd.refresh(); |
tim004 | 0:e792bd7ebca3 | 53 | while(1) { |
tim004 | 0:e792bd7ebca3 | 54 | |
tim004 | 0:e792bd7ebca3 | 55 | if(VRx < 1.0/3.0) { |
tim004 | 0:e792bd7ebca3 | 56 | x-=2; |
tim004 | 0:e792bd7ebca3 | 57 | } |
tim004 | 0:e792bd7ebca3 | 58 | else if(VRx > 2.0/3.0) { |
tim004 | 0:e792bd7ebca3 | 59 | x+=2; |
tim004 | 0:e792bd7ebca3 | 60 | } |
tim004 | 0:e792bd7ebca3 | 61 | if(VRy < 1.0/3.0) { |
tim004 | 0:e792bd7ebca3 | 62 | y-=2; |
tim004 | 0:e792bd7ebca3 | 63 | } |
tim004 | 0:e792bd7ebca3 | 64 | else if(VRy > 2.0/3.0){ |
tim004 | 0:e792bd7ebca3 | 65 | y+=2; |
tim004 | 0:e792bd7ebca3 | 66 | } |
tim004 | 0:e792bd7ebca3 | 67 | t.attach(&trepci, 0.1); |
tim004 | 0:e792bd7ebca3 | 68 | lcd.refresh(); |
tim004 | 0:e792bd7ebca3 | 69 | } |
tim004 | 0:e792bd7ebca3 | 70 | } |