aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@theqtcompany.com>2015-11-10 22:54:27 +0100
committerLaszlo Agocs <laszlo.agocs@theqtcompany.com>2015-11-11 08:48:52 +0000
commitf41bb7708e1cedd68723942573b5ffae91948b31 (patch)
tree8cdfbf17eb08a3bed9b08f5e5f5a05619af192c6
parentf8d953dc2bc63b3b3045b091c7648635ba6f871d (diff)
Make the leds example more interesting with scrolling "text"
Change-Id: I563164e0a3ed1ab4668da1b95228c71fba3a845a Reviewed-by: Andy Nichols <andy.nichols@theqtcompany.com>
-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);