Psi Swarm robot library version 0.9

Dependents:   PsiSwarm_V9_Blank

Fork of PsiSwarmV9 by James Hilder

Revision:
12:878c6e9d9e60
Parent:
11:312663037b8c
Child:
16:50686c07ad07
diff -r 312663037b8c -r 878c6e9d9e60 i2c_setup.cpp
--- a/i2c_setup.cpp	Sun Oct 16 21:06:15 2016 +0000
+++ b/i2c_setup.cpp	Mon Oct 17 13:09:10 2016 +0000
@@ -167,9 +167,9 @@
     if(primary_i2c.write(GPIO_IC_ADDRESS,data,3,false) != 0) {
         system_warnings += 2;
         okay = 0;
-        debug("- WARNING: No I2C acknowledge for main GPIO IC\n");
+        psi.debug("- WARNING: No I2C acknowledge for main GPIO IC\n");
         if(HALT_ON_GPIO_ERROR){
-            debug("- PROGRAM HALTED.  Check that robot is switched on!\n");
+            psi.debug("- PROGRAM HALTED.  Check that robot is switched on!\n");
             while(1){
                mbed_led1=1;
                mbed_led2=1;
@@ -201,7 +201,7 @@
     gpio_byte0 = read_data[0];
     //char ret_val = (gpio_byte0 & 0xF8) >> 3;  //Returns a >0 value if a button is being pushed
     gpio_byte1 = read_data[1];
-    if(okay && testing_voltage_regulators_flag)debug("- Checking 3.3V voltage regulators\n");
+    if(okay && testing_voltage_regulators_flag)psi.debug("- Checking 3.3V voltage regulators\n");
     IF_parse_gpio_byte0(gpio_byte0);
     IF_parse_gpio_byte1(gpio_byte1);
     testing_voltage_regulators_flag = 0;
@@ -220,7 +220,7 @@
 
     if(primary_i2c.write(AUX_IC_ADDRESS,data,2,false) != 0) {
         system_warnings += 4;
-        debug("- WARNING: No I2C acknowledge for aux GPIO IC\n");
+        psi.debug("- WARNING: No I2C acknowledge for aux GPIO IC\n");
     }
     data [0] = 0x06;  //Write to GPPU register
     data [1] = 0x3F;  //Set GP0-3 as active pull-up outputs and P4,P5 as pull-up inputs
@@ -242,8 +242,8 @@
     char old_charging_state = status_dc_in;
     status_dc_in = 1-((read_data[0] & 0x10) >> 4);
     if(status_dc_in!=old_charging_state){
-        if(status_dc_in == 0)debug("No DC input\n");
-        else debug("DC input to charge pins\n");
+        if(status_dc_in == 0)psi.debug("No DC input\n");
+        else psi.debug("DC input to charge pins\n");
     }
     //pc.printf("Aux IC Data:%X Charge:%d\n",read_data[0],charge_in);
 }
@@ -267,30 +267,30 @@
     if(((gpio_byte0 & 0x01)) != power_good_motor_left){
         power_good_motor_left = (gpio_byte0 & 0x01);
         if(!power_good_motor_left){
-            if(testing_voltage_regulators_flag || SHOW_VR_WARNINGS)debug("- WARNING: Voltage regulator left motor low\n");    
+            if(testing_voltage_regulators_flag || SHOW_VR_WARNINGS)psi.debug("- WARNING: Voltage regulator left motor low\n");    
         }
-        else if(testing_voltage_regulators_flag)debug("- Power good left motor v.reg\n");
+        else if(testing_voltage_regulators_flag)psi.debug("- Power good left motor v.reg\n");
     } 
     if(((gpio_byte0 & 0x02) >> 1) != power_good_motor_right){
         power_good_motor_right = (gpio_byte0 & 0x02) >> 1;
         if(!power_good_motor_right){
-            if(testing_voltage_regulators_flag || SHOW_VR_WARNINGS)debug("- WARNING: Voltage regulator right motor low\n");
+            if(testing_voltage_regulators_flag || SHOW_VR_WARNINGS)psi.debug("- WARNING: Voltage regulator right motor low\n");
         }
-        else if(testing_voltage_regulators_flag)debug("- Power good right motor v.reg\n");
+        else if(testing_voltage_regulators_flag)psi.debug("- Power good right motor v.reg\n");
     } 
     if(((gpio_byte0 & 0x04) >> 2) != power_good_infrared){
         power_good_infrared = (gpio_byte0 & 0x04) >> 2;
         if(!power_good_infrared){
-            if(testing_voltage_regulators_flag || SHOW_VR_WARNINGS)debug("- WARNING: Voltage regulator infrared low\n");
+            if(testing_voltage_regulators_flag || SHOW_VR_WARNINGS)psi.debug("- WARNING: Voltage regulator infrared low\n");
         }
-        else if(testing_voltage_regulators_flag)debug("- Power good infrared and aux v.reg\n");
+        else if(testing_voltage_regulators_flag)psi.debug("- Power good infrared and aux v.reg\n");
     } 
     if(USE_LED4_FOR_VR_WARNINGS){
          mbed_led4 = (!power_good_motor_left || !power_good_motor_right || !power_good_infrared);
     }
     //Halt the system if settings flag is set and all v-regs are bad [usually this means robot is switched off!]
     if(HALT_ON_ALL_VREGS_LOW && !power_good_motor_left && !power_good_motor_right && !power_good_infrared){
-        debug("- PROGRAM HALTED.  Check that robot is switched on!\n");
+        psi.debug("- PROGRAM HALTED.  Check that robot is switched on!\n");
         while(1){
              mbed_led1=1;
              mbed_led2=0;
@@ -424,13 +424,13 @@
     char UpperByte = data[0];
     char LowerByte = data[1];
     if ((UpperByte & 0x80) == 0x80) {
-        debug("- WARNING: Temperature sensor reports critical temperature\n");
+        psi.debug("- WARNING: Temperature sensor reports critical temperature\n");
     }
     if ((UpperByte & 0x40) == 0x40) {
-        debug("- WARNING: Temperature sensor reports above upper limit\n");
+        psi.debug("- WARNING: Temperature sensor reports above upper limit\n");
     }
     if ((UpperByte & 0x20) == 0x20) {
-        debug("- WARNING: Temperature sensor reports below lower limit\n");
+        psi.debug("- WARNING: Temperature sensor reports below lower limit\n");
     }
     UpperByte = UpperByte & 0x1F;       //Clear flag bits
     if ((UpperByte & 0x10) == 0x10) {