Ref T111, blink function for LED

This commit is contained in:
Klaus Basan
2017-08-09 02:40:23 +02:00
committed by Mathew Sutcliffe
parent ccdfa8e12f
commit c2ff451415
2 changed files with 19 additions and 11 deletions

View File

@@ -237,6 +237,11 @@ namespace BlackGui
setLed();
}
void CLedWidget::blink(int resetTimeMs)
{
this->setOn(true, resetTimeMs);
}
void CLedWidget::setTriState(int resetTimeMs)
{
if (resetTimeMs < 0 && m_resetTimer.isActive()) { m_resetTimer.stop();}
@@ -283,13 +288,13 @@ namespace BlackGui
const QStringList &CLedWidget::shapes()
{
static const QStringList shapes( {":/qled/icons/qled/circle_" , ":/qled/icons/qled/square_" , ":/qled/icons/qled/triang_" , ":/qled/icons/qled/round_"});
static const QStringList shapes({":/qled/icons/qled/circle_" , ":/qled/icons/qled/square_" , ":/qled/icons/qled/triang_" , ":/qled/icons/qled/round_"});
return shapes;
}
const QStringList &CLedWidget::colorFiles()
{
static const QStringList colors( { "red.svg", "green.svg", "yellow.svg", "grey.svg", "orange.svg", "purple.svg", "blue.svg", "black.svg" });
static const QStringList colors({ "red.svg", "green.svg", "yellow.svg", "grey.svg", "orange.svg", "purple.svg", "blue.svg", "black.svg" });
return colors;
}

View File

@@ -65,6 +65,9 @@ namespace BlackGui
//! Allows to set the led value {true, false}
void setOn(bool on, int resetTimeMs = -1);
//! Set to on for resetTimeMs
void blink(int resetTimeMs = 500);
//! Sets the 3rd state
void setTriState(int resetTimeMs = -1);
@@ -133,21 +136,21 @@ namespace BlackGui
void clicked();
protected:
State m_value = Off; //!< current value
LedColor m_colorOn = Yellow; //!< On color
LedColor m_colorOff = Black; //!< Off color
State m_value = Off; //!< current value
LedColor m_colorOn = Yellow; //!< On color
LedColor m_colorOff = Black; //!< Off color
LedColor m_colorTriState = Blue; //!< tri-state color
LedShape m_shape = Circle; //!< shape
double m_whRatio = 1.0; //!< width/height ratio
int m_widthTarget = -1; //!< desired width
int m_heightCalculated = 1; //!< calculated height
LedShape m_shape = Circle; //!< shape
double m_whRatio = 1.0; //!< width/height ratio
int m_widthTarget = -1; //!< desired width
int m_heightCalculated = 1; //!< calculated height
QString m_tooltipOn = "on"; //!< tooltip when on
QString m_tooltipOff = "off"; //!< tooltip when off
QString m_tooltipTriState = "tri-state"; //!< tooltip tri state
QString m_tooltipTriState = "tri-state"; //!< tooltip tri-state
QString m_currentToolTip = "off"; //!< currently used tooltip
QScopedPointer<QSvgRenderer> m_renderer; //!< Renderer
QTimer m_resetTimer {this}; //!< reset state
QTimer m_resetTimer { this }; //!< reset state
//! Init
void init();