grove: remove deprecated classes and examples

Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
This commit is contained in:
Mihai Tudor Panu
2019-05-07 18:00:34 -07:00
parent 7d0600df1c
commit 33d0aee280
217 changed files with 11 additions and 12042 deletions

View File

@ -1,50 +0,0 @@
/*
* Author: Sarah Knepper <sarah.knepper@intel.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 <iostream>
#include <string>
#include "grovebutton.hpp"
#include "upm_utilities.h"
int
main(int argc, char** argv)
{
// This example uses GPIO 0
//! [Interesting]
// Create the button object using GPIO pin 0
upm::GroveButton button(0);
// Read the input and print, waiting one second between readings
while (1) {
std::cout << button.name() << " value is " << button.value() << std::endl;
upm_delay(1);
}
// Delete the button object
//! [Interesting]
return 0;
}

View File

@ -1,68 +0,0 @@
/*
* Author: Jon Trulson <jtrulson@ics.com>
* Copyright (c) 2014-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.
*/
#include <iostream>
#include <signal.h>
#include "groveled.hpp"
#include "upm_utilities.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 LED on D2. Here we are controlling a Grove
// Multi-color flash LED. We just just need to turn it on - it will
// then cycle through various colors (red, green, blue, purple) on it's
// own until turned off.
upm::GroveLed led(2);
// start the light show
led.on();
// just upm_delay until interrupted
while (shouldRun)
upm_delay(1);
//! [Interesting]
led.off();
cout << "Exiting..." << endl;
return 0;
}

View File

@ -1,56 +0,0 @@
/*
* Author: Brendan Le Foll <brendan.le.foll@intel.com>
* Contributions: Sarah Knepper <sarah.knepper@intel.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 <iostream>
#include <string>
#include "groveled.hpp"
#include "upm_utilities.h"
int
main(int argc, char** argv)
{
//! [Interesting]
// Create the Grove LED object using GPIO pin 2
upm::GroveLed led(2);
// Print the name
std::cout << led.name() << std::endl;
// Turn the LED on and off 10 times, pausing one second
// between transitions
for (int i = 0; i < 10; i++) {
led.on();
upm_delay(1);
led.off();
upm_delay(1);
}
// Delete the Grove LED object
//! [Interesting]
return 0;
}

View File

@ -1,50 +0,0 @@
/*
* Author: Brendan Le Foll <brendan.le.foll@intel.com>
* Contributions: Sarah Knepper <sarah.knepper@intel.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 <iostream>
#include <string>
#include "grovelight.hpp"
#include "upm_utilities.h"
int
main(int argc, char** argv)
{
//! [Interesting]
// Create the light sensor object using AIO pin 0
upm::GroveLight light(0);
// Read the input and print both the raw value and a rough lux value,
// waiting one second between readings
while (1) {
std::cout << light.name() << " raw value is " << light.raw_value() << ", which is roughly "
<< light.value() << " lux" << std::endl;
upm_delay(1);
}
// Delete the light sensor object
//! [Interesting]
return 0;
}

View File

@ -1,59 +0,0 @@
/*
* Author: Sarah Knepper <sarah.knepper@intel.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.
*/
#include <iostream>
#include <string>
#include "groverelay.hpp"
#include "upm_utilities.h"
int
main(int argc, char** argv)
{
// This example uses GPIO 0
//! [Interesting]
// Create the relay switch object using GPIO pin 0
upm::GroveRelay relay(0);
// Close and then open the relay switch 3 times,
// waiting one second each time. The LED on the relay switch
// will light up when the switch is on (closed).
// The switch will also make a noise between transitions.
for (int i = 0; i < 3; i++) {
relay.on();
if (relay.isOn())
std::cout << relay.name() << " is on" << std::endl;
upm_delay(1);
relay.off();
if (relay.isOff())
std::cout << relay.name() << " is off" << std::endl;
upm_delay(1);
}
// Delete the relay switch object
//! [Interesting]
return 0;
}

View File

@ -1,67 +0,0 @@
/*
* Author: Mihai Tudor Panu <mihai.tudor.panu@intel.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 <iostream>
#include <stdint.h>
#include <stdio.h>
#include <string>
#include "groverotary.hpp"
#include "upm_utilities.h"
using namespace std;
int
main()
{
//! [Interesting]
// Instantiate a rotary sensor on analog pin A0
upm::GroveRotary knob(0);
// Print sensor name to confirm it initialized properly
cout << knob.name() << endl;
while (true) {
float abs_value = knob.abs_value(); // Absolute raw value
float abs_deg = knob.abs_deg(); // Absolute degrees
float abs_rad = knob.abs_rad(); // Absolute radians
float rel_value = knob.rel_value(); // Relative raw value
float rel_deg = knob.rel_deg(); // Relative degrees
float rel_rad = knob.rel_rad(); // Relative radians
fprintf(stdout,
"Absolute: %4d raw %5.2f deg = %3.2f rad Relative: %4d raw %5.2f "
"deg %3.2f rad\n",
(int16_t) abs_value,
abs_deg,
abs_rad,
(int16_t) rel_value,
rel_deg,
rel_rad);
upm_delay_us(2500000); // Sleep for 2.5s
}
//! [Interesting]
return 0;
}

View File

@ -1,52 +0,0 @@
/*
* Author: Mihai Tudor Panu <mihai.tudor.panu@intel.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 <iostream>
#include <stdint.h>
#include <stdio.h>
#include <string>
#include "groveslide.hpp"
#include "upm_utilities.h"
using namespace std;
int
main()
{
//! [Interesting]
upm::GroveSlide slide(0);
cout << slide.name() << endl;
while (true) {
float adc_value = slide.raw_value(); // Read raw value
float volts = slide.voltage_value(); // Read voltage, board reference set at 5.0V
fprintf(stdout, "%4d = %.2f V\n", (uint16_t) adc_value, volts);
upm_delay_us(2500000); // Sleep for 2.5s
}
//! [Interesting]
return 0;
}

View File

@ -1,55 +0,0 @@
/*
* Author: Brendan Le Foll <brendan.le.foll@intel.com>
* Contributions: Sarah Knepper <sarah.knepper@intel.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 <iostream>
#include <stdio.h>
#include <string>
#include "grovetemp.hpp"
#include "upm_utilities.h"
int
main(int argc, char** argv)
{
//! [Interesting]
// Create the temperature sensor object using AIO pin 0
upm::GroveTemp temp(0);
std::cout << temp.name() << std::endl;
// Read the temperature ten times, printing both the Celsius and
// equivalent Fahrenheit temperature, waiting one second between readings
for (int i = 0; i < 10; i++) {
int celsius = temp.value();
int fahrenheit = (int) (celsius * 9.0 / 5.0 + 32.0);
printf("%d degrees Celsius, or %d degrees Fahrenheit\n", celsius, fahrenheit);
upm_delay(1);
}
// Delete the temperature sensor object
//! [Interesting]
return 0;
}

View File

@ -1,66 +0,0 @@
/*
* 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.
*/
#include <iostream>
#include <signal.h>
#include "grovecollision.hpp"
using namespace std;
int shouldRun = true;
void
sig_handler(int signo)
{
if (signo == SIGINT)
shouldRun = false;
}
int
main(int argc, char** argv)
{
signal(SIGINT, sig_handler);
//! [Interesting]
// The was tested with the Grove Collision Sensor
// Instantiate a Grove Collision on digital pin D2
upm::GroveCollision collision(2);
bool collisionState = false;
cout << "No collision" << endl;
while (shouldRun) {
if (collision.isColliding() && !collisionState) {
cout << "Collision!" << endl;
collisionState = true;
} else if (collisionState) {
cout << "No collision" << endl;
collisionState = false;
}
}
//! [Interesting]
cout << "Exiting" << endl;
return 0;
}

View File

@ -1,78 +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 <iostream>
#include <signal.h>
#include "groveehr.hpp"
#include "upm_utilities.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 Ear-clip Heart Rate sensor on digital pin D2
upm::GroveEHR heart(2);
// set the beat counter to 0, init the clock and start counting beats
heart.clearBeatCounter();
heart.initClock();
heart.startBeatCounter();
while (shouldRun) {
// we grab these just for display purposes in this example
uint32_t millis = heart.getMillis();
uint32_t beats = heart.beatCounter();
// heartRate() requires that at least 5 seconds pass before
// returning anything other than 0
int hr = heart.heartRate();
// output milliseconds passed, beat count, and computed heart rate
cout << "Millis: " << millis << " Beats: " << beats;
cout << " Heart Rate: " << hr << endl;
upm_delay(1);
}
heart.stopBeatCounter();
//! [Interesting]
cout << "Exiting..." << endl;
return 0;
}

View File

@ -1,67 +0,0 @@
/*
* 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.
*/
#include <iostream>
#include <signal.h>
#include "groveeldriver.hpp"
#include "upm_utilities.h"
using namespace std;
int shouldRun = true;
void
sig_handler(int signo)
{
if (signo == SIGINT)
shouldRun = false;
}
int
main(int argc, char** argv)
{
signal(SIGINT, sig_handler);
//! [Interesting]
// The was tested with the Grove El Driver Module
// Instantiate a Grove El Driver on digital pin D2
upm::GroveElDriver eldriver(2);
bool lightState = true;
while (shouldRun) {
if (lightState)
eldriver.on();
else
eldriver.off();
lightState = !lightState;
upm_delay(1);
}
//! [Interesting]
eldriver.off();
cout << "Exiting" << endl;
return 0;
}

View File

@ -1,81 +0,0 @@
/*
* 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.
*/
#include <iostream>
#include <signal.h>
#include <sys/time.h>
#include <time.h>
#include "groveelectromagnet.hpp"
using namespace std;
int shouldRun = true;
void
sig_handler(int signo)
{
if (signo == SIGINT)
shouldRun = false;
}
float
get_time()
{
return ((float) (clock())) / CLOCKS_PER_SEC;
}
int
main(int argc, char** argv)
{
signal(SIGINT, sig_handler);
//! [Interesting]
// The was tested with the Grove Electromagnetic Module
// Instantiate a Grove Electromagnet on digital pin D2
upm::GroveElectromagnet magnet(2);
cout << "Starting up magnet...." << endl;
magnet.off();
bool magnetState = false;
float time_passed = get_time();
// Turn magnet on and off every 5 seconds
while (shouldRun) {
if ((get_time() - time_passed) > 5.0) {
magnetState = !magnetState;
if (magnetState)
magnet.on();
else
magnet.off();
cout << "Turning magnet " << ((magnetState) ? "on" : "off") << endl;
time_passed = get_time();
}
}
//! [Interesting]
magnet.off();
cout << "Exiting" << endl;
return 0;
}

View File

@ -1,61 +0,0 @@
/*
* 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.
*/
#include <iostream>
#include <signal.h>
#include "groveemg.hpp"
#include "upm_utilities.h"
using namespace std;
int shouldRun = true;
void
sig_handler(int signo)
{
if (signo == SIGINT)
shouldRun = false;
}
int
main(int argc, char** argv)
{
signal(SIGINT, sig_handler);
//! [Interesting]
// The was tested with the GroveEMG Muscle Signal Reader Sensor Module
// Instantiate a GroveEMG on analog pin A0
upm::GroveEMG emg(0);
cout << "Calibrating...." << endl;
emg.calibrate();
while (shouldRun) {
cout << emg.value() << endl;
upm_delay_us(100000);
}
//! [Interesting]
cout << "Exiting" << endl;
return 0;
}

View File

@ -1,102 +0,0 @@
/*
* Author: Jon Trulson <jtrulson@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.
*/
#include <iostream>
#include "grovegprs.hpp"
#include "upm_utilities.h"
using namespace std;
using namespace upm;
void
printUsage(char* progname)
{
cout << "Usage: " << progname << " [AT command]" << endl;
cout << endl;
cout << "If an argument is supplied on the command line, that argument is" << endl;
cout << "sent to the module and the response is printed out." << endl;
cout << endl;
cout << "If no argument is used, then the manufacturer and the current" << endl;
cout << "saved profiles are queried and the results printed out." << endl;
cout << endl;
cout << endl;
}
// simple helper function to send a command and wait for a response
void
sendCommand(upm::GroveGPRS& sensor, string cmd)
{
// commands need to be terminated with a carriage return
cmd += "\r";
sensor.writeDataStr(cmd);
// wait up to 1 second
if (sensor.dataAvailable(1000)) {
cout << "Returned: " << sensor.readDataStr(1024) << endl;
} else {
cerr << "Timed out waiting for response" << endl;
}
}
int
main(int argc, char** argv)
{
//! [Interesting]
// Instantiate a GroveGPRS Module on UART 0
upm::GroveGPRS sensor(0);
// Set the baud rate, 19200 baud is the default.
if (sensor.setBaudRate(19200) != 0) {
cerr << "Failed to set tty baud rate" << endl;
return 1;
}
printUsage(argv[0]);
if (argc > 1) {
cout << "Sending command line argument (" << argv[1] << ")..." << endl;
sendCommand(sensor, argv[1]);
} else {
// query the module manufacturer
cout << "Querying module manufacturer (AT+CGMI)..." << endl;
sendCommand(sensor, "AT+CGMI");
upm_delay(1);
// query the saved profiles
cout << "Querying the saved profiles (AT&V)..." << endl;
sendCommand(sensor, "AT&V");
// A comprehensive list is available from the datasheet at:
// http://www.seeedstudio.com/wiki/images/7/72/AT_Commands_v1.11.pdf
}
//! [Interesting]
return 0;
}

View File

@ -1,64 +0,0 @@
/*
* 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.
*/
#include <iostream>
#include <signal.h>
#include "grovegsr.hpp"
#include "upm_utilities.h"
using namespace std;
bool shouldRun = true;
void
sig_handler(int signo)
{
if (signo == SIGINT)
shouldRun = false;
}
int
main()
{
signal(SIGINT, sig_handler);
//! [Interesting]
// The was tested with the GroveGSR Galvanic Skin Response Sensor module.
// Instantiate a GroveGSR on analog pin A0
upm::GroveGSR gsr(0);
cout << "Calibrating...." << endl;
gsr.calibrate();
while (shouldRun) {
cout << gsr.value() << endl;
upm_delay_us(500000);
}
//! [Interesting]
cout << "Exiting" << endl;
return 0;
}

View File

@ -1,66 +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 <iostream>
#include <signal.h>
#include "grovelinefinder.hpp"
#include "upm_utilities.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 Line Finder sensor on digital pin D2
upm::GroveLineFinder finder(2);
// check every second for the presence of white detection
while (shouldRun) {
bool val = finder.whiteDetected();
if (val)
cout << "White detected." << endl;
else
cout << "Black detected." << endl;
upm_delay(1);
}
//! [Interesting]
cout << "Exiting..." << endl;
return 0;
}

View File

@ -1,65 +0,0 @@
/*
* Author: Jon Trulson <jtrulson@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.
*/
#include <iostream>
#include "grovemd.hpp"
#include "upm_utilities.h"
using namespace std;
int
main(int argc, char** argv)
{
//! [Interesting]
// Instantiate an I2C Grove Motor Driver on I2C bus 0
upm::GroveMD motors(GROVEMD_I2C_BUS, GROVEMD_DEFAULT_I2C_ADDR);
// This example demonstrates using the GroveMD to drive a stepper motor
// configure it, for this example, we'll assume 200 steps per rev
motors.configStepper(200);
// set for half a rotation
motors.setStepperSteps(100);
// let it go - clockwise rotation, 10 RPM speed
motors.enableStepper(upm::GroveMD::STEP_DIR_CW, 10);
upm_delay(3);
// Now do it backwards...
motors.setStepperSteps(100);
motors.enableStepper(upm::GroveMD::STEP_DIR_CCW, 10);
// now disable
motors.disableStepper();
//! [Interesting]
cout << "Exiting..." << endl;
return 0;
}

View File

@ -1,59 +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 <iostream>
#include "grovemd.hpp"
#include "upm_utilities.h"
using namespace std;
int
main(int argc, char** argv)
{
//! [Interesting]
// Instantiate an I2C Grove Motor Driver on I2C bus 0
upm::GroveMD motors(GROVEMD_I2C_BUS, GROVEMD_DEFAULT_I2C_ADDR);
// set direction to CW and set speed to 50%
cout << "Spin M1 and M2 at half speed for 3 seconds" << endl;
motors.setMotorDirections(upm::GroveMD::DIR_CW, upm::GroveMD::DIR_CW);
motors.setMotorSpeeds(127, 127);
upm_delay(3);
// counter clockwise
cout << "Reversing M1 and M2 for 3 seconds" << endl;
motors.setMotorDirections(upm::GroveMD::DIR_CCW, upm::GroveMD::DIR_CCW);
upm_delay(3);
//! [Interesting]
cout << "Stopping motors" << endl;
motors.setMotorSpeeds(0, 0);
cout << "Exiting..." << endl;
return 0;
}

View File

@ -1,75 +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 <iostream>
#include <signal.h>
#include "grovemoisture.hpp"
#include "upm_utilities.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 Moisture sensor on analog pin A0
upm::GroveMoisture moisture(0);
// Values (approximate):
// 0-300, sensor in air or dry soil
// 300-600, sensor in humid soil
// 600+, sensor in wet soil or submerged in water.
// Read the value every second and print the corresponding moisture level
while (shouldRun) {
int val = moisture.value();
cout << "Moisture value: " << val << ", ";
if (val >= 0 && val < 300)
cout << "dry";
else if (val >= 300 && val < 600)
cout << "moist";
else
cout << "wet";
cout << endl;
upm_delay(1);
}
//! [Interesting]
cout << "Exiting" << endl;
return 0;
}

View File

@ -1,58 +0,0 @@
/*
* 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.
*/
#include <iostream>
#include <signal.h>
#include "groveo2.hpp"
#include "upm_utilities.h"
using namespace std;
int shouldRun = true;
void
sig_handler(int signo)
{
if (signo == SIGINT)
shouldRun = false;
}
int
main(int argc, char** argv)
{
signal(SIGINT, sig_handler);
//! [Interesting]
// The was tested with the O2 Oxygen Concentration Sensor Module
// Instantiate a GroveO2 on analog pin A0
upm::GroveO2 O2(0);
while (shouldRun) {
cout << "The output voltage is: " << O2.voltageValue() << "mV" << endl;
upm_delay_us(100000);
}
//! [Interesting]
cout << "Exiting" << endl;
return 0;
}

View File

@ -1,73 +0,0 @@
/*
* Author: Jon Trulson <jtrulson@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.
*/
#include <iostream>
#include "grovescam.hpp"
using namespace std;
using namespace upm;
int
main(int argc, char** argv)
{
//! [Interesting]
// Instantiate a Grove Serial Camera on UART 0
upm::GROVESCAM camera(0);
// make sure port is initialized properly. 115200 baud is the default.
if (!camera.setupTty()) {
cerr << "Failed to setup tty port parameters" << endl;
return 1;
}
if (camera.init())
cout << "Initialized..." << endl;
else
cout << "init() failed" << endl;
if (camera.preCapture())
cout << "preCapture succeeded..." << endl;
else
cout << "preCapture failed." << endl;
if (camera.doCapture())
cout << "doCapture succeeded..." << endl;
else
cout << "doCapture failed." << endl;
cout << "Image size is " << camera.getImageSize() << " bytes" << endl;
if (camera.getImageSize() > 0) {
cout << "Storing image.jpg..." << endl;
if (camera.storeImage("image.jpg"))
cout << "storeImage succeeded..." << endl;
else
cout << "storeImage failed." << endl;
}
//! [Interesting]
return 0;
}

View File

@ -1,48 +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 <iostream>
#include "grovespeaker.hpp"
using namespace std;
int
main()
{
//! [Interesting]
// Instantiate a Grove Speaker on digital pin D2
upm::GroveSpeaker speaker(2);
// Play all 7 of the lowest notes
speaker.playAll();
// Play a medium C-sharp
speaker.playSound('c', true, "med");
//! [Interesting]
cout << "Exiting" << endl;
return 0;
}

View File

@ -1,59 +0,0 @@
/*
* Author: Jun Kato <i@junkato.jp>
* Copyright (c) 2015 Jun Kato.
*
* Thanks to Seeed Studio for a working arduino sketch
*
* 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 <signal.h>
#include <stdio.h>
#include "groveultrasonic.hpp"
#include "upm_utilities.h"
bool running = true;
void
sig_handler(int signo)
{
if (signo == SIGINT) {
running = false;
}
}
int
main(int argc, char** argv)
{
signal(SIGINT, sig_handler);
//! [Interesting]
// upm::GroveUltraSonic *sonar = NULL;
upm::GroveUltraSonic sonar(2);
while (running) {
int width = sonar.getDistance();
printf("Echo width = %d\n", width);
printf("Distance inches = %f.2\n\n", width / 148.0);
upm_delay(3);
}
//! [Interesting]
printf("exiting application\n");
return 0;
}

View File

@ -1,67 +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 <iostream>
#include <signal.h>
#include "grovevdiv.hpp"
#include "upm_utilities.h"
using namespace std;
bool shouldRun = true;
void
sig_handler(int signo)
{
if (signo == SIGINT)
shouldRun = false;
}
int
main()
{
signal(SIGINT, sig_handler);
//! [Interesting]
// Instantiate a Grove Voltage Divider sensor on analog pin A0
upm::GroveVDiv vDiv(0);
// collect data and output measured voltage according to the setting
// of the scaling switch (3 or 10)
while (shouldRun) {
unsigned int val = vDiv.value(100);
float gain3val = vDiv.computedValue(3, val);
float gain10val = vDiv.computedValue(10, val);
cout << "ADC value: " << val << " Gain 3: " << gain3val << "v Gain 10: " << gain10val << "v"
<< endl;
upm_delay(1);
}
//! [Interesting]
cout << "Exiting..." << endl;
return 0;
}

View File

@ -1,65 +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 <iostream>
#include <signal.h>
#include "grovewater.hpp"
#include "upm_utilities.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 Water sensor on digital pin D2
upm::GroveWater water(2);
while (shouldRun) {
bool val = water.isWet();
if (val)
cout << "Sensor is wet." << endl;
else
cout << "Sensor is dry." << endl;
upm_delay(1);
}
//! [Interesting]
cout << "Exiting..." << endl;
return 0;
}

View File

@ -1,78 +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 <iostream>
#include <signal.h>
#include "grovewfs.hpp"
#include "upm_utilities.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 Water Flow Sensor on digital pin D2
upm::GroveWFS flow(2);
// set the flow counter to 0 and start counting
flow.clearFlowCounter();
flow.startFlowCounter();
while (shouldRun) {
// we grab these (,illis and flowCount) just for display
// purposes in this example
uint32_t millis = flow.getMillis();
uint32_t flowCount = flow.flowCounter();
float fr = flow.flowRate();
// output milliseconds passed, flow count, and computed flow rate
cout << "Millis: " << millis << " Flow Count: " << flowCount;
cout << " Flow Rate: " << fr << " LPM" << endl;
// best to gather data for at least one second for reasonable
// results.
upm_delay(2);
}
flow.stopFlowCounter();
//! [Interesting]
cout << "Exiting..." << endl;
return 0;
}

View File

@ -104,31 +104,10 @@ add_example(ENC03R_Example enc03r)
add_example(ES08A_Example "servo")
add_example(FlexSensor_Example flex)
add_example(Gp2y0a_Example "gp2y0a;interfaces")
add_example(GroveButton_Example "grove;interfaces")
add_example(GroveButton_intr_Example "grove;interfaces")
add_example(GroveEHR_Example "groveehr;interfaces")
add_example(GroveEmg_Example "groveemg;interfaces")
add_example(GroveGsr_Example "grovegsr;interfaces")
add_example(GroveLEDBar_Example my9221)
add_example(GroveLED_Example grove)
add_example(GroveLed_multi_Example grove)
add_example(GroveLight_Example "grove;interfaces")
add_example(GroveLineFinder_Example "grovelinefinder;interfaces")
add_example(GroveMD_Example grovemd)
add_example(GroveMoisture_Example "grovemoisture;interfaces")
add_example(GroveMQ3_Example "gas;interfaces")
add_example(GroveMQ9_Example "gas;interfaces")
add_example(GroveO2_Example "groveo2;interfaces")
add_example(GroveQTouch_Example at42qt1070)
add_example(GroveRelay_Example grove)
add_example(GroveRotary_Example "grove;interfaces")
add_example(GROVESCAM_Example grovescam)
add_example(GroveSlide_Example grove)
add_example(GroveSpeaker_Example grovespeaker)
add_example(GroveTemp_Example "grove;interfaces")
add_example(GroveVDiv_Example "grovevdiv;interfaces")
add_example(GroveWater_Example grovewater)
add_example(GroveWFS_Example grovewfs)
add_example(Gsr_Example "gsr;interfaces")
add_example(GUVAS12D_Example guvas12d)
add_example(H3LIS331DL_Example "h3lis331dl;interfaces")
@ -179,8 +158,12 @@ add_example(MPL3115A2_Example "mpl3115a2;interfaces")
add_example(MPR121_Example mpr121)
add_example(MPU9150_Example "mpu9150;interfaces")
add_example(MQ2_Example "gas;interfaces")
add_example(MQ303A_Example mq303a)
add_example(MQ4_Example "gas;interfaces")
add_example(MQ5_Example "gas;interfaces")
add_example(MQ6_Example "gas;interfaces")
add_example(MQ7_Example "gas;interfaces")
add_example(MQ8_Example "gas;interfaces")
add_example(MQ303A_Example mq303a)
add_example(MS5803_Example "ms5803;interfaces")
add_example(NMEAGPS_Example nmea_gps)
add_example(NMEAGPS_I2C_Example nmea_gps)

View File

@ -1,66 +0,0 @@
/*
* Author: Stefan Andritoiu <stefan.andritoiu@intel.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.
*/
//NOT TESTED!!!
public class GROVESCAM_Example {
public static void main(String[] args) throws InterruptedException {
// ! [Interesting]
// Instantiate a Grove Serial Camera on UART 0
upm_grovescam.GROVESCAM camera = new upm_grovescam.GROVESCAM(0);
// make sure port is initialized properly. 115200 baud is the default.
if (!camera.setupTty()) {
System.err.println("Failed to setup tty port parameters");
System.exit(-1);
}
if (camera.init())
System.out.println("Initialized...");
else
System.out.println("Initialization failed");
if (camera.preCapture())
System.out.println("preCapture succeeded...");
else
System.out.println("preCapture failed.");
if (camera.doCapture())
System.out.println("doCapture succeeded...");
else
System.out.println("doCapture failed.");
if (camera.getImageSize() > 0) {
System.out.println("Storing image.jpg...");
if (camera.storeImage("image.jpg"))
System.out.println("storeImage succeeded...");
else
System.out.println("storeImage failed.");
}
// ! [Interesting]
}
}

View File

@ -1,40 +0,0 @@
/*
* Author: Stefan Andritoiu <stefan.andritoiu@intel.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.
*/
public class GroveButton_Example {
public static void main(String[] args) throws InterruptedException {
// ! [Interesting]
// Create the button object using GPIO pin 2
upm_grove.GroveButton button = new upm_grove.GroveButton(2);
while (true) {
System.out.println(button.name() + " value is " + button.value());
Thread.sleep(1000);
}
// ! [Interesting]
}
}

View File

@ -1,56 +0,0 @@
/*
* Author: Stefan Andritoiu <stefan.andritoiu@intel.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.
*/
public class GroveButton_intr_Example {
private static int counter = 0;
public static void incrementCounter() {
counter++;
}
public static void main(String[] args) throws InterruptedException {
// ! [Interesting]
upm_grove.GroveButton b = new upm_grove.GroveButton(2);
ButtonISR callback = new ButtonISR();
b.installISR(2, callback);
while (true) {
System.out.println("Counter: " + counter);
Thread.sleep(1000);
}
// ! [Interesting]
}
}
class ButtonISR implements Runnable {
public ButtonISR() {
super();
}
public void run() {
GroveButton_intr_Example.incrementCounter();
System.out.println("Button pressed!");
}
}

View File

@ -1,48 +0,0 @@
/*
* Author: Abhishek Malik <abhishek.malik@intel.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 upm_grovecollision.*;
public class GroveCollision_Example {
public static void main(String[] args) {
// Initializing the sensor on D2 on the Base Shield
upm_grovecollision.GroveCollision collision = new upm_grovecollision.GroveCollision(2);
boolean collisionState = false;
// ! [Interesting]
while(true){
if(collision.isColliding() && !collisionState){
System.out.println("Collision!!");
collisionState = true;
}
else if (collisionState){
System.out.println("No Collision!");
collisionState = false;
}
}
// ! [Interesting]
}
}

View File

@ -1,53 +0,0 @@
/*
* Author: Stefan Andritoiu <stefan.andritoiu@intel.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.
*/
//NOT TESTED!!!
public class GroveEHR_Example {
public static void main(String[] args) throws InterruptedException {
// ! [Interesting]
// Instantiate a Grove Ear-clip Heart Rate sensor on digital pin D2
upm_groveehr.GroveEHR heart = new upm_groveehr.GroveEHR(2);
// set the beat counter to 0, init the clock and start counting beats
heart.clearBeatCounter();
heart.initClock();
heart.startBeatCounter();
while (true) {
long millis = heart.getMillis();
long beats = heart.beatCounter();
// heartRate() requires that at least 5 seconds pass before
// returning anything other than 0
int hr = heart.heartRate();
// output milliseconds passed, beat count, and computed heart rate
System.out.println("Millis: " + millis + ", Beats: " + beats + ", Heart rate: " + hr);
Thread.sleep(1000);
}
// ! [Interesting]
}
}

View File

@ -1,47 +0,0 @@
/*
* Author: Abhishek Malik <abhishek.malik@intel.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 upm_groveemg.GroveEMG;
public class GroveEmg_Example {
public static void main(String[] args) {
// TODO Auto-generated method stub
//! [Interesting]
// Instantiating the Grove EMG sensor on Analog pin 0
GroveEMG emg = new GroveEMG(0);
System.out.println("Calibrating ... ");
emg.calibrate();
while(true){
System.out.println("EMG Val: "+emg.value());
try {
Thread.sleep(100);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
System.out.println("The following exception occurred: "+e.getMessage());
}
}
}
//! [Interesting]
}

View File

@ -1,50 +0,0 @@
/*
* Author: Abhishek Malik <abhishek.malik@intel.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 upm_grovegsr.GroveGSR;
public class GroveGsr_Example {
public static void main(String[] args) {
// TODO Auto-generated method stub
//! [Interesting]
// Instantiate a Grove GSR sensor on analog pin A0
GroveGSR gsr = new GroveGSR(0);
System.out.println("Calibrating...");
gsr.calibrate();
while(true){
System.out.println("Value: "+gsr.value());
try {
Thread.sleep(500);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
System.out.println("The following exception occurred: "+e.getMessage());
}
}
//! [Interesting]
}
}

View File

@ -1,39 +0,0 @@
/*
* Author: Andrei Vasiliu <andrei.vasiliu@intel.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.
*/
public class GroveLED_Example {
public static void main (String args[]) throws InterruptedException {
//! [Interesting]
upm_grove.GroveLed led = new upm_grove.GroveLed(2);
for (int i = 0; i < 10; ++i) {
led.on();
Thread.sleep(1000);
led.off();
Thread.sleep(1000);
}
led.delete();
//! [Interesting]
}
}

View File

@ -1,45 +0,0 @@
/*
* Author: Stefan Andritoiu <stefan.andritoiu@intel.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.
*/
//NOT TESTED!!!
public class GroveLed_multi_Example {
public static void main(String[] args) throws InterruptedException {
// ! [Interesting]
// Instantiate a grove LED on D2. Here we are controlling a Grove
// Multi-color flash LED. We just just need to turn it on - it will
// then cycle through various colors (red, green, blue, purple) on it's
// own until turned off.
upm_grove.GroveLed led = new upm_grove.GroveLed(2);
// start the light show
led.on();
// just sleep until interrupted
while (true) {
Thread.sleep(1);
}
// ! [Interesting]
}
}

View File

@ -1,41 +0,0 @@
/*
* Author: Stefan Andritoiu <stefan.andritoiu@intel.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.
*/
public class GroveLight_Example {
public static void main(String args[]) throws InterruptedException {
// ! [Interesting]
upm_grove.GroveLight gl = new upm_grove.GroveLight(2);
while (true) {
float raw_value = gl.raw_value();
float value = gl.value();
System.out.println("raw value: " + raw_value);
System.out.println("value: " + value);
Thread.sleep(1000);
}
// ! [Interesting]
}
}

View File

@ -1,45 +0,0 @@
/*
* Author: Stefan Andritoiu <stefan.andritoiu@intel.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.
*/
public class GroveLineFinder_Example {
public static void main(String[] args) throws InterruptedException {
// ! [Interesting]
// Instantiate a Grove Line Finder sensor on digital pin D2
upm_grovelinefinder.GroveLineFinder finder = new upm_grovelinefinder.GroveLineFinder(2);
// check every second for the presence of white detection
while (true) {
boolean val = finder.whiteDetected();
if (val) {
System.out.println("White detected");
} else {
System.out.println("Black detected");
}
Thread.sleep(1000);
}
// ! [Interesting]
}
}

View File

@ -1,53 +0,0 @@
/*
* Author: Stefan Andritoiu <stefan.andritoiu@intel.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.
*/
public class GroveMD_Example {
private static final short speed50 = 127;
private static final short speed0 = 0;
public static void main(String[] args) throws InterruptedException {
// ! [Interesting]
// Instantiate an I2C Grove Motor Driver on I2C bus 0
upm_grovemd.GroveMD motors = new upm_grovemd.GroveMD();
// set direction to clockwise (CW) and set speed to 50%
System.out.println("Spin M1 and M2 at half speed for 3 seconds");
motors.setMotorDirections(upm_grovemd.GroveMD.DC_DIRECTION_T.DIR_CW,
upm_grovemd.GroveMD.DC_DIRECTION_T.DIR_CW);
motors.setMotorSpeeds(speed50, speed50);
Thread.sleep(3000);
// counter clockwise (CCW)
System.out.println("Reversing M1 and M2 for 3 seconds");
motors.setMotorDirections(upm_grovemd.GroveMD.DC_DIRECTION_T.DIR_CCW,
upm_grovemd.GroveMD.DC_DIRECTION_T.DIR_CCW);
Thread.sleep(3000);
// stop motors
System.out.println("Stopping motors");
motors.setMotorSpeeds(speed0, speed0);
// ! [Interesting]
}
}

View File

@ -1,47 +0,0 @@
/*
* Author: Stefan Andritoiu <stefan.andritoiu@intel.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.
*/
public class GroveMoisture_Example {
public static void main(String args[]) throws InterruptedException {
// ! [Interesting]
upm_grovemoisture.GroveMoisture gm = new upm_grovemoisture.GroveMoisture(1);
while (true) {
int moisture_val = gm.value();
String result;
if (moisture_val >= 0 && moisture_val < 300)
result = "Dry";
else if ((moisture_val >= 0 && moisture_val < 300))
result = "Moist";
else
result = "Wet";
System.out.println("Moisture Value: " + moisture_val + ", " + result);
Thread.sleep(1000);
}
// ! [Interesting]
}
}

View File

@ -1,46 +0,0 @@
/*
* Author: Abhishek Malik <abhishek.malik@intel.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 upm_groveo2.GroveO2;
public class GroveO2_Example {
public static void main(String[] args) {
// TODO Auto-generated method stub
//! [Interesting]
// Initializing the Grove O2 sensor on the A) analog pin
GroveO2 o2 = new GroveO2(0);
while(true){
System.out.println("The output voltage is: "+o2.voltageValue());
try {
Thread.sleep(100);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
System.out.println("The following exception has occurred: "+e.getMessage());
}
}
//! [Interesting]
}
}

View File

@ -1,44 +0,0 @@
/*
* Author: Stefan Andritoiu <stefan.andritoiu@intel.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.
*/
public class GroveRelay_Example {
public static void main(String[] args) throws InterruptedException {
// ! [Interesting]
// Create the button object using UART
upm_grove.GroveRelay relay = new upm_grove.GroveRelay(5);
for (int i = 0; i < 3; i++) {
relay.on();
if (relay.isOn())
System.out.println("Relay is on");
Thread.sleep(1000);
relay.off();
if (relay.isOff())
System.out.println("Relay is off");
Thread.sleep(1000);
}
// ! [Interesting]
}
}

View File

@ -1,49 +0,0 @@
/*
* Author: Stefan Andritoiu <stefan.andritoiu@intel.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.
*/
public class GroveRotary_Example {
public static void main(String[] args) throws InterruptedException {
// ! [Interesting]
upm_grove.GroveRotary knob = new upm_grove.GroveRotary(0);
while (true) {
float abs_value = knob.abs_value(); // Absolute raw value
float abs_deg = knob.abs_deg(); // Absolute degrees
float abs_rad = knob.abs_rad(); // Absolute radians
float rel_value = knob.rel_value(); // Relative raw value
float rel_deg = knob.rel_deg(); // Relative degrees
float rel_rad = knob.rel_rad(); // Relative radians
System.out.println("Absolute: " + abs_value + " raw, " + abs_deg + " deg, " + abs_rad
+ " rad");
System.out.println("Relative: " + rel_value + " raw, " + rel_deg + " deg, " + rel_rad
+ " rad");
Thread.sleep(3000);
}
// ! [Interesting]
}
}

View File

@ -1,42 +0,0 @@
/*
* Author: Andrei Vasiliu <andrei.vasiliu@intel.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.
*/
public class GroveSlide_Example {
public static void main (String args[]) throws InterruptedException {
//! [Interesting]
// Instantiate new grove slide potentiometer on analog pin A0
upm_grove.GroveSlide slide = new upm_grove.GroveSlide(0);
while (true) {
float raw_value = slide.raw_value();
float value = slide.voltage_value();
System.out.println("raw value: " + raw_value);
System.out.println("value: " + value);
Thread.sleep(2500);
}
//! [Interesting]
}
}

View File

@ -1,40 +0,0 @@
/*
* Author: Andrei Vasiliu <andrei.vasiliu@intel.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.
*/
public class GroveSpeaker_Example {
public static void main(String[] args) throws InterruptedException {
// ! [Interesting]
// Instantiate a Grove Speaker on digital pin D2
upm_grovespeaker.GroveSpeaker speaker = new upm_grovespeaker.GroveSpeaker(2);
// Play all 7 of the lowest notes
speaker.playAll();
// Play a medium C-sharp
speaker.playSound('c', true, "med");
// ! [Interesting]
}
}

View File

@ -1,43 +0,0 @@
/*
* Author: Andrei Vasiliu <andrei.vasiliu@intel.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.
*/
public class GroveTemp_Example {
public static void main (String args[]) throws InterruptedException {
//! [Interesting]
upm_grove.GroveTemp temp = new upm_grove.GroveTemp(3);
for (int i = 0; i < 10; ++i) {
int celsius = temp.value();
int fahrneheit = celsius * 2 + 32;
System.out.println("Celsius: " + celsius);
System.out.println("Fahrneheit: " + fahrneheit);
Thread.sleep(1000);
}
temp.delete();
//! [Interesting]
}
}

View File

@ -1,41 +0,0 @@
/*
* Author: Stefan Andritoiu <stefan.andritoiu@gmail.com>
* Copyright (c) 2017 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.
*/
public class GroveUltraSonic_Example {
public static void main(String[] args) throws InterruptedException {
// ! [Interesting]
upm_groveultrasonic.GroveUltraSonic sonar = new upm_groveultrasonic.GroveUltraSonic(2);
while (true) {
int width = sonar.getDistance();
System.out.println("Echo width = " + width);
System.out.println("Distance inches = " + width / 148.0);
Thread.sleep(1000);
}
// ! [Interesting]
}
}

View File

@ -1,50 +0,0 @@
/*
* Author: Stefan Andritoiu <stefan.andritoiu@intel.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.
*/
//NOT TESTED!!!
public class GroveVDiv_Example {
private static final short gain3 = 3;
private static final short gain10 = 10;
public static void main(String[] args) throws InterruptedException {
// ! [Interesting]
// Instantiate a Grove Voltage Divider sensor on analog pin A0
upm_grovevdiv.GroveVDiv vDiv = new upm_grovevdiv.GroveVDiv(0);
// collect data and output measured voltage according to the setting
// of the scaling switch (3 or 10)
while (true) {
long val = vDiv.value(100);
float gain3val = vDiv.computedValue(gain3, val);
float gain10val = vDiv.computedValue(gain10, val);
System.out.println("ADC value: " + val + ", Gain 3: " + gain3val + "v, Gain 10: "
+ gain10val);
Thread.sleep(1000);
}
// ! [Interesting]
}
}

View File

@ -1,44 +0,0 @@
/*
* Author: Stefan Andritoiu <stefan.andritoiu@intel.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.
*/
//NOT TESTED!!!
public class GroveWFS_Example {
public static void main(String[] args) throws InterruptedException {
// ! [Interesting]
// Instantiate a Grove Water Flow Sensor on digital pin D2
upm_grovewfs.GroveWFS flow = new upm_grovewfs.GroveWFS(2);
flow.clearFlowCounter();
flow.startFlowCounter();
while (true) {
System.out.print("Millis: " + flow.getMillis() + " FlowCount: " + flow.flowCounter());
System.out.println(" Flow Rate: " + flow.flowRate() + " LPM");
Thread.sleep(2000);
}
// ! [Interesting]
}
}

View File

@ -1,45 +0,0 @@
/*
* Author: Stefan Andritoiu <stefan.andritoiu@intel.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.
*/
public class GroveWater_Example {
public static void main(String[] args) throws InterruptedException {
// ! [Interesting]
// Instantiate a Grove Water sensor on digital pin D2
upm_grovewater.GroveWater water = new upm_grovewater.GroveWater(2);
while (true) {
boolean val = water.isWet();
if (val) {
System.out.println("Sensor is wet");
} else {
System.out.println("Sensor is dry");
}
Thread.sleep(1000);
}
// ! [Interesting]
}
}

View File

@ -1,44 +0,0 @@
/*
* 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.
*/
var upmled = require("jsupm_grove");
// Initialize on GPIO 2
var myled = new upmled.GroveLed(2);
myled.on();
// Dummy setInterval, just to keep program from quitting
// This way, the LED turns off when you quit the program
var myInterval = setInterval(function()
{
;
}, 1000);
// When exiting: turn off LED, clear interval, and print message
process.on('SIGINT', function()
{
clearInterval(myInterval);
myled.off();
console.log("Exiting...");
process.exit(0);
});

View File

@ -1,35 +0,0 @@
/*
* Author: Sarah Knepper <sarah.knepper@intel.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.
*/
// Load Grove module
var groveSensor = require('jsupm_grove');
// Create the button object using GPIO pin 0
var button = new groveSensor.GroveButton(0);
// Read the input and print, waiting one second between readings
function readButtonValue() {
console.log(button.name() + " value is " + button.value());
}
setInterval(readButtonValue, 1000);

View File

@ -1,60 +0,0 @@
/*
* 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.
*/
var collision_lib = require("jsupm_grovecollision");
// The was tested with the Grove Collision Sensor
// Instantiate a Grove Collision on digital pin D2
var collision_obj = new collision_lib.GroveCollision(2);
var collisionState = false;
console.log("No collision");
// Having an infinate loop prevents nodeJS from catching Cntl-C
// We need to catch Cntl-C to clean up memory
// Instead, we check the collision sensor every millisecond
var myInterval = setInterval(function()
{
if (collision_obj.isColliding() && !collisionState)
{
console.log("Collision!");
collisionState = true;
}
else if (!collision_obj.isColliding() && collisionState)
{
console.log("No collision");
collisionState = false;
}
}, 1);
// When exiting: clear interval, clean up memory, and print message
process.on('SIGINT', function()
{
clearInterval(myInterval);
collision_obj = null;
collision_lib.cleanUp();
collision_lib = null;
console.log("Exiting...");
process.exit(0);
});

View File

@ -1,62 +0,0 @@
/*
* 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.
*/
// Load heart rate sensor module
var heartRateSensor = require('jsupm_groveehr');
// Instantiate a Grove Ear-clip Heart Rate sensor on digital pin D2
var myHeartRateSensor = new heartRateSensor.GroveEHR(2);
// set the beat counter to 0, init the clock and start counting beats
myHeartRateSensor.clearBeatCounter();
myHeartRateSensor.initClock();
myHeartRateSensor.startBeatCounter();
var millis, beats, hr;
var myInterval = setInterval(function()
{
// we grab these just for display purposes in this example
millis = myHeartRateSensor.getMillis();
beats = myHeartRateSensor.beatCounter();
// heartRate() requires that at least 5 seconds pass before
// returning anything other than 0
hr = myHeartRateSensor.heartRate();
// output milliseconds passed, beat count, and computed heart rate
console.log("Millis: " + millis + " Beats: " + beats +
" Heart Rate: " + hr);
}, 1000);
// Print message when exiting
process.on('SIGINT', function()
{
clearInterval(myInterval);
myHeartRateSensor.stopBeatCounter();
myHeartRateSensor = null
heartRateSensor.cleanUp();
heartRateSensor = null;
console.log("Exiting");
process.exit(0);
});

View File

@ -1,52 +0,0 @@
/*
* 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.
*/
var eldriver_lib = require("jsupm_groveeldriver");
// The was tested with the Grove El Driver Module
// Instantiate a Grove El Driver on digital pin D2
var eldriver_obj = new eldriver_lib.GroveElDriver(2);
var lightState = true;
var myInterval = setInterval(function()
{
if (lightState)
eldriver_obj.on();
else
eldriver_obj.off();
lightState = !lightState;
}, 1000);
// When exiting: turn off EL wire, clear interval, and print message
process.on('SIGINT', function()
{
clearInterval(myInterval);
eldriver_obj.off();
eldriver_obj = null;
eldriver_lib.cleanUp();
eldriver_lib = null;
console.log("Exiting...");
process.exit(0);
});

View File

@ -1,55 +0,0 @@
/*
* 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.
*/
var electromagnet_lib = require("jsupm_groveelectromagnet");
// The was tested with the Grove Electromagnetic Module
// Instantiate a Grove Electromagnet on digital pin D2
var electromagnet_obj = new electromagnet_lib.GroveElectromagnet(2);
console.log("Starting up magnet....");
electromagnet_obj.off();
var magnetState = false;
// Turn magnet on and off every 5 seconds
var myInterval = setInterval(function()
{
magnetState = !magnetState;
if (magnetState)
electromagnet_obj.on();
else
electromagnet_obj.off();
console.log("Turning magnet " + ((magnetState) ? "on" : "off"));
}, 5000);
// When exiting: clear interval, turn off magnet, run memory cleanup, and print message
process.on('SIGINT', function()
{
clearInterval(myInterval);
electromagnet_obj.off();
electromagnet_obj = null;
electromagnet_lib.cleanUp();
electromagnet_lib = null;
console.log("Exiting...");
process.exit(0);
});

View File

@ -1,46 +0,0 @@
/*
* 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.
*/
var groveemg_lib = require("jsupm_groveemg");
// The was tested with the GroveEMG Muscle Signal Reader Sensor Module
// Instantiate a GroveEMG on analog pin A0
var groveemg_obj = new groveemg_lib.GroveEMG(0);
console.log("Calibrating....");
groveemg_obj.calibrate();
var myInterval = setInterval(function()
{
console.log(groveemg_obj.value());
}, 100);
// When exiting: clear interval, and print message
process.on('SIGINT', function()
{
clearInterval(myInterval);
groveemg_obj = null;
groveemg_lib.cleanUp();
groveemg_lib = null;
console.log("Exiting...");
process.exit(0);
});

View File

@ -1,111 +0,0 @@
/*
* Author: Jon Trulson <jtrulson@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.
*/
var sensorObj = require('jsupm_grovegprs');
/************** Functions **************/
function printUsage(progname)
{
var outputStr = "Usage: " + progname + " [AT command]\n\n" +
"If an argument is supplied on the command line, that argument is\n" +
"sent to the module and the response is printed out.\n\n" +
"If no argument is used, then the manufacturer and the current\n" +
"saved profiles are queried and the results printed out.\n\n"
console.log(outputStr);
}
// simple helper function to send a command and wait for a response
function sendCommand(sensor, cmd, callback)
{
// commands need to be terminated with a carriage return
cmd += "\r";
sensor.writeDataStr(cmd);
// wait up to 1 second
if (sensor.dataAvailable(1000))
{
console.log("Returned: " + sensor.readDataStr(1024));
}
else
console.log("Timed out waiting for response");
if (callback)
callback();
}
/************** Main code **************/
// Instantiate a GROVEGPRS Module on UART 0
var sensor = new sensorObj.GroveGPRS(0);
// Set the baud rate, 19200 baud is the default.
if (sensor.setBaudRate(19200))
{
console.log("Failed to set baud rate");
process.exit(0);
}
printUsage(process.argv[1]);
// Note: in nodeJS, command-line argument 0 is "node".
// Command-line argument 1 is "grovegprs.js"
// If you have a third argument, then it's a command
if (process.argv.length > 2)
{
console.log("Sending command line argument (" + process.argv[2] + ")...");
sendCommand(sensor, process.argv[2]);
}
else
{
// sending this command as a synchronous callback ensures better timing
var callbackFunc = function()
{
setTimeout(function()
{
// query the saved profiles
console.log("Querying the saved profiles (AT&V)...");
sendCommand(sensor, "AT&V");
// A comprehensive list is available from the
// datasheet at:
// http://www.seeedstudio.com/wiki/images/7/72/AT_Commands_v1.11.pdf
}, 1000);
};
// query the module manufacturer
console.log("Querying module manufacturer (AT+CGMI)...");
sendCommand(sensor, "AT+CGMI", callbackFunc);
}
/************** Exit code **************/
process.on('SIGINT', function()
{
sensor = null;
sensorObj.cleanUp();
sensorObj = null;
console.log("Exiting...");
process.exit(0);
});

View File

@ -1,49 +0,0 @@
/*
* 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.
*/
var grovegsr_lib = require("jsupm_grovegsr");
// The was tested with the GroveGSR Galvanic Skin Response Sensor module.
// Instantiate a GroveGSR on analog pin A0
var grovegsr_obj = new grovegsr_lib.GroveGSR(0);
console.log("Calibrating....");
grovegsr_obj.calibrate();
var myInterval = setInterval(function()
{
console.log(grovegsr_obj.value());
}, 500);
// When exiting: clear interval, and print message
process.on('SIGINT', function()
{
clearInterval(myInterval);
grovegsr_obj = null;
grovegsr_lib.cleanUp();
grovegsr_lib = null;
console.log("Exiting...");
process.exit(0);
});

View File

@ -1,46 +0,0 @@
/*
* Author: Sarah Knepper <sarah.knepper@intel.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.
*/
// Load Grove module
var groveSensor = require('jsupm_grove');
// Create the Grove LED object using GPIO pin 2
var led = new groveSensor.GroveLed(2);
// Print the name
console.log(led.name());
// Turn the LED on and off 10 times, pausing one second
// between transitions
var i = 0;
var waiting = setInterval(function() {
if ( i % 2 == 0 ) {
led.on();
} else {
led.off();
}
i++;
if ( i == 20 ) clearInterval(waiting);
}, 1000);

View File

@ -1,37 +0,0 @@
/*
* Author: Sarah Knepper <sarah.knepper@intel.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.
*/
// Load Grove module
var groveSensor = require('jsupm_grove');
// Create the light sensor object using AIO pin 0
var light = new groveSensor.GroveLight(0);
// Read the input and print both the raw value and a rough lux value,
// waiting one second between readings
function readLightSensorValue() {
console.log(light.name() + " raw value is " + light.raw_value() +
", which is roughly " + light.value() + " lux");
}
setInterval(readLightSensorValue, 1000);

View File

@ -1,44 +0,0 @@
/*
* 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 lineFinderSensor = require('jsupm_grovelinefinder');
// Instantiate a Grove line finder sensor on digital pin D2
var myLineFinderSensor = new lineFinderSensor.GroveLineFinder(2);
// Check every second for the presence of white detection
setInterval(function()
{
if (myLineFinderSensor.whiteDetected())
console.log("White detected.");
else
console.log("Black detected.");
}, 1000);
// Turn relay off when exiting
process.on('SIGINT', function()
{
console.log("Exiting...");
process.exit(0);
});

View File

@ -1,92 +0,0 @@
/*
* Author: Jon Trulson <jtrulson@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.
*/
var grovemdObj = require('jsupm_grovemd');
// This example demonstrates using the GroveMD to drive a stepper motor
function start()
{
if (motor)
{
// configure it, for this example, we'll assume 200 steps per rev
motor.configStepper(200);
motor.setStepperSteps(100);
// start it going at 10 RPM
motor.enableStepper(grovemdObj.GroveMD.STEP_DIR_CW, 10);
}
}
function reverse()
{
if (motor)
{
// now reverse
motor.setStepperSteps(100);
// start it going at 10 RPM
motor.enableStepper(grovemdObj.GroveMD.STEP_DIR_CCW, 10);
}
}
function end()
{
if (motor)
{
motor.disableStepper();
}
exit();
}
// When exiting: clear memory and print exit message
function exit()
{
if (motor)
{
motor = null;
grovemdObj.cleanUp();
}
grovemdObj = null;
console.log("Exiting");
process.exit(0);
}
// Instantiate an I2C Grove Motor Driver on I2C bus 0
var motor = new grovemdObj.GroveMD(
grovemdObj.GROVEMD_I2C_BUS,
grovemdObj.GROVEMD_DEFAULT_I2C_ADDR);
start();
setTimeout(function()
{
reverse();
setTimeout(end, 3000);
}, 3000);
process.on('SIGINT', function()
{
exit();
});

View File

@ -1,91 +0,0 @@
/*
* 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.
*/
var groveMotorDriver_lib = require('jsupm_grovemd');
function start()
{
if (my_MotorDriver_obj)
{
// set direction to CW and set speed to 50%
console.log("Spin M1 and M2 at half speed for 3 seconds");
my_MotorDriver_obj.setMotorDirections(groveMotorDriver_lib.GroveMD.DIR_CW,
groveMotorDriver_lib.GroveMD.DIR_CW);
my_MotorDriver_obj.setMotorSpeeds(127, 127);
}
}
function reverse()
{
if (my_MotorDriver_obj)
{
// counter clockwise
console.log("Reversing M1 and M2 for 3 seconds");
my_MotorDriver_obj.setMotorDirections(groveMotorDriver_lib.GroveMD.DIR_CCW,
groveMotorDriver_lib.GroveMD.DIR_CCW);
}
}
function end()
{
if (my_MotorDriver_obj)
{
console.log("Stopping motors");
my_MotorDriver_obj.setMotorSpeeds(0, 0);
}
exit();
}
// When exiting: clear memory and print exit message
function exit()
{
if (my_MotorDriver_obj)
{
my_MotorDriver_obj = null;
groveMotorDriver_lib.cleanUp();
}
groveMotorDriver_lib = null;
console.log("Exiting");
process.exit(0);
}
// Instantiate an I2C Grove Motor Driver on I2C bus 0
var my_MotorDriver_obj = new groveMotorDriver_lib.GroveMD(
groveMotorDriver_lib.GROVEMD_I2C_BUS,
groveMotorDriver_lib.GROVEMD_DEFAULT_I2C_ADDR);
start();
setTimeout(function()
{
reverse();
setTimeout(end, 3000);
}, 3000);
process.on('SIGINT', function()
{
exit();
});

View File

@ -1,54 +0,0 @@
/*
* 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.
*/
//Load Grove Moisture module
var grove_moisture = require('jsupm_grovemoisture');
// Instantiate a Grove Moisture sensor on analog pin A0
var myMoistureObj = new grove_moisture.GroveMoisture(0);
// Values (approximate):
// 0-300, sensor in air or dry soil
// 300-600, sensor in humid soil
// 600+, sensor in wet soil or submerged in water
// Read the value every second and print the corresponding moisture level
setInterval(function()
{
var result;
var moisture_val = parseInt(myMoistureObj.value());
if (moisture_val >= 0 && moisture_val < 300)
result = "Dry";
else if (moisture_val >= 300 && moisture_val < 600)
result = "Moist";
else
result = "Wet";
console.log("Moisture value: " + moisture_val + ", " + result);
}, 1000);
// Print message when exiting
process.on('SIGINT', function()
{
console.log("Exiting...");
process.exit(0);
});

View File

@ -1,50 +0,0 @@
/*
* 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.
*/
var groveO2_lib = require("jsupm_groveo2");
// The was tested with the O2 Oxygen Concentration Sensor Module
// Instantiate a GroveO2 on analog pin A0
var groveO2_obj = new groveO2_lib.GroveO2(0);
var myInterval = setInterval(function()
{
console.log("The output voltage is: " + roundNum(groveO2_obj.voltageValue(), 5) + "mV");
}, 100);
function roundNum(num, decimalPlaces)
{
var extraNum = (1 / (Math.pow(10, decimalPlaces) * 1000));
return (Math.round((num + extraNum) * (Math.pow(10, decimalPlaces))) / Math.pow(10, decimalPlaces));
}
// When exiting: clear interval, and print message
process.on('SIGINT', function()
{
clearInterval(myInterval);
groveO2_obj = null;
groveO2_lib.cleanUp();
groveO2_lib = null;
console.log("Exiting...");
process.exit(0);
});

View File

@ -1,49 +0,0 @@
/*
* Author: Sarah Knepper <sarah.knepper@intel.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.
*/
// Load Grove module
var groveSensor = require('jsupm_grove');
// Create the relay switch object using GPIO pin 0
var relay = new groveSensor.GroveRelay(0);
// Close and then open the relay switch 3 times,
// waiting one second each time. The LED on the relay switch
// will light up when the switch is on (closed).
// The switch will also make a noise between transitions.
var i = 0;
var waiting = setInterval(function() {
if ( i % 2 == 0 ) {
relay.on();
if ( relay.isOn() )
console.log(relay.name() + " is on");
} else {
relay.off();
if ( relay.isOff() )
console.log(relay.name() + " is off");
}
i++;
if ( i == 6) clearInterval(waiting);
}, 1000);

View File

@ -1,49 +0,0 @@
/*
* Author: Mihai Tudor Panu <mihai.tudor.panu@intel.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.
*/
//setup/Initialization
var upm_grove = require('jsupm_grove');
//setup access analog input Analog pin #0 (A0)
var groveRotary = new upm_grove.GroveRotary(0);
loop();
function loop()
{
var abs = groveRotary.abs_value();
var absdeg = groveRotary.abs_deg();
var absrad = groveRotary.abs_rad();
var rel = groveRotary.rel_value();
var reldeg = groveRotary.rel_deg();
var relrad = groveRotary.rel_rad();
//write the knob value to the console in different formats
console.log("Abs: " + abs + " " + Math.round(parseInt(absdeg)) + " " + absrad.toFixed(3));
console.log("Rel: " + rel + " " + Math.round(parseInt(reldeg)) + " " + relrad.toFixed(3));
//wait 2 s and call function again
setTimeout(loop, 2000);
}

View File

@ -1,69 +0,0 @@
/*
* Author: Jon Trulson <jtrulson@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.
*/
var cameraObj = require('jsupm_grovescam');
// Instantiate a Grove Serial Camera on UART 0
var camera = new cameraObj.GROVESCAM(0);
// make sure port is initialized properly. 115200 baud is the default.
if (!camera.setupTty())
{
console.log("Failed to setup tty port parameters");
process.exit(1);
}
if (camera.init())
console.log("Initialized...");
else
console.log("init() failed");
if (camera.preCapture())
console.log("preCapture succeeded...");
else
console.log("preCapture failed.");
if (camera.doCapture())
console.log("doCapture succeeded...");
else
console.log("doCapture failed.");
console.log("Image size is " + camera.getImageSize() + " bytes");
if (camera.getImageSize() > 0)
{
console.log("Storing image.jpg...");
if (camera.storeImage("image.jpg"))
console.log("storeImage succeeded...");
else
console.log("storeImage failed.");
}
camera = null;
cameraObj.cleanUp();
cameraObj = null;
console.log("Exiting.");
process.exit(0);

View File

@ -1,42 +0,0 @@
/*
* Author: Mihai Tudor Panu <mihai.tudor.panu@intel.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 upm_grove = require('jsupm_grove');
//setup access analog input Analog pin #0 (A0)
var groveSlide = new upm_grove.GroveSlide(0);
loop();
function loop()
{
var raw = groveSlide.raw_value();
var volts = groveSlide.voltage_value();
//write the slider values to the console
console.log("Slider Value: " + raw + " = " + volts.toFixed(2) + " V");
//wait 2 s then call function again
setTimeout(loop, 2000);
}

View File

@ -1,41 +0,0 @@
/*
* 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.
*/
//Load Grove Speaker module
var groveSpeaker = require('jsupm_grovespeaker');
// Instantiate a Grove Speaker on digital pin D2
var mySpeaker = new groveSpeaker.GroveSpeaker(2);
// Play all 7 of the lowest notes
mySpeaker.playAll();
// Play a medium C-sharp
mySpeaker.playSound('c', true, "med");
// Print message when exiting
process.on('SIGINT', function()
{
console.log("Exiting...");
process.exit(0);
});

View File

@ -1,42 +0,0 @@
/*
* Author: Sarah Knepper <sarah.knepper@intel.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.
*/
// Load Grove module
var groveSensor = require('jsupm_grove');
// Create the temperature sensor object using AIO pin 0
var temp = new groveSensor.GroveTemp(0);
console.log(temp.name());
// Read the temperature ten times, printing both the Celsius and
// equivalent Fahrenheit temperature, waiting one second between readings
var i = 0;
var waiting = setInterval(function() {
var celsius = temp.value();
var fahrenheit = celsius * 9.0/5.0 + 32.0;
console.log(celsius + " degrees Celsius, or " +
Math.round(fahrenheit) + " degrees Fahrenheit");
i++;
if (i == 10) clearInterval(waiting);
}, 1000);

View File

@ -1,45 +0,0 @@
/*
* Author: Jun Kato <i@junkato.jp>
* Copyright (c) 2015 Jun Kato.
*
* Thanks to Seeed Studio for a working arduino sketch
*
* 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 ultrasonic = require("jsupm_groveultrasonic");
var sensor = new ultrasonic.GroveUltraSonic(2);
var myInterval = setInterval(function()
{
var travelTime = sensor.getDistance();
if (travelTime > 0) {
var distance = (travelTime / 29 / 2).toFixed(3);
console.log("distance: " + distance + " [cm]");
}
}, 200);
// When exiting: clear interval and print message
process.on('SIGINT', function()
{
clearInterval(myInterval);
console.log("Exiting...");
process.exit(0);
});

View File

@ -1,51 +0,0 @@
/*
* 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 voltageDivider = require('jsupm_grovevdiv');
// Instantiate a Grove Voltage Divider sensor on analog pin A0
var myVoltageDivider = new voltageDivider.GroveVDiv(0);
// collect data and output measured voltage according to the setting
// of the scaling switch (3 or 10)
var val, gain3val, gain10val;
function getVoltageInfo()
{
val = myVoltageDivider.value(100);
gain3val = myVoltageDivider.computedValue(3, val);
gain10val = myVoltageDivider.computedValue(10, val);
console.log("ADC value: " + val + " Gain 3: " + gain3val
+ "v Gain 10: " + gain10val + "v");
}
setInterval(getVoltageInfo, 1000);
// Print message when exiting
process.on('SIGINT', function()
{
myVoltageDivider = null;
voltageDivider.cleanUp();
voltageDivider = null;
console.log("Exiting...");
process.exit(0);
});

View File

@ -1,46 +0,0 @@
/*
* 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.
*/
// Load Grove module
var waterSensor = require('jsupm_grovewater');
// Instantiate a Grove Water sensor on digital pin D2
var water = new waterSensor.GroveWater(2);
// Read whether the sensor is wet/dry, waiting one second between readings
function readWaterState()
{
if (water.isWet())
console.log("Sensor is wet");
else
console.log("Sensor is dry");
}
setInterval(readWaterState, 1000);
// Print message when exiting
process.on('SIGINT', function()
{
console.log("Exiting...");
process.exit(0);
});

View File

@ -1,66 +0,0 @@
/*
* 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.
*/
var waterFlow_lib = require('jsupm_grovewfs');
// Instantiate a Grove Water Flow Sensor on digital pin D2
var myWaterFlow_obj = new waterFlow_lib.GroveWFS(2);
// set the flow counter to 0 and start counting
myWaterFlow_obj.clearFlowCounter();
myWaterFlow_obj.startFlowCounter();
var millis, flowCount, fr;
var myInterval = setInterval(function()
{
// we grab these (millis and flowCount) just for display
// purposes in this example
millis = myWaterFlow_obj.getMillis();
flowCount = myWaterFlow_obj.flowCounter();
fr = myWaterFlow_obj.flowRate();
// output milliseconds passed, flow count, and computed flow rate
outputStr = "Millis: " + millis + " Flow Count: " + flowCount +
" Flow Rate: " + fr + " LPM";
console.log(outputStr);
// best to gather data for at least one second for reasonable
// results.
}, 2000);
// When exiting: clear interval and print message
process.on('SIGINT', function()
{
clearInterval(myInterval);
myWaterFlow_obj.stopFlowCounter();
myWaterFlow_obj = null
waterFlow_lib.cleanUp();
waterFlow_lib = null;
console.log("Exiting");
process.exit(0);
});

View File

@ -23,11 +23,11 @@ from __future__ import print_function
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
import time
from upm import pyupm_grove as grove
from upm import pyupm_button as upmbutton
def main():
# Create the button object using GPIO pin 0
button = grove.Button(0)
button = upmbutton.Button(0)
# Read the input and print, waiting one second between readings
while 1:

View File

@ -1,41 +0,0 @@
#!/usr/bin/env python
from __future__ import print_function
# Author: Sarah Knepper <sarah.knepper@intel.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.
import time
from upm import pyupm_grove as grove
def main():
# Create the button object using GPIO pin 0
button = grove.GroveButton(0)
# Read the input and print, waiting one second between readings
while 1:
print(button.name(), ' value is ', button.value())
time.sleep(1)
# Delete the button object
del button
if __name__ == '__main__':
main()

View File

@ -1,60 +0,0 @@
#!/usr/bin/env 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.
from __future__ import print_function
import time, sys, signal, atexit
from upm import pyupm_grovecollision as upmGrovecollision
def main():
# The was tested with the Grove Collision Sensor
# Instantiate a Grove Collision on digital pin D2
myGrovecollision = upmGrovecollision.GroveCollision(2)
## 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 myGrovecollision
def exitHandler():
print("Exiting")
sys.exit(0)
# Register exit handlers
atexit.register(exitHandler)
signal.signal(signal.SIGINT, SIGINTHandler)
collisionState = False
print("No collision")
while(1):
if (myGrovecollision.isColliding() and not collisionState):
print("Collision!")
collisionState = True
elif (not myGrovecollision.isColliding() and collisionState):
print("No collision")
collisionState = False
if __name__ == '__main__':
main()

View File

@ -1,70 +0,0 @@
#!/usr/bin/env 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.
from __future__ import print_function
import time, sys, signal, atexit
from upm import pyupm_groveehr as upmGroveehr
def main():
# Instantiate a Grove Ear-clip Heart Rate sensor on digital pin D2
myHeartRateSensor = upmGroveehr.GroveEHR(2)
## 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 myHeartRateSensor
def exitHandler():
myHeartRateSensor.stopBeatCounter()
print("Exiting")
sys.exit(0)
# Register exit handlers
atexit.register(exitHandler)
signal.signal(signal.SIGINT, SIGINTHandler)
# set the beat counter to 0, init the clock and start counting beats
myHeartRateSensor.clearBeatCounter()
myHeartRateSensor.initClock()
myHeartRateSensor.startBeatCounter()
while(1):
# we grab these (millis and flowCount) just for display
# purposes in this example
millis = myHeartRateSensor.getMillis()
beats = myHeartRateSensor.beatCounter()
# heartRate() requires that at least 5 seconds pass before
# returning anything other than 0
fr = myHeartRateSensor.heartRate()
# output milliseconds passed, beat count, and computed heart rate
outputStr = "Millis: {0} Beats: {1} Heart Rate: {2}".format(
millis, beats, fr)
print(outputStr)
time.sleep(1)
if __name__ == '__main__':
main()

View File

@ -1,60 +0,0 @@
#!/usr/bin/env 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.
from __future__ import print_function
import time, sys, signal, atexit
from upm import pyupm_groveeldriver as upmGroveeldriver
def main():
# The was tested with the Grove El Driver Module
# Instantiate a Grove El Driver on digital pin D2
myEldriver = upmGroveeldriver.GroveElDriver(2)
## Exit handlers ##
# This function stops python from printing a stacktrace when you hit control-C
def SIGINTHandler(signum, frame):
raise SystemExit
# This function lets you run code on exit, including functions from myEldriver
def exitHandler():
print("Exiting")
myEldriver.off()
sys.exit(0)
# Register exit handlers
atexit.register(exitHandler)
signal.signal(signal.SIGINT, SIGINTHandler)
lightState = True
while(1):
if (lightState):
myEldriver.on()
else:
myEldriver.off()
lightState = not lightState
time.sleep(1)
if __name__ == '__main__':
main()

View File

@ -1,63 +0,0 @@
#!/usr/bin/env 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.
from __future__ import print_function
import time, sys, signal, atexit
from upm import pyupm_groveelectromagnet as upmGroveelectromagnet
def main():
# This was tested with the Grove Electromagnetic Module
# Instantiate a Grove Electromagnet on digital pin D2
myElectromagnet = upmGroveelectromagnet.GroveElectromagnet(2)
## 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 myElectromagnet
def exitHandler():
print("Exiting")
myElectromagnet.off()
sys.exit(0)
# Register exit handlers
atexit.register(exitHandler)
signal.signal(signal.SIGINT, SIGINTHandler)
magnetState = False
# Turn magnet on and off every 5 seconds
while(1):
magnetState = not magnetState
if (magnetState):
myElectromagnet.on()
else:
myElectromagnet.off()
print("Turning magnet", ("on" if magnetState else "off"))
time.sleep(5)
if __name__ == '__main__':
main()

View File

@ -1,55 +0,0 @@
#!/usr/bin/env 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.
from __future__ import print_function
import time, sys, signal, atexit
from upm import pyupm_groveemg as upmGroveemg
def main():
# Tested with the GroveEMG Muscle Signal Reader Sensor Module
# Instantiate a GroveEMG on analog pin A0
myEMG = upmGroveemg.GroveEMG(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 myEMG
def exitHandler():
print("Exiting")
sys.exit(0)
# Register exit handlers
atexit.register(exitHandler)
signal.signal(signal.SIGINT, SIGINTHandler)
print("Calibrating....")
myEMG.calibrate()
while (1):
print(myEMG.value())
time.sleep(.1)
if __name__ == '__main__':
main()

View File

@ -1,89 +0,0 @@
#!/usr/bin/env python
# Author: Jon Trulson <jtrulson@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.
from __future__ import print_function
import time, sys, signal, atexit
from upm import pyupm_grovegprs as sensorObj
def main():
# Instantiate a GroveGPRS Module on UART 0
sensor = sensorObj.GroveGPRS(0)
## Exit handlers ##
# This stops python from printing a stacktrace when you hit control-C
def SIGINTHandler(signum, frame):
raise SystemExit
# This function lets you run code on exit
def exitHandler():
print("Exiting")
sys.exit(0)
# Register exit handlers
atexit.register(exitHandler)
signal.signal(signal.SIGINT, SIGINTHandler)
# Set the baud rate, 19200 baud is the default.
if (sensor.setBaudRate(19200)):
print("Failed to set baud rate")
sys.exit(0)
usageStr = ("Usage:\n"
"If an argument is supplied on the command line, that argument is\n"
"sent to the module and the response is printed out.\n\n"
"If no argument is used, then the manufacturer and the current\n"
"saved profiles are queried and the results printed out.\n\n")
print(usageStr)
# simple helper function to send a command and wait for a response
def sendCommand(sensor, cmd):
# commands need to be terminated with a carriage return
cmd += "\r";
sensor.writeDataStr(cmd)
# wait up to 1 second
if (sensor.dataAvailable(1000)):
print("Returned: ", end=' ')
print(sensor.readDataStr(1024))
else:
print("Timed out waiting for response")
if (len(sys.argv) > 1):
print("Sending command line argument (" + sys.argv[1] + ")...")
sendCommand(sensor, sys.argv[1])
else:
# query the module manufacturer
print("Querying module manufacturer (AT+CGMI)...")
sendCommand(sensor, "AT+CGMI");
time.sleep(1);
# query the saved profiles
print("Querying the saved profiles (AT&V)...")
sendCommand(sensor, "AT&V");
# A comprehensive list is available from the datasheet at:
# http://www.seeedstudio.com/wiki/images/7/72/AT_Commands_v1.11.pdf
if __name__ == '__main__':
main()

View File

@ -1,56 +0,0 @@
#!/usr/bin/env 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.
from __future__ import print_function
import time, sys, signal, atexit
from upm import pyupm_grovegsr as upmGrovegsr
def main():
# Tested with the GroveGSR Galvanic Skin Response Sensor module.
# Instantiate a GroveGSR on analog pin A0
myGSR = upmGrovegsr.GroveGSR(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 myGSR
def exitHandler():
print("Exiting")
sys.exit(0)
# Register exit handlers
atexit.register(exitHandler)
signal.signal(signal.SIGINT, SIGINTHandler)
print("Calibrating....")
myGSR.calibrate()
while (1):
print(myGSR.value())
time.sleep(.5)
if __name__ == '__main__':
main()

View File

@ -1,47 +0,0 @@
#!/usr/bin/env python
from __future__ import print_function
# Author: Sarah Knepper <sarah.knepper@intel.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
from upm import pyupm_grove as grove
def main():
# Create the Grove LED object using GPIO pin 2
led = grove.GroveLed(2)
# Print the name
print(led.name())
# Turn the LED on and off 10 times, pausing one second
# between transitions
for i in range (0,10):
led.on()
time.sleep(1)
led.off()
time.sleep(1)
# Delete the Grove LED object
del led
if __name__ == '__main__':
main()

View File

@ -1,43 +0,0 @@
#!/usr/bin/env python
from __future__ import print_function
# Author: Sarah Knepper <sarah.knepper@intel.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.
import time
from upm import pyupm_grove as grove
def main():
# Create the light sensor object using AIO pin 0
light = grove.GroveLight(0)
# Read the input and print both the raw value and a rough lux value,
# waiting one second between readings
while 1:
print(light.name() + " raw value is %d" % light.raw_value() + \
", which is roughly %d" % light.value() + " lux");
time.sleep(1)
# Delete the light sensor object
del light
if __name__ == '__main__':
main()

View File

@ -1,54 +0,0 @@
#!/usr/bin/env 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.
from __future__ import print_function
import time, sys, signal, atexit
from upm import pyupm_grovelinefinder as upmGrovelinefinder
def main():
# Instantiate a Grove line finder sensor on digital pin D2
myLineFinder = upmGrovelinefinder.GroveLineFinder(2)
## Exit handlers ##
# This function stops python from printing a stacktrace when you hit control-C
def SIGINTHandler(signum, frame):
raise SystemExit
# This function lets you run code on exit, including functions from myLineFinder
def exitHandler():
print("Exiting")
sys.exit(0)
# Register exit handlers
atexit.register(exitHandler)
signal.signal(signal.SIGINT, SIGINTHandler)
while(1):
if (myLineFinder.whiteDetected()):
print("White detected.")
else:
print("Black detected.")
time.sleep(1)
if __name__ == '__main__':
main()

View File

@ -1,55 +0,0 @@
#!/usr/bin/env python
# Author: Jon Trulson <jtrulson@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
from upm import pyupm_grovemd as upmGrovemd
def main():
I2C_BUS = upmGrovemd.GROVEMD_I2C_BUS
I2C_ADDR = upmGrovemd.GROVEMD_DEFAULT_I2C_ADDR
# Instantiate an I2C Grove Motor Driver on I2C bus 0
myMotorDriver = upmGrovemd.GroveMD(I2C_BUS, I2C_ADDR)
# This example demonstrates using the GroveMD to drive a stepper motor
# configure it, for this example, we'll assume 200 steps per rev
myMotorDriver.configStepper(200)
# set for half a rotation
myMotorDriver.setStepperSteps(100)
# let it go - clockwise rotation, 10 RPM speed
myMotorDriver.enableStepper(upmGrovemd.GroveMD.STEP_DIR_CW, 10)
time.sleep(3)
# Now do it backwards...
myMotorDriver.setStepperSteps(100)
myMotorDriver.enableStepper(upmGrovemd.GroveMD.STEP_DIR_CCW, 10)
# now disable
myMotorDriver.disableStepper()
if __name__ == '__main__':
main()

View File

@ -1,51 +0,0 @@
#!/usr/bin/env 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.
from __future__ import print_function
import time
from upm import pyupm_grovemd as upmGrovemd
def main():
I2C_BUS = upmGrovemd.GROVEMD_I2C_BUS
I2C_ADDR = upmGrovemd.GROVEMD_DEFAULT_I2C_ADDR
# Instantiate an I2C Grove Motor Driver on I2C bus 0
myMotorDriver = upmGrovemd.GroveMD(I2C_BUS, I2C_ADDR)
# set direction to CW and set speed to 50%
print("Spin M1 and M2 at half speed for 3 seconds")
myMotorDriver.setMotorDirections(upmGrovemd.GroveMD.DIR_CW, upmGrovemd.GroveMD.DIR_CW)
myMotorDriver.setMotorSpeeds(127, 127)
time.sleep(3)
# counter clockwise
print("Reversing M1 and M2 for 3 seconds")
myMotorDriver.setMotorDirections(upmGrovemd.GroveMD.DIR_CCW,
upmGrovemd.GroveMD.DIR_CCW)
time.sleep(3)
print("Stopping motors")
myMotorDriver.setMotorSpeeds(0, 0)
if __name__ == '__main__':
main()

View File

@ -1,64 +0,0 @@
#!/usr/bin/env 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.
from __future__ import print_function
import time, sys, signal, atexit
from upm import pyupm_grovemoisture as upmMoisture
def main():
# Instantiate a Grove Moisture sensor on analog pin A0
myMoisture = upmMoisture.GroveMoisture(0)
## Exit handlers ##
# This function stops python from printing a stacktrace when you hit control-C
def SIGINTHandler(signum, frame):
raise SystemExit
# This function lets you run code on exit, including functions from myMoisture
def exitHandler():
print("Exiting")
sys.exit(0)
# Register exit handlers
atexit.register(exitHandler)
signal.signal(signal.SIGINT, SIGINTHandler)
# Values (approximate):
# 0-300, sensor in air or dry soil
# 300-600, sensor in humid soil
# 600+, sensor in wet soil or submerged in water
# Read the value every second and print the corresponding moisture level
while(1):
moisture_val = myMoisture.value()
if (moisture_val >= 0 and moisture_val < 300):
result = "Dry"
elif (moisture_val >= 300 and moisture_val < 600):
result = "Moist"
else:
result = "Wet"
print("Moisture value: {0}, {1}".format(moisture_val, result))
time.sleep(1)
if __name__ == '__main__':
main()

View File

@ -1,54 +0,0 @@
#!/usr/bin/env 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.
from __future__ import print_function
import time, sys, signal, atexit
from upm import pyupm_groveo2 as upmGroveo2
def main():
# This was tested with the O2 Oxygen Concentration Sensor Module
# Instantiate a GroveO2 on analog pin A0
myGroveO2 = upmGroveo2.GroveO2(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 myGroveO2
def exitHandler():
print("Exiting")
sys.exit(0)
# Register exit handlers
atexit.register(exitHandler)
signal.signal(signal.SIGINT, SIGINTHandler)
while(1):
print("The output voltage is: {0}mV".format(
myGroveO2.voltageValue()))
time.sleep(.1)
if __name__ == '__main__':
main()

View File

@ -1,50 +0,0 @@
#!/usr/bin/env python
from __future__ import print_function
# Author: Sarah Knepper <sarah.knepper@intel.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
from upm import pyupm_grove as grove
def main():
# Create the relay switch object using GPIO pin 0
relay = grove.GroveRelay(0)
# Close and then open the relay switch 3 times,
# waiting one second each time. The LED on the relay switch
# will light up when the switch is on (closed).
# The switch will also make a noise between transitions.
for i in range (0,3):
relay.on()
if relay.isOn():
print(relay.name(), 'is on')
time.sleep(1)
relay.off()
if relay.isOff():
print(relay.name(), 'is off')
time.sleep(1)
# Delete the relay switch object
del relay
if __name__ == '__main__':
main()

View File

@ -1,50 +0,0 @@
#!/usr/bin/env python
from __future__ import print_function
# Author: Mihai Tudor Panu <mihai.tudor.panu@intel.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.
from time import sleep
from upm import pyupm_grove as grove
def main():
# New knob on AIO pin 0
knob = grove.GroveRotary(0)
# Loop indefinitely
while True:
# Read values
abs = knob.abs_value()
absdeg = knob.abs_deg()
absrad = knob.abs_rad()
rel = knob.rel_value()
reldeg = knob.rel_deg()
relrad = knob.rel_rad()
print("Abs values: %4d" % int(abs) , " raw %4d" % int(absdeg), "deg = %5.2f" % absrad , " rad ", end=' ')
print("Rel values: %4d" % int(rel) , " raw %4d" % int(reldeg), "deg = %5.2f" % relrad , " rad")
# Sleep for 2.5 s
sleep(2.5)
if __name__ == '__main__':
main()

View File

@ -1,66 +0,0 @@
#!/usr/bin/env python
#
# Author: Jon Trulson <jtrulson@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.
from __future__ import print_function
import sys
from upm import pyupm_grovescam as upmGrovescam
def main():
# Instantiate a Grove Serial Camera on UART 0
camera = upmGrovescam.GROVESCAM(0)
# make sure port is initialized properly. 115200 baud is the default.
if (not camera.setupTty()):
print("Failed to setup tty port parameters")
sys.exit(1)
if (camera.init()):
print("Initialized...")
else:
print("init() failed")
if (camera.preCapture()):
print("preCapture succeeded...")
else:
print("preCapture failed.")
if (camera.doCapture()):
print("doCapture succeeded...")
else:
print("doCapture failed.")
print("Image size is", camera.getImageSize(), "bytes")
if (camera.getImageSize() > 0):
print("Storing image.jpg...")
if (camera.storeImage("image.jpg")):
print("storeImage succeeded...")
else:
print("storeImage failed.")
print("Exiting.")
sys.exit(0)
if __name__ == '__main__':
main()

View File

@ -1,44 +0,0 @@
#!/usr/bin/env python
from __future__ import print_function
# Author: Mihai Tudor Panu <mihai.tudor.panu@intel.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.
from time import sleep
from upm import pyupm_grove as grove
def main():
# New Grove Slider on AIO pin 0
slider = grove.GroveSlide(0)
# Loop indefinitely
while True:
# Read values
raw = slider.raw_value()
volts = slider.voltage_value()
print("Slider value: ", raw , " = %.2f" % volts , " V")
# Sleep for 2.5 s
sleep(2.5)
if __name__ == '__main__':
main()

View File

@ -1,38 +0,0 @@
#!/usr/bin/env 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
from upm import pyupm_grovespeaker as upmGrovespeaker
def main():
# Instantiate a Grove Speaker on digital pin D2
mySpeaker = upmGrovespeaker.GroveSpeaker(2)
# Play all 7 of the lowest notes
mySpeaker.playAll()
# Play a medium C-sharp
mySpeaker.playSound('c', True, "med")
if __name__ == '__main__':
main()

View File

@ -1,47 +0,0 @@
#!/usr/bin/env python
from __future__ import print_function
# Author: Brendan Le Foll <brendan.le.foll@intel.com>
# Contributions: Sarah Knepper <sarah.knepper@intel.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.
import time
from upm import pyupm_grove as grove
def main():
# Create the temperature sensor object using AIO pin 0
temp = grove.GroveTemp(0)
print(temp.name())
# Read the temperature ten times, printing both the Celsius and
# equivalent Fahrenheit temperature, waiting one second between readings
for i in range(0, 10):
celsius = temp.value()
fahrenheit = celsius * 9.0/5.0 + 32.0;
print("%d degrees Celsius, or %d degrees Fahrenheit" \
% (celsius, fahrenheit))
time.sleep(1)
# Delete the temperature sensor object
del temp
if __name__ == '__main__':
main()

View File

@ -1,57 +0,0 @@
#!/usr/bin/env 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.
from __future__ import print_function
import time, sys, signal, atexit
from upm import pyupm_grovevdiv as upmGrovevdiv
def main():
# Instantiate a Grove Voltage Divider sensor on analog pin A0
myVoltageDivider = upmGrovevdiv.GroveVDiv(0)
## Exit handlers ##
# This stops python from printing a stacktrace when you hit control-C
def SIGINTHandler(signum, frame):
raise SystemExit
# This function lets you run code on exit,
# including functions from myVoltageDivider
def exitHandler():
print("Exiting")
sys.exit(0)
# Register exit handlers
atexit.register(exitHandler)
signal.signal(signal.SIGINT, SIGINTHandler)
while(1):
val = myVoltageDivider.value(100)
gain3val = myVoltageDivider.computedValue(3, val)
gain10val = myVoltageDivider.computedValue(10, val)
print("ADC value: {0} Gain 3: {1}v Gain 10: {2}v".format(
val, gain3val, gain10val))
time.sleep(1)
if __name__ == '__main__':
main()

View File

@ -1,54 +0,0 @@
#!/usr/bin/env 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.
from __future__ import print_function
import time, sys, signal, atexit
from upm import pyupm_grovewater as upmGrovewater
def main():
# Instantiate a Grove Water sensor on digital pin D2
myWaterSensor = upmGrovewater.GroveWater(2)
## Exit handlers ##
# This function stops python from printing a stacktrace when you hit control-C
def SIGINTHandler(signum, frame):
raise SystemExit
# This function lets you run code on exit, including functions from myWaterSensor
def exitHandler():
print("Exiting")
sys.exit(0)
# Register exit handlers
atexit.register(exitHandler)
signal.signal(signal.SIGINT, SIGINTHandler)
while(1):
if (myWaterSensor.isWet()):
print("Sensor is wet")
else:
print("Sensor is dry")
time.sleep(1)
if __name__ == '__main__':
main()

Some files were not shown because too many files have changed in this diff Show More