Speaker: Removed grove dependency

* Renamed all files from grovespeaker to speaker
    * Replaced all instances of grovespeaker with speaker
    * Updated all CMake files
This commit is contained in:
Sisinty Sasmita Patra 2016-09-13 16:09:09 -07:00 committed by Noel Eck
parent c759932ee6
commit 982065a7b7
16 changed files with 58 additions and 58 deletions

View File

Before

Width:  |  Height:  |  Size: 97 KiB

After

Width:  |  Height:  |  Size: 97 KiB

View File

@ -20,7 +20,7 @@ relay.cxx RelaySample.java
rotary.cxx RotarySample.java rotary.cxx RotarySample.java
grovescam.cxx GROVESCAMSample.java grovescam.cxx GROVESCAMSample.java
slide.cxx SlideSample.java slide.cxx SlideSample.java
grovespeaker.cxx GroveSpeakerSample.java speaker.cxx SpeakerSample.java
vdiv.cxx VDivSample.java vdiv.cxx VDivSample.java
water.cxx WaterSample.java water.cxx WaterSample.java
grovewfs.cxx GroveWFSSample.java grovewfs.cxx GroveWFSSample.java

View File

@ -154,7 +154,7 @@ add_example (yg1006)
add_example (wt5001) add_example (wt5001)
add_example (ppd42ns) add_example (ppd42ns)
add_example (mq303a) add_example (mq303a)
add_example (grovespeaker) add_example (speaker)
add_example (rfr359f) add_example (rfr359f)
add_example (biss0001) add_example (biss0001)
add_example (rotaryencoder) add_example (rotaryencoder)

View File

@ -25,15 +25,15 @@
#include <unistd.h> #include <unistd.h>
#include <iostream> #include <iostream>
#include <signal.h> #include <signal.h>
#include "grovespeaker.hpp" #include "speaker.hpp"
using namespace std; using namespace std;
int main () int main ()
{ {
//! [Interesting] //! [Interesting]
// Instantiate a Grove Speaker on digital pin D2 // Instantiate a Speaker on digital pin D2
upm::GroveSpeaker* speaker = new upm::GroveSpeaker(2); upm::Speaker* speaker = new upm::Speaker(2);
// Play all 7 of the lowest notes // Play all 7 of the lowest notes
speaker->playAll(); speaker->playAll();

View File

@ -50,7 +50,7 @@ add_example(RelaySample relay)
add_example(RotarySample rotary) add_example(RotarySample rotary)
add_example(GROVESCAMSample grovescam) add_example(GROVESCAMSample grovescam)
add_example(SlideSample slide) add_example(SlideSample slide)
add_example(GroveSpeakerSample grovespeaker) add_example(SpeakerSample speaker)
add_example(TemperatureSample temperature) add_example(TemperatureSample temperature)
add_example(VDivSample vdiv) add_example(VDivSample vdiv)
add_example(WaterSample water) add_example(WaterSample water)

View File

@ -22,12 +22,12 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
public class GroveSpeakerSample { public class SpeakerSample {
public static void main(String[] args) throws InterruptedException { public static void main(String[] args) throws InterruptedException {
// ! [Interesting] // ! [Interesting]
// Instantiate a Grove Speaker on digital pin D2 // Instantiate a Speaker on digital pin D2
upm_grovespeaker.GroveSpeaker speaker = new upm_grovespeaker.GroveSpeaker(2); upm_speaker.Speaker speaker = new upm_speaker.Speaker(2);
// Play all 7 of the lowest notes // Play all 7 of the lowest notes
speaker.playAll(); speaker.playAll();
@ -37,4 +37,4 @@ public class GroveSpeakerSample {
// ! [Interesting] // ! [Interesting]
} }
} }

View File

@ -22,10 +22,10 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
//Load Grove Speaker module //Load Speaker module
var groveSpeaker = require('jsupm_grovespeaker'); var Speaker = require('jsupm_speaker');
// Instantiate a Grove Speaker on digital pin D2 // Instantiate a Speaker on digital pin D2
var mySpeaker = new groveSpeaker.GroveSpeaker(2); var mySpeaker = new Speaker.Speaker(2);
// Play all 7 of the lowest notes // Play all 7 of the lowest notes
mySpeaker.playAll(); mySpeaker.playAll();

View File

@ -22,10 +22,10 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
import time, sys, signal, atexit import time, sys, signal, atexit
import pyupm_grovespeaker as upmGrovespeaker import pyupm_speaker as upmspeaker
# Instantiate a Grove Speaker on digital pin D2 # Instantiate a Speaker on digital pin D2
mySpeaker = upmGrovespeaker.GroveSpeaker(2) mySpeaker = upmspeaker.Speaker(2)
# Play all 7 of the lowest notes # Play all 7 of the lowest notes
mySpeaker.playAll() mySpeaker.playAll()

View File

@ -1,5 +0,0 @@
set (libname "grovespeaker")
set (libdescription "upm grovespeaker speaker module")
set (module_src ${libname}.cxx)
set (module_hpp ${libname}.hpp)
upm_module_init()

View File

@ -1,8 +0,0 @@
%module jsupm_grovespeaker
%include "../upm.i"
%{
#include "grovespeaker.hpp"
%}
%include "grovespeaker.hpp"

View File

@ -0,0 +1,5 @@
upm_mixed_module_init (NAME speaker
DESCRIPTION "UPM Speaker Module"
CPP_HDR speaker.hpp
CPP_SRC speaker.cxx
REQUIRES mraa)

View File

@ -1,16 +1,16 @@
%module javaupm_grovespeaker %module javaupm_speaker
%include "../upm.i" %include "../upm.i"
%{ %{
#include "grovespeaker.hpp" #include "speaker.hpp"
%} %}
%include "grovespeaker.hpp" %include "speaker.hpp"
%pragma(java) jniclasscode=%{ %pragma(java) jniclasscode=%{
static { static {
try { try {
System.loadLibrary("javaupm_grovespeaker"); System.loadLibrary("javaupm_speaker");
} catch (UnsatisfiedLinkError e) { } catch (UnsatisfiedLinkError e) {
System.err.println("Native code library failed to load. \n" + e); System.err.println("Native code library failed to load. \n" + e);
System.exit(1); System.exit(1);

View File

@ -0,0 +1,8 @@
%module jsupm_speaker
%include "../upm.i"
%{
#include "speaker.hpp"
%}
%include "speaker.hpp"

View File

@ -1,11 +1,11 @@
// Include doxygen-generated documentation // Include doxygen-generated documentation
%include "pyupm_doxy2swig.i" %include "pyupm_doxy2swig.i"
%module pyupm_grovespeaker %module pyupm_speaker
%include "../upm.i" %include "../upm.i"
%feature("autodoc", "3"); %feature("autodoc", "3");
%include "grovespeaker.hpp" %include "speaker.hpp"
%{ %{
#include "grovespeaker.hpp" #include "speaker.hpp"
%} %}

View File

@ -26,11 +26,11 @@
#include <string> #include <string>
#include <stdexcept> #include <stdexcept>
#include "grovespeaker.hpp" #include "speaker.hpp"
using namespace upm; using namespace upm;
GroveSpeaker::GroveSpeaker(int pin) Speaker::Speaker(int pin)
{ {
if ( !(m_gpio = mraa_gpio_init(pin)) ) if ( !(m_gpio = mraa_gpio_init(pin)) )
throw std::invalid_argument(std::string(__FUNCTION__) + throw std::invalid_argument(std::string(__FUNCTION__) +
@ -46,12 +46,12 @@ GroveSpeaker::GroveSpeaker(int pin)
m_note_list['g'] = storeNote(1276, 1204, 638, 602, 319, 301); m_note_list['g'] = storeNote(1276, 1204, 638, 602, 319, 301);
} }
GroveSpeaker::~GroveSpeaker() Speaker::~Speaker()
{ {
mraa_gpio_close(m_gpio); mraa_gpio_close(m_gpio);
} }
NoteData GroveSpeaker::storeNote(int noteDelayLow, int noteDelayLowSharp, NoteData Speaker::storeNote(int noteDelayLow, int noteDelayLowSharp,
int noteDelayMed, int noteDelayMedSharp, int noteDelayMed, int noteDelayMedSharp,
int noteDelayHigh, int noteDelayHighSharp) int noteDelayHigh, int noteDelayHighSharp)
{ {
@ -65,7 +65,7 @@ NoteData GroveSpeaker::storeNote(int noteDelayLow, int noteDelayLowSharp,
return note; return note;
} }
void GroveSpeaker::playAll() void Speaker::playAll()
{ {
playSound('c', false, "low"); playSound('c', false, "low");
usleep(200000); usleep(200000);
@ -83,7 +83,7 @@ void GroveSpeaker::playAll()
usleep(500000); usleep(500000);
} }
void GroveSpeaker::playSound(char letter, bool sharp, std::string vocalWeight) void Speaker::playSound(char letter, bool sharp, std::string vocalWeight)
{ {
std::map<char, NoteData>::iterator it = m_note_list.find(letter); std::map<char, NoteData>::iterator it = m_note_list.find(letter);
if(it == m_note_list.end()) if(it == m_note_list.end())
@ -134,7 +134,7 @@ void GroveSpeaker::playSound(char letter, bool sharp, std::string vocalWeight)
sound(delayTime); sound(delayTime);
} }
void GroveSpeaker::sound(int note_delay) void Speaker::sound(int note_delay)
{ {
mraa_result_t error = MRAA_SUCCESS; mraa_result_t error = MRAA_SUCCESS;
for (int i = 0; i < 100; i++) for (int i = 0; i < 100; i++)

View File

@ -33,8 +33,8 @@
namespace upm { namespace upm {
/** /**
* @brief Grove Speaker library * @brief Speaker library
* @defgroup grovespeaker libupm-grovespeaker * @defgroup speaker libupm-speaker
* @ingroup seeed gpio sound hak * @ingroup seeed gpio sound hak
*/ */
typedef struct typedef struct
@ -47,35 +47,35 @@ typedef struct
int delayTimeHighSharp; int delayTimeHighSharp;
} NoteData; } NoteData;
/** /**
* @library grovespeaker * @library speaker
* @sensor grovespeaker * @sensor speaker libupm-speaker
* @comname Grove Speaker * @comname Speaker
* @type sound * @type sound
* @man seeed * @man seeed
* @con gpio * @con gpio
* @kit hak * @kit hak
* *
* @brief API for the Grove Speaker * @brief API for the Speaker
* *
* UPM module for the Grove Speaker. * UPM module for the Speaker.
* This sensor can generate different tones and sounds depending on the * This sensor can generate different tones and sounds depending on the
* frequency of the input signal. * frequency of the input signal.
* *
* @image html grovespeaker.jpg * @image html speaker.jpg
* @snippet grovespeaker.cxx Interesting * @snippet speaker.cxx Interesting
*/ */
class GroveSpeaker { class Speaker {
public: public:
/** /**
* Grove Speaker constructor * Speaker constructor
* *
* @param pin Digital pin to use * @param pin Digital pin to use
*/ */
GroveSpeaker(int pin); Speaker(int pin);
/** /**
* GroveSpeaker destructor * Speaker destructor
*/ */
~GroveSpeaker(); ~Speaker();
/** /**
* Plays all alto notes (lowest notes) * Plays all alto notes (lowest notes)
* *