tim010 tim010
/
LV8-Grupa1-Tim010-Z3
Enil Pajić, Irma Jakić
main.cpp@0:4c2857ed48ec, 2014-05-05 (annotated)
- Committer:
- tim010
- Date:
- Mon May 05 07:44:35 2014 +0000
- Revision:
- 0:4c2857ed48ec
LV8-Grupa1-Tim010-Z3
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
tim010 | 0:4c2857ed48ec | 1 | //LV8-Grupa1-Tim010-Z3 |
tim010 | 0:4c2857ed48ec | 2 | #include "mbed.h" |
tim010 | 0:4c2857ed48ec | 3 | #include "N5110.h" |
tim010 | 0:4c2857ed48ec | 4 | //By EnilP, 04.05.2014, ETF PAI |
tim010 | 0:4c2857ed48ec | 5 | DigitalOut ENBL (dp14); |
tim010 | 0:4c2857ed48ec | 6 | N5110 DISP (dp4, dp24, dp23, dp25, dp2, dp6, dp18); |
tim010 | 0:4c2857ed48ec | 7 | Serial PC (USBTX, USBRX); |
tim010 | 0:4c2857ed48ec | 8 | Ticker T; |
tim010 | 0:4c2857ed48ec | 9 | int eX = 0, eY = 0; |
tim010 | 0:4c2857ed48ec | 10 | void DoIt() |
tim010 | 0:4c2857ed48ec | 11 | { |
tim010 | 0:4c2857ed48ec | 12 | if (!PC.readable()) return; |
tim010 | 0:4c2857ed48ec | 13 | char C = PC.getc(); |
tim010 | 0:4c2857ed48ec | 14 | DISP.setXYAddress (eX, eY); |
tim010 | 0:4c2857ed48ec | 15 | if (C == 8 || C == 10 || C == 127 || C == '!' || C == '"') // C == 13 (ENTER)? |
tim010 | 0:4c2857ed48ec | 16 | { |
tim010 | 0:4c2857ed48ec | 17 | if (C == 127) |
tim010 | 0:4c2857ed48ec | 18 | { |
tim010 | 0:4c2857ed48ec | 19 | eX -= 6; |
tim010 | 0:4c2857ed48ec | 20 | if (eX < 0) eY = (eY ? eY - 1 : eY), eX = 77; //Možda i onemogućiti ovo!? |
tim010 | 0:4c2857ed48ec | 21 | DISP.setXYAddress (eX, eY); |
tim010 | 0:4c2857ed48ec | 22 | DISP.printChar (' '); |
tim010 | 0:4c2857ed48ec | 23 | //eX -= 6; |
tim010 | 0:4c2857ed48ec | 24 | } |
tim010 | 0:4c2857ed48ec | 25 | else if (C == '!') // == 13 |
tim010 | 0:4c2857ed48ec | 26 | {eY = (eY + 1) % 5; DISP.setXYAddress (eX = 0, eY);} // (eX, eY); |
tim010 | 0:4c2857ed48ec | 27 | else if (C == '"') DISP.refresh(), DISP.setXYAddress (eX = 0, eY = 0); //DISP.clear(), DISP.refresh(), DISP.setXYAddress (eX = 0, eY = 0); |
tim010 | 0:4c2857ed48ec | 28 | } |
tim010 | 0:4c2857ed48ec | 29 | else if (C > 31 && C < 126) // Ne može tildu (~) ispisati |
tim010 | 0:4c2857ed48ec | 30 | { |
tim010 | 0:4c2857ed48ec | 31 | if (eX >= 77) eX = 0, eY = (eY + 1) % 5; //Možda i onemogućiti ovaj WW!? |
tim010 | 0:4c2857ed48ec | 32 | DISP.setXYAddress (eX, eY); |
tim010 | 0:4c2857ed48ec | 33 | DISP.printChar (C); |
tim010 | 0:4c2857ed48ec | 34 | eX += 6; //Provjeriti |
tim010 | 0:4c2857ed48ec | 35 | } |
tim010 | 0:4c2857ed48ec | 36 | } |
tim010 | 0:4c2857ed48ec | 37 | int main() |
tim010 | 0:4c2857ed48ec | 38 | { |
tim010 | 0:4c2857ed48ec | 39 | ENBL = 1; |
tim010 | 0:4c2857ed48ec | 40 | DISP.init(); |
tim010 | 0:4c2857ed48ec | 41 | //T.attach (&DoIt, 0.05); //Regulirati 0.1, 0.2, 0.01 |
tim010 | 0:4c2857ed48ec | 42 | PC.attach (&DoIt); |
tim010 | 0:4c2857ed48ec | 43 | while (7); |
tim010 | 0:4c2857ed48ec | 44 | } |