Skip to content

Commit

Permalink
Merge pull request #307 from moshe-braner/CAN
Browse files Browse the repository at this point in the history
avoid crash due to null CAN in IPSdisplay.cpp
  • Loading branch information
iltis42 authored Feb 6, 2024
2 parents 26066cd + 6c16336 commit 10a1eb9
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions main/IpsDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -945,24 +945,28 @@ void IpsDisplay::drawCable(int16_t x, int16_t y)
{
const int16_t CANH = 8;
const int16_t CANW = 14;
CAN->connectedXCV() ? ucg->setColor(COLOR_LBLUE) : ucg->setColor(COLOR_MGREY);
bool CANconnectedXCV = false;
bool CANconnectedMag = false;
if (CAN) {
CANconnectedXCV = CAN->connectedXCV();
CANconnectedMag = CAN->connectedMagSens();
}
CANconnectedXCV ? ucg->setColor(COLOR_LBLUE) : ucg->setColor(COLOR_MGREY);
if (CANconnectedMag)
ucg->setColor(COLOR_GREEN);
// ucg->setFont(ucg_font_fub11_hr);
// ucg->setPrintPos(x - 8, y);
if (CAN->connectedMagSens()) {
ucg->setColor(COLOR_GREEN);
}
ucg->drawLine( x-CANW/2, y+CANH/2, x+3, y+CANH/2 );
ucg->drawLine( x-CANW/2, y+CANH/2-1, x+3, y+CANH/2-1 );
ucg->drawDisc( x-CANW/2, y+CANH/2, 2, UCG_DRAW_ALL);
// ucg->print("c");
CAN->connectedMagSens() ? ucg->setColor(COLOR_LBLUE) : ucg->setColor(COLOR_MGREY);
if (Flarm::connected()) {
CANconnectedMag ? ucg->setColor(COLOR_LBLUE) : ucg->setColor(COLOR_MGREY);
if (Flarm::connected())
ucg->setColor(COLOR_GREEN);
}
ucg->drawLine( x+2, y+CANH/2, x-4, y-CANH/2 );
ucg->drawLine( x+3, y+CANH/2-1, x-3, y-CANH/2-1 );
// ucg->print("a");
CAN->connectedXCV() ? ucg->setColor(COLOR_LBLUE) : ucg->setColor(COLOR_MGREY);
CANconnectedXCV ? ucg->setColor(COLOR_LBLUE) : ucg->setColor(COLOR_MGREY);
ucg->drawLine( x-3, y-CANH/2, x+CANW/2, y-CANH/2 );
ucg->drawLine( x-3, y-CANH/2-1, x+CANW/2, y-CANH/2-1 );
ucg->drawDisc( x+CANW/2, y-CANH/2, 2, UCG_DRAW_ALL);
Expand Down

0 comments on commit 10a1eb9

Please sign in to comment.