Removed tight coupling of target pin widgets with Insight window - moved target pin state toggling into an InsightWorker task.

This commit is contained in:
Nav
2021-09-04 18:03:45 +01:00
parent 1bc881e9ae
commit 85ef2c57e1
15 changed files with 114 additions and 85 deletions

View File

@@ -333,9 +333,14 @@ void InsightWindow::selectVariant(const TargetVariant* variant) {
}
if (this->targetPackageWidget != nullptr) {
this->targetPackageWidget->setTargetState(this->targetState);
if (this->targetState == TargetState::STOPPED) {
this->toggleUi(true);
emit this->refreshTargetPinStates(variant->id);
this->targetPackageWidget->refreshPinStates([this] {
if (this->targetState == TargetState::STOPPED) {
this->targetPackageWidget->setDisabled(false);
}
});
}
this->targetPackageWidget->show();
@@ -441,17 +446,6 @@ void InsightWindow::onTargetIoPortsUpdate() {
}
}
void InsightWindow::togglePinIoState(InsightTargetWidgets::TargetPinWidget* pinWidget) {
auto pinState = pinWidget->getPinState();
// Currently, we only allow users to toggle the IO state of output pins
if (pinState.has_value()
&& pinState.value().ioDirection == TargetPinState::IoDirection::OUTPUT
&& this->selectedVariant != nullptr
) {
auto& pinDescriptor = pinWidget->getPinDescriptor();
pinState.value().ioState = (pinState.value().ioState == TargetPinState::IoState::HIGH) ?
TargetPinState::IoState::LOW : TargetPinState::IoState::HIGH;
emit this->setTargetPinState(this->selectedVariant->id, pinDescriptor, pinState.value());
}
}