tim007 tim007
/
lv8_tim007_grupa5_zad3
Elma Kusundzija Amela Spica
main.cpp@0:91269f323f72, 2014-05-08 (annotated)
- Committer:
- tim007
- Date:
- Thu May 08 14:04:36 2014 +0000
- Revision:
- 0:91269f323f72
lv8_tim007_grupa5_zad3
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
tim007 | 0:91269f323f72 | 1 | #include "mbed.h" |
tim007 | 0:91269f323f72 | 2 | #include "N5110.h" |
tim007 | 0:91269f323f72 | 3 | |
tim007 | 0:91269f323f72 | 4 | Serial pc(USBTX, USBRX); |
tim007 | 0:91269f323f72 | 5 | N5110 display(dp4,dp24,dp23,dp25,dp2,dp6,dp18); |
tim007 | 0:91269f323f72 | 6 | int x=0; |
tim007 | 0:91269f323f72 | 7 | int y=0; |
tim007 | 0:91269f323f72 | 8 | |
tim007 | 0:91269f323f72 | 9 | void ispisi(char znak) |
tim007 | 0:91269f323f72 | 10 | { |
tim007 | 0:91269f323f72 | 11 | display.printChar(znak); |
tim007 | 0:91269f323f72 | 12 | x = x + 6; |
tim007 | 0:91269f323f72 | 13 | if(x==84 && y==6)return; |
tim007 | 0:91269f323f72 | 14 | if(x==84) |
tim007 | 0:91269f323f72 | 15 | { |
tim007 | 0:91269f323f72 | 16 | x = 0; |
tim007 | 0:91269f323f72 | 17 | y = y + 1; |
tim007 | 0:91269f323f72 | 18 | } |
tim007 | 0:91269f323f72 | 19 | display.setXYAddress(x,y); |
tim007 | 0:91269f323f72 | 20 | } |
tim007 | 0:91269f323f72 | 21 | void backspace() |
tim007 | 0:91269f323f72 | 22 | { |
tim007 | 0:91269f323f72 | 23 | if(x==0 && y==0) |
tim007 | 0:91269f323f72 | 24 | { |
tim007 | 0:91269f323f72 | 25 | /*x = 84; |
tim007 | 0:91269f323f72 | 26 | y = 40;*/ |
tim007 | 0:91269f323f72 | 27 | return; |
tim007 | 0:91269f323f72 | 28 | } |
tim007 | 0:91269f323f72 | 29 | else if(x==0) |
tim007 | 0:91269f323f72 | 30 | { |
tim007 | 0:91269f323f72 | 31 | y = y - 1; |
tim007 | 0:91269f323f72 | 32 | x = 78; |
tim007 | 0:91269f323f72 | 33 | display.setXYAddress(x,y); |
tim007 | 0:91269f323f72 | 34 | ispisi(' '); |
tim007 | 0:91269f323f72 | 35 | x=x-6; |
tim007 | 0:91269f323f72 | 36 | display.setXYAddress(x,y); |
tim007 | 0:91269f323f72 | 37 | |
tim007 | 0:91269f323f72 | 38 | } |
tim007 | 0:91269f323f72 | 39 | else if(x==78) |
tim007 | 0:91269f323f72 | 40 | { |
tim007 | 0:91269f323f72 | 41 | x=x-6; |
tim007 | 0:91269f323f72 | 42 | display.setXYAddress(x,y); |
tim007 | 0:91269f323f72 | 43 | ispisi(' '); |
tim007 | 0:91269f323f72 | 44 | x=x-6; |
tim007 | 0:91269f323f72 | 45 | display.setXYAddress(x,y); |
tim007 | 0:91269f323f72 | 46 | } |
tim007 | 0:91269f323f72 | 47 | else |
tim007 | 0:91269f323f72 | 48 | {x=x-6; |
tim007 | 0:91269f323f72 | 49 | display.setXYAddress(x,y); |
tim007 | 0:91269f323f72 | 50 | ispisi(' '); |
tim007 | 0:91269f323f72 | 51 | x=x-6; |
tim007 | 0:91269f323f72 | 52 | display.setXYAddress(x,y); |
tim007 | 0:91269f323f72 | 53 | |
tim007 | 0:91269f323f72 | 54 | } |
tim007 | 0:91269f323f72 | 55 | /*display.setXYAddress(x,y); |
tim007 | 0:91269f323f72 | 56 | ispisi(' '); |
tim007 | 0:91269f323f72 | 57 | if(x==0){ |
tim007 | 0:91269f323f72 | 58 | y=y-1; |
tim007 | 0:91269f323f72 | 59 | x=84;} |
tim007 | 0:91269f323f72 | 60 | else {x=x-6;} |
tim007 | 0:91269f323f72 | 61 | display.setXYAddress(x,y);*/ |
tim007 | 0:91269f323f72 | 62 | |
tim007 | 0:91269f323f72 | 63 | } |
tim007 | 0:91269f323f72 | 64 | void DeleteAll() |
tim007 | 0:91269f323f72 | 65 | { |
tim007 | 0:91269f323f72 | 66 | display.clear(); |
tim007 | 0:91269f323f72 | 67 | display.refresh(); |
tim007 | 0:91269f323f72 | 68 | x = y = 0; |
tim007 | 0:91269f323f72 | 69 | display.setXYAddress(x,y); |
tim007 | 0:91269f323f72 | 70 | } |
tim007 | 0:91269f323f72 | 71 | void Enter() |
tim007 | 0:91269f323f72 | 72 | { |
tim007 | 0:91269f323f72 | 73 | if(y==40) return; |
tim007 | 0:91269f323f72 | 74 | else y = y + 1; |
tim007 | 0:91269f323f72 | 75 | x = 0; |
tim007 | 0:91269f323f72 | 76 | display.setXYAddress(x,y); |
tim007 | 0:91269f323f72 | 77 | |
tim007 | 0:91269f323f72 | 78 | } |
tim007 | 0:91269f323f72 | 79 | int main() |
tim007 | 0:91269f323f72 | 80 | { |
tim007 | 0:91269f323f72 | 81 | display.init(); |
tim007 | 0:91269f323f72 | 82 | display.normalMode(); |
tim007 | 0:91269f323f72 | 83 | display.setXYAddress(0,0); |
tim007 | 0:91269f323f72 | 84 | |
tim007 | 0:91269f323f72 | 85 | while(1) |
tim007 | 0:91269f323f72 | 86 | { |
tim007 | 0:91269f323f72 | 87 | char znak = pc.getc(); |
tim007 | 0:91269f323f72 | 88 | if(znak==',') |
tim007 | 0:91269f323f72 | 89 | backspace(); |
tim007 | 0:91269f323f72 | 90 | else if(znak=='.') |
tim007 | 0:91269f323f72 | 91 | DeleteAll(); |
tim007 | 0:91269f323f72 | 92 | else if(znak=='-') |
tim007 | 0:91269f323f72 | 93 | Enter(); |
tim007 | 0:91269f323f72 | 94 | else ispisi(znak); |
tim007 | 0:91269f323f72 | 95 | } |
tim007 | 0:91269f323f72 | 96 | |
tim007 | 0:91269f323f72 | 97 | } |