App 2.34.0: set the chosen drive mode again when the car starts
The car falls back to its own default mode at every start. With "Set at start" (on by default), the service sets the mode last chosen on Settings and confirmed by the car again, once, while the car is in P at 0 km/h, and gives up as soon as the car leaves P or after two minutes (DriveModeWrite.atStart, unit-tested). The buttons and the start share the write and read-back (DriveModeSetter). Not tried on the car. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LhzAVaUyqcw5PkGjz4mWW6
This commit is contained in:
@@ -31,6 +31,32 @@ public class DriveModeWriteTest {
|
||||
assertEquals(DriveModeWrite.Outcome.UNREAD, DriveModeWrite.outcome(4, null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void atStartWritesOnceTheChosenModeInP() {
|
||||
assertEquals(DriveModeWrite.StartStep.WRITE, DriveModeWrite.atStart(4, true, 1, 0f, 2, 5_000));
|
||||
assertEquals(DriveModeWrite.StartStep.ALREADY, DriveModeWrite.atStart(4, true, 1, 0f, 4, 5_000));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void atStartWaitsForReadings() {
|
||||
assertEquals(DriveModeWrite.StartStep.WAIT, DriveModeWrite.atStart(4, true, null, 0f, 2, 1_000));
|
||||
assertEquals(DriveModeWrite.StartStep.WAIT, DriveModeWrite.atStart(4, true, 1, null, 2, 1_000));
|
||||
assertEquals(DriveModeWrite.StartStep.WAIT, DriveModeWrite.atStart(4, true, 1, 0f, null, 1_000));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void atStartGivesUp() {
|
||||
// Nothing chosen (or a code not offered), switched off, too late.
|
||||
assertEquals(DriveModeWrite.StartStep.GIVE_UP, DriveModeWrite.atStart(null, true, 1, 0f, 2, 1_000));
|
||||
assertEquals(DriveModeWrite.StartStep.GIVE_UP, DriveModeWrite.atStart(5, true, 1, 0f, 2, 1_000));
|
||||
assertEquals(DriveModeWrite.StartStep.GIVE_UP, DriveModeWrite.atStart(4, false, 1, 0f, 2, 1_000));
|
||||
assertEquals(DriveModeWrite.StartStep.GIVE_UP,
|
||||
DriveModeWrite.atStart(4, true, 1, 0f, 2, DriveModeWrite.START_WINDOW_MS + 1));
|
||||
// Driven off: out of P, or moving.
|
||||
assertEquals(DriveModeWrite.StartStep.GIVE_UP, DriveModeWrite.atStart(4, true, 4, 0f, 2, 1_000));
|
||||
assertEquals(DriveModeWrite.StartStep.GIVE_UP, DriveModeWrite.atStart(4, true, 1, 3f, 2, 1_000));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void buttonsByCode() {
|
||||
assertEquals(0, DriveModeWrite.indexOf(2));
|
||||
|
||||
Reference in New Issue
Block a user