Skip to content

Commit d4993ad

Browse files
committed
Indicate casting by cycling position LEDs
1 parent 3cc1b7c commit d4993ad

File tree

3 files changed

+47
-6
lines changed

3 files changed

+47
-6
lines changed

Firmware/RTK_Surveyor/RTK_Surveyor.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
Enable various debug outputs sent over BT
3838
3939
TODO
40-
Indicate successful casting
4140
*/
4241

4342
const int FIRMWARE_VERSION_MAJOR = 1;
@@ -233,6 +232,7 @@ uint32_t lastBaseLEDupdate = 0; //Controls the blinking of the Base LED
233232
uint32_t lastFileReport = 0; //When logging, print file record stats every few seconds
234233
long lastStackReport = 0; //Controls the report rate of stack highwater mark within a task
235234
uint32_t lastHeapReport = 0;
235+
uint32_t lastCasterLEDupdate = 0; //Controls the cycling of position LEDs during casting
236236

237237
uint32_t lastSatelliteDishIconUpdate = 0;
238238
bool satelliteDishIconDisplayed = false; //Toggles as lastSatelliteDishIconUpdate goes above 1000ms

Firmware/RTK_Surveyor/States.ino

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ void updateSystemState()
2626
displayRoverFail(1000);
2727
return;
2828
}
29-
29+
3030
stopWiFi(); //Turn off WiFi and release all resources
3131
startBluetooth(); //Turn on Bluetooth with 'Rover' name
3232

@@ -215,8 +215,8 @@ void updateSystemState()
215215
{
216216
Serial.print(F("WiFi Status: "));
217217
switch (wifiStatus) {
218-
case WL_NO_SSID_AVAIL:
219-
Serial.printf("SSID '%s' not detected\n\r", settings.wifiSSID);
218+
case WL_NO_SSID_AVAIL:
219+
Serial.printf("SSID '%s' not detected\n\r", settings.wifiSSID);
220220
break;
221221
case WL_NO_SHIELD: Serial.println(F("WL_NO_SHIELD")); break;
222222
case WL_IDLE_STATUS: Serial.println(F("WL_IDLE_STATUS")); break;
@@ -233,6 +233,10 @@ void updateSystemState()
233233

234234
case (STATE_BASE_TEMP_WIFI_CONNECTED):
235235
{
236+
digitalWrite(positionAccuracyLED_1cm, LOW);
237+
digitalWrite(positionAccuracyLED_10cm, LOW);
238+
digitalWrite(positionAccuracyLED_100cm, LOW);
239+
236240
if (settings.enableNtripServer == true)
237241
{
238242
//Open connection to caster service
@@ -313,6 +317,8 @@ void updateSystemState()
313317
//Monitor connected state
314318
case (STATE_BASE_TEMP_CASTER_CONNECTED):
315319
{
320+
cyclePositionLEDs();
321+
316322
if (caster.connected() == false)
317323
{
318324
Serial.println(F("Caster no longer connected. Reconnecting..."));
@@ -372,8 +378,8 @@ void updateSystemState()
372378
{
373379
Serial.print(F("WiFi Status: "));
374380
switch (wifiStatus) {
375-
case WL_NO_SSID_AVAIL:
376-
Serial.printf("SSID '%s' not detected\n\r", settings.wifiSSID);
381+
case WL_NO_SSID_AVAIL:
382+
Serial.printf("SSID '%s' not detected\n\r", settings.wifiSSID);
377383
break;
378384
case WL_NO_SHIELD: Serial.println(F("WL_NO_SHIELD")); break;
379385
case WL_IDLE_STATUS: Serial.println(F("WL_IDLE_STATUS")); break;
@@ -390,6 +396,10 @@ void updateSystemState()
390396

391397
case (STATE_BASE_FIXED_WIFI_CONNECTED):
392398
{
399+
digitalWrite(positionAccuracyLED_1cm, LOW);
400+
digitalWrite(positionAccuracyLED_10cm, LOW);
401+
digitalWrite(positionAccuracyLED_100cm, LOW);
402+
393403
if (settings.enableNtripServer == true)
394404
{
395405
//Open connection to caster service
@@ -471,6 +481,8 @@ void updateSystemState()
471481
//Monitor connected state
472482
case (STATE_BASE_FIXED_CASTER_CONNECTED):
473483
{
484+
cyclePositionLEDs();
485+
474486
if (caster.connected() == false)
475487
{
476488
changeState(STATE_BASE_FIXED_WIFI_CONNECTED);

Firmware/RTK_Surveyor/System.ino

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,3 +764,32 @@ void reportHeap()
764764
}
765765
}
766766
}
767+
768+
//Based on current LED state, blink upwards fashion
769+
//Used to indicate casting
770+
void cyclePositionLEDs()
771+
{
772+
//Cycle position LEDs to indicate casting
773+
if (millis() - lastCasterLEDupdate > 500)
774+
{
775+
lastCasterLEDupdate = millis();
776+
if (digitalRead(positionAccuracyLED_100cm) == HIGH)
777+
{
778+
digitalWrite(positionAccuracyLED_1cm, LOW);
779+
digitalWrite(positionAccuracyLED_10cm, HIGH);
780+
digitalWrite(positionAccuracyLED_100cm, LOW);
781+
}
782+
else if (digitalRead(positionAccuracyLED_10cm) == HIGH)
783+
{
784+
digitalWrite(positionAccuracyLED_1cm, HIGH);
785+
digitalWrite(positionAccuracyLED_10cm, LOW);
786+
digitalWrite(positionAccuracyLED_100cm, LOW);
787+
}
788+
else //Catch all
789+
{
790+
digitalWrite(positionAccuracyLED_1cm, LOW);
791+
digitalWrite(positionAccuracyLED_10cm, LOW);
792+
digitalWrite(positionAccuracyLED_100cm, HIGH);
793+
}
794+
}
795+
}

0 commit comments

Comments
 (0)