Skip to content

Commit 163b8fb

Browse files
committed
Move beginFuelGauge to begin tab. Change how bluetooth begins.
1 parent 575d7f0 commit 163b8fb

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

Firmware/RTK_Surveyor/begin.ino

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -160,18 +160,7 @@ void beginBT()
160160
unitMACAddress[5] += 2; //Convert MAC address to Bluetooth MAC (add 2): https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/system/system.html#mac-address
161161

162162
SerialBT.register_callback(btCallback);
163-
if (startBluetooth() == false)
164-
{
165-
Serial.println(F("An error occurred initializing Bluetooth"));
166-
radioState = RADIO_OFF;
167-
digitalWrite(bluetoothStatusLED, LOW);
168-
}
169-
else
170-
{
171-
radioState = BT_ON_NOCONNECTION;
172-
digitalWrite(bluetoothStatusLED, HIGH);
173-
lastBluetoothLEDBlink = millis();
174-
}
163+
startBluetooth();
175164
}
176165

177166
//Set LEDs for output and configure PWM
@@ -199,3 +188,20 @@ void beginLEDs()
199188
ledcWrite(ledRedChannel, 0);
200189
ledcWrite(ledGreenChannel, 0);
201190
}
191+
192+
//Configure the on board MAX17048 fuel gauge
193+
void beginFuelGauge()
194+
{
195+
// Set up the MAX17048 LiPo fuel gauge
196+
if (lipo.begin() == false)
197+
{
198+
Serial.println(F("MAX17048 not detected. Continuing."));
199+
return;
200+
}
201+
202+
//Always use hibernate mode
203+
if (lipo.getHIBRTActThr() < 0xFF) lipo.setHIBRTActThr((uint8_t)0xFF);
204+
if (lipo.getHIBRTHibThr() < 0xFF) lipo.setHIBRTHibThr((uint8_t)0xFF);
205+
206+
Serial.println(F("MAX17048 configuration complete"));
207+
}

0 commit comments

Comments
 (0)