tim003 tim003
/
LukaIElmir26
Novo
Fork of LukaIElmir by
Diff: main.cpp
- Revision:
- 6:dd675b967b60
- Parent:
- 5:654e3398c1ef
--- a/main.cpp Mon May 26 18:28:21 2014 +0000 +++ b/main.cpp Mon Jun 02 15:35:11 2014 +0000 @@ -1,32 +1,192 @@ #include "mbed.h" #include "DotMatrix.h" - #include "MatrixSPI.h" -MatrixSPI mspi; - -/*void funkcija(){ - int temp = pot*16; - load = LOW; - max72_spi.write(max7219_reg_intensity); - max72_spi.write(temp); - load = HIGH; -}*/ - +//MatrixSPI mspi; DotMatrix d; -int main() { - - - d.inicijaliziraj(); - d.PromijeniMod(char_by_char); - d.PromijeniRecenicu("ABCD"); +Serial pc(USBTX, USBRX); + + + +void Meni() +{ + pc.printf("1 - promjena teksta \n2 - promjena moda\n3 - promjena osvjetljenja\n4 - ukljuci prikaz teksta\n4 - iskljuci prikaz teksta\n6 - live input\nUnos: "); + char komanda = pc.getc(); + + if(komanda == '1') + { + pc.printf ("\nUnesite novi tekst: "); + string line; + char c = pc.getc(); + while (c != '\n') + { + line.push_back(c); + c = pc.getc(); + } + d.PromijeniRecenicu(line); + } + else if (komanda == '2') + { + char c; + do + { + pc.printf("1 - scroll \n2 - slovo po slovo\n0 - povratak na glavni meni\nMod: "); + c = pc.getc(); + if(c == '1') d.PromijeniMod(scroll); + else if(c == '2') d.PromijeniMod(char_by_char); + } + while(c < '0' || c > '2'); + } else if (komanda == '3') + { + char c; + do + { + pc.printf("Unesite broj od 0 do 9 za promjenu osvjetljenja: "); + c = pc.getc(); + if(c >= '0' && c <= '9') d.setIntensity((c - '0')/ 10.0); + } + while(c < '0' || c > '9'); + } + else if (komanda == '4') + { + d.turnON(); + } + else if (komanda == '5') + { + d.turnOFF(); + } + else if (komanda == '6') + { + char c; + while ((c = pc.getc()) != '\n') d.displaySingleChar(c); + d.refresh(); + } + else pc.printf ("Unos nije ispravan!!!\nPonovite unos: "); +} + + +void test1(){ + d.displaySingleChar('L'); + wait(0.33); + d.displaySingleChar('U'); + wait(0.33); + d.displaySingleChar('K'); + wait(0.33); + d.displaySingleChar('A'); + wait(0.33); + d.displaySingleChar('i'); + wait(0.33); + d.displaySingleChar('e'); + wait(0.33); + d.displaySingleChar('l'); + wait(0.33); + d.displaySingleChar('m'); + wait(0.33); + d.displaySingleChar('i'); + wait(0.33); + d.displaySingleChar('e'); + wait(0.33); + d.displaySingleChar('.'); + wait(0.33); + d.displaySingleChar(','); + wait(0.33); + d.displaySingleChar('Ć'); + wait(0.33); + d.displaySingleChar('L'); + wait(0.33); + + for(int i = 0; i < 10; i++) + { + char c = (i%2? 'M' : 0); + d.displaySingleChar(c); + wait(0.5); + } + +} - //enable = 1; - /*t.attach(&funkcija, 0.01); - setup ();*/ - while(1){} +void test2(){ + d.setChar('L',1); + d.refresh(); + wait(0.33); + d.setChar('U',1); + d.refresh(); + wait(0.33); + d.setChar('K',1); + d.refresh(); + wait(0.33); + d.setChar('A',1); + d.refresh(); + wait(0.33); + d.setChar('i',1); + d.refresh(); + wait(0.33); + d.setChar('e',1); + d.refresh(); + wait(0.33); + d.setChar('l',1); + d.refresh(); + wait(0.33); + d.setChar('m',1); + d.refresh(); + wait(0.33); + d.setChar('i',1); + d.refresh(); + wait(0.33); + d.setChar('e',1); + d.refresh(); + wait(0.33); + d.setChar('.',1); + d.refresh(); + wait(0.33); + d.setChar(',',1); + d.refresh(); + wait(0.33); + d.setChar(0,1); + d.refresh(); + wait(0.33); + d.setChar('L',1); + d.refresh(); + wait(0.33); + + + for(int i = 0; i < 60; i++) + { + d.setChar('M', (i%16)-8); + d.refresh(); + wait(0.25); + } + +} + +void test3(){//test recenica + d.PromijeniRecenicu("Luka bio ovdje"); + bool t = false; + + for(int i = 0; i < d.recenica.size(); i++){ + d.displaySingleChar(d.recenica[i]); + + wait(t ? d.brzina_ms*1000 : 0.25); + } } - +int main() +{ + + d.PromijeniMod(char_by_char); + d.turnON(); + for(int i = 0; i < d.recenica.size(); i++) + { + pc.putc(d.recenica[i]); + } + pc.putc('\n'); + //enable = 1; + /*t.attach(&funkcija, 0.01); + setup ();*/ + Meni(); + while(1) + { + + } +} \ No newline at end of file