diff options
author | Laszlo Agocs <laszlo.agocs@theqtcompany.com> | 2015-11-09 12:02:14 +0100 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@theqtcompany.com> | 2015-11-09 11:29:46 +0000 |
commit | cd30924a6f8697d2e6794644e1d4a6e590b736b4 (patch) | |
tree | 5c2243ac374b54fbe77ba0a02c9b6d550f739706 /README.md | |
parent | bd0f7487fc281965821bb1ec772edc51b4082ef2 (diff) |
Initial version of the Qt Sense HAT module
Change-Id: I15c9b5665e4d32e580df4878a0c26a15172c06bc
Reviewed-by: Andy Nichols <andy.nichols@theqtcompany.com>
Diffstat (limited to 'README.md')
-rw-r--r-- | README.md | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/README.md b/README.md new file mode 100644 index 0000000..0d932e3 --- /dev/null +++ b/README.md @@ -0,0 +1,61 @@ +Raspberry Pi Sense HAT support module for Qt 5 +============================================== + +Tested on Raspbian Jessie 2015/09/24 and Qt 5.6 as described on https://wiki.qt.io/RaspberryPi2EGLFS + +Sensor support is based on RTIMULib as shipped in Raspbian and https://github.com/RPi-Distro/python-sense-hat. + +This a true Qt module. To build, do qmake -r && make && make install. To use, add QT += sensehat. + +LED example: + + int main(int argc, char **argv) + { + QCoreApplication app(argc, argv); + QSenseHatFb fb; + 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); + } + p.fillRect(QRect(QPoint(), fb.size()), Qt::black); + return 0; + } + +An alternative is to run with the linuxfb platform plugin and use QRasterWindow. However, +QSenseHatFb is handy because it automatically finds the right device, supports device +specifics (low-light mode), functions (to some extent) without initializing QtGui, and +allows using any platform plugin and simultaneous HDMI output. + +Sensors example: + + int main(int argc, char **argv) + { + QCoreApplication app(argc, argv); + QSenseHatSensors sensors; + sensors.setAutoPoll(true); + QObject::connect(&sensors, &QSenseHatSensors::humidityChanged, [](qreal h) { + qDebug() << "Humidity:" << h; + }); + QObject::connect(&sensors, &QSenseHatSensors::pressureChanged, [](qreal p) { + qDebug() << "Pressure:" << p; + }); + QObject::connect(&sensors, &QSenseHatSensors::temperatureChanged, [](qreal c) { + qDebug() << "Temperature:" << c; + }); + QObject::connect(&sensors, &QSenseHatSensors::gyroChanged, [](const QVector3D &v) { + qDebug() << "Gyro:" << v; + }); + QObject::connect(&sensors, &QSenseHatSensors::accelerationChanged, [](const QVector3D &v) { + qDebug() << "Acceleration:" << v; + }); + QObject::connect(&sensors, &QSenseHatSensors::compassChanged, [](const QVector3D &v) { + qDebug() << "Compass:" << v; + }); + QTimer::singleShot(10000, &app, &QCoreApplication::quit); + return app.exec(); + } |