From 30b15c6d1a328df5d8b0f99a5cbb1f72f25c9cdf Mon Sep 17 00:00:00 2001 From: Pavel Pisa Date: Thu, 27 Jun 2019 21:09:43 +0200 Subject: Simulate push of dial buttons by check box. Signed-off-by: Pavel Pisa --- qtmips_gui/peripheralsview.cpp | 8 ++++++++ qtmips_gui/peripheralsview.ui | 21 +++++++++++++++++++++ qtmips_machine/peripspiled.cpp | 18 ++++++++++++++++++ qtmips_machine/peripspiled.h | 4 +++- 4 files changed, 50 insertions(+), 1 deletion(-) diff --git a/qtmips_gui/peripheralsview.cpp b/qtmips_gui/peripheralsview.cpp index 6c1208d..f90dd53 100644 --- a/qtmips_gui/peripheralsview.cpp +++ b/qtmips_gui/peripheralsview.cpp @@ -43,6 +43,14 @@ void PeripheralsView::setup(const machine::PeripSpiLed *perip_spi_led) { ui->spinBlue->setValue(val - 1); ui->spinBlue->setValue(val); + connect(ui->checkRed, SIGNAL(clicked(bool)), perip_spi_led, SLOT(red_knob_push(bool))); + connect(ui->checkGreen, SIGNAL(clicked(bool)), perip_spi_led, SLOT(green_knob_push(bool))); + connect(ui->checkBlue, SIGNAL(clicked(bool)), perip_spi_led, SLOT(blue_knob_push(bool))); + + ui->checkRed->setChecked(false); + ui->checkGreen->setChecked(false);; + ui->checkBlue->setChecked(false);; + ui->labelRgb1->setAutoFillBackground(true); ui->labelRgb2->setAutoFillBackground(true); diff --git a/qtmips_gui/peripheralsview.ui b/qtmips_gui/peripheralsview.ui index 60726a2..6aa83d6 100644 --- a/qtmips_gui/peripheralsview.ui +++ b/qtmips_gui/peripheralsview.ui @@ -113,6 +113,13 @@ + + + + + + + @@ -160,6 +167,13 @@ + + + + + + + @@ -207,6 +221,13 @@ + + + + + + + diff --git a/qtmips_machine/peripspiled.cpp b/qtmips_machine/peripspiled.cpp index 0404311..d016f90 100644 --- a/qtmips_machine/peripspiled.cpp +++ b/qtmips_machine/peripspiled.cpp @@ -137,3 +137,21 @@ void PeripSpiLed::blue_knob_update(int val) { spiled_reg_knobs_8bit &= ~(0xff << 0); spiled_reg_knobs_8bit |= (val & 0xff) << 0; } + +void PeripSpiLed::red_knob_push(bool state) { + spiled_reg_knobs_8bit &= ~(1 << 26); + if (state) + spiled_reg_knobs_8bit |= 1 << 26; +} + +void PeripSpiLed::green_knob_push(bool state) { + spiled_reg_knobs_8bit &= ~(1 << 25); + if (state) + spiled_reg_knobs_8bit |= 1 << 25; +} + +void PeripSpiLed::blue_knob_push(bool state) { + spiled_reg_knobs_8bit &= ~(1 << 24); + if (state) + spiled_reg_knobs_8bit |= 1 << 24; +} diff --git a/qtmips_machine/peripspiled.h b/qtmips_machine/peripspiled.h index 2e2be72..8c884e3 100644 --- a/qtmips_machine/peripspiled.h +++ b/qtmips_machine/peripspiled.h @@ -63,7 +63,9 @@ public slots: void red_knob_update(int val); void green_knob_update(int val); void blue_knob_update(int val); - + void red_knob_push(bool state); + void green_knob_push(bool state); + void blue_knob_push(bool state); public: bool wword(std::uint32_t address, std::uint32_t value); std::uint32_t rword(std::uint32_t address, bool debug_access = false) const; -- cgit v1.2.3