support a clip LED, coded by fleutot (#220)

This commit is contained in:
Volker Fischer 2020-06-22 16:38:44 +02:00
parent a3aa58dbe0
commit 25bfa70eaf
3 changed files with 50 additions and 37 deletions

View file

@ -11,6 +11,8 @@
- new group switch to change several faders in sync, coded by Alberstein8 (#202, #379) - new group switch to change several faders in sync, coded by Alberstein8 (#202, #379)
- support a clip LED, coded by fleutot (#220)
- add server recording indicator, coded by pljones (#295) - add server recording indicator, coded by pljones (#295)
- support for storing/recovering the server window positions (#357) - support for storing/recovering the server window positions (#357)
@ -28,6 +30,11 @@
3.5.6 (2020-06-09) 3.5.6 (2020-06-09)
- support sorting faders by channel name (#178) - support sorting faders by channel name (#178)

View file

@ -40,16 +40,16 @@ CLevelMeter::CLevelMeter ( QWidget* parent, Qt::WindowFlags f ) :
pLEDLayout->setMargin ( 0 ); pLEDLayout->setMargin ( 0 );
pLEDLayout->setSpacing ( 0 ); pLEDLayout->setSpacing ( 0 );
// create LEDs // create LEDs plus the clip LED
vecpLEDs.Init ( NUM_STEPS_LED_BAR ); vecpLEDs.Init ( NUM_LEDS_INCL_CLIP_LED );
for ( int iLEDIdx = NUM_STEPS_LED_BAR - 1; iLEDIdx >= 0; iLEDIdx-- ) for ( int iLEDIdx = NUM_LEDS_INCL_CLIP_LED - 1; iLEDIdx >= 0; iLEDIdx-- )
{ {
// create LED object // create LED object
vecpLEDs[iLEDIdx] = new cLED ( parent ); vecpLEDs[iLEDIdx] = new cLED ( parent );
// add LED to layout with spacer (do not add spacer on the bottom of the first LED) // add LED to layout with spacer (do not add spacer on the bottom of the first LED)
if ( iLEDIdx < NUM_STEPS_LED_BAR - 1 ) if ( iLEDIdx < NUM_LEDS_INCL_CLIP_LED - 1 )
{ {
pLEDLayout->addStretch(); pLEDLayout->addStretch();
} }
@ -76,44 +76,26 @@ CLevelMeter::CLevelMeter ( QWidget* parent, Qt::WindowFlags f ) :
// update the meter type (using the default value of the meter type) // update the meter type (using the default value of the meter type)
SetLevelMeterType ( eLevelMeterType ); SetLevelMeterType ( eLevelMeterType );
// setup clip indicator timer
TimerClip.setSingleShot ( true );
TimerClip.setInterval ( CLIP_IND_TIME_OUT_MS );
// Connections -------------------------------------------------------------
QObject::connect ( &TimerClip, &QTimer::timeout,
this, &CLevelMeter::ClipReset );
} }
CLevelMeter::~CLevelMeter() CLevelMeter::~CLevelMeter()
{ {
// clean up the LED objects // clean up the LED objects
for ( int iLEDIdx = 0; iLEDIdx < NUM_STEPS_LED_BAR; iLEDIdx++ ) for ( int iLEDIdx = 0; iLEDIdx < NUM_LEDS_INCL_CLIP_LED; iLEDIdx++ )
{ {
delete vecpLEDs[iLEDIdx]; delete vecpLEDs[iLEDIdx];
} }
} }
void CLevelMeter::changeEvent ( QEvent* curEvent )
{
// act on enabled changed state
if ( curEvent->type() == QEvent::EnabledChange )
{
// reset all LEDs
Reset ( this->isEnabled() );
}
}
void CLevelMeter::Reset ( const bool bEnabled )
{
// update state of all LEDs
for ( int iLEDIdx = 0; iLEDIdx < NUM_STEPS_LED_BAR; iLEDIdx++ )
{
// different reset behavoiur for enabled and disabled control
if ( bEnabled )
{
vecpLEDs[iLEDIdx]->setColor ( cLED::RL_BLACK );
}
else
{
vecpLEDs[iLEDIdx]->setColor ( cLED::RL_DISABLED );
}
}
}
void CLevelMeter::SetLevelMeterType ( const ELevelMeterType eNType ) void CLevelMeter::SetLevelMeterType ( const ELevelMeterType eNType )
{ {
eLevelMeterType = eNType; eLevelMeterType = eNType;
@ -135,7 +117,7 @@ void CLevelMeter::SetLevelMeterType ( const ELevelMeterType eNType )
case MT_SLIM_BAR: case MT_SLIM_BAR:
// set all LEDs to disabled, otherwise we would not get our desired small width // set all LEDs to disabled, otherwise we would not get our desired small width
for ( int iLEDIdx = 0; iLEDIdx < NUM_STEPS_LED_BAR; iLEDIdx++ ) for ( int iLEDIdx = 0; iLEDIdx < NUM_LEDS_INCL_CLIP_LED; iLEDIdx++ )
{ {
vecpLEDs[iLEDIdx]->setColor ( cLED::RL_DISABLED ); vecpLEDs[iLEDIdx]->setColor ( cLED::RL_DISABLED );
} }
@ -158,7 +140,7 @@ void CLevelMeter::SetValue ( const double dValue )
switch ( eLevelMeterType ) switch ( eLevelMeterType )
{ {
case MT_LED: case MT_LED:
// update state of all LEDs for current level value // update state of all LEDs for current level value (except of the clip LED)
for ( int iLEDIdx = 0; iLEDIdx < NUM_STEPS_LED_BAR; iLEDIdx++ ) for ( int iLEDIdx = 0; iLEDIdx < NUM_STEPS_LED_BAR; iLEDIdx++ )
{ {
// set active LED color if value is above current LED index // set active LED color if value is above current LED index
@ -190,6 +172,13 @@ void CLevelMeter::SetValue ( const double dValue )
vecpLEDs[iLEDIdx]->setColor ( cLED::RL_BLACK ); vecpLEDs[iLEDIdx]->setColor ( cLED::RL_BLACK );
} }
} }
// clip LED management
if ( dValue > LEV_METER_CLIP_LIMIT_RATIO * NUM_STEPS_LED_BAR)
{
vecpLEDs[NUM_STEPS_LED_BAR]->setColor ( cLED::RL_RED );
TimerClip.start();
}
break; break;
case MT_BAR: case MT_BAR:
@ -200,6 +189,15 @@ void CLevelMeter::SetValue ( const double dValue )
} }
} }
void CLevelMeter::ClipReset()
{
if ( eLevelMeterType == MT_LED )
{
vecpLEDs[NUM_STEPS_LED_BAR]->setColor ( cLED::RL_BLACK );
}
}
CLevelMeter::cLED::cLED ( QWidget* parent ) : CLevelMeter::cLED::cLED ( QWidget* parent ) :
BitmCubeRoundBlack ( QString::fromUtf8 ( ":/png/LEDs/res/HLEDBlackSmall.png" ) ), BitmCubeRoundBlack ( QString::fromUtf8 ( ":/png/LEDs/res/HLEDBlackSmall.png" ) ),
BitmCubeRoundGreen ( QString::fromUtf8 ( ":/png/LEDs/res/HLEDGreenSmall.png" ) ), BitmCubeRoundGreen ( QString::fromUtf8 ( ":/png/LEDs/res/HLEDGreenSmall.png" ) ),

View file

@ -34,6 +34,12 @@
#include "global.h" #include "global.h"
/* Definitions ****************************************************************/
#define LEV_METER_CLIP_LIMIT_RATIO 0.99
#define NUM_LEDS_INCL_CLIP_LED ( NUM_STEPS_LED_BAR + 1 )
#define CLIP_IND_TIME_OUT_MS 20000
/* Classes ********************************************************************/ /* Classes ********************************************************************/
class CLevelMeter : public QWidget class CLevelMeter : public QWidget
{ {
@ -80,11 +86,13 @@ protected:
QLabel* pLEDLabel; QLabel* pLEDLabel;
}; };
void Reset ( const bool bEnabled );
virtual void changeEvent ( QEvent* curEvent );
QStackedLayout* pStackedLayout; QStackedLayout* pStackedLayout;
ELevelMeterType eLevelMeterType; ELevelMeterType eLevelMeterType;
CVector<cLED*> vecpLEDs; CVector<cLED*> vecpLEDs;
QProgressBar* pBarMeter; QProgressBar* pBarMeter;
QTimer TimerClip;
protected slots:
void ClipReset();
}; };