Replaced TargetIoPortsUpdated event with RegistersWrittenToTarget event

This commit is contained in:
Nav
2021-09-12 23:28:16 +01:00
parent dca5b362b3
commit 39c95857e5
14 changed files with 17 additions and 101 deletions

View File

@@ -75,7 +75,6 @@ void Insight::startup() {
this->connect(this->insightWorker, &InsightWorker::targetControllerResumed, this->mainWindow, &InsightWindow::onTargetControllerResumed);
this->connect(this->insightWorker, &InsightWorker::targetStateUpdated, this->mainWindow, &InsightWindow::onTargetStateUpdate);
this->connect(this->insightWorker, &InsightWorker::targetProgramCounterUpdated, this->mainWindow, &InsightWindow::onTargetProgramCounterUpdate);
this->connect(this->insightWorker, &InsightWorker::targetIoPortsUpdated, this->mainWindow, &InsightWindow::onTargetIoPortsUpdate);
this->connect(this->mainWindow, &InsightWindow::refreshTargetPinStates, this->insightWorker, &InsightWorker::requestPinStates);
this->mainWindow->setInsightConfig(this->insightConfig);

View File

@@ -28,10 +28,6 @@ void InsightWorker::startup() {
std::bind(&InsightWorker::onTargetResumedEvent, this, std::placeholders::_1)
);
this->eventListener->registerCallbackForEventType<Events::TargetIoPortsUpdated>(
std::bind(&InsightWorker::onTargetIoPortsUpdatedEvent, this, std::placeholders::_1)
);
this->eventListener->registerCallbackForEventType<Events::RegistersWrittenToTarget>(
std::bind(&InsightWorker::onTargetRegistersWrittenEvent, this, std::placeholders::_1)
);
@@ -117,10 +113,6 @@ void InsightWorker::onTargetResumedEvent(const Events::TargetExecutionResumed& e
emit this->targetStateUpdated(TargetState::RUNNING);
}
void InsightWorker::onTargetIoPortsUpdatedEvent(const Events::TargetIoPortsUpdated& event) {
emit this->targetIoPortsUpdated();
}
void InsightWorker::onTargetRegistersWrittenEvent(const Events::RegistersWrittenToTarget& event) {
emit this->targetRegistersWritten(event.registers);
}

View File

@@ -39,7 +39,6 @@ namespace Bloom
void onTargetStoppedEvent(const Events::TargetExecutionStopped& event);
void onTargetResumedEvent(const Events::TargetExecutionResumed& event);
void onTargetIoPortsUpdatedEvent(const Events::TargetIoPortsUpdated& event);
void onTargetRegistersWrittenEvent(const Events::RegistersWrittenToTarget& event);
void onTargetControllerStateReportedEvent(const Events::TargetControllerStateReported& event);
@@ -63,7 +62,6 @@ namespace Bloom
void taskQueued();
void targetStateUpdated(Bloom::Targets::TargetState newState);
void targetProgramCounterUpdated(quint32 programCounter);
void targetIoPortsUpdated();
void targetControllerSuspended();
void targetControllerResumed(const Bloom::Targets::TargetDescriptor& targetDescriptor);
void targetRegistersWritten(const Bloom::Targets::TargetRegisters& targetRegisters);

View File

@@ -482,12 +482,6 @@ void InsightWindow::onTargetProgramCounterUpdate(quint32 programCounter) {
);
}
void InsightWindow::onTargetIoPortsUpdate() {
if (this->targetState == TargetState::STOPPED && this->selectedVariant != nullptr) {
emit this->refreshTargetPinStates(this->selectedVariant->id);
}
}
void InsightWindow::toggleTargetRegistersPane() {
if (this->targetRegistersSidePane->activated) {
this->targetRegistersSidePane->deactivate();

View File

@@ -90,7 +90,6 @@ namespace Bloom
void onTargetControllerResumed(const Bloom::Targets::TargetDescriptor& targetDescriptor);
void onTargetStateUpdate(Targets::TargetState newState);
void onTargetProgramCounterUpdate(quint32 programCounter);
void onTargetIoPortsUpdate();
void close();
void openReportIssuesUrl();
void openGettingStartedUrl();

View File

@@ -23,13 +23,9 @@ TargetPackageWidget::TargetPackageWidget(
this->connect(
&(this->insightWorker),
&InsightWorker::targetIoPortsUpdated,
&InsightWorker::targetRegistersWritten,
this,
[this] {
if (this->targetState == TargetState::STOPPED) {
this->refreshPinStates();
}
}
&TargetPackageWidget::onRegistersWritten
);
this->setDisabled(true);
@@ -81,3 +77,17 @@ void TargetPackageWidget::onTargetStateChanged(TargetState newState) {
});
}
}
void TargetPackageWidget::onRegistersWritten(Targets::TargetRegisters targetRegisters) {
if (this->targetState != TargetState::STOPPED) {
return;
}
// If a PORT register was just updated, refresh pin states.
for (const auto& targetRegister : targetRegisters) {
if (targetRegister.descriptor.type == Targets::TargetRegisterType::PORT_REGISTER) {
this->refreshPinStates();
return;
}
}
}

View File

@@ -29,6 +29,7 @@ namespace Bloom::Widgets::InsightTargetWidgets
protected slots:
virtual void updatePinStates(const Targets::TargetPinStateMappingType& pinStatesByNumber);
void onTargetStateChanged(Targets::TargetState newState);
void onRegistersWritten(Targets::TargetRegisters targetRegisters);
public:
TargetPackageWidget(Targets::TargetVariant targetVariant, InsightWorker& insightWorker, QWidget* parent);