Skip to content

Commit 0b1a550

Browse files
committed
examples: sensors: Add moisture support
Signed-off-by: Alistair Francis <[email protected]>
1 parent 4b6027e commit 0b1a550

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

examples/sensors/main.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#include <libtock-sync/sensors/ambient_light.h>
55
#include <libtock-sync/sensors/humidity.h>
6+
#include <libtock-sync/sensors/moisture.h>
67
#include <libtock-sync/sensors/ninedof.h>
78
#include <libtock-sync/sensors/proximity.h>
89
#include <libtock-sync/sensors/sound_pressure.h>
@@ -20,12 +21,14 @@ static bool ninedof_mag = false;
2021
static bool ninedof_gyro = false;
2122
static bool proximity = false;
2223
static bool sound_pressure = false;
24+
static bool moisture = false;
2325
static void alarm_cb(__attribute__ ((unused)) uint32_t now,
2426
__attribute__ ((unused)) uint32_t scheduled,
2527
__attribute__ ((unused)) void* opaque) {
2628
int lite = 0;
2729
int temp = 0;
2830
int humi = 0;
31+
int mois = 0;
2932
int ninedof_accel_x = 0, ninedof_accel_y = 0, ninedof_accel_z = 0;
3033
int ninedof_magneto_x = 0, ninedof_magneto_y = 0, ninedof_magneto_z = 0;
3134
int ninedof_gyro_x = 0, ninedof_gyro_y = 0, ninedof_gyro_z = 0;
@@ -41,6 +44,7 @@ static void alarm_cb(__attribute__ ((unused)) uint32_t now,
4144
if (ninedof_gyro) libtocksync_ninedof_read_gyroscope(&ninedof_gyro_x, &ninedof_gyro_y, &ninedof_gyro_z);
4245
if (proximity) libtocksync_proximity_read(&prox_reading);
4346
if (sound_pressure) libtocksync_sound_pressure_read(&sound_pressure_reading);
47+
if (moisture) libtocksync_moisture_read(&mois);
4448

4549
if (light) printf("Amb. Light: Light Intensity: %d\n", lite);
4650
if (temperature) printf("Temperature: %d deg C\n", temp/100);
@@ -50,6 +54,7 @@ static void alarm_cb(__attribute__ ((unused)) uint32_t now,
5054
if (ninedof_gyro) printf("Gyro: X: %d Y: %d Z: %d\n", ninedof_gyro_x, ninedof_gyro_y, ninedof_gyro_z);
5155
if (proximity) printf("Proximity: %u\n", prox_reading);
5256
if (sound_pressure) printf("Sound Pressure: %u\n", sound_pressure_reading);
57+
if (moisture) printf("Moisture: %d%%\n", mois/100);
5358

5459
/* *INDENT-ON* */
5560

@@ -68,6 +73,7 @@ int main(void) {
6873
ninedof = libtock_ninedof_exists();
6974
proximity = libtock_proximity_exists();
7075
sound_pressure = libtock_sound_pressure_exists();
76+
moisture = libtock_moisture_exists();
7177
/* *INDENT-ON* */
7278

7379
if (ninedof) {
@@ -86,6 +92,7 @@ int main(void) {
8692
if (ninedof_gyro) printf("[Sensors] Sampling Gyroscope.\n");
8793
if (proximity) printf("[Sensors] Sampling Proximity sensor.\n");
8894
if (sound_pressure) printf("[Sensors] Sampling Sound Pressure sensor.\n");
95+
if (moisture) printf("[Sensors] Sampling Moisture sensor.\n");
8996
/* *INDENT-ON* */
9097

9198
if (sound_pressure) {

0 commit comments

Comments
 (0)