aboutsummaryrefslogtreecommitdiffstats
path: root/examples/sensehat/leds/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'examples/sensehat/leds/main.cpp')
-rw-r--r--examples/sensehat/leds/main.cpp22
1 files changed, 16 insertions, 6 deletions
diff --git a/examples/sensehat/leds/main.cpp b/examples/sensehat/leds/main.cpp
index 36e9221..957027d 100644
--- a/examples/sensehat/leds/main.cpp
+++ b/examples/sensehat/leds/main.cpp
@@ -57,12 +57,22 @@ int main(int argc, char **argv)
fb.setLowLight(true);
QPainter p(fb.paintDevice());
- p.fillRect(QRect(QPoint(), fb.size()), Qt::black);
- for (int i = Qt::white; i < Qt::darkYellow; ++i) {
- p.setPen(Qt::GlobalColor(i));
- p.drawEllipse(QPoint(4, 4), 3, 3);
- p.drawLine(QPoint(4, 4), QPoint(7, 7));
- sleep(1);
+ int x = 7, dx = -1;
+ Qt::GlobalColor col = Qt::white;
+ for (int i = 0; i < 200; ++i) {
+ p.fillRect(QRect(QPoint(), fb.size()), Qt::black);
+ p.setPen(col);
+ p.drawEllipse(QPoint(x, 4), 3, 3);
+ p.drawLine(QPoint(x, 4), QPoint(x + 3, 7));
+ x += dx;
+ if (x < -4 || x > 10)
+ dx *= -1;
+ usleep(1000 * 100);
+ if (!(i % 8)) {
+ col = Qt::GlobalColor(col + 1);
+ if (col == Qt::transparent)
+ col = Qt::white;
+ }
}
p.fillRect(QRect(QPoint(), fb.size()), Qt::black);