![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Novo
Fork of LukaIElmir by
DotMatrix.cpp@3:43648fa57d55, 2014-05-26 (annotated)
- Committer:
- tim003
- Date:
- Mon May 26 15:07:13 2014 +0000
- Revision:
- 3:43648fa57d55
17:06
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
tim003 | 3:43648fa57d55 | 1 | #include "DotMatrix.h" |
tim003 | 3:43648fa57d55 | 2 | #include "MatrixSPI.h" |
tim003 | 3:43648fa57d55 | 3 | |
tim003 | 3:43648fa57d55 | 4 | void DotMatrix::refresh(){ |
tim003 | 3:43648fa57d55 | 5 | for(int i = 0; i < 8; i++) |
tim003 | 3:43648fa57d55 | 6 | { |
tim003 | 3:43648fa57d55 | 7 | spi.sendCol(i, buffer[i]); |
tim003 | 3:43648fa57d55 | 8 | buffer[i] = 0; |
tim003 | 3:43648fa57d55 | 9 | } |
tim003 | 3:43648fa57d55 | 10 | } |
tim003 | 3:43648fa57d55 | 11 | |
tim003 | 3:43648fa57d55 | 12 | void DotMatrix::setIntensity(float jacina){ |
tim003 | 3:43648fa57d55 | 13 | if(jacina <= 0){ |
tim003 | 3:43648fa57d55 | 14 | spi.turnOFF(); |
tim003 | 3:43648fa57d55 | 15 | turnedON = false; |
tim003 | 3:43648fa57d55 | 16 | |
tim003 | 3:43648fa57d55 | 17 | |
tim003 | 3:43648fa57d55 | 18 | } else if(jacina >= 0.98){ |
tim003 | 3:43648fa57d55 | 19 | if(!turnedON){ |
tim003 | 3:43648fa57d55 | 20 | spi.turnON(); |
tim003 | 3:43648fa57d55 | 21 | turnedON = true; |
tim003 | 3:43648fa57d55 | 22 | } |
tim003 | 3:43648fa57d55 | 23 | |
tim003 | 3:43648fa57d55 | 24 | spi.sendSingle(MatrixSPI::intensity, 0x0f); |
tim003 | 3:43648fa57d55 | 25 | } else { |
tim003 | 3:43648fa57d55 | 26 | if(!turnedON){ |
tim003 | 3:43648fa57d55 | 27 | spi.turnON(); |
tim003 | 3:43648fa57d55 | 28 | turnedON = true; |
tim003 | 3:43648fa57d55 | 29 | } |
tim003 | 3:43648fa57d55 | 30 | |
tim003 | 3:43648fa57d55 | 31 | int temp = jacina*0x0f; |
tim003 | 3:43648fa57d55 | 32 | spi.sendSingle(MatrixSPI::intensity, temp); |
tim003 | 3:43648fa57d55 | 33 | } |
tim003 | 3:43648fa57d55 | 34 | } |
tim003 | 3:43648fa57d55 | 35 | |
tim003 | 3:43648fa57d55 | 36 | void DotMatrix::attach() |
tim003 | 3:43648fa57d55 | 37 | { |
tim003 | 3:43648fa57d55 | 38 | ticker.detach(); |
tim003 | 3:43648fa57d55 | 39 | if(mod == scroll) |
tim003 | 3:43648fa57d55 | 40 | { |
tim003 | 3:43648fa57d55 | 41 | ticker.attach(this, &DotMatrix::prikaziScroll, brzina_ms/8); |
tim003 | 3:43648fa57d55 | 42 | } else if(mod == char_by_char){ |
tim003 | 3:43648fa57d55 | 43 | ticker.attach(this, &DotMatrix::prikaziCBC, brzina_ms); |
tim003 | 3:43648fa57d55 | 44 | } |
tim003 | 3:43648fa57d55 | 45 | } |
tim003 | 3:43648fa57d55 | 46 | |
tim003 | 3:43648fa57d55 | 47 | void DotMatrix::setSpeed_ms(int ms) |
tim003 | 3:43648fa57d55 | 48 | { |
tim003 | 3:43648fa57d55 | 49 | ticker.detach(); |
tim003 | 3:43648fa57d55 | 50 | |
tim003 | 3:43648fa57d55 | 51 | attach(); |
tim003 | 3:43648fa57d55 | 52 | |
tim003 | 3:43648fa57d55 | 53 | } |
tim003 | 3:43648fa57d55 | 54 | |
tim003 | 3:43648fa57d55 | 55 | void DotMatrix::turnON(){ |
tim003 | 3:43648fa57d55 | 56 | if(!turnedON){ |
tim003 | 3:43648fa57d55 | 57 | spi.turnON(); |
tim003 | 3:43648fa57d55 | 58 | turnedON = true; |
tim003 | 3:43648fa57d55 | 59 | |
tim003 | 3:43648fa57d55 | 60 | attach(); |
tim003 | 3:43648fa57d55 | 61 | } |
tim003 | 3:43648fa57d55 | 62 | } |
tim003 | 3:43648fa57d55 | 63 | |
tim003 | 3:43648fa57d55 | 64 | void DotMatrix::turnOFF(){ |
tim003 | 3:43648fa57d55 | 65 | if(turnedON){ |
tim003 | 3:43648fa57d55 | 66 | spi.turnOFF(); |
tim003 | 3:43648fa57d55 | 67 | turnedON = false; |
tim003 | 3:43648fa57d55 | 68 | |
tim003 | 3:43648fa57d55 | 69 | ticker.detach(); |
tim003 | 3:43648fa57d55 | 70 | } |
tim003 | 3:43648fa57d55 | 71 | } |