Skip to content

Commit 5ed19ec

Browse files
committed
Fix tracking armed duration
1 parent 7281b58 commit 5ed19ec

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/sp140/sp140.ino

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -773,6 +773,13 @@ void disarmSystem() {
773773
resetSmoothing();
774774
resumeLEDTask();
775775
runDisarmAlert();
776+
777+
// Calculate elapsed armed time in seconds before updating hour meter
778+
if (armedAtMillis > 0) {
779+
unsigned long currentMillis = millis();
780+
armedSecs = (currentMillis - armedAtMillis) / 1000;
781+
}
782+
776783
updateArmedTime();
777784
writeDeviceData();
778785

@@ -994,6 +1001,7 @@ bool armSystem() {
9941001
setESCThrottle(ESC_DISARMED_PWM); // initialize the signal to low
9951002

9961003
armedAtMillis = millis();
1004+
armedSecs = 0; // Reset armed seconds for new session
9971005
setGroundAltitude(deviceData);
9981006

9991007
vTaskSuspend(blinkLEDTaskHandle);
@@ -1033,13 +1041,13 @@ void afterCruiseEnd() {
10331041
// pre-populate it with the current throttle position to ensure smooth transition
10341042
pot->update();
10351043
int currentPotVal = pot->getValue();
1036-
1044+
10371045
// Pre-fill the buffer with current pot value for smooth transition
10381046
potBuffer.clear(); // Clear first
10391047
for (int i = 0; i < 8; i++) { // Buffer size is 8
10401048
potBuffer.push(currentPotVal);
10411049
}
1042-
1050+
10431051
cruisedPotVal = 0;
10441052
//pulseVibeMotor();
10451053
}

0 commit comments

Comments
 (0)