Skip to content

Commit 3028e84

Browse files
committed
Continue system state conversion. Add display checks.
1 parent 5eb01e5 commit 3028e84

File tree

5 files changed

+679
-552
lines changed

5 files changed

+679
-552
lines changed

Firmware/RTK_Surveyor/Buttons.ino

Lines changed: 79 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,39 +5,95 @@ void checkSetupButton()
55
{
66
//Check rover switch and configure module accordingly
77
//When switch is set to '1' = BASE, pin will be shorted to ground
8-
if (digitalRead(baseSwitch) == HIGH && baseState != BASE_OFF)
8+
if (digitalRead(baseSwitch) == LOW) //Switch is set to base mode
99
{
10-
//Configure for rover mode
11-
Serial.println(F("Rover Mode"));
10+
if (systemState == STATE_ROVER_NO_FIX ||
11+
systemState == STATE_ROVER_FIX ||
12+
systemState == STATE_ROVER_RTK_FLOAT ||
13+
systemState == STATE_ROVER_RTK_FIX)
14+
{
15+
displayBaseStart();
1216

13-
baseState = BASE_OFF;
17+
//Configure for base mode
18+
Serial.println(F("Base Mode"));
1419

15-
beginBluetooth(); //Restart Bluetooth with 'Rover' name
20+
//Configure for base mode
21+
Serial.println(F("Base Mode"));
1622

17-
//If we are survey'd in, but switch is rover then disable survey
18-
if (configureUbloxModuleRover() == false)
19-
{
20-
Serial.println(F("Rover config failed!"));
21-
}
23+
//Restart Bluetooth with 'Base' name
24+
//We start BT regardless of Ntrip Server in case user wants to transmit survey-in stats over BT
25+
beginBluetooth();
26+
27+
if (settings.fixedBase == false)
28+
{
29+
//Don't configure base if we are going to do a survey in. We need to wait for surveyInStartingAccuracy to be achieved in state machine
30+
changeState(STATE_BASE_TEMP_SURVEY_NOT_STARTED);
31+
}
32+
else if (settings.fixedBase == true)
33+
{
34+
if (configureUbloxModuleBase() == false)
35+
{
36+
Serial.println(F("Base config failed!"));
37+
displayBaseFail();
38+
return;
39+
}
40+
41+
bool response = startFixedBase();
42+
if (response == true)
43+
{
44+
changeState(STATE_BASE_FIXED_TRANSMITTING);
45+
}
46+
else
47+
{
48+
//TODO maybe create a custom fixed base fail screen
49+
Serial.println(F("Fixed base start failed!"));
50+
displayBaseFail();
51+
return;
52+
}
53+
}
2254

23-
digitalWrite(baseStatusLED, LOW);
55+
displayBaseSuccess();
56+
delay(500);
57+
}
2458
}
25-
else if (digitalRead(baseSwitch) == LOW && baseState == BASE_OFF)
59+
else if (digitalRead(baseSwitch) == HIGH) //Switch is set to Rover
2660
{
27-
//Configure for base mode
28-
Serial.println(F("Base Mode"));
29-
30-
if (configureUbloxModuleBase() == false)
61+
if (systemState == STATE_BASE_TEMP_SURVEY_NOT_STARTED ||
62+
systemState == STATE_BASE_TEMP_SURVEY_STARTED ||
63+
systemState == STATE_BASE_TEMP_TRANSMITTING ||
64+
systemState == STATE_BASE_TEMP_WIFI_STARTED ||
65+
systemState == STATE_BASE_TEMP_WIFI_CONNECTED ||
66+
systemState == STATE_BASE_TEMP_CASTER_STARTED ||
67+
systemState == STATE_BASE_TEMP_CASTER_CONNECTED ||
68+
systemState == STATE_BASE_FIXED_TRANSMITTING ||
69+
systemState == STATE_BASE_FIXED_WIFI_STARTED ||
70+
systemState == STATE_BASE_FIXED_WIFI_CONNECTED ||
71+
systemState == STATE_BASE_FIXED_CASTER_STARTED ||
72+
systemState == STATE_BASE_FIXED_CASTER_CONNECTED)
3173
{
32-
Serial.println(F("Base config failed!"));
33-
}
74+
displayRoverStart();
75+
3476

35-
//Restart Bluetooth with 'Base' name
36-
//We start BT regardless of Ntrip Server in case user wants to transmit survey-in stats over BT
37-
beginBluetooth();
77+
//Configure for rover mode
78+
Serial.println(F("Rover Mode"));
3879

39-
baseState = BASE_SURVEYING_IN_NOTSTARTED; //Switch to new state
40-
}
80+
//If we are survey'd in, but switch is rover then disable survey
81+
if (configureUbloxModuleRover() == false)
82+
{
83+
Serial.println(F("Rover config failed!"));
84+
displayRoverFail();
85+
return;
86+
}
87+
88+
beginBluetooth(); //Restart Bluetooth with 'Rover' name
89+
90+
digitalWrite(baseStatusLED, LOW);
91+
92+
changeState(STATE_ROVER_NO_FIX);
93+
displayRoverSuccess();
94+
delay(500);
95+
}
96+
}
4197
}
4298

4399
//Create or close UBX/NMEA files as needed (startup or as user changes settings)

0 commit comments

Comments
 (0)