diff --git a/src/Insight/InsightWorker/InsightWorker.cpp b/src/Insight/InsightWorker/InsightWorker.cpp index eea1ded9..97315a89 100644 --- a/src/Insight/InsightWorker/InsightWorker.cpp +++ b/src/Insight/InsightWorker/InsightWorker.cpp @@ -45,6 +45,14 @@ namespace Bloom std::bind(&InsightWorker::onTargetRegistersWrittenEvent, this, std::placeholders::_1) ); + this->eventListener->registerCallbackForEventType( + std::bind(&InsightWorker::onProgrammingModeEnabledEvent, this, std::placeholders::_1) + ); + + this->eventListener->registerCallbackForEventType( + std::bind(&InsightWorker::onProgrammingModeDisabledEvent, this, std::placeholders::_1) + ); + this->eventDispatchTimer = new QTimer(this); QObject::connect(this->eventDispatchTimer, &QTimer::timeout, this, &InsightWorker::dispatchEvents); this->eventDispatchTimer->start(5); @@ -161,6 +169,14 @@ namespace Bloom } } + void InsightWorker::onProgrammingModeEnabledEvent(const Events::ProgrammingModeEnabled& event) { + emit this->programmingModeEnabled(); + } + + void InsightWorker::onProgrammingModeDisabledEvent(const Events::ProgrammingModeDisabled& event) { + emit this->programmingModeDisabled(); + } + void InsightWorker::executeTasks() { auto task = std::optional(); diff --git a/src/Insight/InsightWorker/InsightWorker.hpp b/src/Insight/InsightWorker/InsightWorker.hpp index f508b3d9..3b088524 100644 --- a/src/Insight/InsightWorker/InsightWorker.hpp +++ b/src/Insight/InsightWorker/InsightWorker.hpp @@ -42,6 +42,8 @@ namespace Bloom void targetControllerSuspended(); void targetControllerResumed(const Bloom::Targets::TargetDescriptor& targetDescriptor); void targetRegistersWritten(const Bloom::Targets::TargetRegisters& targetRegisters, const QDateTime& timestamp); + void programmingModeEnabled(); + void programmingModeDisabled(); private: EventListenerPointer eventListener = std::make_shared("InsightWorkerEventListener"); @@ -65,6 +67,8 @@ namespace Bloom void onTargetResetEvent(const Events::TargetReset& event); void onTargetRegistersWrittenEvent(const Events::RegistersWrittenToTarget& event); void onTargetControllerStateChangedEvent(const Events::TargetControllerStateChanged& event); + void onProgrammingModeEnabledEvent(const Events::ProgrammingModeEnabled& event); + void onProgrammingModeDisabledEvent(const Events::ProgrammingModeDisabled& event); void executeTasks(); }; diff --git a/src/Insight/UserInterfaces/InsightWindow/InsightWindow.cpp b/src/Insight/UserInterfaces/InsightWindow/InsightWindow.cpp index 030ce5d9..de824836 100644 --- a/src/Insight/UserInterfaces/InsightWindow/InsightWindow.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/InsightWindow.cpp @@ -213,6 +213,20 @@ namespace Bloom this, &InsightWindow::onTargetProgramCounterUpdate ); + + QObject::connect( + &(this->insightWorker), + &InsightWorker::programmingModeEnabled, + this, + &InsightWindow::onProgrammingModeEnabled + ); + + QObject::connect( + &(this->insightWorker), + &InsightWorker::programmingModeDisabled, + this, + &InsightWindow::onProgrammingModeDisabled + ); } void InsightWindow::init(TargetDescriptor targetDescriptor) { @@ -863,6 +877,15 @@ namespace Bloom this->adjustMinimumSize(); } + void InsightWindow::onProgrammingModeEnabled() { + this->targetStatusLabel->setText("Programming Mode Enabled"); + this->programCounterValueLabel->setText("-"); + } + + void InsightWindow::onProgrammingModeDisabled() { + this->onTargetStateUpdate(this->targetState); + } + void InsightWindow::recordInsightSettings() { auto& projectSettings = this->insightProjectSettings; diff --git a/src/Insight/UserInterfaces/InsightWindow/InsightWindow.hpp b/src/Insight/UserInterfaces/InsightWindow/InsightWindow.hpp index bce81a81..0049cb58 100644 --- a/src/Insight/UserInterfaces/InsightWindow/InsightWindow.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/InsightWindow.hpp @@ -139,6 +139,8 @@ namespace Bloom void toggleTargetRegistersPane(); void toggleRamInspectionPane(); void toggleEepromInspectionPane(); + void onProgrammingModeEnabled(); + void onProgrammingModeDisabled(); void recordInsightSettings(); }; diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/TargetMemoryInspectionPane.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/TargetMemoryInspectionPane.cpp index fd0bf208..5606e3f2 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/TargetMemoryInspectionPane.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/TargetMemoryInspectionPane.cpp @@ -85,6 +85,20 @@ namespace Bloom::Widgets &TargetMemoryInspectionPane::onTargetStateChanged ); + QObject::connect( + &insightWorker, + &InsightWorker::programmingModeEnabled, + this, + &TargetMemoryInspectionPane::onProgrammingModeEnabled + ); + + QObject::connect( + &insightWorker, + &InsightWorker::programmingModeDisabled, + this, + &TargetMemoryInspectionPane::onProgrammingModeDisabled + ); + QObject::connect( this->hexViewerWidget->refreshButton, &QToolButton::clicked, @@ -295,4 +309,12 @@ namespace Bloom::Widgets void TargetMemoryInspectionPane::onMemoryRegionsChange() { this->hexViewerWidget->refreshRegions(); } + + void TargetMemoryInspectionPane::onProgrammingModeEnabled() { + this->hexViewerWidget->setDisabled(true); + } + + void TargetMemoryInspectionPane::onProgrammingModeDisabled() { + this->hexViewerWidget->setDisabled(this->targetState != Targets::TargetState::STOPPED); + } } diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/TargetMemoryInspectionPane.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/TargetMemoryInspectionPane.hpp index d5d81d98..5932cf7f 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/TargetMemoryInspectionPane.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/TargetMemoryInspectionPane.hpp @@ -63,5 +63,7 @@ namespace Bloom::Widgets void onMemoryRead(const Targets::TargetMemoryBuffer& buffer); void openMemoryRegionManagerWindow(); void onMemoryRegionsChange(); + void onProgrammingModeEnabled(); + void onProgrammingModeDisabled(); }; } diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/TargetPackageWidget.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/TargetPackageWidget.cpp index 6e9a37de..f39547d2 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/TargetPackageWidget.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/TargetPackageWidget.cpp @@ -31,6 +31,20 @@ namespace Bloom::Widgets::InsightTargetWidgets &TargetPackageWidget::onRegistersWritten ); + QObject::connect( + &(this->insightWorker), + &InsightWorker::programmingModeEnabled, + this, + &TargetPackageWidget::onProgrammingModeEnabled + ); + + QObject::connect( + &(this->insightWorker), + &InsightWorker::programmingModeDisabled, + this, + &TargetPackageWidget::onProgrammingModeDisabled + ); + this->setDisabled(true); } @@ -85,6 +99,18 @@ namespace Bloom::Widgets::InsightTargetWidgets } } + void TargetPackageWidget::onProgrammingModeEnabled() { + if (this->targetState == TargetState::STOPPED) { + this->setDisabled(true); + } + } + + void TargetPackageWidget::onProgrammingModeDisabled() { + if (this->targetState == TargetState::STOPPED) { + this->setDisabled(false); + } + } + void TargetPackageWidget::onRegistersWritten(Targets::TargetRegisters targetRegisters) { if (this->targetState != TargetState::STOPPED) { return; diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/TargetPackageWidget.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/TargetPackageWidget.hpp index 71460190..4d6345eb 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/TargetPackageWidget.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetWidgets/TargetPackageWidget.hpp @@ -46,6 +46,8 @@ namespace Bloom::Widgets::InsightTargetWidgets protected slots: virtual void updatePinStates(const Targets::TargetPinStateMappingType& pinStatesByNumber); void onTargetStateChanged(Targets::TargetState newState); + void onProgrammingModeEnabled(); + void onProgrammingModeDisabled(); void onRegistersWritten(Targets::TargetRegisters targetRegisters); }; }