tim007 tim007
/
LV8-Grupa6-Tim007-zad3
Armin Klačar Josip Kvesić
main.cpp@0:3c58a06d8217, 2014-05-08 (annotated)
- Committer:
- tim007
- Date:
- Thu May 08 15:46:47 2014 +0000
- Revision:
- 0:3c58a06d8217
LV8-PAI-Grupa6-Tim007;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
tim007 | 0:3c58a06d8217 | 1 | #include "mbed.h" |
tim007 | 0:3c58a06d8217 | 2 | #include "N5110.h" |
tim007 | 0:3c58a06d8217 | 3 | N5110 lcd(dp4,dp24,dp23,dp25,dp2,dp6,dp18); |
tim007 | 0:3c58a06d8217 | 4 | Serial pc(USBTX, USBRX); |
tim007 | 0:3c58a06d8217 | 5 | DigitalOut enable (dp14); |
tim007 | 0:3c58a06d8217 | 6 | int x=0; |
tim007 | 0:3c58a06d8217 | 7 | int y=0; |
tim007 | 0:3c58a06d8217 | 8 | void readwrite() |
tim007 | 0:3c58a06d8217 | 9 | { |
tim007 | 0:3c58a06d8217 | 10 | if(!pc.readable()) return; |
tim007 | 0:3c58a06d8217 | 11 | char c = pc.getc(); |
tim007 | 0:3c58a06d8217 | 12 | if (c=='1') |
tim007 | 0:3c58a06d8217 | 13 | { |
tim007 | 0:3c58a06d8217 | 14 | lcd.clear(); |
tim007 | 0:3c58a06d8217 | 15 | lcd.setXYAddress(x=0,y=0); |
tim007 | 0:3c58a06d8217 | 16 | } |
tim007 | 0:3c58a06d8217 | 17 | else if (c=='2') |
tim007 | 0:3c58a06d8217 | 18 | { |
tim007 | 0:3c58a06d8217 | 19 | ++y; |
tim007 | 0:3c58a06d8217 | 20 | if(y==6) y=0; |
tim007 | 0:3c58a06d8217 | 21 | lcd.setXYAddress(x=0,y); |
tim007 | 0:3c58a06d8217 | 22 | } |
tim007 | 0:3c58a06d8217 | 23 | else if (c=='3') |
tim007 | 0:3c58a06d8217 | 24 | { |
tim007 | 0:3c58a06d8217 | 25 | x-=6; |
tim007 | 0:3c58a06d8217 | 26 | if(x<0) {y--; x = 77;if(y<0) y=0; } |
tim007 | 0:3c58a06d8217 | 27 | lcd.setXYAddress(x,y); |
tim007 | 0:3c58a06d8217 | 28 | lcd.printChar(' '); |
tim007 | 0:3c58a06d8217 | 29 | lcd.setXYAddress(x,y); |
tim007 | 0:3c58a06d8217 | 30 | } |
tim007 | 0:3c58a06d8217 | 31 | else if(c >= 32 && c < 126) |
tim007 | 0:3c58a06d8217 | 32 | { |
tim007 | 0:3c58a06d8217 | 33 | if(x>77) |
tim007 | 0:3c58a06d8217 | 34 | { |
tim007 | 0:3c58a06d8217 | 35 | x=0; |
tim007 | 0:3c58a06d8217 | 36 | y++; |
tim007 | 0:3c58a06d8217 | 37 | if (y==6) y=0; |
tim007 | 0:3c58a06d8217 | 38 | lcd.setXYAddress(x,y); |
tim007 | 0:3c58a06d8217 | 39 | } |
tim007 | 0:3c58a06d8217 | 40 | lcd.printChar(c); |
tim007 | 0:3c58a06d8217 | 41 | x+=6; |
tim007 | 0:3c58a06d8217 | 42 | } |
tim007 | 0:3c58a06d8217 | 43 | |
tim007 | 0:3c58a06d8217 | 44 | } |
tim007 | 0:3c58a06d8217 | 45 | int main() |
tim007 | 0:3c58a06d8217 | 46 | { |
tim007 | 0:3c58a06d8217 | 47 | enable = 1; |
tim007 | 0:3c58a06d8217 | 48 | lcd.init(); |
tim007 | 0:3c58a06d8217 | 49 | lcd.setXYAddress(x,y); |
tim007 | 0:3c58a06d8217 | 50 | pc.attach(readwrite); |
tim007 | 0:3c58a06d8217 | 51 | while(1); |
tim007 | 0:3c58a06d8217 | 52 | } |