Skip to content

Commit 698c6cd

Browse files
authored
Merge pull request #48 from sparkfun/release_candidate
v1.4
2 parents 6a282cb + 740f3b3 commit 698c6cd

21 files changed

+1227
-1077
lines changed
Binary file not shown.
1.47 MB
Binary file not shown.

Firmware/RTK_Surveyor/Base.ino

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,13 @@ bool configureUbloxModuleBase()
6565
bool beginSurveyIn()
6666
{
6767
bool needSurveyReset = false;
68-
if (i2cGNSS.getSurveyInActive() == true) needSurveyReset = true;
69-
if (i2cGNSS.getSurveyInValid() == true) needSurveyReset = true;
68+
if (i2cGNSS.getSurveyInActive(100) == true) needSurveyReset = true;
69+
if (i2cGNSS.getSurveyInValid(100) == true) needSurveyReset = true;
7070

7171
if (needSurveyReset == true)
7272
{
73+
Serial.println("Resetting survey");
74+
7375
if (resetSurvey() == false)
7476
{
7577
Serial.println(F("Survey reset failed"));
@@ -80,7 +82,7 @@ bool beginSurveyIn()
8082
}
8183
}
8284

83-
bool response = i2cGNSS.enableSurveyMode(settings.observationSeconds, settings.observationPositionAccuracy); //Enable Survey in, with user parameters
85+
bool response = i2cGNSS.enableSurveyMode(settings.observationSeconds, settings.observationPositionAccuracy, 5000); //Enable Survey in, with user parameters. Wait up to 5s.
8486
if (response == false)
8587
{
8688
Serial.println(F("Survey start failed"));
@@ -92,6 +94,15 @@ bool beginSurveyIn()
9294
settings.observationPositionAccuracy
9395
);
9496

97+
//Wait until active becomes true
98+
long maxTime = 5000;
99+
long startTime = millis();
100+
while(i2cGNSS.getSurveyInActive(100) == false)
101+
{
102+
delay(100);
103+
if(millis() - startTime > maxTime) return(false); //Reset of survey failed
104+
}
105+
95106
return (true);
96107
}
97108

@@ -105,8 +116,20 @@ bool resetSurvey()
105116
response &= i2cGNSS.enableSurveyMode(1000, 400.000, maxWait); //Enable Survey in with bogus values
106117
delay(1000);
107118
response &= i2cGNSS.disableSurveyMode(maxWait); //Disable survey
108-
delay(1000);
109-
return (response);
119+
120+
if(response == false)
121+
return(response);
122+
123+
//Wait until active and valid becomes false
124+
long maxTime = 5000;
125+
long startTime = millis();
126+
while(i2cGNSS.getSurveyInActive(100) == true || i2cGNSS.getSurveyInValid(100) == true)
127+
{
128+
delay(100);
129+
if(millis() - startTime > maxTime) return(false); //Reset of survey failed
130+
}
131+
132+
return(true);
110133
}
111134

112135
//Start the base using fixed coordinates
@@ -126,9 +149,9 @@ bool startFixedBase()
126149
long majorEcefZ = floor((settings.fixedEcefZ * 100) + 0.5);
127150
long minorEcefZ = floor((((settings.fixedEcefZ * 100.0) - majorEcefZ) * 100.0) + 0.5);
128151

129-
// Serial.printf("fixedEcefY (should be -4716808.5807): %0.04f\n\r", settings.fixedEcefY);
130-
// Serial.printf("major (should be -471680858): %ld\n\r", majorEcefY);
131-
// Serial.printf("minor (should be -7): %ld\n\r", minorEcefY);
152+
// Serial.printf("fixedEcefY (should be -4716808.5807): %0.04f\n\r", settings.fixedEcefY);
153+
// Serial.printf("major (should be -471680858): %ld\n\r", majorEcefY);
154+
// Serial.printf("minor (should be -7): %ld\n\r", minorEcefY);
132155

133156
//Units are cm with a high precision extension so -1234.5678 should be called: (-123456, -78)
134157
//-1280208.308,-4716803.847,4086665.811 is SparkFun HQ so...
@@ -196,10 +219,12 @@ void SFE_UBLOX_GNSS::processRTCM(uint8_t incoming)
196219
if (rtcmPacketsSent > 9999) rtcmPacketsSent = 1;
197220
}
198221

222+
#ifdef COMPILE_WIFI
199223
if (caster.connected() == true)
200224
{
201225
caster.write(incoming); //Send this byte to socket
202226
casterBytesSent++;
203227
lastServerSent_ms = millis();
204228
}
229+
#endif
205230
}

Firmware/RTK_Surveyor/Begin.ino

Lines changed: 64 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,19 @@
44
//Must be called after Wire.begin so that we can do I2C tests
55
void beginBoard()
66
{
7-
productVariant = RTK_SURVEYOR;
8-
if (isConnected(0x19) == true) //Check for accelerometer
7+
//Use ADC to check 50% resistor divider
8+
int pin_adc_rtk_facet = 35;
9+
if (analogReadMilliVolts(pin_adc_rtk_facet) > (3300 / 2 * 0.9) && analogReadMilliVolts(pin_adc_rtk_facet) < (3300 / 2 * 1.1))
10+
{
11+
productVariant = RTK_FACET;
12+
}
13+
else if (isConnected(0x19) == true) //Check for accelerometer
914
{
1015
productVariant = RTK_EXPRESS;
1116
}
12-
else if (analogRead(35) > 400 && analogRead(35) < 600)
17+
else
1318
{
14-
productVariant = RTK_FACET;
19+
productVariant = RTK_SURVEYOR;
1520
}
1621

1722
//Setup hardware pins
@@ -61,7 +66,7 @@ void beginBoard()
6166
}
6267
else if (productVariant == RTK_FACET)
6368
{
64-
//v10
69+
//v11
6570
pin_muxA = 2;
6671
pin_muxB = 0;
6772
pin_powerSenseAndControl = 13;
@@ -79,17 +84,20 @@ void beginBoard()
7984
powerOnCheck(); //Only do check if we POR start
8085
}
8186

87+
pinMode(pin_peripheralPowerControl, OUTPUT);
8288
digitalWrite(pin_peripheralPowerControl, HIGH); //Turn on SD, ZED, etc
8389

8490
setMuxport(settings.dataPortChannel); //Set mux to user's choice: NMEA, I2C, PPS, or DAC
8591

92+
delay(1000);
93+
8694
strcpy(platformFilePrefix, "SFE_Facet");
8795
strcpy(platformPrefix, "Facet");
8896
}
8997

9098
Serial.printf("SparkFun RTK %s v%d.%d-%s\r\n", platformPrefix, FIRMWARE_VERSION_MAJOR, FIRMWARE_VERSION_MINOR, __DATE__);
9199

92-
//For all boards, check reset reason. If reset was do to wdt or panic, append last log
100+
//For all boards, check reset reason. If reset was due to wdt or panic, append last log
93101
if (esp_reset_reason() == ESP_RST_POWERON)
94102
{
95103
reuseLastLog = false; //Start new log
@@ -240,22 +248,33 @@ void beginGNSS()
240248
i2cGNSS.i2cTransactionSize = 128;
241249

242250
//Check the firmware version of the ZED-F9P. Based on Example21_ModuleInfo.
243-
// if (i2cGNSS.getModuleInfo(1100) == true) // Try to get the module info
244-
// {
245-
// if (strcmp(i2cGNSS.minfo.extension[1], latestZEDFirmware) != 0)
246-
// {
247-
// Serial.print(F("The ZED-F9P appears to have outdated firmware. Found: "));
248-
// Serial.println(i2cGNSS.minfo.extension[1]);
249-
// Serial.print(F("The Surveyor works best with "));
250-
// Serial.println(latestZEDFirmware);
251-
// Serial.print(F("Please upgrade using u-center."));
252-
// Serial.println();
253-
// }
254-
// else
255-
// {
256-
// Serial.println(F("ZED-F9P firmware is current"));
257-
// }
258-
// }
251+
if (i2cGNSS.getModuleInfo(1100) == true) // Try to get the module info
252+
{
253+
strcpy(zedFirmwareVersion, i2cGNSS.minfo.extension[1]);
254+
255+
//i2cGNSS.minfo.extension[1] looks like 'FWVER=HPG 1.12'
256+
//Replace = with - to avoid NVM parsing issues
257+
char *ptr = strchr(zedFirmwareVersion, '=');
258+
if (ptr != NULL)
259+
zedFirmwareVersion[ptr - zedFirmwareVersion] = ':';
260+
261+
Serial.print(F("ZED-F9P firmware: "));
262+
Serial.println(zedFirmwareVersion);
263+
264+
// if (strcmp(i2cGNSS.minfo.extension[1], latestZEDFirmware) != 0)
265+
// {
266+
// Serial.print(F("The ZED-F9P appears to have outdated firmware. Found: "));
267+
// Serial.println(i2cGNSS.minfo.extension[1]);
268+
// Serial.print(F("The Surveyor works best with "));
269+
// Serial.println(latestZEDFirmware);
270+
// Serial.print(F("Please upgrade using u-center."));
271+
// Serial.println();
272+
// }
273+
// else
274+
// {
275+
// Serial.println(F("ZED-F9P firmware is current"));
276+
// }
277+
}
259278

260279
bool response = configureUbloxModule();
261280
if (response == false)
@@ -268,6 +287,7 @@ void beginGNSS()
268287
if (response == false)
269288
{
270289
Serial.println(F("Failed to configure module. Hard stop."));
290+
displayGNSSFail(0);
271291
blinkError(ERROR_GPS_CONFIG_FAIL);
272292
}
273293
}
@@ -342,3 +362,25 @@ void beginAccelerometer()
342362

343363
online.accelerometer = true;
344364
}
365+
366+
//Depending on platform and previous power down state, set system state
367+
void beginSystemState()
368+
{
369+
if (productVariant == RTK_SURVEYOR)
370+
{
371+
//Assume Rover. checkButtons() will correct as needed.
372+
systemState = STATE_ROVER_NOT_STARTED;
373+
buttonPreviousState = BUTTON_BASE;
374+
}
375+
if (productVariant == RTK_EXPRESS || productVariant == RTK_EXPRESS)
376+
{
377+
systemState = settings.lastState; //Return to system state previous to power down.
378+
379+
if (systemState == STATE_ROVER_NOT_STARTED)
380+
buttonPreviousState = BUTTON_ROVER;
381+
else if (systemState == STATE_BASE_NOT_STARTED)
382+
buttonPreviousState = BUTTON_BASE;
383+
else
384+
buttonPreviousState = BUTTON_ROVER;
385+
}
386+
}

Firmware/RTK_Surveyor/Buttons.ino

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,17 @@ void checkButtons()
2323
}
2424
else if (productVariant == RTK_EXPRESS)
2525
{
26+
//Check to see if user is pressing both buttons simultaneously - show test screen
27+
if (digitalRead(pin_powerSenseAndControl) == LOW && digitalRead(pin_setupButton) == LOW)
28+
{
29+
delay(debounceDelay); //Debounce
30+
if (digitalRead(pin_powerSenseAndControl) == LOW && digitalRead(pin_setupButton) == LOW)
31+
{
32+
displayTest();
33+
setupButtonState = BUTTON_RELEASED;
34+
}
35+
}
36+
2637
//Check power button
2738
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
2839
if (digitalRead(pin_powerSenseAndControl) == LOW && powerPressedStartTime == 0)
@@ -94,19 +105,6 @@ void checkButtons()
94105
//Return to unpressed state
95106
setupButtonState = BUTTON_RELEASED;
96107
}
97-
98-
//Check to see if user is pressing both buttons simultaneously - show test screen
99-
if (digitalRead(pin_powerSenseAndControl) == LOW && digitalRead(pin_setupButton) == LOW)
100-
{
101-
delay(debounceDelay); //Debounce
102-
if (digitalRead(pin_powerSenseAndControl) == LOW && digitalRead(pin_setupButton) == LOW)
103-
{
104-
displayTest();
105-
setupButtonState = BUTTON_RELEASED;
106-
buttonPreviousState = BUTTON_ROVER;
107-
changeState(STATE_ROVER_NOT_STARTED);
108-
}
109-
}
110108
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
111109
}//end productVariant = Express
112110

Firmware/RTK_Surveyor/Display.ino

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ void updateDisplay()
5252
paintBaseTempCasterConnected();
5353
break;
5454
case (STATE_BASE_FIXED_NOT_STARTED):
55-
//Do nothing. Static display shown during state change.
55+
paintBaseFixedNotStarted();
5656
break;
5757
case (STATE_BASE_FIXED_TRANSMITTING):
5858
paintBaseFixedTransmitting();
@@ -69,6 +69,9 @@ void updateDisplay()
6969
case (STATE_BASE_FIXED_CASTER_CONNECTED):
7070
paintBaseFixedCasterConnected();
7171
break;
72+
default:
73+
displayError((char*)"Display");
74+
break;
7275
}
7376

7477
oled.display(); //Push internal buffer to display
@@ -546,17 +549,14 @@ void paintBaseTempSurveyStarted()
546549

547550
paintBaseState(); //Top center
548551

549-
float meanAccuracy = i2cGNSS.getSurveyInMeanAccuracy(100);
550-
int elapsedTime = i2cGNSS.getSurveyInObservationTime(100);
551-
552552
oled.setFontType(0);
553553
oled.setCursor(0, 23); //x, y
554554
oled.print("Mean:");
555555

556556
oled.setCursor(29, 20); //x, y
557557
oled.setFontType(1);
558-
if (meanAccuracy < 10.0) //Error check
559-
oled.print(meanAccuracy, 2);
558+
if (svinMeanAccuracy < 10.0) //Error check
559+
oled.print(svinMeanAccuracy, 2);
560560
else
561561
oled.print(">10");
562562

@@ -566,8 +566,8 @@ void paintBaseTempSurveyStarted()
566566

567567
oled.setCursor(30, 36); //x, y
568568
oled.setFontType(1);
569-
if (elapsedTime < 1000) //Error check
570-
oled.print(elapsedTime);
569+
if (svinObservationTime < 1000) //Error check
570+
oled.print(svinObservationTime);
571571
else
572572
oled.print("0");
573573

@@ -738,6 +738,19 @@ void paintBaseTempCasterConnected()
738738
}
739739
}
740740

741+
//Show transmission of RTCM packets
742+
void paintBaseFixedNotStarted()
743+
{
744+
if (online.display == true)
745+
{
746+
paintBatteryLevel(); //Top right corner
747+
748+
paintWirelessIcon(); //Top left corner
749+
750+
paintBaseState(); //Top center
751+
}
752+
}
753+
741754
//Show transmission of RTCM packets
742755
void paintBaseFixedTransmitting()
743756
{
@@ -1297,15 +1310,18 @@ void displayTest()
12971310
else
12981311
oled.print(F("FAIL"));
12991312

1313+
i2cGNSS.checkUblox();
13001314
oled.setCursor(xOffset, yOffset + (3 * charHeight) ); //x, y
13011315
oled.print(F("GNSS:"));
13021316
int satsInView = i2cGNSS.getSIV();
13031317
if (online.gnss == true && satsInView > 8)
1318+
{
13041319
oled.print(F("OK"));
1320+
oled.print(F("/"));
1321+
oled.print(satsInView);
1322+
}
13051323
else
13061324
oled.print(F("FAIL"));
1307-
oled.print(F("/"));
1308-
oled.print(satsInView);
13091325

13101326
oled.setCursor(xOffset, yOffset + (4 * charHeight) ); //x, y
13111327
oled.print(F("Mux:"));
@@ -1365,7 +1381,7 @@ void displayTest()
13651381

13661382
oled.display();
13671383

1368-
//Wait for user to stop pressing buttons
1384+
//Wait for user to stop pressing buttons
13691385
if (productVariant == RTK_EXPRESS)
13701386
{
13711387
while (digitalRead(pin_setupButton) == LOW)
@@ -1377,7 +1393,7 @@ void displayTest()
13771393
delay(10);
13781394
}
13791395

1380-
delay(2000); //Big debounce
1396+
delay(500);
13811397
}
13821398
}
13831399

0 commit comments

Comments
 (0)