blink fault codes

This commit is contained in:
Matthew Kennedy 2020-12-10 21:46:41 -08:00
parent 47050e8c5a
commit 5c2dd19c3f
2 changed files with 30 additions and 17 deletions

View File

@ -2,8 +2,10 @@
enum class Fault
{
None,
SensorDidntHeat,
None = 0,
// First fault code at 3 so it's easier to see
SensorDidntHeat = 3,
};
void setFault(Fault fault);

View File

@ -25,8 +25,6 @@ static const UARTConfig uartCfg =
.cr3 = 0,
};
char strBuffer[200];
/*
* Application entry point.
*/
@ -46,30 +44,43 @@ int main() {
while(true)
{
if (!hasFault())
{
// blue is off
palClearPad(GPIOB, 5);
// Green is blinking
palTogglePad(GPIOB, 6);
// Fast blink if closed loop, slow if not
chThdSleepMilliseconds(IsRunningClosedLoop() ? 50 : 400);
continue;
}
auto fault = getCurrentFault();
switch (fault)
{
case Fault::None:
// blue is off
palClearPad(GPIOB, 5);
// Green is blinking
palTogglePad(GPIOB, 6);
// Fast blink if closed loop, slow if not
chThdSleepMilliseconds(IsRunningClosedLoop() ? 50 : 400);
break;
case Fault::SensorDidntHeat:
// Blue is blinking
palTogglePad(GPIOB, 5);
// green is off
palClearPad(GPIOB, 6);
// fast blink
chThdSleepMilliseconds(50);
// Blink out the error code
for (int i = 0; i < 2 * static_cast<int>(fault); i++)
{
// Blue is blinking
palTogglePad(GPIOB, 5);
// fast blink
chThdSleepMilliseconds(300);
}
break;
}
chThdSleepMilliseconds(2000);
}
}