From c9bb67ae14cff5c4dbd7fbfe3e8a7381f519ab12 Mon Sep 17 00:00:00 2001 From: Volker Fischer Date: Fri, 1 May 2009 14:00:53 +0000 Subject: [PATCH] first version of LED input level meter finished -> not yet ready, some work still has to be done --- src/audiomixerboard.cpp | 4 +- src/global.h | 5 +++ src/llconclientdlg.cpp | 29 ++++++-------- src/llconclientdlg.h | 3 -- src/llconclientdlgbase.ui | 80 +++++++++++---------------------------- src/multicolorledbar.cpp | 77 +++++++++++++++++++++++++++++++++---- src/multicolorledbar.h | 21 ++++++---- 7 files changed, 122 insertions(+), 97 deletions(-) diff --git a/src/audiomixerboard.cpp b/src/audiomixerboard.cpp index 418e2339..b333994d 100755 --- a/src/audiomixerboard.cpp +++ b/src/audiomixerboard.cpp @@ -107,9 +107,7 @@ CAudioMixerBoard::CAudioMixerBoard ( QWidget* parent, Qt::WindowFlags f ) : QFra setFrameShadow ( QFrame::Sunken ); // add hboxlayout with horizontal spacer - -// TODO is this ok this way? Don't we need the border 11 and space 0? - pMainLayout = new QHBoxLayout ( this );//, 11, 0 ); + pMainLayout = new QHBoxLayout ( this ); pMainLayout->addItem ( new QSpacerItem ( 0, 0, QSizePolicy::Expanding ) ); diff --git a/src/global.h b/src/global.h index e98f15d6..1c2a66aa 100755 --- a/src/global.h +++ b/src/global.h @@ -96,6 +96,11 @@ #define MAX_NUMBER_SOUND_CARDS 10 #define INVALID_SNC_CARD_DEVICE -1 +// defines for LED input level meter +#define NUM_STEPS_INP_LEV_METER 10 +#define YELLOW_BOUND_INP_LEV_METER 7 +#define RED_BOUND_INP_LEV_METER 9 + // maximum number of internet connections (channels) // if you want to change this paramter, there has to be done code modifications diff --git a/src/llconclientdlg.cpp b/src/llconclientdlg.cpp index 4324855c..0bb6e1a7 100755 --- a/src/llconclientdlg.cpp +++ b/src/llconclientdlg.cpp @@ -36,11 +36,10 @@ CLlconClientDlg::CLlconClientDlg ( CClient* pNCliP, QWidget* parent, // add help text to controls QString strInpLevH = tr ( "Input level meter: Shows the level of the " - "input audio signal of the sound card. The level is in dB. Overload " - "should be avoided." ); - TextLabelInputLevel->setWhatsThis ( strInpLevH ); - ProgressBarInputLevelL->setWhatsThis ( strInpLevH ); - ProgressBarInputLevelR->setWhatsThis ( strInpLevH ); + "input audio signal of the sound card. Overload should be avoided." ); + TextLabelInputLevel->setWhatsThis ( strInpLevH ); + MultiColorLEDBarInputLevelL->setWhatsThis ( strInpLevH ); + MultiColorLEDBarInputLevelR->setWhatsThis ( strInpLevH ); PushButtonConnect->setWhatsThis ( tr ( "Connect / Disconnect Button:" " Push this button to connect the server. A valid IP address has " @@ -105,12 +104,8 @@ CLlconClientDlg::CLlconClientDlg ( CClient* pNCliP, QWidget* parent, PushButtonConnect->setText ( CON_BUT_CONNECTTEXT ); // init input level meter bars - ProgressBarInputLevelL->setMinimum ( 0 ); - ProgressBarInputLevelL->setMaximum ( NUM_STEPS_INP_LEV_METER ); - ProgressBarInputLevelL->setValue ( 0 ); - ProgressBarInputLevelR->setMinimum ( 0 ); - ProgressBarInputLevelR->setMaximum ( NUM_STEPS_INP_LEV_METER ); - ProgressBarInputLevelR->setValue ( 0 ); + MultiColorLEDBarInputLevelL->setValue ( 0 ); + MultiColorLEDBarInputLevelR->setValue ( 0 ); // init slider controls --- @@ -296,8 +291,8 @@ void CLlconClientDlg::OnConnectDisconBut() // stop timer for level meter bars and reset them TimerSigMet.stop(); - ProgressBarInputLevelL->setValue ( 0 ); - ProgressBarInputLevelR->setValue ( 0 ); + MultiColorLEDBarInputLevelL->setValue ( 0 ); + MultiColorLEDBarInputLevelR->setValue ( 0 ); // immediately update status bar OnTimerStatus(); @@ -353,8 +348,8 @@ void CLlconClientDlg::OnTimerSigMet() double dCurSigLevelL = pClient->MicLevelL(); double dCurSigLevelR = pClient->MicLevelR(); - /* linear transformation of the input level range to the progress-bar - range */ + // linear transformation of the input level range to the progress-bar + // range dCurSigLevelL -= LOW_BOUND_SIG_METER; dCurSigLevelL *= NUM_STEPS_INP_LEV_METER / ( UPPER_BOUND_SIG_METER - LOW_BOUND_SIG_METER ); @@ -376,8 +371,8 @@ void CLlconClientDlg::OnTimerSigMet() } // show current level - ProgressBarInputLevelL->setValue ( (int) ceil ( dCurSigLevelL ) ); - ProgressBarInputLevelR->setValue ( (int) ceil ( dCurSigLevelR ) ); + MultiColorLEDBarInputLevelL->setValue ( (int) ceil ( dCurSigLevelL ) ); + MultiColorLEDBarInputLevelR->setValue ( (int) ceil ( dCurSigLevelR ) ); } void CLlconClientDlg::UpdateDisplay() diff --git a/src/llconclientdlg.h b/src/llconclientdlg.h index dfb44c69..904d5738 100755 --- a/src/llconclientdlg.h +++ b/src/llconclientdlg.h @@ -51,9 +51,6 @@ #define CON_BUT_CONNECTTEXT "C&onnect" #define CON_BUT_DISCONNECTTEXT "D&isconnect" -// steps for input level meter -#define NUM_STEPS_INP_LEV_METER 100 - // update time for GUI controls #define LEVELMETER_UPDATE_TIME 100 // ms #define STATUSBAR_UPDATE_TIME 1000 // ms diff --git a/src/llconclientdlgbase.ui b/src/llconclientdlgbase.ui index 7cdcc8ef..eb0fc30c 100755 --- a/src/llconclientdlgbase.ui +++ b/src/llconclientdlgbase.ui @@ -5,8 +5,8 @@ 0 0 - 492 - 310 + 488 + 336 @@ -28,21 +28,6 @@ QFrame::Raised - - 6 - - - 9 - - - 9 - - - 9 - - - 9 - @@ -67,21 +52,6 @@ - - 6 - - - 0 - - - 0 - - - 0 - - - 0 - @@ -136,49 +106,37 @@ - 6 - - - 0 - - - 0 - - - 0 - - 0 - + - + 0 0 - - 24 - - - Qt::Horizontal + + + 50 + 25 + - + - + 0 0 - - 24 - - - Qt::Horizontal + + + 50 + 25 + @@ -645,6 +603,12 @@ Fader QWidget
audiomixerboard.h
+ + CMultiColorLEDBar + QWidget +
multicolorledbar.h
+ 1 +
LineEditServerAddr diff --git a/src/multicolorledbar.cpp b/src/multicolorledbar.cpp index 2082be52..f12c8f32 100755 --- a/src/multicolorledbar.cpp +++ b/src/multicolorledbar.cpp @@ -31,14 +31,75 @@ /* Implementation *************************************************************/ CMultiColorLEDBar::CMultiColorLEDBar ( QWidget* parent, Qt::WindowFlags f ) : QLabel ( parent, f ), - BitmCubeRoundGrey ( QString::fromUtf8 ( ":/png/LEDs/res/VRLEDGreySmall.png" ) ), - BitmCubeRoundGreen ( QString::fromUtf8 ( ":/png/LEDs/res/VRLEDGreySmall.png" ) ), - BitmCubeRoundYellow ( QString::fromUtf8 ( ":/png/LEDs/res/VRLEDGreySmall.png" ) ), - BitmCubeRoundRed ( QString::fromUtf8 ( ":/png/LEDs/res/VRLEDGreySmall.png" ) ), - BitmCubeEdgeGrey ( QString::fromUtf8 ( ":/png/LEDs/res/VLEDGreySmall.png" ) ), - BitmCubeEdgeGreen ( QString::fromUtf8 ( ":/png/LEDs/res/VLEDGreySmall.png" ) ), - BitmCubeEdgeYellow ( QString::fromUtf8 ( ":/png/LEDs/res/VLEDGreySmall.png" ) ), - BitmCubeEdgeRed ( QString::fromUtf8 ( ":/png/LEDs/res/VLEDGreySmall.png" ) ) + BitmCubeRoundGrey ( QString::fromUtf8 ( ":/png/LEDs/res/VLEDGreySmall.png" ) ), + BitmCubeRoundGreen ( QString::fromUtf8 ( ":/png/LEDs/res/VLEDGreenSmall.png" ) ), + BitmCubeRoundYellow ( QString::fromUtf8 ( ":/png/LEDs/res/VLEDYellowSmall.png" ) ), + BitmCubeRoundRed ( QString::fromUtf8 ( ":/png/LEDs/res/VLEDRedSmall.png" ) ) +{ + // set total number of LEDs + iNumLEDs = NUM_STEPS_INP_LEV_METER; + + // create layout and set spacing to zero + pMainLayout = new QHBoxLayout ( this ); + pMainLayout->setSpacing ( 0 ); + + // create LEDs + vecpLEDs.Init ( iNumLEDs ); + for ( int i = 0; i < iNumLEDs; i++ ) + { + // create LED label + vecpLEDs[i] = new QLabel ( "", parent ); + + // add LED to layout + pMainLayout->addWidget ( vecpLEDs[i] ); + + // set initial bitmap + vecpLEDs[i]->setPixmap ( BitmCubeRoundGrey ); + + // bitmap defines minimum size of the label + vecpLEDs[i]->setMinimumSize ( + BitmCubeRoundGrey.width(), BitmCubeRoundGrey.height() ); + } +} + +void CMultiColorLEDBar::setValue ( const int value ) { +// TODO speed optimiation: only change bitmaps of LEDs which +// actually have to be changed + + // use green LEDs for the range from 0 to the YELLOW_BOUND_INP_LEV_METER, + // yellow in the range YELLOW_BOUND_INP_LEV_METER to + // RED_BOUND_INP_LEV_METER and red for up to value and grey for the rest + for ( int i = 0; i < iNumLEDs; i++ ) + { + if ( i < value ) + { + // we are below current input level, check which color + // we should use (green, yellow or red) + if ( i < YELLOW_BOUND_INP_LEV_METER ) + { + // green region + vecpLEDs[i]->setPixmap ( BitmCubeRoundGreen ); + } + else + { + if ( i < RED_BOUND_INP_LEV_METER ) + { + // yellow region + vecpLEDs[i]->setPixmap ( BitmCubeRoundYellow ); + } + else + { + // red region + vecpLEDs[i]->setPixmap ( BitmCubeRoundRed ); + } + } + } + else + { + // we are above current input level -> use grey LED + vecpLEDs[i]->setPixmap ( BitmCubeRoundGrey ); + } + } } diff --git a/src/multicolorledbar.h b/src/multicolorledbar.h index 0f603ce7..a646d0c9 100755 --- a/src/multicolorledbar.h +++ b/src/multicolorledbar.h @@ -28,6 +28,8 @@ #include #include #include +#include +#include "util.h" #include "global.h" @@ -39,15 +41,18 @@ class CMultiColorLEDBar : public QLabel public: CMultiColorLEDBar ( QWidget* parent = 0, Qt::WindowFlags f = 0 ); + void setValue ( const int value ); + protected: - QPixmap BitmCubeRoundGrey; - QPixmap BitmCubeRoundGreen; - QPixmap BitmCubeRoundYellow; - QPixmap BitmCubeRoundRed; - QPixmap BitmCubeEdgeGrey; - QPixmap BitmCubeEdgeGreen; - QPixmap BitmCubeEdgeYellow; - QPixmap BitmCubeEdgeRed; + QPixmap BitmCubeRoundGrey; + QPixmap BitmCubeRoundGreen; + QPixmap BitmCubeRoundYellow; + QPixmap BitmCubeRoundRed; + + QHBoxLayout* pMainLayout; + + int iNumLEDs; + CVector vecpLEDs; }; #endif // _MULTCOLORLEDBAR_H__FD6B49B5_87DF_48DD_E1606C2AC__INCLUDED_