![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Novo
Fork of LukaIElmir by
DotMatrix.h@4:ba24ce878e87, 2014-05-26 (annotated)
- Committer:
- tim003
- Date:
- Mon May 26 17:39:37 2014 +0000
- Revision:
- 4:ba24ce878e87
- Parent:
- 3:43648fa57d55
- Child:
- 5:654e3398c1ef
Verzija koja radi;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
tim003 | 3:43648fa57d55 | 1 | #include "mbed.h" |
tim003 | 3:43648fa57d55 | 2 | #include "MatrixSPI.h" |
tim003 | 3:43648fa57d55 | 3 | #include <string> |
tim003 | 3:43648fa57d55 | 4 | #include <vector> |
tim003 | 3:43648fa57d55 | 5 | |
tim003 | 3:43648fa57d55 | 6 | #ifndef DOTMATRIX_H |
tim003 | 3:43648fa57d55 | 7 | #define DOTMATRIX_H |
tim003 | 3:43648fa57d55 | 8 | |
tim003 | 3:43648fa57d55 | 9 | enum ModPrikazivanja{scroll, char_by_char, live_input}; |
tim003 | 3:43648fa57d55 | 10 | |
tim003 | 3:43648fa57d55 | 11 | class DotMatrix{ |
tim003 | 3:43648fa57d55 | 12 | |
tim003 | 3:43648fa57d55 | 13 | public: |
tim003 | 3:43648fa57d55 | 14 | DotMatrix(PinName data_input = dp2, PinName clock = dp6, PinName loadcs = dp24) |
tim003 | 3:43648fa57d55 | 15 | :spi(data_input, clock, loadcs), turnedON(false), mod(scroll), char_trenutni(0), |
tim003 | 3:43648fa57d55 | 16 | char_offset(0), repeat(true), brzina_ms(1000) |
tim003 | 3:43648fa57d55 | 17 | { |
tim003 | 3:43648fa57d55 | 18 | for(int i = 0; i < 8; i++) buffer[i] = 0; |
tim003 | 3:43648fa57d55 | 19 | } |
tim003 | 3:43648fa57d55 | 20 | |
tim003 | 3:43648fa57d55 | 21 | void refresh(); |
tim003 | 3:43648fa57d55 | 22 | void setIntensity(float jacina); |
tim003 | 3:43648fa57d55 | 23 | void setSpeed_ms(int ms); |
tim003 | 3:43648fa57d55 | 24 | void turnON(); |
tim003 | 3:43648fa57d55 | 25 | void turnOFF(); |
tim003 | 3:43648fa57d55 | 26 | void PromijeniRecenicu(string recenica){ |
tim003 | 3:43648fa57d55 | 27 | this->recenica = recenica; |
tim003 | 3:43648fa57d55 | 28 | } |
tim003 | 3:43648fa57d55 | 29 | void NadodajNaRecenicu(char c){ |
tim003 | 3:43648fa57d55 | 30 | recenica += c; |
tim003 | 3:43648fa57d55 | 31 | } |
tim003 | 3:43648fa57d55 | 32 | void NadodajNaRecenicu(string str){ |
tim003 | 3:43648fa57d55 | 33 | recenica += str; |
tim003 | 3:43648fa57d55 | 34 | } |
tim003 | 3:43648fa57d55 | 35 | void PromijeniMod(ModPrikazivanja mod){ |
tim003 | 3:43648fa57d55 | 36 | if(this->mod != mod){ |
tim003 | 3:43648fa57d55 | 37 | this->mod = mod; |
tim003 | 3:43648fa57d55 | 38 | attach(); |
tim003 | 3:43648fa57d55 | 39 | } |
tim003 | 3:43648fa57d55 | 40 | } |
tim003 | 3:43648fa57d55 | 41 | ModPrikazivanja dajMod() const{ |
tim003 | 3:43648fa57d55 | 42 | return mod; |
tim003 | 3:43648fa57d55 | 43 | } |
tim003 | 4:ba24ce878e87 | 44 | void SetRepeat(bool r){ |
tim003 | 4:ba24ce878e87 | 45 | repeat = r; |
tim003 | 4:ba24ce878e87 | 46 | } |
tim003 | 3:43648fa57d55 | 47 | |
tim003 | 4:ba24ce878e87 | 48 | bool GetRepeat() const{ |
tim003 | 4:ba24ce878e87 | 49 | return repeat; |
tim003 | 4:ba24ce878e87 | 50 | } |
tim003 | 3:43648fa57d55 | 51 | |
tim003 | 4:ba24ce878e87 | 52 | int buffer[8]; |
tim003 | 3:43648fa57d55 | 53 | private: |
tim003 | 3:43648fa57d55 | 54 | void attach(); |
tim003 | 4:ba24ce878e87 | 55 | void prikaziScroll(){} |
tim003 | 4:ba24ce878e87 | 56 | void prikaziCBC(){} |
tim003 | 3:43648fa57d55 | 57 | |
tim003 | 3:43648fa57d55 | 58 | MatrixSPI spi; |
tim003 | 4:ba24ce878e87 | 59 | |
tim003 | 3:43648fa57d55 | 60 | bool turnedON; |
tim003 | 3:43648fa57d55 | 61 | string recenica; |
tim003 | 3:43648fa57d55 | 62 | ModPrikazivanja mod; |
tim003 | 3:43648fa57d55 | 63 | int char_trenutni, char_offset; |
tim003 | 3:43648fa57d55 | 64 | Ticker ticker; |
tim003 | 3:43648fa57d55 | 65 | //bool isAttached potrebno ako se ticker ne može 2. detachirati... |
tim003 | 3:43648fa57d55 | 66 | bool repeat; |
tim003 | 3:43648fa57d55 | 67 | int brzina_ms; |
tim003 | 3:43648fa57d55 | 68 | }; |
tim003 | 3:43648fa57d55 | 69 | |
tim003 | 3:43648fa57d55 | 70 | #endif //DotMatrix_h |