|
@@ -41,6 +41,8 @@ void beginShotEvent(FirmwareState* state, uint32_t timestamp) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void endShotEvent(FirmwareState* state, uint32_t endTimestamp, uint32_t beginTimestamp) {
|
|
void endShotEvent(FirmwareState* state, uint32_t endTimestamp, uint32_t beginTimestamp) {
|
|
|
|
|
+ // V10 counts release and timeout as activity, including a burst with no begin.
|
|
|
|
|
+ state->powerSchedule.lastActivityTimestamp = endTimestamp;
|
|
|
setGroupEnabled(&groupForRole(&state->outputChannels, OutputGroupRole::Pump), false);
|
|
setGroupEnabled(&groupForRole(&state->outputChannels, OutputGroupRole::Pump), false);
|
|
|
setGroupEnabled(&groupForRole(&state->outputChannels, OutputGroupRole::Valve), false);
|
|
setGroupEnabled(&groupForRole(&state->outputChannels, OutputGroupRole::Valve), false);
|
|
|
state->shot.lastShotDuration = endTimestamp - beginTimestamp;
|
|
state->shot.lastShotDuration = endTimestamp - beginTimestamp;
|
|
@@ -94,7 +96,7 @@ bool isInputQualified(const DebouncedInput& input) {
|
|
|
|
|
|
|
|
void initializeDebouncedInput(DebouncedInput* input) {
|
|
void initializeDebouncedInput(DebouncedInput* input) {
|
|
|
*input = DebouncedInput{};
|
|
*input = DebouncedInput{};
|
|
|
- input->isLastLevelHigh = true;
|
|
|
|
|
|
|
+ input->isLastLevelHigh = false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
ShotOutputRequest evaluateShotOutputRequest(const SettingsValues& settings, uint8_t alternateMode, uint32_t elapsedMilliseconds) {
|
|
ShotOutputRequest evaluateShotOutputRequest(const SettingsValues& settings, uint8_t alternateMode, uint32_t elapsedMilliseconds) {
|
|
@@ -114,6 +116,12 @@ void pollDebouncedInput(FirmwareState* state, DebouncedInput* input, InputRole r
|
|
|
if (isPinHigh != input->isLastLevelHigh) {
|
|
if (isPinHigh != input->isLastLevelHigh) {
|
|
|
input->isLastLevelHigh = isPinHigh;
|
|
input->isLastLevelHigh = isPinHigh;
|
|
|
input->lastChangeTimestamp = foregroundSnapshotMilliseconds;
|
|
input->lastChangeTimestamp = foregroundSnapshotMilliseconds;
|
|
|
|
|
+ // V10 begins on the edge after qualification, before recording its time.
|
|
|
|
|
+ // The qualifying edge itself can run the active callback with a zero origin.
|
|
|
|
|
+ if (isInputQualified(*input) && input->beginTimestamp == 0) {
|
|
|
|
|
+ runInputStateChange(state, role, 1, foregroundSnapshotMilliseconds, 0);
|
|
|
|
|
+ input->beginTimestamp = foregroundSnapshotMilliseconds;
|
|
|
|
|
+ }
|
|
|
uint8_t& edgeCount = isPinHigh ? input->risingEdgeCount : input->fallingEdgeCount;
|
|
uint8_t& edgeCount = isPinHigh ? input->risingEdgeCount : input->fallingEdgeCount;
|
|
|
if (edgeCount < 255) {
|
|
if (edgeCount < 255) {
|
|
|
++edgeCount;
|
|
++edgeCount;
|
|
@@ -121,12 +129,6 @@ void pollDebouncedInput(FirmwareState* state, DebouncedInput* input, InputRole r
|
|
|
if (!isInputQualified(*input)) {
|
|
if (!isInputQualified(*input)) {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
- // The begin guard and the active callback run in the same call, so the first qualified
|
|
|
|
|
- // falling edge both begins the burst and requests the outputs.
|
|
|
|
|
- if (!isPinHigh && input->beginTimestamp == 0) {
|
|
|
|
|
- input->beginTimestamp = foregroundSnapshotMilliseconds;
|
|
|
|
|
- runInputStateChange(state, role, 1, foregroundSnapshotMilliseconds, 0);
|
|
|
|
|
- }
|
|
|
|
|
if (role == InputRole::Shot) {
|
|
if (role == InputRole::Shot) {
|
|
|
runShotActiveCallback(state, foregroundSnapshotMilliseconds, input->beginTimestamp);
|
|
runShotActiveCallback(state, foregroundSnapshotMilliseconds, input->beginTimestamp);
|
|
|
}
|
|
}
|