@@ -27,12 +27,14 @@ extern "C" {
2727
2828Lights::Lights(QObject* parent)
2929 : QObject(parent),
30+ m_lightDevice(0),
31+ m_color("blue"),
3032 m_state(Lights::Off),
31− m_lightDevice(0)
33+ m_onMs(1000),
34+ m_offMs(3000)
3235{
3336}
3437
35−
3638Lights::~Lights()
3739{
3840 if (m_lightDevice) {
@@ -57,6 +59,48 @@ Lights::State Lights::state() const
5759 return m_state;
5860}
5961
62+void Lights::setColor(const QColor &color)
63+{
64+ if (m_color != color) {
65+ m_color = color;
66+ Q_EMIT colorChanged(m_color);
67+ // FIXME: update the collor if the light is already on
68+ }
69+}
70+
71+QColor Lights::color() const
72+{
73+ return m_color;
74+}
75+
76+int Lights::onMillisec() const
77+{
78+ return m_onMs;
79+}
80+
81+void Lights::setOnMillisec(int onMs)
82+{
83+ if (m_onMs != onMs) {
84+ m_onMs = onMs;
85+ Q_EMIT onMillisecChanged(m_onMs);
86+ // FIXME: update the property if the light is already on
87+ }
88+}
89+
90+int Lights::offMillisec() const
91+{
92+ return m_offMs;
93+}
94+
95+void Lights::setOffMillisec(int offMs)
96+{
97+ if (m_offMs != offMs) {
98+ m_offMs = offMs;
99+ Q_EMIT offMillisecChanged(m_offMs);
100+ // FIXME: update the property if the light is already on
101+ }
102+}
103+
60104bool Lights::init()
61105{
62106 if (m_lightDevice) {
@@ -96,10 +140,10 @@ void Lights::turnOn()
96140 // pulse
97141 light_state_t state;
98142 memset(&state, 0, sizeof(light_state_t));
99− state.color = 0xff0000ff; // blue
143+ state.color = m_color.rgba();
100144 state.flashMode = LIGHT_FLASH_TIMED;
101− state.flashOnMS = 1000;
102− state.flashOffMS = 1000;
145+ state.flashOnMS = m_onMs;
146+ state.flashOffMS = m_offMs;
103147 state.brightnessMode = BRIGHTNESS_MODE_USER;
104148
105149 if (m_lightDevice->set_light(m_lightDevice, &state) != 0) {