set missing ina219 to zero, BUS same as BAT

pico-i2c
alanbjohnston 3 years ago committed by GitHub
parent aff5693a78
commit ba257eb1b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -2227,8 +2227,11 @@ void read_ina219()
Serial.print(current_mA); Serial.print(current_mA);
Serial.println(" mA"); Serial.println(" mA");
} }
voltage[0] = loadvoltage; voltage[PLUS_X] = loadvoltage;
current[0] = current_mA; current[PLUS_X] = current_mA;
} else {
voltage[PLUS_X] = 0.0;
current[PLUS_X] = 0.0;
} }
if (i2c2) { if (i2c2) {
@ -2244,8 +2247,11 @@ void read_ina219()
Serial.print(current_mA); Serial.print(current_mA);
Serial.println(" mA"); Serial.println(" mA");
} }
voltage[1] = loadvoltage; voltage[PLUS_Y] = loadvoltage;
current[1] = current_mA; current[PLUS_Y] = current_mA;
} else {
voltage[PLUS_Y] = 0.0;
current[PLUS_Y] = 0.0;
} }
if (i2c3) { if (i2c3) {
@ -2261,8 +2267,8 @@ void read_ina219()
Serial.print(current_mA); Serial.print(current_mA);
Serial.println(" mA"); Serial.println(" mA");
} }
voltage[2] = loadvoltage; voltage[BATT] = loadvoltage;
current[2] = current_mA; current[BATT] = current_mA;
/* /*
shuntvoltage = ina219_1_0x45.getShuntVoltage_mV(); shuntvoltage = ina219_1_0x45.getShuntVoltage_mV();
busvoltage = ina219_1_0x45.getBusVoltage_V(); busvoltage = ina219_1_0x45.getBusVoltage_V();
@ -2276,10 +2282,14 @@ void read_ina219()
Serial.print(current_mA); Serial.print(current_mA);
Serial.println(" mA"); Serial.println(" mA");
} }
voltage[3] = loadvoltage;
current[3] = current_mA;
*/ */
voltage[BUS] = loadvoltage; // since battery directly supplies, make BUS same as BAT for FoxTelem
current[BUS] = current_mA;
} else {
voltage[BATT] = 0.0;
current[BATT] = 0.0;
} }
if (i2c5) { if (i2c5) {
@ -2295,8 +2305,11 @@ void read_ina219()
Serial.print(current_mA); Serial.print(current_mA);
Serial.println(" mA"); Serial.println(" mA");
} }
voltage[4] = loadvoltage; voltage[PLUS_Z] = loadvoltage;
current[4] = current_mA; current[PLUS_Z] = current_mA;
} else {
voltage[PLUS_Z] = 0.0;
current[PLUS_Z] = 0.0;
} }
if (i2c6) { if (i2c6) {
@ -2312,8 +2325,11 @@ void read_ina219()
Serial.print(current_mA); Serial.print(current_mA);
Serial.println(" mA"); Serial.println(" mA");
} }
voltage[5] = loadvoltage; voltage[MINUS_X] = loadvoltage;
current[5] = current_mA; current[MINUS_X] = current_mA;
} else {
voltage[MINUS_X] = 0.0;
current[MINUS_X] = 0.0;
} }
if (i2c7) { if (i2c7) {
@ -2329,8 +2345,11 @@ void read_ina219()
Serial.print(current_mA); Serial.print(current_mA);
Serial.println(" mA"); Serial.println(" mA");
} }
voltage[6] = loadvoltage; voltage[MINUS_Y] = loadvoltage;
current[6] = current_mA; current[MINUS_Y] = current_mA;
} else {
voltage[MINUS_Y] = 0.0;
current[MINUS_Y] = 0.0;
} }
if (i2c8) { if (i2c8) {
@ -2346,8 +2365,11 @@ void read_ina219()
Serial.print(current_mA); Serial.print(current_mA);
Serial.println(" mA"); Serial.println(" mA");
} }
voltage[7] = loadvoltage; voltage[MINUS_Z] = loadvoltage;
current[7] = current_mA; current[MINUS_Z] = current_mA;
} else {
voltage[MINUS_Z] = 0.0;
current[MINUS_Z] = 0.0;
} }
voltage_read = false; voltage_read = false;
} }
@ -2998,7 +3020,7 @@ void start_ina219() {
// Serial.println(digitalRead(PI_3V3_PIN)); // Serial.println(digitalRead(PI_3V3_PIN));
if (digitalRead(PI_3V3_PIN) == LOW) { if (digitalRead(PI_3V3_PIN) == LOW) {
// if (true) { // if (true) {
Serial.println("Pi Zero not present, powering INA219s through 3.3V pin"); Serial.println("Pico powering INA219s through 3.3V pin");
pinMode(PI_3V3_PIN, OUTPUT); pinMode(PI_3V3_PIN, OUTPUT);
digitalWrite(PI_3V3_PIN, HIGH); digitalWrite(PI_3V3_PIN, HIGH);
} else { } else {

Loading…
Cancel
Save

Powered by TurnKey Linux.