mirror of
https://github.com/eclipse/upm.git
synced 2025-07-03 02:11:15 +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:
@ -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]
|
||||
|
Reference in New Issue
Block a user