Skip to content

Commit d1e3bd2

Browse files
committed
Check coordinate types are the same in menuBase
1 parent da4809b commit d1e3bd2

File tree

2 files changed

+21
-14
lines changed

2 files changed

+21
-14
lines changed

Firmware/RTK_Surveyor/Form.ino

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1163,7 +1163,6 @@ void updateSettingWithValue(const char *settingName, const char *settingValueStr
11631163
else if (strcmp(settingName, "fixedLongText") == 0)
11641164
{
11651165
// Lat defines the settings.coordinateInputType. Don't update it here
1166-
// TODO: We need to check that the lat and long types are the same... But where...?
11671166
double newCoordinate = 0.0;
11681167
if (coordinateIdentifyInputType((char *)settingValueStr, &newCoordinate) ==
11691168
COORDINATE_INPUT_TYPE_INVALID_UNKNOWN)

Firmware/RTK_Surveyor/menuBase.ino

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -191,11 +191,11 @@ void menuBase()
191191
if (getString(userEntry, sizeof(userEntry)) == INPUT_RESPONSE_VALID)
192192
{
193193
double fixedLat = 0.0;
194+
194195
// Identify which type of method they used
195-
if (coordinateIdentifyInputType(userEntry, &fixedLat) != COORDINATE_INPUT_TYPE_INVALID_UNKNOWN)
196+
CoordinateInputType latCoordinateInputType = coordinateIdentifyInputType(userEntry, &fixedLat);
197+
if (latCoordinateInputType != COORDINATE_INPUT_TYPE_INVALID_UNKNOWN)
196198
{
197-
settings.fixedLat = fixedLat;
198-
199199
// Progress with additional prompts only if the user enters valid data
200200
systemPrint("\r\nLongitude in degrees (ex: -105.184774720, -105 11.0864832, -105-11.0864832, "
201201
"-105 11 05.188992, etc): ");
@@ -204,17 +204,25 @@ void menuBase()
204204
double fixedLong = 0.0;
205205

206206
// Identify which type of method they used
207-
if (coordinateIdentifyInputType(userEntry, &fixedLong) !=
208-
COORDINATE_INPUT_TYPE_INVALID_UNKNOWN)
207+
CoordinateInputType longCoordinateInputType = coordinateIdentifyInputType(userEntry, &fixedLong);
208+
if (longCoordinateInputType != COORDINATE_INPUT_TYPE_INVALID_UNKNOWN)
209209
{
210-
settings.fixedLong = fixedLong;
211-
settings.coordinateInputType = coordinateIdentifyInputType(userEntry, &fixedLong);
212-
213-
systemPrint("\nAltitude in meters (ex: 1560.2284): ");
214-
double fixedAltitude = getDouble();
215-
if (fixedAltitude != INPUT_RESPONSE_GETNUMBER_TIMEOUT &&
216-
fixedAltitude != INPUT_RESPONSE_GETNUMBER_EXIT)
217-
settings.fixedAltitude = fixedAltitude;
210+
if (latCoordinateInputType == longCoordinateInputType)
211+
{
212+
settings.fixedLat = fixedLat;
213+
settings.fixedLong = fixedLong;
214+
settings.coordinateInputType = latCoordinateInputType;
215+
216+
systemPrint("\r\nAltitude in meters (ex: 1560.2284): ");
217+
double fixedAltitude = getDouble();
218+
if (fixedAltitude != INPUT_RESPONSE_GETNUMBER_TIMEOUT &&
219+
fixedAltitude != INPUT_RESPONSE_GETNUMBER_EXIT)
220+
settings.fixedAltitude = fixedAltitude;
221+
}
222+
else
223+
{
224+
systemPrintln("\r\nCoordinate types must match!");
225+
}
218226
} // idInput on fixedLong
219227
} // getString for fixedLong
220228
} // idInput on fixedLat

0 commit comments

Comments
 (0)