mirror of
https://github.com/eclipse/upm.git
synced 2025-03-26 10:20:01 +03:00
examples: Cleaned up C examples.
This commit cleans up multiple items with the UPM C example source. * Switch from usleep and sleep to upm_delay* methods * Include a mraa_init and check return value prior to using sensor * All example mains now return * Added include for mraa.h and upm_utilites.h to all examples * Reformatted/removed tabs * Updated author line for the examples I wrote Signed-off-by: Noel Eck <noel.eck@intel.com>
This commit is contained in:
parent
2ccdc3e673
commit
324af8fc92
@ -7,8 +7,17 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include "a110x.h"
|
#include "a110x.h"
|
||||||
|
|
||||||
|
#include "upm_utilities.h"
|
||||||
|
#include "mraa.h"
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
if (mraa_init() != MRAA_SUCCESS)
|
||||||
|
{
|
||||||
|
perror("Failed to initialize mraa\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
a110x_context dev = a110x_init(2);
|
a110x_context dev = a110x_init(2);
|
||||||
bool abc = 0;
|
bool abc = 0;
|
||||||
while(1){
|
while(1){
|
||||||
|
@ -26,6 +26,8 @@
|
|||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
|
||||||
#include "bh1750.h"
|
#include "bh1750.h"
|
||||||
|
#include "upm_utilities.h"
|
||||||
|
#include "mraa.h"
|
||||||
|
|
||||||
bool shouldRun = true;
|
bool shouldRun = true;
|
||||||
|
|
||||||
@ -37,6 +39,12 @@ void sig_handler(int signo)
|
|||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
if (mraa_init() != MRAA_SUCCESS)
|
||||||
|
{
|
||||||
|
perror("Failed to initialize mraa\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
signal(SIGINT, sig_handler);
|
signal(SIGINT, sig_handler);
|
||||||
|
|
||||||
//! [Interesting]
|
//! [Interesting]
|
||||||
@ -62,7 +70,7 @@ int main()
|
|||||||
|
|
||||||
bh1750_get_lux(sensor, &lux);
|
bh1750_get_lux(sensor, &lux);
|
||||||
printf("Detected Light Level (lux): %f\n", lux);
|
printf("Detected Light Level (lux): %f\n", lux);
|
||||||
sleep(1);
|
upm_delay(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
//! [Interesting]
|
//! [Interesting]
|
||||||
|
@ -7,8 +7,17 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include "collision.h"
|
#include "collision.h"
|
||||||
|
|
||||||
|
#include "upm_utilities.h"
|
||||||
|
#include "mraa.h"
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
if (mraa_init() != MRAA_SUCCESS)
|
||||||
|
{
|
||||||
|
perror("Failed to initialize mraa\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
collision_context dev = collision_init(2);
|
collision_context dev = collision_init(2);
|
||||||
bool abc = 0;
|
bool abc = 0;
|
||||||
while(1){
|
while(1){
|
||||||
|
@ -26,6 +26,8 @@
|
|||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
|
||||||
#include "dfrec.h"
|
#include "dfrec.h"
|
||||||
|
#include "upm_utilities.h"
|
||||||
|
#include "mraa.h"
|
||||||
|
|
||||||
bool shouldRun = true;
|
bool shouldRun = true;
|
||||||
|
|
||||||
@ -37,6 +39,12 @@ void sig_handler(int signo)
|
|||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
{
|
||||||
|
if (mraa_init() != MRAA_SUCCESS)
|
||||||
|
perror("Failed to initialize mraa\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
signal(SIGINT, sig_handler);
|
signal(SIGINT, sig_handler);
|
||||||
|
|
||||||
//! [Interesting]
|
//! [Interesting]
|
||||||
@ -63,7 +71,7 @@ int main()
|
|||||||
dfrec_get_volts(sensor), dfrec_get_temperature(sensor));
|
dfrec_get_volts(sensor), dfrec_get_temperature(sensor));
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
||||||
sleep(2);
|
upm_delay(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
//! [Interesting]
|
//! [Interesting]
|
||||||
|
@ -26,6 +26,8 @@
|
|||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
|
||||||
#include "dfrorp.h"
|
#include "dfrorp.h"
|
||||||
|
#include "upm_utilities.h"
|
||||||
|
#include "mraa.h"
|
||||||
|
|
||||||
bool shouldRun = true;
|
bool shouldRun = true;
|
||||||
|
|
||||||
@ -37,6 +39,12 @@ void sig_handler(int signo)
|
|||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
if (mraa_init() != MRAA_SUCCESS)
|
||||||
|
{
|
||||||
|
perror("Failed to initialize mraa\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
signal(SIGINT, sig_handler);
|
signal(SIGINT, sig_handler);
|
||||||
|
|
||||||
//! [Interesting]
|
//! [Interesting]
|
||||||
@ -73,7 +81,7 @@ int main()
|
|||||||
|
|
||||||
printf("ORP = %f mV\n", dfrorp_get_orp(sensor));
|
printf("ORP = %f mV\n", dfrorp_get_orp(sensor));
|
||||||
|
|
||||||
sleep(1);
|
upm_delay(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
//! [Interesting]
|
//! [Interesting]
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Author: Jon Trulson <jtrulson@ics.com>
|
* Author: Noel Eck <noel.eck@intel.com>
|
||||||
* Copyright (c) 2016 Intel Corporation.
|
* Copyright (c) 2016 Intel Corporation.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
@ -26,6 +26,8 @@
|
|||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
|
||||||
#include "dfrph.h"
|
#include "dfrph.h"
|
||||||
|
#include "upm_utilities.h"
|
||||||
|
#include "mraa.h"
|
||||||
|
|
||||||
bool shouldRun = true;
|
bool shouldRun = true;
|
||||||
|
|
||||||
@ -37,6 +39,12 @@ void sig_handler(int signo)
|
|||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
if (mraa_init() != MRAA_SUCCESS)
|
||||||
|
{
|
||||||
|
perror("Failed to initialize mraa\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
signal(SIGINT, sig_handler);
|
signal(SIGINT, sig_handler);
|
||||||
|
|
||||||
//! [Interesting]
|
//! [Interesting]
|
||||||
@ -61,7 +69,7 @@ int main()
|
|||||||
printf("Detected volts: %0.03f\n", volts);
|
printf("Detected volts: %0.03f\n", volts);
|
||||||
printf("pH value: %0.03f\n", pH);
|
printf("pH value: %0.03f\n", pH);
|
||||||
|
|
||||||
usleep(500000);
|
upm_delay_ms(500);
|
||||||
}
|
}
|
||||||
|
|
||||||
//! [Interesting]
|
//! [Interesting]
|
||||||
|
@ -27,6 +27,8 @@
|
|||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
|
||||||
#include "ds18b20.h"
|
#include "ds18b20.h"
|
||||||
|
#include "upm_utilities.h"
|
||||||
|
#include "mraa.h"
|
||||||
|
|
||||||
bool shouldRun = true;
|
bool shouldRun = true;
|
||||||
|
|
||||||
@ -38,6 +40,12 @@ void sig_handler(int signo)
|
|||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
if (mraa_init() != MRAA_SUCCESS)
|
||||||
|
{
|
||||||
|
perror("Failed to initialize mraa\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
signal(SIGINT, sig_handler);
|
signal(SIGINT, sig_handler);
|
||||||
|
|
||||||
//! [Interesting]
|
//! [Interesting]
|
||||||
@ -69,7 +77,7 @@ int main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
||||||
sleep(2);
|
upm_delay(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("Exiting...\n");
|
printf("Exiting...\n");
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Author: Jon Trulson <jtrulson@ics.com>
|
* Author: Noel Eck <noel.eck@intel.com>
|
||||||
* Copyright (c) 2016 Intel Corporation.
|
* Copyright (c) 2016 Intel Corporation.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
@ -26,6 +26,8 @@
|
|||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
|
||||||
#include "emg.h"
|
#include "emg.h"
|
||||||
|
#include "upm_utilities.h"
|
||||||
|
#include "mraa.h"
|
||||||
|
|
||||||
bool shouldRun = true;
|
bool shouldRun = true;
|
||||||
|
|
||||||
@ -37,6 +39,12 @@ void sig_handler(int signo)
|
|||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
if (mraa_init() != MRAA_SUCCESS)
|
||||||
|
{
|
||||||
|
perror("Failed to initialize mraa\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
signal(SIGINT, sig_handler);
|
signal(SIGINT, sig_handler);
|
||||||
|
|
||||||
//! [Interesting]
|
//! [Interesting]
|
||||||
@ -73,7 +81,7 @@ int main()
|
|||||||
printf("Normalized output: %0.03f, raw emg sensor output: %0.03f v "
|
printf("Normalized output: %0.03f, raw emg sensor output: %0.03f v "
|
||||||
"adjusted output: %0.03f v\n", normalized, raw_volts, volts);
|
"adjusted output: %0.03f v\n", normalized, raw_volts, volts);
|
||||||
|
|
||||||
usleep(500000);
|
upm_delay_ms(500);
|
||||||
}
|
}
|
||||||
|
|
||||||
//! [Interesting]
|
//! [Interesting]
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Author: Jon Trulson <jtrulson@ics.com>
|
* Author: Noel Eck <noel.eck@intel.com>
|
||||||
* Copyright (c) 2016 Intel Corporation.
|
* Copyright (c) 2016 Intel Corporation.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
@ -26,6 +26,8 @@
|
|||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
|
||||||
#include "flex.h"
|
#include "flex.h"
|
||||||
|
#include "upm_utilities.h"
|
||||||
|
#include "mraa.h"
|
||||||
|
|
||||||
bool shouldRun = true;
|
bool shouldRun = true;
|
||||||
|
|
||||||
@ -37,6 +39,12 @@ void sig_handler(int signo)
|
|||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
if (mraa_init() != MRAA_SUCCESS)
|
||||||
|
{
|
||||||
|
perror("Failed to initialize mraa\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
signal(SIGINT, sig_handler);
|
signal(SIGINT, sig_handler);
|
||||||
|
|
||||||
//! [Interesting]
|
//! [Interesting]
|
||||||
@ -73,7 +81,7 @@ int main()
|
|||||||
printf("Normalized output: %0.03f, raw flex sensor output: %0.03f v "
|
printf("Normalized output: %0.03f, raw flex sensor output: %0.03f v "
|
||||||
"adjusted output: %0.03f v\n", normalized, raw_volts, volts);
|
"adjusted output: %0.03f v\n", normalized, raw_volts, volts);
|
||||||
|
|
||||||
usleep(500000);
|
upm_delay_ms(500);
|
||||||
}
|
}
|
||||||
|
|
||||||
//! [Interesting]
|
//! [Interesting]
|
||||||
|
@ -7,8 +7,17 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include "gp2y0a.h"
|
#include "gp2y0a.h"
|
||||||
|
|
||||||
|
#include "upm_utilities.h"
|
||||||
|
#include "mraa.h"
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
if (mraa_init() != MRAA_SUCCESS)
|
||||||
|
{
|
||||||
|
perror("Failed to initialize mraa\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
gp2y0a_context dev = gp2y0a_init(14, 5.0);
|
gp2y0a_context dev = gp2y0a_init(14, 5.0);
|
||||||
float val;
|
float val;
|
||||||
while(1){
|
while(1){
|
||||||
|
@ -7,8 +7,17 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include "grovemoisture.h"
|
#include "grovemoisture.h"
|
||||||
|
|
||||||
|
#include "upm_utilities.h"
|
||||||
|
#include "mraa.h"
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
if (mraa_init() != MRAA_SUCCESS)
|
||||||
|
{
|
||||||
|
perror("Failed to initialize mraa\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
grovemoisture_context dev = grovemoisture_init(14);
|
grovemoisture_context dev = grovemoisture_init(14);
|
||||||
int val;
|
int val;
|
||||||
while(1){
|
while(1){
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Author: Jon Trulson <jtrulson@ics.com>
|
* Author: Noel Eck <noel.eck@intel.com>
|
||||||
* Copyright (c) 2016 Intel Corporation.
|
* Copyright (c) 2016 Intel Corporation.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
@ -26,6 +26,8 @@
|
|||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
|
||||||
#include "gsr.h"
|
#include "gsr.h"
|
||||||
|
#include "upm_utilities.h"
|
||||||
|
#include "mraa.h"
|
||||||
|
|
||||||
bool shouldRun = true;
|
bool shouldRun = true;
|
||||||
|
|
||||||
@ -37,6 +39,12 @@ void sig_handler(int signo)
|
|||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
if (mraa_init() != MRAA_SUCCESS)
|
||||||
|
{
|
||||||
|
perror("Failed to initialize mraa\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
signal(SIGINT, sig_handler);
|
signal(SIGINT, sig_handler);
|
||||||
|
|
||||||
//! [Interesting]
|
//! [Interesting]
|
||||||
@ -73,7 +81,7 @@ int main()
|
|||||||
printf("Normalized output: %0.03f, raw gsr sensor output: %0.03f v "
|
printf("Normalized output: %0.03f, raw gsr sensor output: %0.03f v "
|
||||||
"adjusted output: %0.03f v\n", normalized, raw_volts, volts);
|
"adjusted output: %0.03f v\n", normalized, raw_volts, volts);
|
||||||
|
|
||||||
usleep(500000);
|
upm_delay_ms(500);
|
||||||
}
|
}
|
||||||
|
|
||||||
//! [Interesting]
|
//! [Interesting]
|
||||||
|
@ -26,6 +26,8 @@
|
|||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
|
||||||
#include "hka5.h"
|
#include "hka5.h"
|
||||||
|
#include "upm_utilities.h"
|
||||||
|
#include "mraa.h"
|
||||||
|
|
||||||
bool shouldRun = true;
|
bool shouldRun = true;
|
||||||
|
|
||||||
@ -37,6 +39,12 @@ void sig_handler(int signo)
|
|||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
if (mraa_init() != MRAA_SUCCESS)
|
||||||
|
{
|
||||||
|
perror("Failed to initialize mraa\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
signal(SIGINT, sig_handler);
|
signal(SIGINT, sig_handler);
|
||||||
|
|
||||||
//! [Interesting]
|
//! [Interesting]
|
||||||
@ -65,7 +73,7 @@ int main()
|
|||||||
printf("PM 10 : %d ug/m3\n", hka5_get_pm10(sensor));
|
printf("PM 10 : %d ug/m3\n", hka5_get_pm10(sensor));
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
||||||
sleep(2);
|
upm_delay(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
//! [Interesting]
|
//! [Interesting]
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Author: Jon Trulson <jtrulson@ics.com>
|
* Author: Noel Eck <noel.eck@intel.com>
|
||||||
* Copyright (c) 2016 Intel Corporation.
|
* Copyright (c) 2016 Intel Corporation.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
@ -26,6 +26,9 @@
|
|||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
|
||||||
#include "joystick12.h"
|
#include "joystick12.h"
|
||||||
|
#include "upm_utilities.h"
|
||||||
|
#include "mraa.h"
|
||||||
|
|
||||||
|
|
||||||
bool shouldRun = true;
|
bool shouldRun = true;
|
||||||
|
|
||||||
@ -37,6 +40,12 @@ void sig_handler(int signo)
|
|||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
if (mraa_init() != MRAA_SUCCESS)
|
||||||
|
{
|
||||||
|
perror("Failed to initialize mraa\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
signal(SIGINT, sig_handler);
|
signal(SIGINT, sig_handler);
|
||||||
|
|
||||||
//! [Interesting]
|
//! [Interesting]
|
||||||
@ -73,7 +82,7 @@ int main()
|
|||||||
joystick12_get_value_y(sensor, &y);
|
joystick12_get_value_y(sensor, &y);
|
||||||
|
|
||||||
printf("X: %5.02f Y: %5.02f\n", x, y);
|
printf("X: %5.02f Y: %5.02f\n", x, y);
|
||||||
usleep(500000);
|
upm_delay_ms(500);
|
||||||
}
|
}
|
||||||
|
|
||||||
//! [Interesting]
|
//! [Interesting]
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Author: Jon Trulson <jtrulson@ics.com>
|
* Author: Noel Eck <noel.eck@intel.com>
|
||||||
* Copyright (c) 2016 Intel Corporation.
|
* Copyright (c) 2016 Intel Corporation.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
@ -26,6 +26,8 @@
|
|||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
|
||||||
#include "ldt0028.h"
|
#include "ldt0028.h"
|
||||||
|
#include "upm_utilities.h"
|
||||||
|
#include "mraa.h"
|
||||||
|
|
||||||
bool shouldRun = true;
|
bool shouldRun = true;
|
||||||
|
|
||||||
@ -37,6 +39,12 @@ void sig_handler(int signo)
|
|||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
if (mraa_init() != MRAA_SUCCESS)
|
||||||
|
{
|
||||||
|
perror("Failed to initialize mraa\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
signal(SIGINT, sig_handler);
|
signal(SIGINT, sig_handler);
|
||||||
|
|
||||||
//! [Interesting]
|
//! [Interesting]
|
||||||
@ -82,7 +90,7 @@ int main()
|
|||||||
"adjusted output: %0.03f v\n\n", normalized, raw_volts, volts);
|
"adjusted output: %0.03f v\n\n", normalized, raw_volts, volts);
|
||||||
}
|
}
|
||||||
|
|
||||||
usleep(50000);
|
upm_delay_ms(500);
|
||||||
}
|
}
|
||||||
|
|
||||||
//! [Interesting]
|
//! [Interesting]
|
||||||
|
@ -7,8 +7,17 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include "led.h"
|
#include "led.h"
|
||||||
|
|
||||||
void main(void)
|
#include "upm_utilities.h"
|
||||||
|
#include "mraa.h"
|
||||||
|
|
||||||
|
int main(void)
|
||||||
{
|
{
|
||||||
|
if (mraa_init() != MRAA_SUCCESS)
|
||||||
|
{
|
||||||
|
perror("Failed to initialize mraa\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
led_context dev = led_init(2);
|
led_context dev = led_init(2);
|
||||||
while(1){
|
while(1){
|
||||||
if(led_on(dev) != UPM_SUCCESS){
|
if(led_on(dev) != UPM_SUCCESS){
|
||||||
@ -21,4 +30,5 @@ void main(void)
|
|||||||
upm_delay(1);
|
upm_delay(1);
|
||||||
}
|
}
|
||||||
led_close(dev);
|
led_close(dev);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Author: Jon Trulson <jtrulson@ics.com>
|
* Author: Noel Eck <noel.eck@intel.com>
|
||||||
* Copyright (c) 2016 Intel Corporation.
|
* Copyright (c) 2016 Intel Corporation.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
@ -26,6 +26,8 @@
|
|||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
|
||||||
#include "light.h"
|
#include "light.h"
|
||||||
|
#include "upm_utilities.h"
|
||||||
|
#include "mraa.h"
|
||||||
|
|
||||||
bool shouldRun = true;
|
bool shouldRun = true;
|
||||||
|
|
||||||
@ -37,6 +39,12 @@ void sig_handler(int signo)
|
|||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
if (mraa_init() != MRAA_SUCCESS)
|
||||||
|
{
|
||||||
|
perror("Failed to initialize mraa\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
signal(SIGINT, sig_handler);
|
signal(SIGINT, sig_handler);
|
||||||
|
|
||||||
//! [Interesting]
|
//! [Interesting]
|
||||||
@ -73,7 +81,7 @@ int main()
|
|||||||
printf("Normalized output: %0.03f, raw light sensor output: %0.03f v "
|
printf("Normalized output: %0.03f, raw light sensor output: %0.03f v "
|
||||||
"light output: %0.03f lux\n", normalized, raw_volts, lux);
|
"light output: %0.03f lux\n", normalized, raw_volts, lux);
|
||||||
|
|
||||||
usleep(500000);
|
upm_delay_ms(500);
|
||||||
}
|
}
|
||||||
|
|
||||||
//! [Interesting]
|
//! [Interesting]
|
||||||
|
@ -7,8 +7,17 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include "loudness.h"
|
#include "loudness.h"
|
||||||
|
|
||||||
|
#include "upm_utilities.h"
|
||||||
|
#include "mraa.h"
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
if (mraa_init() != MRAA_SUCCESS)
|
||||||
|
{
|
||||||
|
perror("Failed to initialize mraa\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
loudness_context dev = loudness_init(14);
|
loudness_context dev = loudness_init(14);
|
||||||
int val;
|
int val;
|
||||||
while(1){
|
while(1){
|
||||||
|
@ -5,8 +5,17 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include "m24lr64e.h"
|
#include "m24lr64e.h"
|
||||||
|
|
||||||
|
#include "upm_utilities.h"
|
||||||
|
#include "mraa.h"
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
if (mraa_init() != MRAA_SUCCESS)
|
||||||
|
{
|
||||||
|
perror("Failed to initialize mraa\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
m24lr64e_context dev = m24lr64e_init(0, M24LR64E_USER_MODE);
|
m24lr64e_context dev = m24lr64e_init(0, M24LR64E_USER_MODE);
|
||||||
int addr = M24LR64E_EEPROM_I2C_LENGTH-1;
|
int addr = M24LR64E_EEPROM_I2C_LENGTH-1;
|
||||||
printf("address being accessed: %d\n", addr);
|
printf("address being accessed: %d\n", addr);
|
||||||
|
@ -26,6 +26,8 @@
|
|||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
|
||||||
#include "mma7361.h"
|
#include "mma7361.h"
|
||||||
|
#include "upm_utilities.h"
|
||||||
|
#include "mraa.h"
|
||||||
|
|
||||||
bool shouldRun = true;
|
bool shouldRun = true;
|
||||||
|
|
||||||
@ -37,6 +39,12 @@ void sig_handler(int signo)
|
|||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
if (mraa_init() != MRAA_SUCCESS)
|
||||||
|
{
|
||||||
|
perror("Failed to initialize mraa\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
signal(SIGINT, sig_handler);
|
signal(SIGINT, sig_handler);
|
||||||
|
|
||||||
//! [Interesting]
|
//! [Interesting]
|
||||||
@ -72,7 +80,7 @@ int main()
|
|||||||
printf("Volts x = %f y = %f z = %f\n\n",
|
printf("Volts x = %f y = %f z = %f\n\n",
|
||||||
x, y, z);
|
x, y, z);
|
||||||
|
|
||||||
usleep(100000);
|
upm_delay_ms(500);
|
||||||
}
|
}
|
||||||
|
|
||||||
//! [Interesting]
|
//! [Interesting]
|
||||||
|
@ -7,8 +7,17 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include "moisture.h"
|
#include "moisture.h"
|
||||||
|
|
||||||
|
#include "upm_utilities.h"
|
||||||
|
#include "mraa.h"
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
if (mraa_init() != MRAA_SUCCESS)
|
||||||
|
{
|
||||||
|
perror("Failed to initialize mraa\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
moisture_context dev = moisture_init(14);
|
moisture_context dev = moisture_init(14);
|
||||||
int val;
|
int val;
|
||||||
while(1){
|
while(1){
|
||||||
@ -22,4 +31,3 @@ int main()
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,8 +7,17 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include "mpr121.h"
|
#include "mpr121.h"
|
||||||
|
|
||||||
|
#include "upm_utilities.h"
|
||||||
|
#include "mraa.h"
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
if (mraa_init() != MRAA_SUCCESS)
|
||||||
|
{
|
||||||
|
perror("Failed to initialize mraa\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
mpr121_context dev = mpr121_init(MPR121_I2C_BUS, MPR121_DEFAULT_I2C_ADDR);
|
mpr121_context dev = mpr121_init(MPR121_I2C_BUS, MPR121_DEFAULT_I2C_ADDR);
|
||||||
|
|
||||||
if(mpr121_config_an3944(dev) != UPM_SUCCESS){
|
if(mpr121_config_an3944(dev) != UPM_SUCCESS){
|
||||||
|
@ -7,7 +7,16 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include "mq303a.h"
|
#include "mq303a.h"
|
||||||
|
|
||||||
|
#include "upm_utilities.h"
|
||||||
|
#include "mraa.h"
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
|
if (mraa_init() != MRAA_SUCCESS)
|
||||||
|
{
|
||||||
|
perror("Failed to initialize mraa\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* --------- MQ303A EXAMPLE -------- */
|
/* --------- MQ303A EXAMPLE -------- */
|
||||||
mq303a_context dev = mq303a_init(0, 15);
|
mq303a_context dev = mq303a_init(0, 15);
|
||||||
@ -23,4 +32,3 @@ int main() {
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Author: Jon Trulson <jtrulson@ics.com>
|
* Author: Noel Eck <noel.eck@intel.com>
|
||||||
* Copyright (c) 2016 Intel Corporation.
|
* Copyright (c) 2016 Intel Corporation.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
@ -26,6 +26,8 @@
|
|||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
|
||||||
#include "mqx.h"
|
#include "mqx.h"
|
||||||
|
#include "upm_utilities.h"
|
||||||
|
#include "mraa.h"
|
||||||
|
|
||||||
bool shouldRun = true;
|
bool shouldRun = true;
|
||||||
|
|
||||||
@ -37,6 +39,12 @@ void sig_handler(int signo)
|
|||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
if (mraa_init() != MRAA_SUCCESS)
|
||||||
|
{
|
||||||
|
perror("Failed to initialize mraa\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
signal(SIGINT, sig_handler);
|
signal(SIGINT, sig_handler);
|
||||||
|
|
||||||
//! [Interesting]
|
//! [Interesting]
|
||||||
@ -73,7 +81,7 @@ int main()
|
|||||||
printf("Normalized output: %0.03f, raw mqx sensor output: %0.03f v "
|
printf("Normalized output: %0.03f, raw mqx sensor output: %0.03f v "
|
||||||
"adjusted output: %0.03f v\n", normalized, raw_volts, volts);
|
"adjusted output: %0.03f v\n", normalized, raw_volts, volts);
|
||||||
|
|
||||||
usleep(500000);
|
upm_delay_ms(500);
|
||||||
}
|
}
|
||||||
|
|
||||||
//! [Interesting]
|
//! [Interesting]
|
||||||
|
@ -26,6 +26,8 @@
|
|||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
|
||||||
#include "nmea_gps.h"
|
#include "nmea_gps.h"
|
||||||
|
#include "upm_utilities.h"
|
||||||
|
#include "mraa.h"
|
||||||
|
|
||||||
bool shouldRun = true;
|
bool shouldRun = true;
|
||||||
|
|
||||||
@ -39,6 +41,12 @@ void sig_handler(int signo)
|
|||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
if (mraa_init() != MRAA_SUCCESS)
|
||||||
|
{
|
||||||
|
perror("Failed to initialize mraa\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
signal(SIGINT, sig_handler);
|
signal(SIGINT, sig_handler);
|
||||||
|
|
||||||
//! [Interesting]
|
//! [Interesting]
|
||||||
|
@ -26,6 +26,8 @@
|
|||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
|
||||||
#include "nmea_gps.h"
|
#include "nmea_gps.h"
|
||||||
|
#include "upm_utilities.h"
|
||||||
|
#include "mraa.h"
|
||||||
|
|
||||||
bool shouldRun = true;
|
bool shouldRun = true;
|
||||||
|
|
||||||
@ -39,6 +41,12 @@ void sig_handler(int signo)
|
|||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
if (mraa_init() != MRAA_SUCCESS)
|
||||||
|
{
|
||||||
|
perror("Failed to initialize mraa\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
signal(SIGINT, sig_handler);
|
signal(SIGINT, sig_handler);
|
||||||
|
|
||||||
//! [Interesting]
|
//! [Interesting]
|
||||||
@ -60,7 +68,7 @@ int main()
|
|||||||
while (shouldRun)
|
while (shouldRun)
|
||||||
{
|
{
|
||||||
if (!nmea_gps_data_available(sensor, 0))
|
if (!nmea_gps_data_available(sensor, 0))
|
||||||
usleep(100);
|
upm_delay_ms(500);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ((rv = nmea_gps_read(sensor, buffer, bufferLength)) >= 0)
|
if ((rv = nmea_gps_read(sensor, buffer, bufferLength)) >= 0)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Author: Jon Trulson <jtrulson@ics.com>
|
* Author: Noel Eck <noel.eck@intel.com>
|
||||||
* Copyright (c) 2016 Intel Corporation.
|
* Copyright (c) 2016 Intel Corporation.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
@ -26,6 +26,8 @@
|
|||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
|
||||||
#include "o2.h"
|
#include "o2.h"
|
||||||
|
#include "upm_utilities.h"
|
||||||
|
#include "mraa.h"
|
||||||
|
|
||||||
bool shouldRun = true;
|
bool shouldRun = true;
|
||||||
|
|
||||||
@ -37,6 +39,12 @@ void sig_handler(int signo)
|
|||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
if (mraa_init() != MRAA_SUCCESS)
|
||||||
|
{
|
||||||
|
perror("Failed to initialize mraa\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
signal(SIGINT, sig_handler);
|
signal(SIGINT, sig_handler);
|
||||||
|
|
||||||
//! [Interesting]
|
//! [Interesting]
|
||||||
@ -62,7 +70,7 @@ int main()
|
|||||||
printf("O2 raw volts: %0.03f v, o2: %0.03f %%\n",
|
printf("O2 raw volts: %0.03f v, o2: %0.03f %%\n",
|
||||||
raw_volts, o2_percent);
|
raw_volts, o2_percent);
|
||||||
|
|
||||||
usleep(500000);
|
upm_delay_ms(500);
|
||||||
}
|
}
|
||||||
|
|
||||||
//! [Interesting]
|
//! [Interesting]
|
||||||
|
@ -7,8 +7,17 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include "es08a.c"
|
#include "es08a.c"
|
||||||
|
|
||||||
|
#include "upm_utilities.h"
|
||||||
|
#include "mraa.h"
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
if (mraa_init() != MRAA_SUCCESS)
|
||||||
|
{
|
||||||
|
perror("Failed to initialize mraa\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
es08a_context dev = es08a_init(3, ES08A_MIN_PULSE_WIDTH, ES08A_MAX_PULSE_WIDTH);
|
es08a_context dev = es08a_init(3, ES08A_MIN_PULSE_WIDTH, ES08A_MAX_PULSE_WIDTH);
|
||||||
if(dev == NULL){
|
if(dev == NULL){
|
||||||
printf("unable to initialize the servo context\n");
|
printf("unable to initialize the servo context\n");
|
||||||
|
@ -26,6 +26,8 @@
|
|||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
|
||||||
#include "sht1x.h"
|
#include "sht1x.h"
|
||||||
|
#include "upm_utilities.h"
|
||||||
|
#include "mraa.h"
|
||||||
|
|
||||||
bool shouldRun = true;
|
bool shouldRun = true;
|
||||||
|
|
||||||
@ -37,6 +39,12 @@ void sig_handler(int signo)
|
|||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
if (mraa_init() != MRAA_SUCCESS)
|
||||||
|
{
|
||||||
|
perror("Failed to initialize mraa\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
signal(SIGINT, sig_handler);
|
signal(SIGINT, sig_handler);
|
||||||
|
|
||||||
//! [Interesting]
|
//! [Interesting]
|
||||||
@ -64,7 +72,7 @@ int main()
|
|||||||
printf("Humidity: %f RH\n", sht1x_get_humidity(sensor));
|
printf("Humidity: %f RH\n", sht1x_get_humidity(sensor));
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
||||||
sleep(2);
|
upm_delay(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
//! [Interesting]
|
//! [Interesting]
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Author: Jon Trulson <jtrulson@ics.com>
|
* Author: Noel Eck <noel.eck@intel.com>
|
||||||
* Copyright (c) 2016 Intel Corporation.
|
* Copyright (c) 2016 Intel Corporation.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
@ -26,6 +26,8 @@
|
|||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
|
||||||
#include "slide.h"
|
#include "slide.h"
|
||||||
|
#include "upm_utilities.h"
|
||||||
|
#include "mraa.h"
|
||||||
|
|
||||||
bool shouldRun = true;
|
bool shouldRun = true;
|
||||||
|
|
||||||
@ -37,6 +39,12 @@ void sig_handler(int signo)
|
|||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
if (mraa_init() != MRAA_SUCCESS)
|
||||||
|
{
|
||||||
|
perror("Failed to initialize mraa\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
signal(SIGINT, sig_handler);
|
signal(SIGINT, sig_handler);
|
||||||
|
|
||||||
//! [Interesting]
|
//! [Interesting]
|
||||||
@ -73,7 +81,7 @@ int main()
|
|||||||
printf("Normalized output: %0.03f, raw slide sensor output: %0.03f v "
|
printf("Normalized output: %0.03f, raw slide sensor output: %0.03f v "
|
||||||
"adjusted output: %0.03f v\n", normalized, raw_volts, volts);
|
"adjusted output: %0.03f v\n", normalized, raw_volts, volts);
|
||||||
|
|
||||||
usleep(500000);
|
upm_delay_ms(500);
|
||||||
}
|
}
|
||||||
|
|
||||||
//! [Interesting]
|
//! [Interesting]
|
||||||
|
@ -7,8 +7,17 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include "tsl2561.h"
|
#include "tsl2561.h"
|
||||||
|
|
||||||
|
#include "upm_utilities.h"
|
||||||
|
#include "mraa.h"
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
if (mraa_init() != MRAA_SUCCESS)
|
||||||
|
{
|
||||||
|
perror("Failed to initialize mraa\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
tsl2561_context dev = tsl2561_init(0, TSL2561_Address, GAIN_0X, INTEGRATION_TIME1_101MS);
|
tsl2561_context dev = tsl2561_init(0, TSL2561_Address, GAIN_0X, INTEGRATION_TIME1_101MS);
|
||||||
float abc = 0;
|
float abc = 0;
|
||||||
if(tsl2561_get_lux(dev, &abc) != UPM_SUCCESS){
|
if(tsl2561_get_lux(dev, &abc) != UPM_SUCCESS){
|
||||||
|
@ -7,8 +7,17 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include "ttp223.h"
|
#include "ttp223.h"
|
||||||
|
|
||||||
|
#include "upm_utilities.h"
|
||||||
|
#include "mraa.h"
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
if (mraa_init() != MRAA_SUCCESS)
|
||||||
|
{
|
||||||
|
perror("Failed to initialize mraa\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
ttp223_context dev = ttp223_init(2);
|
ttp223_context dev = ttp223_init(2);
|
||||||
bool abc = 0;
|
bool abc = 0;
|
||||||
while(1){
|
while(1){
|
||||||
|
@ -26,6 +26,8 @@
|
|||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
|
||||||
#include "urm37.h"
|
#include "urm37.h"
|
||||||
|
#include "upm_utilities.h"
|
||||||
|
#include "mraa.h"
|
||||||
|
|
||||||
bool shouldRun = true;
|
bool shouldRun = true;
|
||||||
|
|
||||||
@ -37,6 +39,12 @@ void sig_handler(int signo)
|
|||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
if (mraa_init() != MRAA_SUCCESS)
|
||||||
|
{
|
||||||
|
perror("Failed to initialize mraa\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
signal(SIGINT, sig_handler);
|
signal(SIGINT, sig_handler);
|
||||||
|
|
||||||
//! [Interesting]
|
//! [Interesting]
|
||||||
@ -62,7 +70,7 @@ int main()
|
|||||||
|
|
||||||
urm37_get_temperature(sensor, &temperature);
|
urm37_get_temperature(sensor, &temperature);
|
||||||
printf("Temperature (C): %f\n\n", temperature);
|
printf("Temperature (C): %f\n\n", temperature);
|
||||||
usleep(500000);
|
upm_delay_ms(500);
|
||||||
}
|
}
|
||||||
|
|
||||||
//! [Interesting]
|
//! [Interesting]
|
||||||
|
@ -26,6 +26,8 @@
|
|||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
|
||||||
#include "urm37.h"
|
#include "urm37.h"
|
||||||
|
#include "upm_utilities.h"
|
||||||
|
#include "mraa.h"
|
||||||
|
|
||||||
bool shouldRun = true;
|
bool shouldRun = true;
|
||||||
|
|
||||||
@ -37,6 +39,12 @@ void sig_handler(int signo)
|
|||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
if (mraa_init() != MRAA_SUCCESS)
|
||||||
|
{
|
||||||
|
perror("Failed to initialize mraa\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
signal(SIGINT, sig_handler);
|
signal(SIGINT, sig_handler);
|
||||||
|
|
||||||
//! [Interesting]
|
//! [Interesting]
|
||||||
@ -60,7 +68,7 @@ int main()
|
|||||||
|
|
||||||
urm37_get_distance(sensor, &distance, 0);
|
urm37_get_distance(sensor, &distance, 0);
|
||||||
printf("Detected distance (cm): %f\n", distance);
|
printf("Detected distance (cm): %f\n", distance);
|
||||||
usleep(500000);
|
upm_delay_ms(500);
|
||||||
}
|
}
|
||||||
|
|
||||||
//! [Interesting]
|
//! [Interesting]
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Author: Jon Trulson <jtrulson@ics.com>
|
* Author: Noel Eck <noel.eck@intel.com>
|
||||||
* Copyright (c) 2016 Intel Corporation.
|
* Copyright (c) 2016 Intel Corporation.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
@ -26,6 +26,8 @@
|
|||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
|
||||||
#include "vdiv.h"
|
#include "vdiv.h"
|
||||||
|
#include "upm_utilities.h"
|
||||||
|
#include "mraa.h"
|
||||||
|
|
||||||
bool shouldRun = true;
|
bool shouldRun = true;
|
||||||
|
|
||||||
@ -37,6 +39,12 @@ void sig_handler(int signo)
|
|||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
if (mraa_init() != MRAA_SUCCESS)
|
||||||
|
{
|
||||||
|
perror("Failed to initialize mraa\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
signal(SIGINT, sig_handler);
|
signal(SIGINT, sig_handler);
|
||||||
|
|
||||||
//! [Interesting]
|
//! [Interesting]
|
||||||
@ -61,7 +69,7 @@ int main()
|
|||||||
printf("Divide SW: %d ADC voltage: %0.03f Sensor voltage: %0.03f\n",
|
printf("Divide SW: %d ADC voltage: %0.03f Sensor voltage: %0.03f\n",
|
||||||
vdiv_get_divsw(sensor), raw_volts, computed_volts);
|
vdiv_get_divsw(sensor), raw_volts, computed_volts);
|
||||||
|
|
||||||
usleep(500000);
|
upm_delay_ms(500);
|
||||||
}
|
}
|
||||||
|
|
||||||
//! [Interesting]
|
//! [Interesting]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user