updaye from Wulfnor fixing epsilon
authorJim Morris <morris@wolfman.com>
Wed, 29 Jan 2014 22:16:08 +0000 (14:16 -0800)
committerJim Morris <morris@wolfman.com>
Wed, 29 Jan 2014 22:16:08 +0000 (14:16 -0800)
src/modules/utils/currentcontrol/ad5206.h

index 9ef0da9..bf9d7d9 100644 (file)
@@ -20,14 +20,15 @@ class AD5206 : public DigipotBase {
 
         void set_current( int channel, float current )
         {
-            current = min( max( current, 0.0L ), 2.0L );
-
-
-            char adresses[6] = { 0x05, 0x03, 0x01, 0x00, 0x02, 0x04 };
-            cs.set(0);
-            spi->write((int)adresses[channel]);
-            spi->write((int)current_to_wiper(current));
-            cs.set(1);
+                       if(channel<6){
+                               current = min( max( current, 0.0L ), 2.0L );
+                               char adresses[6] = { 0x05, 0x03, 0x01, 0x00, 0x02, 0x04 };
+                               currents[channel] = current;
+                               cs.set(0);
+                               spi->write((int)adresses[channel]);
+                               spi->write((int)current_to_wiper(current));
+                               cs.set(1);
+                       }
         }