fix whitespace tabs -> spaces
authorJim Morris <morris@wolfman.com>
Thu, 13 Jun 2013 09:52:29 +0000 (02:52 -0700)
committerJim Morris <morris@wolfman.com>
Thu, 13 Jun 2013 09:52:29 +0000 (02:52 -0700)
src/modules/utils/currentcontrol/CurrentControl.cpp
src/modules/utils/currentcontrol/CurrentControl.h
src/modules/utils/currentcontrol/DigipotBase.h
src/modules/utils/currentcontrol/ad5206.h
src/modules/utils/currentcontrol/mcp4451.h

index 0696b95..e462a2f 100644 (file)
 using namespace std;
 
 CurrentControl::CurrentControl(){
-       digipot= NULL;
+    digipot= NULL;
 }
 
 void CurrentControl::on_module_loaded(){
-       if( !this->kernel->config->value( currentcontrol_module_enable_checksum )->by_default(false)->as_bool() ){
-               // as this module is not needed free up the resource
-               delete this;
-               return;
-       }
+    if( !this->kernel->config->value( currentcontrol_module_enable_checksum )->by_default(false)->as_bool() ){
+        // as this module is not needed free up the resource
+        delete this;
+        return;
+    }
 
-       // allocate digipot, if already allocated delete it first
-       delete digipot;
+    // allocate digipot, if already allocated delete it first
+    delete digipot;
 
-       // see which chip to use
-       int chip_checksum = get_checksum(this->kernel->config->value(digipotchip_checksum)->by_default("mcp4451")->as_string());
-       if(chip_checksum == mcp4451_checksum) {
-               digipot = new MCP4451();
-       }else if(chip_checksum == ad5206_checksum) {
-               digipot = new AD5206();
-       }else { // need a default so use smoothie
-               digipot = new MCP4451();
-       }
+    // see which chip to use
+    int chip_checksum = get_checksum(this->kernel->config->value(digipotchip_checksum)->by_default("mcp4451")->as_string());
+    if(chip_checksum == mcp4451_checksum) {
+        digipot = new MCP4451();
+    }else if(chip_checksum == ad5206_checksum) {
+        digipot = new AD5206();
+    }else { // need a default so use smoothie
+        digipot = new MCP4451();
+    }
 
     // Get configuration
     this->alpha_current =           this->kernel->config->value(alpha_current_checksum  )->by_default(0.8)->as_number();
index a5b6b29..e354499 100644 (file)
 #define gamma_current_checksum                  CHECKSUM("gamma_current")
 #define delta_current_checksum                  CHECKSUM("delta_current")
 #define currentcontrol_module_enable_checksum   CHECKSUM("currentcontrol_module_enable")
-#define digipotchip_checksum                                   CHECKSUM("digipotchip")
+#define digipotchip_checksum                    CHECKSUM("digipotchip")
 
-#define mcp4451_checksum                                               CHECKSUM("mcp4451")
-#define ad5206_checksum                                                    CHECKSUM("ad5206")
+#define mcp4451_checksum                        CHECKSUM("mcp4451")
+#define ad5206_checksum                         CHECKSUM("ad5206")
 
 class CurrentControl : public Module {
     public:
index 7aa37a7..2d88e90 100644 (file)
@@ -9,7 +9,7 @@
 class DigipotBase {
     public:
         DigipotBase(){}
-               virtual ~DigipotBase(){}
+        virtual ~DigipotBase(){}
 
         virtual void set_current( int channel, double current )= 0;
         virtual double get_current(int channel)= 0;
index 61e95bb..1592c60 100644 (file)
 class AD5206 : public DigipotBase {
     public:
         AD5206(){
-               this->spi= new mbed::SPI(P0_9,P0_8,P0_7); //should be able to set those pins in config
-               cs.from_string("4.29")->as_output(); //this also should be configurable
-               cs.set(1);
+            this->spi= new mbed::SPI(P0_9,P0_8,P0_7); //should be able to set those pins in config
+            cs.from_string("4.29")->as_output(); //this also should be configurable
+            cs.set(1);
         }
 
         void set_current( int channel, double current )
         {
-               current = min( max( current, 0.0L ), 2.0L );
+            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);
+            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);
         }
 
 
         //taken from 4pi firmware
         unsigned char current_to_wiper( double current ){
-                       unsigned int count = int((current*1000)*100/743); //6.8k resistor and 10k pot
+            unsigned int count = int((current*1000)*100/743); //6.8k resistor and 10k pot
 
-                       return (unsigned char)count;
-               }
+            return (unsigned char)count;
+        }
 
         double get_current(int channel)
         {
             return currents[channel];
         }
 
-       private:
+    private:
 
         Pin cs;
         mbed::SPI* spi;
index d94fefb..6a6faf2 100644 (file)
@@ -15,11 +15,11 @@ class MCP4451 : public DigipotBase {
             this->i2c = new mbed::I2C(p9, p10);
             for (int i = 0; i < 4; i++)
                 currents[i] = 0.0;
-               }
-               
-               ~MCP4451(){
-                       delete this->i2c;
-               }
+        }
+        
+        ~MCP4451(){
+            delete this->i2c;
+        }
 
         void set_current( int channel, double current )
         {
@@ -38,23 +38,23 @@ class MCP4451 : public DigipotBase {
         double get_current(int channel)
         {
             return currents[channel];
-               }
-               
-       private:
-
-               void i2c_send( char first, char second, char third ){
-                       this->i2c->start();
-                       this->i2c->write(first);
-                       this->i2c->write(second);
-                       this->i2c->write(third);
-                       this->i2c->stop();
-               }
-
-               char current_to_wiper( double current ){
-                       return char(ceil(double((113.33*current))));
-               }
-
-               mbed::I2C* i2c;
+        }
+        
+    private:
+
+        void i2c_send( char first, char second, char third ){
+            this->i2c->start();
+            this->i2c->write(first);
+            this->i2c->write(second);
+            this->i2c->write(third);
+            this->i2c->stop();
+        }
+
+        char current_to_wiper( double current ){
+            return char(ceil(double((113.33*current))));
+        }
+
+        mbed::I2C* i2c;
         double currents[4];
 };