@@ -27,12 +27,14 @@ extern "C" {
28Lights::Lights(QObject* parent)
28Lights::Lights(QObject* parent)
29 : QObject(parent),
29 : QObject(parent),
30 m_state(Lights::Off),
32 m_state(Lights::Off),
31− m_lightDevice(0)
33+ m_onMs(1000),
36Lights::~Lights()
38Lights::~Lights()
38 if (m_lightDevice) {
40 if (m_lightDevice) {
@@ -57,6 +59,48 @@ Lights::State Lights::state() const
57 return m_state;
59 return m_state;
62+void Lights::setColor(const QColor &color)
64+ if (m_color != color) {
66+ Q_EMIT colorChanged(m_color);
67+ // FIXME: update the collor if the light is already on
71+QColor Lights::color() const
76+int Lights::onMillisec() const
81+void Lights::setOnMillisec(int onMs)
83+ if (m_onMs != onMs) {
85+ Q_EMIT onMillisecChanged(m_onMs);
86+ // FIXME: update the property if the light is already on
90+int Lights::offMillisec() const
95+void Lights::setOffMillisec(int offMs)
97+ if (m_offMs != offMs) {
99+ Q_EMIT offMillisecChanged(m_offMs);
100+ // FIXME: update the property if the light is already on
60bool Lights::init()
104bool Lights::init()
62 if (m_lightDevice) {
106 if (m_lightDevice) {
@@ -96,10 +140,10 @@ void Lights::turnOn()
97 light_state_t state;
141 light_state_t state;
98 memset(&state, 0, sizeof(light_state_t));
142 memset(&state, 0, sizeof(light_state_t));
99− state.color = 0xff0000ff; // blue
143+ state.color = m_color.rgba();
100 state.flashMode = LIGHT_FLASH_TIMED;
144 state.flashMode = LIGHT_FLASH_TIMED;
101− state.flashOnMS = 1000;
145+ state.flashOnMS = m_onMs;
102− state.flashOffMS = 1000;
146+ state.flashOffMS = m_offMs;
103 state.brightnessMode = BRIGHTNESS_MODE_USER;
147 state.brightnessMode = BRIGHTNESS_MODE_USER;
105 if (m_lightDevice->set_light(m_lightDevice, &state) != 0) {
149 if (m_lightDevice->set_light(m_lightDevice, &state) != 0) {