From f41bb7708e1cedd68723942573b5ffae91948b31 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Tue, 10 Nov 2015 22:54:27 +0100 Subject: Make the leds example more interesting with scrolling "text" Change-Id: I563164e0a3ed1ab4668da1b95228c71fba3a845a Reviewed-by: Andy Nichols --- examples/sensehat/leds/main.cpp | 22 ++++++++++++++++------ 1 file 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); -- cgit v1.2.3