mirror of
https://github.com/eclipse/upm.git
synced 2025-06-08 14:20:38 +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 "a110x.h"
|
||||
|
||||
#include "upm_utilities.h"
|
||||
#include "mraa.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
if (mraa_init() != MRAA_SUCCESS)
|
||||
{
|
||||
perror("Failed to initialize mraa\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
a110x_context dev = a110x_init(2);
|
||||
bool abc = 0;
|
||||
while(1){
|
||||
|
@ -26,6 +26,8 @@
|
||||
#include <signal.h>
|
||||
|
||||
#include "bh1750.h"
|
||||
#include "upm_utilities.h"
|
||||
#include "mraa.h"
|
||||
|
||||
bool shouldRun = true;
|
||||
|
||||
@ -37,9 +39,15 @@ void sig_handler(int signo)
|
||||
|
||||
int main()
|
||||
{
|
||||
if (mraa_init() != MRAA_SUCCESS)
|
||||
{
|
||||
perror("Failed to initialize mraa\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
signal(SIGINT, sig_handler);
|
||||
|
||||
//! [Interesting]
|
||||
//! [Interesting]
|
||||
|
||||
// Instantiate a BH1750 sensor on default I2C bus (0), using the
|
||||
// default I2C address (0x23), and setting the mode to highest
|
||||
@ -62,10 +70,10 @@ int main()
|
||||
|
||||
bh1750_get_lux(sensor, &lux);
|
||||
printf("Detected Light Level (lux): %f\n", lux);
|
||||
sleep(1);
|
||||
upm_delay(1);
|
||||
}
|
||||
|
||||
//! [Interesting]
|
||||
//! [Interesting]
|
||||
|
||||
printf("Exiting\n");
|
||||
|
||||
|
@ -7,8 +7,17 @@
|
||||
#include <unistd.h>
|
||||
#include "collision.h"
|
||||
|
||||
#include "upm_utilities.h"
|
||||
#include "mraa.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
if (mraa_init() != MRAA_SUCCESS)
|
||||
{
|
||||
perror("Failed to initialize mraa\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
collision_context dev = collision_init(2);
|
||||
bool abc = 0;
|
||||
while(1){
|
||||
|
@ -26,6 +26,8 @@
|
||||
#include <signal.h>
|
||||
|
||||
#include "dfrec.h"
|
||||
#include "upm_utilities.h"
|
||||
#include "mraa.h"
|
||||
|
||||
bool shouldRun = true;
|
||||
|
||||
@ -37,9 +39,15 @@ void sig_handler(int signo)
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
if (mraa_init() != MRAA_SUCCESS)
|
||||
perror("Failed to initialize mraa\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
signal(SIGINT, sig_handler);
|
||||
|
||||
//! [Interesting]
|
||||
//! [Interesting]
|
||||
|
||||
// Instantiate a DFRobot EC sensor on analog pin A0, with a ds18b20
|
||||
// temperature sensor connected to UART 0, and a device index (for
|
||||
@ -63,10 +71,10 @@ int main()
|
||||
dfrec_get_volts(sensor), dfrec_get_temperature(sensor));
|
||||
printf("\n");
|
||||
|
||||
sleep(2);
|
||||
upm_delay(2);
|
||||
}
|
||||
|
||||
//! [Interesting]
|
||||
//! [Interesting]
|
||||
|
||||
printf("Exiting...\n");
|
||||
|
||||
|
@ -26,6 +26,8 @@
|
||||
#include <signal.h>
|
||||
|
||||
#include "dfrorp.h"
|
||||
#include "upm_utilities.h"
|
||||
#include "mraa.h"
|
||||
|
||||
bool shouldRun = true;
|
||||
|
||||
@ -37,9 +39,15 @@ void sig_handler(int signo)
|
||||
|
||||
int main()
|
||||
{
|
||||
if (mraa_init() != MRAA_SUCCESS)
|
||||
{
|
||||
perror("Failed to initialize mraa\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
signal(SIGINT, sig_handler);
|
||||
|
||||
//! [Interesting]
|
||||
//! [Interesting]
|
||||
|
||||
// Instantiate a DFRobot ORP sensor on analog pin A0 with an analog
|
||||
// reference voltage of 5.0.
|
||||
@ -73,10 +81,10 @@ int main()
|
||||
|
||||
printf("ORP = %f mV\n", dfrorp_get_orp(sensor));
|
||||
|
||||
sleep(1);
|
||||
upm_delay(1);
|
||||
}
|
||||
|
||||
//! [Interesting]
|
||||
//! [Interesting]
|
||||
|
||||
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.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
@ -26,6 +26,8 @@
|
||||
#include <signal.h>
|
||||
|
||||
#include "dfrph.h"
|
||||
#include "upm_utilities.h"
|
||||
#include "mraa.h"
|
||||
|
||||
bool shouldRun = true;
|
||||
|
||||
@ -37,6 +39,12 @@ void sig_handler(int signo)
|
||||
|
||||
int main()
|
||||
{
|
||||
if (mraa_init() != MRAA_SUCCESS)
|
||||
{
|
||||
perror("Failed to initialize mraa\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
signal(SIGINT, sig_handler);
|
||||
|
||||
//! [Interesting]
|
||||
@ -61,7 +69,7 @@ int main()
|
||||
printf("Detected volts: %0.03f\n", volts);
|
||||
printf("pH value: %0.03f\n", pH);
|
||||
|
||||
usleep(500000);
|
||||
upm_delay_ms(500);
|
||||
}
|
||||
|
||||
//! [Interesting]
|
||||
|
@ -27,6 +27,8 @@
|
||||
#include <signal.h>
|
||||
|
||||
#include "ds18b20.h"
|
||||
#include "upm_utilities.h"
|
||||
#include "mraa.h"
|
||||
|
||||
bool shouldRun = true;
|
||||
|
||||
@ -38,9 +40,15 @@ void sig_handler(int signo)
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
if (mraa_init() != MRAA_SUCCESS)
|
||||
{
|
||||
perror("Failed to initialize mraa\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
signal(SIGINT, sig_handler);
|
||||
|
||||
//! [Interesting]
|
||||
//! [Interesting]
|
||||
|
||||
printf("Initializing...\n");
|
||||
|
||||
@ -69,13 +77,13 @@ int main(int argc, char **argv)
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
sleep(2);
|
||||
upm_delay(2);
|
||||
}
|
||||
|
||||
printf("Exiting...\n");
|
||||
|
||||
ds18b20_close(sensor);
|
||||
//! [Interesting]
|
||||
//! [Interesting]
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Author: Jon Trulson <jtrulson@ics.com>
|
||||
* Author: Noel Eck <noel.eck@intel.com>
|
||||
* Copyright (c) 2016 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
@ -26,6 +26,8 @@
|
||||
#include <signal.h>
|
||||
|
||||
#include "emg.h"
|
||||
#include "upm_utilities.h"
|
||||
#include "mraa.h"
|
||||
|
||||
bool shouldRun = true;
|
||||
|
||||
@ -37,6 +39,12 @@ void sig_handler(int signo)
|
||||
|
||||
int main()
|
||||
{
|
||||
if (mraa_init() != MRAA_SUCCESS)
|
||||
{
|
||||
perror("Failed to initialize mraa\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
signal(SIGINT, sig_handler);
|
||||
|
||||
//! [Interesting]
|
||||
@ -73,7 +81,7 @@ int main()
|
||||
printf("Normalized output: %0.03f, raw emg sensor output: %0.03f v "
|
||||
"adjusted output: %0.03f v\n", normalized, raw_volts, volts);
|
||||
|
||||
usleep(500000);
|
||||
upm_delay_ms(500);
|
||||
}
|
||||
|
||||
//! [Interesting]
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Author: Jon Trulson <jtrulson@ics.com>
|
||||
* Author: Noel Eck <noel.eck@intel.com>
|
||||
* Copyright (c) 2016 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
@ -26,6 +26,8 @@
|
||||
#include <signal.h>
|
||||
|
||||
#include "flex.h"
|
||||
#include "upm_utilities.h"
|
||||
#include "mraa.h"
|
||||
|
||||
bool shouldRun = true;
|
||||
|
||||
@ -37,6 +39,12 @@ void sig_handler(int signo)
|
||||
|
||||
int main()
|
||||
{
|
||||
if (mraa_init() != MRAA_SUCCESS)
|
||||
{
|
||||
perror("Failed to initialize mraa\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
signal(SIGINT, sig_handler);
|
||||
|
||||
//! [Interesting]
|
||||
@ -73,7 +81,7 @@ int main()
|
||||
printf("Normalized output: %0.03f, raw flex sensor output: %0.03f v "
|
||||
"adjusted output: %0.03f v\n", normalized, raw_volts, volts);
|
||||
|
||||
usleep(500000);
|
||||
upm_delay_ms(500);
|
||||
}
|
||||
|
||||
//! [Interesting]
|
||||
|
@ -7,8 +7,17 @@
|
||||
#include <unistd.h>
|
||||
#include "gp2y0a.h"
|
||||
|
||||
#include "upm_utilities.h"
|
||||
#include "mraa.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
if (mraa_init() != MRAA_SUCCESS)
|
||||
{
|
||||
perror("Failed to initialize mraa\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
gp2y0a_context dev = gp2y0a_init(14, 5.0);
|
||||
float val;
|
||||
while(1){
|
||||
|
@ -7,8 +7,17 @@
|
||||
#include <unistd.h>
|
||||
#include "grovemoisture.h"
|
||||
|
||||
#include "upm_utilities.h"
|
||||
#include "mraa.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
if (mraa_init() != MRAA_SUCCESS)
|
||||
{
|
||||
perror("Failed to initialize mraa\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
grovemoisture_context dev = grovemoisture_init(14);
|
||||
int val;
|
||||
while(1){
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Author: Jon Trulson <jtrulson@ics.com>
|
||||
* Author: Noel Eck <noel.eck@intel.com>
|
||||
* Copyright (c) 2016 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
@ -26,6 +26,8 @@
|
||||
#include <signal.h>
|
||||
|
||||
#include "gsr.h"
|
||||
#include "upm_utilities.h"
|
||||
#include "mraa.h"
|
||||
|
||||
bool shouldRun = true;
|
||||
|
||||
@ -37,6 +39,12 @@ void sig_handler(int signo)
|
||||
|
||||
int main()
|
||||
{
|
||||
if (mraa_init() != MRAA_SUCCESS)
|
||||
{
|
||||
perror("Failed to initialize mraa\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
signal(SIGINT, sig_handler);
|
||||
|
||||
//! [Interesting]
|
||||
@ -73,7 +81,7 @@ int main()
|
||||
printf("Normalized output: %0.03f, raw gsr sensor output: %0.03f v "
|
||||
"adjusted output: %0.03f v\n", normalized, raw_volts, volts);
|
||||
|
||||
usleep(500000);
|
||||
upm_delay_ms(500);
|
||||
}
|
||||
|
||||
//! [Interesting]
|
||||
|
@ -26,6 +26,8 @@
|
||||
#include <signal.h>
|
||||
|
||||
#include "hka5.h"
|
||||
#include "upm_utilities.h"
|
||||
#include "mraa.h"
|
||||
|
||||
bool shouldRun = true;
|
||||
|
||||
@ -37,9 +39,15 @@ void sig_handler(int signo)
|
||||
|
||||
int main()
|
||||
{
|
||||
if (mraa_init() != MRAA_SUCCESS)
|
||||
{
|
||||
perror("Failed to initialize mraa\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
signal(SIGINT, sig_handler);
|
||||
|
||||
//! [Interesting]
|
||||
//! [Interesting]
|
||||
|
||||
// Instantiate a HKA5 sensor on uart 0. We don't use the set or
|
||||
// reset pins, so we pass -1 for them.
|
||||
@ -65,10 +73,10 @@ int main()
|
||||
printf("PM 10 : %d ug/m3\n", hka5_get_pm10(sensor));
|
||||
printf("\n");
|
||||
|
||||
sleep(2);
|
||||
upm_delay(2);
|
||||
}
|
||||
|
||||
//! [Interesting]
|
||||
//! [Interesting]
|
||||
|
||||
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.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
@ -26,6 +26,9 @@
|
||||
#include <signal.h>
|
||||
|
||||
#include "joystick12.h"
|
||||
#include "upm_utilities.h"
|
||||
#include "mraa.h"
|
||||
|
||||
|
||||
bool shouldRun = true;
|
||||
|
||||
@ -37,6 +40,12 @@ void sig_handler(int signo)
|
||||
|
||||
int main()
|
||||
{
|
||||
if (mraa_init() != MRAA_SUCCESS)
|
||||
{
|
||||
perror("Failed to initialize mraa\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
signal(SIGINT, sig_handler);
|
||||
|
||||
//! [Interesting]
|
||||
@ -73,7 +82,7 @@ int main()
|
||||
joystick12_get_value_y(sensor, &y);
|
||||
|
||||
printf("X: %5.02f Y: %5.02f\n", x, y);
|
||||
usleep(500000);
|
||||
upm_delay_ms(500);
|
||||
}
|
||||
|
||||
//! [Interesting]
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Author: Jon Trulson <jtrulson@ics.com>
|
||||
* Author: Noel Eck <noel.eck@intel.com>
|
||||
* Copyright (c) 2016 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
@ -26,6 +26,8 @@
|
||||
#include <signal.h>
|
||||
|
||||
#include "ldt0028.h"
|
||||
#include "upm_utilities.h"
|
||||
#include "mraa.h"
|
||||
|
||||
bool shouldRun = true;
|
||||
|
||||
@ -37,6 +39,12 @@ void sig_handler(int signo)
|
||||
|
||||
int main()
|
||||
{
|
||||
if (mraa_init() != MRAA_SUCCESS)
|
||||
{
|
||||
perror("Failed to initialize mraa\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
signal(SIGINT, sig_handler);
|
||||
|
||||
//! [Interesting]
|
||||
@ -82,7 +90,7 @@ int main()
|
||||
"adjusted output: %0.03f v\n\n", normalized, raw_volts, volts);
|
||||
}
|
||||
|
||||
usleep(50000);
|
||||
upm_delay_ms(500);
|
||||
}
|
||||
|
||||
//! [Interesting]
|
||||
|
@ -7,8 +7,17 @@
|
||||
#include <unistd.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);
|
||||
while(1){
|
||||
if(led_on(dev) != UPM_SUCCESS){
|
||||
@ -21,4 +30,5 @@ void main(void)
|
||||
upm_delay(1);
|
||||
}
|
||||
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.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
@ -26,6 +26,8 @@
|
||||
#include <signal.h>
|
||||
|
||||
#include "light.h"
|
||||
#include "upm_utilities.h"
|
||||
#include "mraa.h"
|
||||
|
||||
bool shouldRun = true;
|
||||
|
||||
@ -37,6 +39,12 @@ void sig_handler(int signo)
|
||||
|
||||
int main()
|
||||
{
|
||||
if (mraa_init() != MRAA_SUCCESS)
|
||||
{
|
||||
perror("Failed to initialize mraa\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
signal(SIGINT, sig_handler);
|
||||
|
||||
//! [Interesting]
|
||||
@ -73,7 +81,7 @@ int main()
|
||||
printf("Normalized output: %0.03f, raw light sensor output: %0.03f v "
|
||||
"light output: %0.03f lux\n", normalized, raw_volts, lux);
|
||||
|
||||
usleep(500000);
|
||||
upm_delay_ms(500);
|
||||
}
|
||||
|
||||
//! [Interesting]
|
||||
|
@ -7,8 +7,17 @@
|
||||
#include <unistd.h>
|
||||
#include "loudness.h"
|
||||
|
||||
#include "upm_utilities.h"
|
||||
#include "mraa.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
if (mraa_init() != MRAA_SUCCESS)
|
||||
{
|
||||
perror("Failed to initialize mraa\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
loudness_context dev = loudness_init(14);
|
||||
int val;
|
||||
while(1){
|
||||
|
@ -5,8 +5,17 @@
|
||||
#include <unistd.h>
|
||||
#include "m24lr64e.h"
|
||||
|
||||
#include "upm_utilities.h"
|
||||
#include "mraa.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
if (mraa_init() != MRAA_SUCCESS)
|
||||
{
|
||||
perror("Failed to initialize mraa\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
m24lr64e_context dev = m24lr64e_init(0, M24LR64E_USER_MODE);
|
||||
int addr = M24LR64E_EEPROM_I2C_LENGTH-1;
|
||||
printf("address being accessed: %d\n", addr);
|
||||
|
@ -26,6 +26,8 @@
|
||||
#include <signal.h>
|
||||
|
||||
#include "mma7361.h"
|
||||
#include "upm_utilities.h"
|
||||
#include "mraa.h"
|
||||
|
||||
bool shouldRun = true;
|
||||
|
||||
@ -37,9 +39,15 @@ void sig_handler(int signo)
|
||||
|
||||
int main()
|
||||
{
|
||||
if (mraa_init() != MRAA_SUCCESS)
|
||||
{
|
||||
perror("Failed to initialize mraa\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
signal(SIGINT, sig_handler);
|
||||
|
||||
//! [Interesting]
|
||||
//! [Interesting]
|
||||
|
||||
// Instantiate a MMA7361 sensor on analog pins A0 (X), A1 (Y) A2
|
||||
// (Z), selftest pin on D2, sleep pin on D3 nd an analog reference
|
||||
@ -72,10 +80,10 @@ int main()
|
||||
printf("Volts x = %f y = %f z = %f\n\n",
|
||||
x, y, z);
|
||||
|
||||
usleep(100000);
|
||||
upm_delay_ms(500);
|
||||
}
|
||||
|
||||
//! [Interesting]
|
||||
//! [Interesting]
|
||||
|
||||
printf("Exiting...\n");
|
||||
|
||||
|
@ -7,8 +7,17 @@
|
||||
#include <unistd.h>
|
||||
#include "moisture.h"
|
||||
|
||||
#include "upm_utilities.h"
|
||||
#include "mraa.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
if (mraa_init() != MRAA_SUCCESS)
|
||||
{
|
||||
perror("Failed to initialize mraa\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
moisture_context dev = moisture_init(14);
|
||||
int val;
|
||||
while(1){
|
||||
@ -22,4 +31,3 @@ int main()
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -7,8 +7,17 @@
|
||||
#include <unistd.h>
|
||||
#include "mpr121.h"
|
||||
|
||||
#include "upm_utilities.h"
|
||||
#include "mraa.h"
|
||||
|
||||
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);
|
||||
|
||||
if(mpr121_config_an3944(dev) != UPM_SUCCESS){
|
||||
|
@ -7,7 +7,16 @@
|
||||
#include <unistd.h>
|
||||
#include "mq303a.h"
|
||||
|
||||
#include "upm_utilities.h"
|
||||
#include "mraa.h"
|
||||
|
||||
int main() {
|
||||
if (mraa_init() != MRAA_SUCCESS)
|
||||
{
|
||||
perror("Failed to initialize mraa\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
/* --------- MQ303A EXAMPLE -------- */
|
||||
mq303a_context dev = mq303a_init(0, 15);
|
||||
@ -23,4 +32,3 @@ int main() {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Author: Jon Trulson <jtrulson@ics.com>
|
||||
* Author: Noel Eck <noel.eck@intel.com>
|
||||
* Copyright (c) 2016 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
@ -26,6 +26,8 @@
|
||||
#include <signal.h>
|
||||
|
||||
#include "mqx.h"
|
||||
#include "upm_utilities.h"
|
||||
#include "mraa.h"
|
||||
|
||||
bool shouldRun = true;
|
||||
|
||||
@ -37,6 +39,12 @@ void sig_handler(int signo)
|
||||
|
||||
int main()
|
||||
{
|
||||
if (mraa_init() != MRAA_SUCCESS)
|
||||
{
|
||||
perror("Failed to initialize mraa\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
signal(SIGINT, sig_handler);
|
||||
|
||||
//! [Interesting]
|
||||
@ -73,7 +81,7 @@ int main()
|
||||
printf("Normalized output: %0.03f, raw mqx sensor output: %0.03f v "
|
||||
"adjusted output: %0.03f v\n", normalized, raw_volts, volts);
|
||||
|
||||
usleep(500000);
|
||||
upm_delay_ms(500);
|
||||
}
|
||||
|
||||
//! [Interesting]
|
||||
|
@ -26,6 +26,8 @@
|
||||
#include <signal.h>
|
||||
|
||||
#include "nmea_gps.h"
|
||||
#include "upm_utilities.h"
|
||||
#include "mraa.h"
|
||||
|
||||
bool shouldRun = true;
|
||||
|
||||
@ -39,9 +41,15 @@ void sig_handler(int signo)
|
||||
|
||||
int main()
|
||||
{
|
||||
if (mraa_init() != MRAA_SUCCESS)
|
||||
{
|
||||
perror("Failed to initialize mraa\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
signal(SIGINT, sig_handler);
|
||||
|
||||
//! [Interesting]
|
||||
//! [Interesting]
|
||||
|
||||
// Instantiate a NMEA_GPS sensor on uart 0 at 9600 baud with enable
|
||||
// pin on D3. If you do not need an enable pin, you can specify -1.
|
||||
@ -70,7 +78,7 @@ int main()
|
||||
if (shouldRun)
|
||||
printf("Timed out\n");
|
||||
|
||||
//! [Interesting]
|
||||
//! [Interesting]
|
||||
|
||||
printf("Exiting\n");
|
||||
|
||||
|
@ -26,6 +26,8 @@
|
||||
#include <signal.h>
|
||||
|
||||
#include "nmea_gps.h"
|
||||
#include "upm_utilities.h"
|
||||
#include "mraa.h"
|
||||
|
||||
bool shouldRun = true;
|
||||
|
||||
@ -39,9 +41,15 @@ void sig_handler(int signo)
|
||||
|
||||
int main()
|
||||
{
|
||||
if (mraa_init() != MRAA_SUCCESS)
|
||||
{
|
||||
perror("Failed to initialize mraa\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
signal(SIGINT, sig_handler);
|
||||
|
||||
//! [Interesting]
|
||||
//! [Interesting]
|
||||
|
||||
// Instantiate a NMEA_GPS UBLOX based i2c sensor on i2c bus 0 at
|
||||
// address 0x42
|
||||
@ -60,7 +68,7 @@ int main()
|
||||
while (shouldRun)
|
||||
{
|
||||
if (!nmea_gps_data_available(sensor, 0))
|
||||
usleep(100);
|
||||
upm_delay_ms(500);
|
||||
else
|
||||
{
|
||||
if ((rv = nmea_gps_read(sensor, buffer, bufferLength)) >= 0)
|
||||
@ -72,7 +80,7 @@ int main()
|
||||
}
|
||||
}
|
||||
|
||||
//! [Interesting]
|
||||
//! [Interesting]
|
||||
|
||||
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.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
@ -26,6 +26,8 @@
|
||||
#include <signal.h>
|
||||
|
||||
#include "o2.h"
|
||||
#include "upm_utilities.h"
|
||||
#include "mraa.h"
|
||||
|
||||
bool shouldRun = true;
|
||||
|
||||
@ -37,6 +39,12 @@ void sig_handler(int signo)
|
||||
|
||||
int main()
|
||||
{
|
||||
if (mraa_init() != MRAA_SUCCESS)
|
||||
{
|
||||
perror("Failed to initialize mraa\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
signal(SIGINT, sig_handler);
|
||||
|
||||
//! [Interesting]
|
||||
@ -62,7 +70,7 @@ int main()
|
||||
printf("O2 raw volts: %0.03f v, o2: %0.03f %%\n",
|
||||
raw_volts, o2_percent);
|
||||
|
||||
usleep(500000);
|
||||
upm_delay_ms(500);
|
||||
}
|
||||
|
||||
//! [Interesting]
|
||||
|
@ -7,8 +7,17 @@
|
||||
#include <unistd.h>
|
||||
#include "es08a.c"
|
||||
|
||||
#include "upm_utilities.h"
|
||||
#include "mraa.h"
|
||||
|
||||
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);
|
||||
if(dev == NULL){
|
||||
printf("unable to initialize the servo context\n");
|
||||
|
@ -26,6 +26,8 @@
|
||||
#include <signal.h>
|
||||
|
||||
#include "sht1x.h"
|
||||
#include "upm_utilities.h"
|
||||
#include "mraa.h"
|
||||
|
||||
bool shouldRun = true;
|
||||
|
||||
@ -37,9 +39,15 @@ void sig_handler(int signo)
|
||||
|
||||
int main()
|
||||
{
|
||||
if (mraa_init() != MRAA_SUCCESS)
|
||||
{
|
||||
perror("Failed to initialize mraa\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
signal(SIGINT, sig_handler);
|
||||
|
||||
//! [Interesting]
|
||||
//! [Interesting]
|
||||
|
||||
// Instantiate a SHT1X sensor using D2 as the clock, and D3 as the
|
||||
// data pin.
|
||||
@ -64,10 +72,10 @@ int main()
|
||||
printf("Humidity: %f RH\n", sht1x_get_humidity(sensor));
|
||||
printf("\n");
|
||||
|
||||
sleep(2);
|
||||
upm_delay(2);
|
||||
}
|
||||
|
||||
//! [Interesting]
|
||||
//! [Interesting]
|
||||
|
||||
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.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
@ -26,6 +26,8 @@
|
||||
#include <signal.h>
|
||||
|
||||
#include "slide.h"
|
||||
#include "upm_utilities.h"
|
||||
#include "mraa.h"
|
||||
|
||||
bool shouldRun = true;
|
||||
|
||||
@ -37,6 +39,12 @@ void sig_handler(int signo)
|
||||
|
||||
int main()
|
||||
{
|
||||
if (mraa_init() != MRAA_SUCCESS)
|
||||
{
|
||||
perror("Failed to initialize mraa\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
signal(SIGINT, sig_handler);
|
||||
|
||||
//! [Interesting]
|
||||
@ -73,7 +81,7 @@ int main()
|
||||
printf("Normalized output: %0.03f, raw slide sensor output: %0.03f v "
|
||||
"adjusted output: %0.03f v\n", normalized, raw_volts, volts);
|
||||
|
||||
usleep(500000);
|
||||
upm_delay_ms(500);
|
||||
}
|
||||
|
||||
//! [Interesting]
|
||||
|
@ -7,8 +7,17 @@
|
||||
#include <unistd.h>
|
||||
#include "tsl2561.h"
|
||||
|
||||
#include "upm_utilities.h"
|
||||
#include "mraa.h"
|
||||
|
||||
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);
|
||||
float abc = 0;
|
||||
if(tsl2561_get_lux(dev, &abc) != UPM_SUCCESS){
|
||||
|
@ -7,8 +7,17 @@
|
||||
#include <unistd.h>
|
||||
#include "ttp223.h"
|
||||
|
||||
#include "upm_utilities.h"
|
||||
#include "mraa.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
if (mraa_init() != MRAA_SUCCESS)
|
||||
{
|
||||
perror("Failed to initialize mraa\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
ttp223_context dev = ttp223_init(2);
|
||||
bool abc = 0;
|
||||
while(1){
|
||||
|
@ -26,6 +26,8 @@
|
||||
#include <signal.h>
|
||||
|
||||
#include "urm37.h"
|
||||
#include "upm_utilities.h"
|
||||
#include "mraa.h"
|
||||
|
||||
bool shouldRun = true;
|
||||
|
||||
@ -37,9 +39,15 @@ void sig_handler(int signo)
|
||||
|
||||
int main()
|
||||
{
|
||||
if (mraa_init() != MRAA_SUCCESS)
|
||||
{
|
||||
perror("Failed to initialize mraa\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
signal(SIGINT, sig_handler);
|
||||
|
||||
//! [Interesting]
|
||||
//! [Interesting]
|
||||
|
||||
// Instantiate a URM37 sensor on UART 0, with the reset pin on D2
|
||||
urm37_context sensor = urm37_init(0, 2, 0, 0, 0, false);
|
||||
@ -62,10 +70,10 @@ int main()
|
||||
|
||||
urm37_get_temperature(sensor, &temperature);
|
||||
printf("Temperature (C): %f\n\n", temperature);
|
||||
usleep(500000);
|
||||
upm_delay_ms(500);
|
||||
}
|
||||
|
||||
//! [Interesting]
|
||||
//! [Interesting]
|
||||
|
||||
printf("Exiting\n");
|
||||
|
||||
|
@ -26,6 +26,8 @@
|
||||
#include <signal.h>
|
||||
|
||||
#include "urm37.h"
|
||||
#include "upm_utilities.h"
|
||||
#include "mraa.h"
|
||||
|
||||
bool shouldRun = true;
|
||||
|
||||
@ -37,9 +39,15 @@ void sig_handler(int signo)
|
||||
|
||||
int main()
|
||||
{
|
||||
if (mraa_init() != MRAA_SUCCESS)
|
||||
{
|
||||
perror("Failed to initialize mraa\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
signal(SIGINT, sig_handler);
|
||||
|
||||
//! [Interesting]
|
||||
//! [Interesting]
|
||||
|
||||
// Instantiate a URM37 sensor on analog pin A0, reset pin on D2,
|
||||
// trigger pin on D3 with an analog reference voltage of 5.0
|
||||
@ -60,10 +68,10 @@ int main()
|
||||
|
||||
urm37_get_distance(sensor, &distance, 0);
|
||||
printf("Detected distance (cm): %f\n", distance);
|
||||
usleep(500000);
|
||||
upm_delay_ms(500);
|
||||
}
|
||||
|
||||
//! [Interesting]
|
||||
//! [Interesting]
|
||||
|
||||
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.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
@ -26,6 +26,8 @@
|
||||
#include <signal.h>
|
||||
|
||||
#include "vdiv.h"
|
||||
#include "upm_utilities.h"
|
||||
#include "mraa.h"
|
||||
|
||||
bool shouldRun = true;
|
||||
|
||||
@ -37,6 +39,12 @@ void sig_handler(int signo)
|
||||
|
||||
int main()
|
||||
{
|
||||
if (mraa_init() != MRAA_SUCCESS)
|
||||
{
|
||||
perror("Failed to initialize mraa\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
signal(SIGINT, sig_handler);
|
||||
|
||||
//! [Interesting]
|
||||
@ -61,7 +69,7 @@ int main()
|
||||
printf("Divide SW: %d ADC voltage: %0.03f Sensor voltage: %0.03f\n",
|
||||
vdiv_get_divsw(sensor), raw_volts, computed_volts);
|
||||
|
||||
usleep(500000);
|
||||
upm_delay_ms(500);
|
||||
}
|
||||
|
||||
//! [Interesting]
|
||||
|
Loading…
x
Reference in New Issue
Block a user