diff options
Diffstat (limited to 'qtmips_gui')
-rw-r--r-- | qtmips_gui/peripheralsview.cpp | 51 | ||||
-rw-r--r-- | qtmips_gui/peripheralsview.h | 5 | ||||
-rw-r--r-- | qtmips_gui/peripheralsview.ui | 212 |
3 files changed, 252 insertions, 16 deletions
diff --git a/qtmips_gui/peripheralsview.cpp b/qtmips_gui/peripheralsview.cpp index 231de90..655b101 100644 --- a/qtmips_gui/peripheralsview.cpp +++ b/qtmips_gui/peripheralsview.cpp @@ -38,4 +38,55 @@ void PeripheralsView::setup(const machine::PeripSpiLed *perip_spi_led) { val = ui->spinBlue->value(); ui->spinBlue->setValue(val - 1); ui->spinBlue->setValue(val); + + ui->labelRgb1->setAutoFillBackground(true); + ui->labelRgb2->setAutoFillBackground(true); + + connect(perip_spi_led, SIGNAL(led_line_changed(uint)), this, SLOT(led_line_changed(uint))); + connect(perip_spi_led, SIGNAL(led_rgb1_changed(int)), this, SLOT(led_rgb1_changed(int))); + connect(perip_spi_led, SIGNAL(led_rgb2_changed(int)), this, SLOT(led_rgb2_changed(int))); + + led_line_changed(0); + led_rgb1_changed(0); + led_rgb2_changed(0); +} + +void PeripheralsView::led_line_changed(uint val) { + QString s, t; + s = QString::number(val, 16); + t.fill('0', 8 - s.count()); + ui->lineEditHex->setText(t + s); + s = QString::number(val, 10); + ui->lineEditDec->setText(s); + s = QString::number(val, 2); + t.fill('0', 32 - s.count()); + ui->lineEditBin->setText(t + s); +} + +static void set_widget_background_color(QWidget *w, int val) { + int r = (val >> 16) & 0xff; + int g = (val >> 8) & 0xff; + int b = (val >> 0) & 0xff; + QPalette::ColorRole brole = w->backgroundRole(); + QPalette pal = w->palette(); + pal.setColor(brole, QColor(r, g, b)); + w->setPalette(pal); +} + +void PeripheralsView::led_rgb1_changed(int val) { + QString s, t; + s = QString::number(val, 16); + t.fill('0', 8 - s.count()); + ui->lineEditRgb1->setText(t + s); + + set_widget_background_color(ui->labelRgb1, val); +} + +void PeripheralsView::led_rgb2_changed(int val) { + QString s, t; + s = QString::number(val, 16); + t.fill('0', 8 - s.count()); + ui->lineEditRgb2->setText(t + s); + + set_widget_background_color(ui->labelRgb2, val); } diff --git a/qtmips_gui/peripheralsview.h b/qtmips_gui/peripheralsview.h index 8aaf9b9..30e85f1 100644 --- a/qtmips_gui/peripheralsview.h +++ b/qtmips_gui/peripheralsview.h @@ -19,6 +19,11 @@ public: void setup(const machine::PeripSpiLed *perip_spi_led); +public slots: + void led_line_changed(uint val); + void led_rgb1_changed(int val); + void led_rgb2_changed(int val); + private: Ui::PeripheralsView *ui; }; diff --git a/qtmips_gui/peripheralsview.ui b/qtmips_gui/peripheralsview.ui index 59a1e4d..60726a2 100644 --- a/qtmips_gui/peripheralsview.ui +++ b/qtmips_gui/peripheralsview.ui @@ -20,6 +20,93 @@ <enum>QLayout::SetMaximumSize</enum> </property> <item> + <layout class="QHBoxLayout" name="horizontalLayout_3"> + <item> + <layout class="QVBoxLayout" name="verticalLayout_5"> + <item> + <layout class="QVBoxLayout" name="verticalLayout_7"> + <item> + <widget class="QLabel" name="label"> + <property name="text"> + <string>LED RGB 1</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="labelRgb1"> + <property name="text"> + <string/> + </property> + <property name="alignment"> + <set>Qt::AlignBottom|Qt::AlignHCenter</set> + </property> + </widget> + </item> + <item> + <widget class="QLineEdit" name="lineEditRgb1"> + <property name="readOnly"> + <bool>true</bool> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </item> + <item> + <spacer name="horizontalSpacer_3"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <layout class="QVBoxLayout" name="verticalLayout_6"> + <item> + <layout class="QVBoxLayout" name="verticalLayout_8"> + <item> + <widget class="QLabel" name="label_2"> + <property name="text"> + <string>LED RGB 2</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="labelRgb2"> + <property name="text"> + <string/> + </property> + <property name="alignment"> + <set>Qt::AlignBottom|Qt::AlignHCenter</set> + </property> + </widget> + </item> + <item> + <widget class="QLineEdit" name="lineEditRgb2"> + <property name="readOnly"> + <bool>true</bool> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </item> + </layout> + </item> + <item> <layout class="QHBoxLayout" name="horizontalLayout"> <property name="sizeConstraint"> <enum>QLayout::SetNoConstraint</enum> @@ -37,6 +124,16 @@ </widget> </item> <item> + <widget class="QLabel" name="label_3"> + <property name="text"> + <string>Red Knob</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + <item> <widget class="QSpinBox" name="spinRed"> <property name="alignment"> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> @@ -74,6 +171,16 @@ </widget> </item> <item> + <widget class="QLabel" name="label_4"> + <property name="text"> + <string>Green Knob</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + <item> <widget class="QSpinBox" name="spinGreen"> <property name="alignment"> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> @@ -111,6 +218,16 @@ </widget> </item> <item> + <widget class="QLabel" name="label_5"> + <property name="text"> + <string>Blue Knob</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + <item> <widget class="QSpinBox" name="spinBlue"> <property name="alignment"> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> @@ -127,31 +244,94 @@ <item> <layout class="QHBoxLayout" name="horizontalLayout_2"> <item> - <widget class="QCheckBox" name="checkBox"> - <property name="text"> - <string>b31</string> + <layout class="QVBoxLayout" name="verticalLayout_9"> + <item> + <widget class="QLabel" name="label_6"> + <property name="text"> + <string>Word hexadecimal</string> + </property> + <property name="alignment"> + <set>Qt::AlignBottom|Qt::AlignHCenter</set> + </property> + </widget> + </item> + <item> + <widget class="QLineEdit" name="lineEditHex"> + <property name="text"> + <string/> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + <property name="readOnly"> + <bool>true</bool> + </property> + </widget> + </item> + </layout> + </item> + <item> + <spacer name="horizontalSpacer_4"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> </property> - <property name="checkable"> - <bool>false</bool> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> </property> - </widget> + </spacer> </item> <item> - <widget class="QCheckBox" name="checkBox_2"> - <property name="text"> - <string>b30</string> - </property> - </widget> + <layout class="QVBoxLayout" name="verticalLayout_10"> + <item> + <widget class="QLabel" name="label_7"> + <property name="text"> + <string>Word decimal</string> + </property> + <property name="alignment"> + <set>Qt::AlignBottom|Qt::AlignHCenter</set> + </property> + </widget> + </item> + <item> + <widget class="QLineEdit" name="lineEditDec"> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + <property name="readOnly"> + <bool>true</bool> + </property> + </widget> + </item> + </layout> </item> <item> - <widget class="QCheckBox" name="checkBox_3"> - <property name="text"> - <string>b29</string> - </property> - </widget> + <layout class="QVBoxLayout" name="verticalLayout_11"/> </item> </layout> </item> + <item> + <widget class="QLabel" name="label_8"> + <property name="text"> + <string>Word binary</string> + </property> + <property name="alignment"> + <set>Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft</set> + </property> + </widget> + </item> + <item> + <widget class="QLineEdit" name="lineEditBin"> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + <property name="readOnly"> + <bool>true</bool> + </property> + </widget> + </item> </layout> </item> </layout> |