Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: DotMatrix.cpp
- Revision:
- 3:43648fa57d55
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/DotMatrix.cpp Mon May 26 15:07:13 2014 +0000
@@ -0,0 +1,71 @@
+#include "DotMatrix.h"
+#include "MatrixSPI.h"
+
+void DotMatrix::refresh(){
+ for(int i = 0; i < 8; i++)
+ {
+ spi.sendCol(i, buffer[i]);
+ buffer[i] = 0;
+ }
+}
+
+void DotMatrix::setIntensity(float jacina){
+ if(jacina <= 0){
+ spi.turnOFF();
+ turnedON = false;
+
+
+ } else if(jacina >= 0.98){
+ if(!turnedON){
+ spi.turnON();
+ turnedON = true;
+ }
+
+ spi.sendSingle(MatrixSPI::intensity, 0x0f);
+ } else {
+ if(!turnedON){
+ spi.turnON();
+ turnedON = true;
+ }
+
+ int temp = jacina*0x0f;
+ spi.sendSingle(MatrixSPI::intensity, temp);
+ }
+}
+
+void DotMatrix::attach()
+{
+ ticker.detach();
+ if(mod == scroll)
+ {
+ ticker.attach(this, &DotMatrix::prikaziScroll, brzina_ms/8);
+ } else if(mod == char_by_char){
+ ticker.attach(this, &DotMatrix::prikaziCBC, brzina_ms);
+ }
+}
+
+void DotMatrix::setSpeed_ms(int ms)
+{
+ ticker.detach();
+
+ attach();
+
+}
+
+void DotMatrix::turnON(){
+ if(!turnedON){
+ spi.turnON();
+ turnedON = true;
+
+ attach();
+ }
+}
+
+void DotMatrix::turnOFF(){
+ if(turnedON){
+ spi.turnOFF();
+ turnedON = false;
+
+ ticker.detach();
+ }
+}
\ No newline at end of file