Skip to content

Commit f15afa2

Browse files
committed
Gracefully handle accel fail
1 parent 6d0c2af commit f15afa2

File tree

2 files changed

+43
-14
lines changed

2 files changed

+43
-14
lines changed

Firmware/RTK_Surveyor/Begin.ino

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -444,9 +444,13 @@ void beginFuelGauge()
444444
//Begin accelerometer if available
445445
void beginAccelerometer()
446446
{
447-
if (accel.begin() == false)
447+
//if (accel.begin() == false)
448+
if (1)
448449
{
449450
online.accelerometer = false;
451+
452+
displayAccelFail(1000);
453+
450454
return;
451455
}
452456

@@ -478,7 +482,7 @@ void beginSystemState()
478482
else if (productVariant == RTK_FACET)
479483
{
480484
systemState = settings.lastState; //Return to system state previous to power down.
481-
if(systemState == STATE_ROVER_NOT_STARTED)
485+
if (systemState == STATE_ROVER_NOT_STARTED)
482486
firstRoverStart = true; //Allow user to enter test screen during first rover start
483487

484488
powerBtn = new Button(pin_powerSenseAndControl); //Create the button in memory

Firmware/RTK_Surveyor/Display.ino

Lines changed: 37 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1170,6 +1170,24 @@ void displayRoverFail(uint16_t displayTime)
11701170
}
11711171
}
11721172

1173+
void displayAccelFail(uint16_t displayTime)
1174+
{
1175+
if (online.display == true)
1176+
{
1177+
oled.clear(PAGE);
1178+
1179+
uint8_t fontHeight = 15;
1180+
uint8_t yPos = LCDHEIGHT / 2 - fontHeight;
1181+
1182+
printTextCenter("Accel", yPos, 1, 1, false); //text, y, font type, kerning, inverted
1183+
printTextCenter("Failed", yPos + fontHeight, 1, 1, false); //text, y, font type, kerning, inverted
1184+
1185+
oled.display();
1186+
1187+
delay(displayTime);
1188+
}
1189+
}
1190+
11731191
//When user enters serial config menu the display will freeze so show splash while config happens
11741192
void displaySerialConfig()
11751193
{
@@ -1458,22 +1476,29 @@ void paintBubbleLevel()
14581476
{
14591477
if (online.display == true)
14601478
{
1461-
forceDisplayUpdate = true; //Update the display as quickly as possible
1479+
if (online.accelerometer == true)
1480+
{
1481+
forceDisplayUpdate = true; //Update the display as quickly as possible
14621482

1463-
getAngles();
1483+
getAngles();
14641484

1465-
//Draw dot in middle
1466-
oled.pixel(LCDWIDTH / 2, LCDHEIGHT / 2);
1467-
oled.pixel(LCDWIDTH / 2 + 1, LCDHEIGHT / 2);
1468-
oled.pixel(LCDWIDTH / 2, LCDHEIGHT / 2 + 1);
1469-
oled.pixel(LCDWIDTH / 2 + 1, LCDHEIGHT / 2 + 1);
1485+
//Draw dot in middle
1486+
oled.pixel(LCDWIDTH / 2, LCDHEIGHT / 2);
1487+
oled.pixel(LCDWIDTH / 2 + 1, LCDHEIGHT / 2);
1488+
oled.pixel(LCDWIDTH / 2, LCDHEIGHT / 2 + 1);
1489+
oled.pixel(LCDWIDTH / 2 + 1, LCDHEIGHT / 2 + 1);
14701490

1471-
//Draw circle relative to dot
1472-
const int radiusLarge = 10;
1473-
const int radiusSmall = 4;
1491+
//Draw circle relative to dot
1492+
const int radiusLarge = 10;
1493+
const int radiusSmall = 4;
14741494

1475-
oled.circle(LCDWIDTH / 2 - averagedPitch, LCDHEIGHT / 2 + averagedRoll, radiusLarge);
1476-
oled.circle(LCDWIDTH / 2 - averagedPitch, LCDHEIGHT / 2 + averagedRoll, radiusSmall);
1495+
oled.circle(LCDWIDTH / 2 - averagedPitch, LCDHEIGHT / 2 + averagedRoll, radiusLarge);
1496+
oled.circle(LCDWIDTH / 2 - averagedPitch, LCDHEIGHT / 2 + averagedRoll, radiusSmall);
1497+
}
1498+
else
1499+
{
1500+
displayAccelFail(0);
1501+
}
14771502
}
14781503
}
14791504

0 commit comments

Comments
 (0)