-
Notifications
You must be signed in to change notification settings - Fork 0
/
Nav.cpp
36 lines (31 loc) · 947 Bytes
/
Nav.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/**
* Copyright 2022 William Edward Fisher.
*/
#include "Nav.h"
#include <Adafruit_NeoTrellis.h>
#include "Hardware.h"
#include "Utils.h"
#include "constants.h"
State Nav::goBack(State state) {
state.navHistoryIndex = state.navHistoryIndex - 1;
if (state.navHistoryIndex < 0) {
Serial.println("Attempting to go back past the earliest step in the navHistory.");
state.navHistoryIndex = 0;
state.screen = SCREEN.ERROR;
} else {
state.screen = state.navHistory[state.navHistoryIndex];
}
return state;
}
State Nav::goForward(State state, Screen_t screen) {
state.navHistoryIndex = state.navHistoryIndex + 1;
if (state.navHistoryIndex > 3) {
Serial.println("Attempting to go forward past the maximum step in the navHistory.");
state.navHistoryIndex = 3;
state.screen = SCREEN.ERROR;
} else {
state.screen = screen;
state.navHistory[state.navHistoryIndex] = state.screen;
}
return state;
}