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:
Noel Eck
2016-09-19 15:45:22 -07:00
parent 2ccdc3e673
commit 324af8fc92
35 changed files with 775 additions and 482 deletions

View File

@ -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]