diff options
author | Laszlo Agocs <[email protected]> | 2015-12-06 13:25:27 +0100 |
---|---|---|
committer | Laszlo Agocs <[email protected]> | 2015-12-06 12:41:44 +0000 |
commit | 9aa21b66d59945ed5551e7d4d25af2f914f1cc99 (patch) | |
tree | c6f9bc375e44132fe3f55ed38ec9fc2b96943e93 | |
parent | ece0924b856c905ce54e97446ea24d7c89a61746 (diff) |
Change-Id: Ie988518e9411d9c704e8616dbb513ef7ffc0abb3
Reviewed-by: Laszlo Agocs <[email protected]>
-rw-r--r-- | README.md | 8 | ||||
-rw-r--r-- | src/sensehat/qsensehatsensors.cpp | 15 |
2 files changed, 17 insertions, 6 deletions
@@ -63,9 +63,5 @@ Sensors example: return app.exec(); } -Raspbian's default calibration from /etc is picked up automatically, similarly to the -Python lib. Note however that this is a text file and numbers may not be parsable with -locale settings that use a decimal separator other than the dot. If the orientation data -is invalid, check this first. - -Orientation is converted to degrees in range 0..360. Other values are reported as-is. +Raspbian's default calibration from /etc is picked up automatically, similarly to the Python +lib. Orientation is converted to degrees in range 0..360. Other values are reported as-is. diff --git a/src/sensehat/qsensehatsensors.cpp b/src/sensehat/qsensehatsensors.cpp index 0baafef..ff52efd 100644 --- a/src/sensehat/qsensehatsensors.cpp +++ b/src/sensehat/qsensehatsensors.cpp @@ -81,6 +81,20 @@ public: QVector3D orientation; }; +class CLocale +{ +public: + CLocale() { + oldLoc = QByteArray(setlocale(LC_ALL, 0)); + setlocale(LC_ALL, "C"); + } + ~CLocale() { + setlocale(LC_ALL, oldLoc.constData()); + } +private: + QByteArray oldLoc; +}; + QSenseHatSensorsPrivate::~QSenseHatSensorsPrivate() { delete rtpressure; @@ -91,6 +105,7 @@ QSenseHatSensorsPrivate::~QSenseHatSensorsPrivate() void QSenseHatSensorsPrivate::open() { + CLocale c; // to avoid decimal separator trouble in the ini file const QString configFileName = QStringLiteral("RTIMULib.ini"); const QString defaultConfig = QStringLiteral("/etc/") + configFileName; const QString writableConfigDir = QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + QStringLiteral("/sense_hat"); |