tim010 tim010
/
LV8-Grupa1-Tim010-Z3
Enil Pajić, Irma Jakić
main.cpp
- Committer:
- tim010
- Date:
- 2014-05-05
- Revision:
- 0:4c2857ed48ec
File content as of revision 0:4c2857ed48ec:
//LV8-Grupa1-Tim010-Z3 #include "mbed.h" #include "N5110.h" //By EnilP, 04.05.2014, ETF PAI DigitalOut ENBL (dp14); N5110 DISP (dp4, dp24, dp23, dp25, dp2, dp6, dp18); Serial PC (USBTX, USBRX); Ticker T; int eX = 0, eY = 0; void DoIt() { if (!PC.readable()) return; char C = PC.getc(); DISP.setXYAddress (eX, eY); if (C == 8 || C == 10 || C == 127 || C == '!' || C == '"') // C == 13 (ENTER)? { if (C == 127) { eX -= 6; if (eX < 0) eY = (eY ? eY - 1 : eY), eX = 77; //Možda i onemogućiti ovo!? DISP.setXYAddress (eX, eY); DISP.printChar (' '); //eX -= 6; } else if (C == '!') // == 13 {eY = (eY + 1) % 5; DISP.setXYAddress (eX = 0, eY);} // (eX, eY); else if (C == '"') DISP.refresh(), DISP.setXYAddress (eX = 0, eY = 0); //DISP.clear(), DISP.refresh(), DISP.setXYAddress (eX = 0, eY = 0); } else if (C > 31 && C < 126) // Ne može tildu (~) ispisati { if (eX >= 77) eX = 0, eY = (eY + 1) % 5; //Možda i onemogućiti ovaj WW!? DISP.setXYAddress (eX, eY); DISP.printChar (C); eX += 6; //Provjeriti } } int main() { ENBL = 1; DISP.init(); //T.attach (&DoIt, 0.05); //Regulirati 0.1, 0.2, 0.01 PC.attach (&DoIt); while (7); }