solettaproject / soletta

Soletta Project is a framework for making IoT devices. With Soletta Project's libraries developers can easily write software for devices that control actuators/sensors and communicate using standard technologies. It enables adding smartness even on the smallest edge devices.
http://solettaproject.org
Apache License 2.0
225 stars 108 forks source link

iio magnetometer c sample #2338

Closed laykuanloon closed 7 years ago

laykuanloon commented 8 years ago
iio+network: iio magnetometer console and mqtt c code sample

IIO magnetometer c code sample will print sensor data in console
and also publish the sensor data through MQTT.

The sample include calibration and denoise algorithm adopt from
https://github.com/01org/android-iio-sensors-hal, and matrix-ops.c
and matrix-ops.h is straight adopt.

The calibration require to shake the sensor in figure 8 pattern.
It will print the calibrated level. UNRELIABLE=0, ACCURACY_LOW=1,
ACCURACY_MEDIUM=2, ACCURACY_HIGH = >=3.

Calibration and denoise is enabled by default. Can disable by
comment out MAGN_CALIBRATE and DENOISE_AVERAGE in the c source file.

The azimuth formula is provided by Han, He <he.han@intel.com>.
laykuanloon commented 8 years ago

@ceolin iio gyroscope sample code is in #2334. This PR #2238 is for iio magnetometer sample code. I commit iio magnetometer sample code on top of iio gyroscope sample code because the 2 sample is in the same make folder.

ceolin commented 8 years ago

@laykuanloon there are lot of places where you are comparing floats/doubles == 0 i think the correct way to do this would be use fpclassify(value) == FP_ZERO.

What do you think ?

laykuanloon commented 7 years ago

@ceolin, thanks for your input.

laykuanloon commented 7 years ago

@ceolin, please help to check the code and merge if it's ok. Thanks

ceolin commented 7 years ago

merged, thanks