Nico De Witte / NeoPixelI2cSlave

Dependencies:   NeoPixelString SimplyLog

Files at this revision

API Documentation at this revision

Comitter:
dwini
Date:
Sun Oct 25 11:36:21 2015 +0000
Parent:
1:a93d16b04770
Commit message:
Add alive led to i2c daemon

Changed in this revision

neopixel_i2c_daemon.cpp Show annotated file Show diff for this revision Revisions of this file
neopixel_i2c_daemon.h Show annotated file Show diff for this revision Revisions of this file
--- a/neopixel_i2c_daemon.cpp	Sun Oct 25 11:27:26 2015 +0000
+++ b/neopixel_i2c_daemon.cpp	Sun Oct 25 11:36:21 2015 +0000
@@ -3,8 +3,9 @@
 #define DEBUG_MODE 1
 #include "log.h"
 
-NeoPixelI2cDaemon::NeoPixelI2cDaemon(I2cDevice * i2c){
+NeoPixelI2cDaemon::NeoPixelI2cDaemon(I2cDevice * i2c, PinName alive_pin) : alive(alive_pin) {
     this->i2c = i2c;
+    cAlive = 0;
 }
 
 void NeoPixelI2cDaemon::attachPixelString(NeoPixelString * pixelstring) {
@@ -101,5 +102,11 @@
         for(int i = 0; i < 10; i++) {
             buffer[i] = 0;    // Clear buffer
         }
+        
+        // Alive LED
+        cAlive = (cAlive + 1) % 100000;
+        if (!cAlive) {
+            alive = !alive;
+        }
     }
 }
\ No newline at end of file
--- a/neopixel_i2c_daemon.h	Sun Oct 25 11:27:26 2015 +0000
+++ b/neopixel_i2c_daemon.h	Sun Oct 25 11:36:21 2015 +0000
@@ -11,9 +11,11 @@
     private:
         I2cDevice * i2c;
         std::vector<NeoPixelString *> pixelstrings;
+        int cAlive;     // Counter for alive led
+        DigitalOut alive;
         
     public:
-        NeoPixelI2cDaemon(I2cDevice * i2c);
+        NeoPixelI2cDaemon(I2cDevice * i2c, PinName alive_pin);
         
     public:
         void attachPixelString(NeoPixelString * pixelstring);