tim007 tim007
/
LV8-Grupa6-Tim007-zad3
Armin Klačar Josip Kvesić
Diff: main.cpp
- Revision:
- 0:3c58a06d8217
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu May 08 15:46:47 2014 +0000 @@ -0,0 +1,52 @@ +#include "mbed.h" +#include "N5110.h" +N5110 lcd(dp4,dp24,dp23,dp25,dp2,dp6,dp18); +Serial pc(USBTX, USBRX); +DigitalOut enable (dp14); +int x=0; +int y=0; +void readwrite() +{ + if(!pc.readable()) return; + char c = pc.getc(); + if (c=='1') + { + lcd.clear(); + lcd.setXYAddress(x=0,y=0); + } + else if (c=='2') + { + ++y; + if(y==6) y=0; + lcd.setXYAddress(x=0,y); + } + else if (c=='3') + { + x-=6; + if(x<0) {y--; x = 77;if(y<0) y=0; } + lcd.setXYAddress(x,y); + lcd.printChar(' '); + lcd.setXYAddress(x,y); + } + else if(c >= 32 && c < 126) + { + if(x>77) + { + x=0; + y++; + if (y==6) y=0; + lcd.setXYAddress(x,y); + } + lcd.printChar(c); + x+=6; + } + +} +int main() +{ + enable = 1; + lcd.init(); + lcd.setXYAddress(x,y); + pc.attach(readwrite); + while(1); +}