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 enum class Fault
{ {
None, None = 0,
SensorDidntHeat,
// First fault code at 3 so it's easier to see
SensorDidntHeat = 3,
}; };
void setFault(Fault fault); void setFault(Fault fault);

View File

@ -25,8 +25,6 @@ static const UARTConfig uartCfg =
.cr3 = 0, .cr3 = 0,
}; };
char strBuffer[200];
/* /*
* Application entry point. * Application entry point.
*/ */
@ -46,30 +44,43 @@ int main() {
while(true) 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(); auto fault = getCurrentFault();
switch (fault) switch (fault)
{ {
case Fault::None: 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; break;
case Fault::SensorDidntHeat: case Fault::SensorDidntHeat:
// Blue is blinking
palTogglePad(GPIOB, 5);
// green is off // green is off
palClearPad(GPIOB, 6); palClearPad(GPIOB, 6);
// fast blink // Blink out the error code
chThdSleepMilliseconds(50); for (int i = 0; i < 2 * static_cast<int>(fault); i++)
{
// Blue is blinking
palTogglePad(GPIOB, 5);
// fast blink
chThdSleepMilliseconds(300);
}
break; break;
} }
chThdSleepMilliseconds(2000);
} }
} }