Skip to content

Commit

Permalink
examples: sensors: Add moisture support
Browse files Browse the repository at this point in the history
Signed-off-by: Alistair Francis <[email protected]>
  • Loading branch information
alistair23 committed Nov 14, 2024
1 parent 818397e commit 0cb891f
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions examples/sensors/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include <libtock-sync/sensors/ambient_light.h>
#include <libtock-sync/sensors/humidity.h>
#include <libtock-sync/sensors/moisture.h>
#include <libtock-sync/sensors/ninedof.h>
#include <libtock-sync/sensors/proximity.h>
#include <libtock-sync/sensors/sound_pressure.h>
Expand All @@ -20,12 +21,14 @@ static bool ninedof_mag = false;
static bool ninedof_gyro = false;
static bool proximity = false;
static bool sound_pressure = false;
static bool moisture = false;
static void alarm_cb(__attribute__ ((unused)) uint32_t now,
__attribute__ ((unused)) uint32_t scheduled,
__attribute__ ((unused)) void* opaque) {
int lite = 0;
int temp = 0;
int humi = 0;
int mois = 0;
int ninedof_accel_x = 0, ninedof_accel_y = 0, ninedof_accel_z = 0;
int ninedof_magneto_x = 0, ninedof_magneto_y = 0, ninedof_magneto_z = 0;
int ninedof_gyro_x = 0, ninedof_gyro_y = 0, ninedof_gyro_z = 0;
Expand All @@ -41,6 +44,7 @@ static void alarm_cb(__attribute__ ((unused)) uint32_t now,
if (ninedof_gyro) libtocksync_ninedof_read_gyroscope(&ninedof_gyro_x, &ninedof_gyro_y, &ninedof_gyro_z);
if (proximity) libtocksync_proximity_read(&prox_reading);
if (sound_pressure) libtocksync_sound_pressure_read(&sound_pressure_reading);
if (moisture) libtocksync_moisture_read(&mois);

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

/* *INDENT-ON* */

Expand All @@ -68,6 +73,7 @@ int main(void) {
ninedof = libtock_ninedof_exists();
proximity = libtock_proximity_exists();
sound_pressure = libtock_sound_pressure_exists();
moisture = libtock_moisture_exists();
/* *INDENT-ON* */

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

if (sound_pressure) {
Expand Down

0 comments on commit 0cb891f

Please sign in to comment.