diff options
author | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2012-07-02 18:33:41 -0500 |
---|---|---|
committer | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2012-07-02 18:33:41 -0500 |
commit | 623cde93fda148d0c36ba13701a7006bd6bea294 (patch) | |
tree | ae991921965d6a87926695d122af82e4b676db00 /clients/tde/src/part/fpgaview/part.cpp | |
parent | 963501ff41849e6bbcaa7a5c12c6e04b37a8a130 (diff) | |
download | ulab-623cde93fda148d0c36ba13701a7006bd6bea294.tar.gz ulab-623cde93fda148d0c36ba13701a7006bd6bea294.zip |
Stabilize clients and complete basic view layout/widgets
Diffstat (limited to 'clients/tde/src/part/fpgaview/part.cpp')
-rw-r--r-- | clients/tde/src/part/fpgaview/part.cpp | 112 |
1 files changed, 110 insertions, 2 deletions
diff --git a/clients/tde/src/part/fpgaview/part.cpp b/clients/tde/src/part/fpgaview/part.cpp index 269c05e..8876e44 100644 --- a/clients/tde/src/part/fpgaview/part.cpp +++ b/clients/tde/src/part/fpgaview/part.cpp @@ -30,6 +30,7 @@ #include <kparts/genericfactory.h> #include <kstatusbar.h> #include <kstdaction.h> +#include <knuminput.h> #include <tqfile.h> //encodeName() #include <tqtimer.h> //postInit() hack #include <tqvbox.h> @@ -72,17 +73,62 @@ void FPGALed::mouseReleaseEvent(TQMouseEvent *e) { } } +FPGAPushButton::FPGAPushButton(TQWidget *parent, const char *name) + : KLed(parent, name), mouseDown(false) +{ + off(); + setColor(green); + setOffColor(TQApplication::palette(this).active().base().dark(200)); +} + +void FPGAPushButton::mousePressEvent(TQMouseEvent *e) { + if (e->button() == TQMouseEvent::LeftButton) { + on(); + mouseDown = true; + emit(buttonPressed()); + emit(changed()); + } +} + +void FPGAPushButton::mouseReleaseEvent(TQMouseEvent *e) { + if (e->button() == TQMouseEvent::LeftButton) { + off(); + mouseDown = false; + emit(buttonReleased()); + emit(changed()); + } +} + +void FPGAPushButton::enterEvent(TQEvent *e) { + Q_UNUSED(e); + if (mouseDown) { + on(); + emit(buttonPressed()); + emit(changed()); + } +} + +void FPGAPushButton::leaveEvent(TQEvent *e) { + Q_UNUSED(e); + if (mouseDown) { + off(); + emit(buttonReleased()); + emit(changed()); + } +} + namespace RemoteLab { typedef KParts::GenericFactory<RemoteLab::FPGAViewPart> Factory; #define CLIENT_LIBRARY "libremotelab_fpgaviewer" K_EXPORT_COMPONENT_FACTORY(libremotelab_fpgaviewer, RemoteLab::Factory) -#define LED_SIZE 20,20 +#define LED_BASE_SIZE 20 +#define LED_SIZE LED_BASE_SIZE,LED_BASE_SIZE FPGAViewPart::FPGAViewPart(TQWidget *parentWidget, const char *widgetName, TQObject *parent, const char *name, const TQStringList&) : RemoteInstrumentPart( parent, name ), m_socket(0), m_base(0), connToServerConnecting(false), connToServerState(-1), connToServerTimeoutTimer(NULL), m_interfaceMode(BasicInterfaceMode), - remoteInputModeEnabled(false), m_8bitInputValue(0), m_8bitOutputValue(0) + remoteInputModeEnabled(false), m_4bitInputValue(0), m_4bitOutputValue(0), m_8bitInputValue(0), m_8bitOutputValue(0), m_16bitInputValue(0), m_16bitOutputValue(0) { // Initialize mutex m_connectionMutex = new TQMutex(false); @@ -111,6 +157,15 @@ FPGAViewPart::FPGAViewPart(TQWidget *parentWidget, const char *widgetName, TQObj m_modeSubMenu->insert(m_modeAdvancedEnabled); // Initialize widgets + m_base->group4BitInputValueLabel->setFixedSize(LED_BASE_SIZE*2, LED_BASE_SIZE*2); + m_base->group4BitOutputValueLabel->setFixedSize(LED_BASE_SIZE*2, LED_BASE_SIZE*2); + m_base->group4BitInputValueText->setFixedSize(LED_BASE_SIZE*2, LED_BASE_SIZE*2); + m_base->group4BitOutputValueText->setFixedSize(LED_BASE_SIZE*2, LED_BASE_SIZE*2); + + m_base->group4BitInputLED3->setFixedSize(LED_SIZE); + m_base->group4BitInputLED2->setFixedSize(LED_SIZE); + m_base->group4BitInputLED1->setFixedSize(LED_SIZE); + m_base->group4BitInputLED0->setFixedSize(LED_SIZE); m_base->group8BitInputLED7->setFixedSize(LED_SIZE); m_base->group8BitInputLED6->setFixedSize(LED_SIZE); m_base->group8BitInputLED5->setFixedSize(LED_SIZE); @@ -128,6 +183,10 @@ FPGAViewPart::FPGAViewPart(TQWidget *parentWidget, const char *widgetName, TQObj m_base->group8BitOutputLED1->setFixedSize(LED_SIZE); m_base->group8BitOutputLED0->setFixedSize(LED_SIZE); + m_base->group4BitInputLED3->setState(KLed::Off); + m_base->group4BitInputLED2->setState(KLed::Off); + m_base->group4BitInputLED1->setState(KLed::Off); + m_base->group4BitInputLED0->setState(KLed::Off); m_base->group8BitInputLED7->setState(KLed::Off); m_base->group8BitInputLED6->setState(KLed::Off); m_base->group8BitInputLED5->setState(KLed::Off); @@ -154,6 +213,11 @@ FPGAViewPart::FPGAViewPart(TQWidget *parentWidget, const char *widgetName, TQObj m_base->group8BitOutputLED1->setClickable(false); m_base->group8BitOutputLED0->setClickable(false); + connect(m_base->group4BitInputLED3, SIGNAL(changed()), this, SLOT(process4BitInputChanges())); + connect(m_base->group4BitInputLED2, SIGNAL(changed()), this, SLOT(process4BitInputChanges())); + connect(m_base->group4BitInputLED1, SIGNAL(changed()), this, SLOT(process4BitInputChanges())); + connect(m_base->group4BitInputLED0, SIGNAL(changed()), this, SLOT(process4BitInputChanges())); + connect(m_base->group8BitInputLED7, SIGNAL(clicked()), this, SLOT(process8BitInputChanges())); connect(m_base->group8BitInputLED6, SIGNAL(clicked()), this, SLOT(process8BitInputChanges())); connect(m_base->group8BitInputLED5, SIGNAL(clicked()), this, SLOT(process8BitInputChanges())); @@ -163,6 +227,8 @@ FPGAViewPart::FPGAViewPart(TQWidget *parentWidget, const char *widgetName, TQObj connect(m_base->group8BitInputLED1, SIGNAL(clicked()), this, SLOT(process8BitInputChanges())); connect(m_base->group8BitInputLED0, SIGNAL(clicked()), this, SLOT(process8BitInputChanges())); + connect(m_base->group16BitInputValue, SIGNAL(valueChanged(int)), this, SLOT(process16BitInputChanges())); + processAllGraphicsUpdates(); TQTimer::singleShot(0, this, TQT_SLOT(postInit())); @@ -181,12 +247,34 @@ void FPGAViewPart::processAllGraphicsUpdates() { // This is an expensive operation // Use it sparingly! + process4BitInputChanges(); + process4BitOutputChanges(); process8BitInputChanges(); process8BitOutputChanges(); + process16BitInputChanges(); + process16BitOutputChanges(); + + processLCDOutputChanges(); processLockouts(); } +void FPGAViewPart::process4BitInputChanges() { + // Read LED status into m_4bitInputValue + m_4bitInputValue = 0; + if (m_base->group4BitInputLED3->state() == KLed::On) m_4bitInputValue |= 0x08; + if (m_base->group4BitInputLED2->state() == KLed::On) m_4bitInputValue |= 0x04; + if (m_base->group4BitInputLED1->state() == KLed::On) m_4bitInputValue |= 0x02; + if (m_base->group4BitInputLED0->state() == KLed::On) m_4bitInputValue |= 0x01; + + m_base->group4BitInputValueText->setText(TQString("0x%1").arg(m_4bitInputValue, 0, 16)); +} + +void FPGAViewPart::process4BitOutputChanges() { + // Write m_4bitOutputValue to label + m_base->group4BitOutputValueText->setText(TQString("0x%1").arg(m_16bitOutputValue, 0, 16)); +} + void FPGAViewPart::process8BitInputChanges() { // Read LED status into m_8bitInputValue m_8bitInputValue = 0; @@ -223,6 +311,25 @@ void FPGAViewPart::process8BitOutputChanges() { m_base->group8BitOutputValueText->setText(TQString("0x%1").arg(m_8bitOutputValue, 0, 16)); } +void FPGAViewPart::process16BitInputChanges() { + // Read input into m_16bitInputValue + m_16bitInputValue = m_base->group16BitInputValue->value(); +} + +void FPGAViewPart::process16BitOutputChanges() { + // Write m_16bitOutputValue to label + m_base->group16BitOutputValue->setText(TQString("0x%1").arg(m_16bitOutputValue, 0, 16)); +} + +void FPGAViewPart::processLCDOutputChanges() { + // Write m_LCDOutputValue to label + TQString topLine = m_LCDOutputValue; + TQString bottomLine = m_LCDOutputValue; + topLine.truncate(16); + bottomLine.remove(0,8); + m_base->LCDOutputLabel->setText(topLine + "\n" + bottomLine); +} + void FPGAViewPart::processLockouts() { TQWidget* mainWidget = widget(); if (mainWidget) { @@ -438,6 +545,7 @@ TQPtrList<KAction> FPGAViewPart::menuActionList() { void FPGAViewPart::updateDisplay() { // RAJA FIXME + // setStatusMessage(i18n("Debug interface timeout, still waiting for data. Please verify that the FPGA is properly configured.")); // or setStatusMessage(i18n("Running")+"... \|/-" } KAboutData* FPGAViewPart::createAboutData() { |