loudness: merge groveloudness and hyld9767 into a single driver

Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
This commit is contained in:
Jon Trulson
2015-09-15 16:52:37 -06:00
committed by Mihai Tudor Panu
parent cd7815aa07
commit 9fe9d4aec2
21 changed files with 66 additions and 330 deletions

View File

@ -72,7 +72,6 @@ add_executable (grovelinefinder-example grovelinefinder.cxx)
add_executable (grovevdiv-example grovevdiv.cxx)
add_executable (grovewater-example grovewater.cxx)
add_executable (guvas12d-example guvas12d.cxx)
add_executable (groveloudness-example groveloudness.cxx)
add_executable (mpr121-example mpr121.cxx)
add_executable (ublox6-example ublox6.cxx)
add_executable (yg1006-example yg1006.cxx)
@ -140,7 +139,7 @@ add_executable (ak8975-example ak8975.cxx)
add_executable (lsm9ds0-example lsm9ds0.cxx)
add_executable (eboled-example eboled.cxx)
add_executable (mpu9250-example mpu9250.cxx)
add_executable (hyld9767-example hyld9767.cxx)
add_executable (loudness-example loudness.cxx)
add_executable (mg811-example mg811.cxx)
add_executable (wheelencoder-example wheelencoder.cxx)
add_executable (sm130-example sm130.cxx)
@ -196,7 +195,6 @@ include_directories (${PROJECT_SOURCE_DIR}/src/grovelinefinder)
include_directories (${PROJECT_SOURCE_DIR}/src/grovevdiv)
include_directories (${PROJECT_SOURCE_DIR}/src/grovewater)
include_directories (${PROJECT_SOURCE_DIR}/src/guvas12d)
include_directories (${PROJECT_SOURCE_DIR}/src/groveloudness)
include_directories (${PROJECT_SOURCE_DIR}/src/mpr121)
include_directories (${PROJECT_SOURCE_DIR}/src/ublox6)
include_directories (${PROJECT_SOURCE_DIR}/src/yg1006)
@ -252,7 +250,7 @@ include_directories (${PROJECT_SOURCE_DIR}/src/rgbringcoder)
include_directories (${PROJECT_SOURCE_DIR}/src/hp20x)
include_directories (${PROJECT_SOURCE_DIR}/src/pn532)
include_directories (${PROJECT_SOURCE_DIR}/src/lsm9ds0)
include_directories (${PROJECT_SOURCE_DIR}/src/hyld9767)
include_directories (${PROJECT_SOURCE_DIR}/src/loudness)
include_directories (${PROJECT_SOURCE_DIR}/src/mg811)
include_directories (${PROJECT_SOURCE_DIR}/src/wheelencoder)
include_directories (${PROJECT_SOURCE_DIR}/src/sm130)
@ -331,7 +329,6 @@ target_link_libraries (grovelinefinder-example grovelinefinder ${CMAKE_THREAD_LI
target_link_libraries (grovevdiv-example grovevdiv ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (grovewater-example grovewater ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (guvas12d-example guvas12d ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (groveloudness-example groveloudness ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (mpr121-example mpr121 ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (ublox6-example ublox6 ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (yg1006-example yg1006 ${CMAKE_THREAD_LIBS_INIT})
@ -399,7 +396,7 @@ target_link_libraries (ak8975-example mpu9150 ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (lsm9ds0-example lsm9ds0 ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (eboled-example i2clcd ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (mpu9250-example mpu9150 ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (hyld9767-example hyld9767 ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (loudness-example loudness ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (mg811-example mg811 ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (wheelencoder-example wheelencoder ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries (sm130-example sm130 ${CMAKE_THREAD_LIBS_INIT})

View File

@ -1,63 +0,0 @@
/*
* Author: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2014 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <unistd.h>
#include <iostream>
#include <signal.h>
#include "groveloudness.h"
using namespace std;
int shouldRun = true;
void sig_handler(int signo)
{
if (signo == SIGINT)
shouldRun = false;
}
int main ()
{
signal(SIGINT, sig_handler);
//! [Interesting]
// Instantiate a Grove Loudness sensor on analog pin A0
upm::GroveLoudness* loudness = new upm::GroveLoudness(0);
// Print the loudness value every 0.1 seconds
while (shouldRun)
{
int val = loudness->value();
cout << "Loudness value (higher is louder): " << val << endl;
usleep(100000);
}
//! [Interesting]
cout << "Exiting" << endl;
delete loudness;
return 0;
}

View File

@ -25,13 +25,13 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
#include "hyld9767.h"
#include "loudness.h"
using namespace std;
bool shouldRun = true;
#define HYLD9767_AREF 5.0
#define LOUDNESS_AREF 5.0
void sig_handler(int signo)
{
@ -45,9 +45,9 @@ int main()
//! [Interesting]
// Instantiate a HYLD9767 on analog pin A0, with an analog
// reference voltage of HYLD9767_AREF
upm::HYLD9767 *loud = new upm::HYLD9767(0, HYLD9767_AREF);
// Instantiate a Loudness sensor on analog pin A0, with an analog
// reference voltage of LOUDNESS_AREF
upm::Loudness *loud = new upm::Loudness(0, LOUDNESS_AREF);
// Every tenth of a second, sample the loudness and output it's
// corresponding analog voltage.

View File

@ -1,43 +0,0 @@
/*jslint node:true, vars:true, bitwise:true, unparam:true */
/*jshint unused:true */
/*global */
/*
* Author: Zion Orent <zorent@ics.com>
* Copyright (c) 2014 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
var loudnessSensor = require('jsupm_groveloudness');
// Instantiate a Grove Loudness sensor on analog pin A0
var myLoudnessSensor = new loudnessSensor.GroveLoudness(0);
// Print the loudness value every 0.1 seconds
setInterval(function()
{
console.log("Loudness value (higher is louder): " + myLoudnessSensor.value());
}, 100);
// Print message when exiting
process.on('SIGINT', function()
{
console.log("Exiting...");
process.exit(0);
});

View File

@ -26,11 +26,11 @@
*/
var sensorObj = require('jsupm_hyld9767');
var sensorObj = require('jsupm_loudness');
// Instantiate a HYLD9767 on analog pin A0, with an analog
// Instantiate a Loudness sensor on analog pin A0, with an analog
// reference voltage of 5.0
var sensor = new sensorObj.HYLD9767(0, 5.0);
var sensor = new sensorObj.Loudness(0, 5.0);
// Every tenth of a second, sample the loudness and output it's
// corresponding analog voltage.

View File

@ -1,48 +0,0 @@
#!/usr/bin/python
# Author: Zion Orent <zorent@ics.com>
# Copyright (c) 2015 Intel Corporation.
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
import time, sys, signal, atexit
import pyupm_groveloudness as upmGroveloudness
# Instantiate a Grove Loudness sensor on analog pin A0
myLoudness = upmGroveloudness.GroveLoudness(0)
## Exit handlers ##
# This stops python from printing a stacktrace when you hit control-C
def SIGINTHandler(signum, frame):
raise SystemExit
# This lets you run code on exit, including functions from myLoudness
def exitHandler():
print "Exiting"
sys.exit(0)
# Register exit handlers
atexit.register(exitHandler)
signal.signal(signal.SIGINT, SIGINTHandler)
while (1):
print "Loudness value (higher is louder):", myLoudness.value()
time.sleep(.1)

View File

@ -22,11 +22,11 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
import time, sys, signal, atexit
import pyupm_hyld9767 as sensorObj
import pyupm_loudness as sensorObj
# Instantiate a HYLD9767 on analog pin A0, with an analog
# Instantiate a Loudness sensor on analog pin A0, with an analog
# reference voltage of 5.0
sensor = sensorObj.HYLD9767(0, 5.0)
sensor = sensorObj.Loudness(0, 5.0)
## Exit handlers ##
# This function stops python from printing a stacktrace when you hit control-C