Improved value display for driving controller in debugger

This commit is contained in:
thrust26 2017-10-01 13:59:00 +02:00
parent 72f46c306f
commit 5bc3d9c83e
2 changed files with 13 additions and 3 deletions

View File

@ -69,7 +69,7 @@ void DrivingWidget::loadConfig()
break;
myFire->setState(!myController.read(Controller::Six));
myGrayValue->setList(0, gray);
setValue();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -82,13 +82,13 @@ void DrivingWidget::handleCommand(
myGrayIndex = (myGrayIndex + 1) % 4;
myController.set(Controller::One, (ourGrayTable[myGrayIndex] & 0x1) != 0);
myController.set(Controller::Two, (ourGrayTable[myGrayIndex] & 0x2) != 0);
myGrayValue->setList(0, ourGrayTable[myGrayIndex]);
setValue();
break;
case kGrayDownCmd:
myGrayIndex = myGrayIndex == 0 ? 3 : myGrayIndex - 1;
myController.set(Controller::One, (ourGrayTable[myGrayIndex] & 0x1) != 0);
myController.set(Controller::Two, (ourGrayTable[myGrayIndex] & 0x2) != 0);
myGrayValue->setList(0, ourGrayTable[myGrayIndex]);
setValue();
break;
case kFireCmd:
myController.set(Controller::Six, !myFire->getState());
@ -96,5 +96,13 @@ void DrivingWidget::handleCommand(
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void DrivingWidget::setValue()
{
int grayCode = ourGrayTable[myGrayIndex];
// * 8 = a nasty hack, because the DataGridWidget does not support 2 digit binary output
myGrayValue->setList(0, (grayCode & 0b01) + (grayCode & 0b10) * 8);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8 DrivingWidget::ourGrayTable[4] = { 0x03, 0x01, 0x00, 0x02 };

View File

@ -51,6 +51,8 @@ class DrivingWidget : public ControllerWidget
void loadConfig() override;
void handleCommand(CommandSender* sender, int cmd, int data, int id) override;
void setValue();
// Following constructors and assignment operators not supported
DrivingWidget() = delete;
DrivingWidget(const DrivingWidget&) = delete;