diff --git a/docs/images/grovebutton.jpg b/docs/images/grovebutton.jpg deleted file mode 100644 index ac2aaa007..000000000 Binary files a/docs/images/grovebutton.jpg and /dev/null differ diff --git a/docs/images/grovecollision.jpg b/docs/images/grovecollision.jpg deleted file mode 100644 index 8476e1d7c..000000000 Binary files a/docs/images/grovecollision.jpg and /dev/null differ diff --git a/docs/images/groveehr.jpg b/docs/images/groveehr.jpg deleted file mode 100644 index fd18394ba..000000000 Binary files a/docs/images/groveehr.jpg and /dev/null differ diff --git a/docs/images/groveeldriver.jpg b/docs/images/groveeldriver.jpg deleted file mode 100644 index cb106d8ff..000000000 Binary files a/docs/images/groveeldriver.jpg and /dev/null differ diff --git a/docs/images/groveelectromagnet.jpg b/docs/images/groveelectromagnet.jpg deleted file mode 100644 index 0da5d1d56..000000000 Binary files a/docs/images/groveelectromagnet.jpg and /dev/null differ diff --git a/docs/images/grovegprs.jpg b/docs/images/grovegprs.jpg deleted file mode 100644 index 591657454..000000000 Binary files a/docs/images/grovegprs.jpg and /dev/null differ diff --git a/docs/images/groveled.jpg b/docs/images/groveled.jpg deleted file mode 100644 index 52f2d7ea2..000000000 Binary files a/docs/images/groveled.jpg and /dev/null differ diff --git a/docs/images/grovelight.jpg b/docs/images/grovelight.jpg deleted file mode 100644 index 4bad3f717..000000000 Binary files a/docs/images/grovelight.jpg and /dev/null differ diff --git a/docs/images/grovelinefinder.jpg b/docs/images/grovelinefinder.jpg deleted file mode 100644 index 48f024080..000000000 Binary files a/docs/images/grovelinefinder.jpg and /dev/null differ diff --git a/docs/images/groveloudness.jpg b/docs/images/groveloudness.jpg deleted file mode 100644 index e98747271..000000000 Binary files a/docs/images/groveloudness.jpg and /dev/null differ diff --git a/docs/images/grovemd.jpg b/docs/images/grovemd.jpg deleted file mode 100644 index f9da824d2..000000000 Binary files a/docs/images/grovemd.jpg and /dev/null differ diff --git a/docs/images/grovemoisture.jpg b/docs/images/grovemoisture.jpg deleted file mode 100644 index 167d7cea5..000000000 Binary files a/docs/images/grovemoisture.jpg and /dev/null differ diff --git a/docs/images/groveo2.jpg b/docs/images/groveo2.jpg deleted file mode 100644 index 806e40d38..000000000 Binary files a/docs/images/groveo2.jpg and /dev/null differ diff --git a/docs/images/groverelay.jpg b/docs/images/groverelay.jpg deleted file mode 100644 index fb0b0e1a5..000000000 Binary files a/docs/images/groverelay.jpg and /dev/null differ diff --git a/docs/images/grovergblcd.jpg b/docs/images/grovergblcd.jpg deleted file mode 100644 index cc7c59fdd..000000000 Binary files a/docs/images/grovergblcd.jpg and /dev/null differ diff --git a/docs/images/groverotary.jpg b/docs/images/groverotary.jpg deleted file mode 100644 index ef6d747da..000000000 Binary files a/docs/images/groverotary.jpg and /dev/null differ diff --git a/docs/images/grovescam.jpg b/docs/images/grovescam.jpg deleted file mode 100644 index a69e1fd02..000000000 Binary files a/docs/images/grovescam.jpg and /dev/null differ diff --git a/docs/images/grovespeaker.jpg b/docs/images/grovespeaker.jpg deleted file mode 100644 index f4e901d44..000000000 Binary files a/docs/images/grovespeaker.jpg and /dev/null differ diff --git a/docs/images/grovetemp.jpg b/docs/images/grovetemp.jpg deleted file mode 100644 index 43fd72cf7..000000000 Binary files a/docs/images/grovetemp.jpg and /dev/null differ diff --git a/docs/images/groveultrasonic.jpg b/docs/images/groveultrasonic.jpg deleted file mode 100644 index 2e6e39d34..000000000 Binary files a/docs/images/groveultrasonic.jpg and /dev/null differ diff --git a/docs/images/grovevdiv.jpg b/docs/images/grovevdiv.jpg deleted file mode 100644 index 1bd9c142f..000000000 Binary files a/docs/images/grovevdiv.jpg and /dev/null differ diff --git a/docs/images/grovewfs.jpg b/docs/images/grovewfs.jpg deleted file mode 100644 index 557830ba9..000000000 Binary files a/docs/images/grovewfs.jpg and /dev/null differ diff --git a/examples/c++/grove-grovebutton.cxx b/examples/c++/grove-grovebutton.cxx deleted file mode 100644 index eae504c87..000000000 --- a/examples/c++/grove-grovebutton.cxx +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Author: Sarah Knepper - * 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 -#include - -#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; -} diff --git a/examples/c++/grove-groveled-multi.cxx b/examples/c++/grove-groveled-multi.cxx deleted file mode 100644 index b82512be5..000000000 --- a/examples/c++/grove-groveled-multi.cxx +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Author: Jon Trulson - * 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 -#include - -#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; -} diff --git a/examples/c++/grove-groveled.cxx b/examples/c++/grove-groveled.cxx deleted file mode 100644 index 02b8e0e39..000000000 --- a/examples/c++/grove-groveled.cxx +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Author: Brendan Le Foll - * Contributions: Sarah Knepper - * 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 -#include - -#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; -} diff --git a/examples/c++/grove-grovelight.cxx b/examples/c++/grove-grovelight.cxx deleted file mode 100644 index b0255c65b..000000000 --- a/examples/c++/grove-grovelight.cxx +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Author: Brendan Le Foll - * Contributions: Sarah Knepper - * 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 -#include - -#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; -} diff --git a/examples/c++/grove-groverelay.cxx b/examples/c++/grove-groverelay.cxx deleted file mode 100644 index 653a748d0..000000000 --- a/examples/c++/grove-groverelay.cxx +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Author: Sarah Knepper - * 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 -#include - -#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; -} diff --git a/examples/c++/grove-groverotary.cxx b/examples/c++/grove-groverotary.cxx deleted file mode 100644 index a101a0b19..000000000 --- a/examples/c++/grove-groverotary.cxx +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Author: Mihai Tudor Panu - * 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 -#include -#include -#include - -#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; -} diff --git a/examples/c++/grove-groveslide.cxx b/examples/c++/grove-groveslide.cxx deleted file mode 100644 index 5b734cea8..000000000 --- a/examples/c++/grove-groveslide.cxx +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Author: Mihai Tudor Panu - * 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 -#include -#include -#include - -#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; -} diff --git a/examples/c++/grove-grovetemp.cxx b/examples/c++/grove-grovetemp.cxx deleted file mode 100644 index 600fdb431..000000000 --- a/examples/c++/grove-grovetemp.cxx +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Author: Brendan Le Foll - * Contributions: Sarah Knepper - * 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 -#include -#include - -#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; -} diff --git a/examples/c++/grovecollision.cxx b/examples/c++/grovecollision.cxx deleted file mode 100644 index 5471f815f..000000000 --- a/examples/c++/grovecollision.cxx +++ /dev/null @@ -1,66 +0,0 @@ -/* -* Author: Zion Orent -* 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 -#include - -#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; -} diff --git a/examples/c++/groveehr.cxx b/examples/c++/groveehr.cxx deleted file mode 100644 index 261edc4c9..000000000 --- a/examples/c++/groveehr.cxx +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Author: Jon Trulson - * 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 -#include - -#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; -} diff --git a/examples/c++/groveeldriver.cxx b/examples/c++/groveeldriver.cxx deleted file mode 100644 index a390b6aa6..000000000 --- a/examples/c++/groveeldriver.cxx +++ /dev/null @@ -1,67 +0,0 @@ -/* -* Author: Zion Orent -* 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 -#include - -#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; -} diff --git a/examples/c++/groveelectromagnet.cxx b/examples/c++/groveelectromagnet.cxx deleted file mode 100644 index 01df036a7..000000000 --- a/examples/c++/groveelectromagnet.cxx +++ /dev/null @@ -1,81 +0,0 @@ -/* -* Author: Zion Orent -* 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 -#include -#include -#include - -#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; -} diff --git a/examples/c++/groveemg.cxx b/examples/c++/groveemg.cxx deleted file mode 100644 index 6e1ae0562..000000000 --- a/examples/c++/groveemg.cxx +++ /dev/null @@ -1,61 +0,0 @@ -/* -* Author: Zion Orent -* 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 -#include - -#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; -} diff --git a/examples/c++/grovegprs.cxx b/examples/c++/grovegprs.cxx deleted file mode 100644 index 1d991772e..000000000 --- a/examples/c++/grovegprs.cxx +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Author: Jon Trulson - * 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 - -#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; -} diff --git a/examples/c++/grovegsr.cxx b/examples/c++/grovegsr.cxx deleted file mode 100644 index 89a7f7ba0..000000000 --- a/examples/c++/grovegsr.cxx +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Author: Zion Orent - * 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 -#include - -#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; -} diff --git a/examples/c++/grovelinefinder.cxx b/examples/c++/grovelinefinder.cxx deleted file mode 100644 index 7c5245fde..000000000 --- a/examples/c++/grovelinefinder.cxx +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Author: Jon Trulson - * 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 -#include - -#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; -} diff --git a/examples/c++/grovemd-stepper.cxx b/examples/c++/grovemd-stepper.cxx deleted file mode 100644 index 3be01f19f..000000000 --- a/examples/c++/grovemd-stepper.cxx +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Author: Jon Trulson - * 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 - -#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; -} diff --git a/examples/c++/grovemd.cxx b/examples/c++/grovemd.cxx deleted file mode 100644 index adf13e0aa..000000000 --- a/examples/c++/grovemd.cxx +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Author: Jon Trulson - * 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 - -#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; -} diff --git a/examples/c++/grovemoisture.cxx b/examples/c++/grovemoisture.cxx deleted file mode 100644 index 6fe4f09cb..000000000 --- a/examples/c++/grovemoisture.cxx +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Author: Jon Trulson - * 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 -#include - -#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; -} diff --git a/examples/c++/groveo2.cxx b/examples/c++/groveo2.cxx deleted file mode 100644 index 5dbc7cb89..000000000 --- a/examples/c++/groveo2.cxx +++ /dev/null @@ -1,58 +0,0 @@ -/* -* Author: Zion Orent -* 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 -#include - -#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; -} diff --git a/examples/c++/grovescam.cxx b/examples/c++/grovescam.cxx deleted file mode 100644 index 81abc6f0c..000000000 --- a/examples/c++/grovescam.cxx +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Author: Jon Trulson - * 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 - -#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; -} diff --git a/examples/c++/grovespeaker.cxx b/examples/c++/grovespeaker.cxx deleted file mode 100644 index 8a4427fd6..000000000 --- a/examples/c++/grovespeaker.cxx +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Author: Jon Trulson - * 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 - -#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; -} diff --git a/examples/c++/groveultrasonic.cxx b/examples/c++/groveultrasonic.cxx deleted file mode 100644 index cc36ecca7..000000000 --- a/examples/c++/groveultrasonic.cxx +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Author: Jun Kato - * 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 -#include - -#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; -} diff --git a/examples/c++/grovevdiv.cxx b/examples/c++/grovevdiv.cxx deleted file mode 100644 index f090c694a..000000000 --- a/examples/c++/grovevdiv.cxx +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Author: Jon Trulson - * 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 -#include - -#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; -} diff --git a/examples/c++/grovewater.cxx b/examples/c++/grovewater.cxx deleted file mode 100644 index 88ed496b0..000000000 --- a/examples/c++/grovewater.cxx +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Author: Jon Trulson - * 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 -#include - -#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; -} diff --git a/examples/c++/grovewfs.cxx b/examples/c++/grovewfs.cxx deleted file mode 100644 index 45e5342f3..000000000 --- a/examples/c++/grovewfs.cxx +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Author: Jon Trulson - * 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 -#include - -#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; -} diff --git a/examples/java/CMakeLists.txt b/examples/java/CMakeLists.txt index d5ef82601..d4aa99233 100644 --- a/examples/java/CMakeLists.txt +++ b/examples/java/CMakeLists.txt @@ -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) diff --git a/examples/java/GROVESCAM_Example.java b/examples/java/GROVESCAM_Example.java deleted file mode 100644 index 9fa6c33ac..000000000 --- a/examples/java/GROVESCAM_Example.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Author: Stefan Andritoiu - * 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] - } - -} \ No newline at end of file diff --git a/examples/java/GroveButton_Example.java b/examples/java/GroveButton_Example.java deleted file mode 100644 index 479a66881..000000000 --- a/examples/java/GroveButton_Example.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Author: Stefan Andritoiu - * 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] - } - -} \ No newline at end of file diff --git a/examples/java/GroveButton_intr_Example.java b/examples/java/GroveButton_intr_Example.java deleted file mode 100644 index 790400f9c..000000000 --- a/examples/java/GroveButton_intr_Example.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Author: Stefan Andritoiu - * 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!"); - } -} \ No newline at end of file diff --git a/examples/java/GroveCollision_Example.java b/examples/java/GroveCollision_Example.java deleted file mode 100644 index 50907f76e..000000000 --- a/examples/java/GroveCollision_Example.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Author: Abhishek Malik - * 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] - } - -} diff --git a/examples/java/GroveEHR_Example.java b/examples/java/GroveEHR_Example.java deleted file mode 100644 index 5a209b5e5..000000000 --- a/examples/java/GroveEHR_Example.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Author: Stefan Andritoiu - * 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] - } -} \ No newline at end of file diff --git a/examples/java/GroveEmg_Example.java b/examples/java/GroveEmg_Example.java deleted file mode 100644 index 5652f62c0..000000000 --- a/examples/java/GroveEmg_Example.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Author: Abhishek Malik - * 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] -} diff --git a/examples/java/GroveGsr_Example.java b/examples/java/GroveGsr_Example.java deleted file mode 100644 index 3aaf5a9e4..000000000 --- a/examples/java/GroveGsr_Example.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Author: Abhishek Malik - * 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] - } - -} diff --git a/examples/java/GroveLED_Example.java b/examples/java/GroveLED_Example.java deleted file mode 100644 index a065dc187..000000000 --- a/examples/java/GroveLED_Example.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Author: Andrei Vasiliu - * 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] - } -} diff --git a/examples/java/GroveLed_multi_Example.java b/examples/java/GroveLed_multi_Example.java deleted file mode 100644 index 9e213f805..000000000 --- a/examples/java/GroveLed_multi_Example.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Author: Stefan Andritoiu - * 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] - } -} \ No newline at end of file diff --git a/examples/java/GroveLight_Example.java b/examples/java/GroveLight_Example.java deleted file mode 100644 index 4b2549e19..000000000 --- a/examples/java/GroveLight_Example.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Author: Stefan Andritoiu - * 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] - } -} \ No newline at end of file diff --git a/examples/java/GroveLineFinder_Example.java b/examples/java/GroveLineFinder_Example.java deleted file mode 100644 index dc7b96648..000000000 --- a/examples/java/GroveLineFinder_Example.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Author: Stefan Andritoiu - * 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] - } - -} \ No newline at end of file diff --git a/examples/java/GroveMD_Example.java b/examples/java/GroveMD_Example.java deleted file mode 100644 index 4c1306ea1..000000000 --- a/examples/java/GroveMD_Example.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Author: Stefan Andritoiu - * 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] - } - -} \ No newline at end of file diff --git a/examples/java/GroveMoisture_Example.java b/examples/java/GroveMoisture_Example.java deleted file mode 100644 index 62076914c..000000000 --- a/examples/java/GroveMoisture_Example.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Author: Stefan Andritoiu - * 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] - } -} \ No newline at end of file diff --git a/examples/java/GroveO2_Example.java b/examples/java/GroveO2_Example.java deleted file mode 100644 index e50edb5a2..000000000 --- a/examples/java/GroveO2_Example.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Author: Abhishek Malik - * 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] - } -} diff --git a/examples/java/GroveRelay_Example.java b/examples/java/GroveRelay_Example.java deleted file mode 100644 index 69d9b2b63..000000000 --- a/examples/java/GroveRelay_Example.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Author: Stefan Andritoiu - * 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] - } -} \ No newline at end of file diff --git a/examples/java/GroveRotary_Example.java b/examples/java/GroveRotary_Example.java deleted file mode 100644 index efddf1be5..000000000 --- a/examples/java/GroveRotary_Example.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Author: Stefan Andritoiu - * 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] - } - -} \ No newline at end of file diff --git a/examples/java/GroveSlide_Example.java b/examples/java/GroveSlide_Example.java deleted file mode 100644 index 3f3ea80c5..000000000 --- a/examples/java/GroveSlide_Example.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Author: Andrei Vasiliu - * 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] - } -} diff --git a/examples/java/GroveSpeaker_Example.java b/examples/java/GroveSpeaker_Example.java deleted file mode 100644 index b75246634..000000000 --- a/examples/java/GroveSpeaker_Example.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Author: Andrei Vasiliu - * 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] - } - -} \ No newline at end of file diff --git a/examples/java/GroveTemp_Example.java b/examples/java/GroveTemp_Example.java deleted file mode 100644 index f09c95859..000000000 --- a/examples/java/GroveTemp_Example.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Author: Andrei Vasiliu - * 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] - } -} diff --git a/examples/java/GroveUltraSonic_Example.java b/examples/java/GroveUltraSonic_Example.java deleted file mode 100644 index 1636b683c..000000000 --- a/examples/java/GroveUltraSonic_Example.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Author: Stefan Andritoiu - * 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] - } -} diff --git a/examples/java/GroveVDiv_Example.java b/examples/java/GroveVDiv_Example.java deleted file mode 100644 index a18ef706a..000000000 --- a/examples/java/GroveVDiv_Example.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Author: Stefan Andritoiu - * 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] - } - -} \ No newline at end of file diff --git a/examples/java/GroveWFS_Example.java b/examples/java/GroveWFS_Example.java deleted file mode 100644 index fd630182a..000000000 --- a/examples/java/GroveWFS_Example.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Author: Stefan Andritoiu - * 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] - } -} \ No newline at end of file diff --git a/examples/java/GroveWater_Example.java b/examples/java/GroveWater_Example.java deleted file mode 100644 index e76446c6c..000000000 --- a/examples/java/GroveWater_Example.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Author: Stefan Andritoiu - * 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] - } - -} \ No newline at end of file diff --git a/examples/javascript/grove_mcfled.js b/examples/javascript/grove_mcfled.js deleted file mode 100644 index eaa6d7872..000000000 --- a/examples/javascript/grove_mcfled.js +++ /dev/null @@ -1,44 +0,0 @@ -/* -* Author: Zion Orent -* 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); -}); diff --git a/examples/javascript/grovebutton.js b/examples/javascript/grovebutton.js deleted file mode 100644 index 428396ad0..000000000 --- a/examples/javascript/grovebutton.js +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Author: Sarah Knepper - * 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); diff --git a/examples/javascript/grovecollision.js b/examples/javascript/grovecollision.js deleted file mode 100644 index 7fa1c0a97..000000000 --- a/examples/javascript/grovecollision.js +++ /dev/null @@ -1,60 +0,0 @@ -/* -* Author: Zion Orent -* 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); -}); diff --git a/examples/javascript/groveehr.js b/examples/javascript/groveehr.js deleted file mode 100644 index 40684900f..000000000 --- a/examples/javascript/groveehr.js +++ /dev/null @@ -1,62 +0,0 @@ -/* -* Author: Zion Orent -* 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); -}); diff --git a/examples/javascript/groveeldriver.js b/examples/javascript/groveeldriver.js deleted file mode 100644 index 0cf03c90b..000000000 --- a/examples/javascript/groveeldriver.js +++ /dev/null @@ -1,52 +0,0 @@ -/* -* Author: Zion Orent -* 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); -}); diff --git a/examples/javascript/groveelectromagnet.js b/examples/javascript/groveelectromagnet.js deleted file mode 100644 index 8a75b713c..000000000 --- a/examples/javascript/groveelectromagnet.js +++ /dev/null @@ -1,55 +0,0 @@ -/* -* Author: Zion Orent -* 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); -}); diff --git a/examples/javascript/groveemg.js b/examples/javascript/groveemg.js deleted file mode 100644 index 4ddcb6e69..000000000 --- a/examples/javascript/groveemg.js +++ /dev/null @@ -1,46 +0,0 @@ -/* -* Author: Zion Orent -* 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); -}); diff --git a/examples/javascript/grovegprs.js b/examples/javascript/grovegprs.js deleted file mode 100644 index dda80acd5..000000000 --- a/examples/javascript/grovegprs.js +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Author: Jon Trulson - * 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); -}); diff --git a/examples/javascript/grovegsr.js b/examples/javascript/grovegsr.js deleted file mode 100644 index 6b98af19c..000000000 --- a/examples/javascript/grovegsr.js +++ /dev/null @@ -1,49 +0,0 @@ -/* -* Author: Zion Orent -* 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); -}); diff --git a/examples/javascript/groveled.js b/examples/javascript/groveled.js deleted file mode 100644 index 7314d39fe..000000000 --- a/examples/javascript/groveled.js +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Author: Sarah Knepper - * 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); - diff --git a/examples/javascript/grovelight.js b/examples/javascript/grovelight.js deleted file mode 100644 index d09b46275..000000000 --- a/examples/javascript/grovelight.js +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Author: Sarah Knepper - * 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); diff --git a/examples/javascript/grovelinefinder.js b/examples/javascript/grovelinefinder.js deleted file mode 100644 index 99f245c7d..000000000 --- a/examples/javascript/grovelinefinder.js +++ /dev/null @@ -1,44 +0,0 @@ -/* -* Author: Zion Orent -* 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); -}); diff --git a/examples/javascript/grovemd-stepper.js b/examples/javascript/grovemd-stepper.js deleted file mode 100644 index 4618f6d3d..000000000 --- a/examples/javascript/grovemd-stepper.js +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Author: Jon Trulson - * 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(); -}); diff --git a/examples/javascript/grovemd.js b/examples/javascript/grovemd.js deleted file mode 100644 index 6ae88cfbf..000000000 --- a/examples/javascript/grovemd.js +++ /dev/null @@ -1,91 +0,0 @@ -/* -* Author: Zion Orent -* 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(); -}); diff --git a/examples/javascript/grovemoisture.js b/examples/javascript/grovemoisture.js deleted file mode 100644 index 76fa9ae9e..000000000 --- a/examples/javascript/grovemoisture.js +++ /dev/null @@ -1,54 +0,0 @@ -/* -* Author: Zion Orent -* 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); -}); diff --git a/examples/javascript/groveo2.js b/examples/javascript/groveo2.js deleted file mode 100644 index fcf3755cb..000000000 --- a/examples/javascript/groveo2.js +++ /dev/null @@ -1,50 +0,0 @@ -/* -* Author: Zion Orent -* 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); -}); diff --git a/examples/javascript/groverelay.js b/examples/javascript/groverelay.js deleted file mode 100644 index a8fefe7b9..000000000 --- a/examples/javascript/groverelay.js +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Author: Sarah Knepper - * 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); - diff --git a/examples/javascript/groverotary.js b/examples/javascript/groverotary.js deleted file mode 100644 index 040f38c60..000000000 --- a/examples/javascript/groverotary.js +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Author: Mihai Tudor Panu - * 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); -} diff --git a/examples/javascript/grovescam.js b/examples/javascript/grovescam.js deleted file mode 100644 index c9441779e..000000000 --- a/examples/javascript/grovescam.js +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Author: Jon Trulson - * 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); - diff --git a/examples/javascript/groveslide.js b/examples/javascript/groveslide.js deleted file mode 100644 index bd16eeee0..000000000 --- a/examples/javascript/groveslide.js +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Author: Mihai Tudor Panu - * 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); -} diff --git a/examples/javascript/grovespeaker.js b/examples/javascript/grovespeaker.js deleted file mode 100644 index de92225ed..000000000 --- a/examples/javascript/grovespeaker.js +++ /dev/null @@ -1,41 +0,0 @@ -/* -* Author: Zion Orent -* 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); -}); diff --git a/examples/javascript/grovetemp.js b/examples/javascript/grovetemp.js deleted file mode 100644 index dba3954c7..000000000 --- a/examples/javascript/grovetemp.js +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Author: Sarah Knepper - * 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); diff --git a/examples/javascript/groveultrasonic.js b/examples/javascript/groveultrasonic.js deleted file mode 100644 index e2b58041e..000000000 --- a/examples/javascript/groveultrasonic.js +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Author: Jun Kato - * 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); -}); diff --git a/examples/javascript/grovevdiv.js b/examples/javascript/grovevdiv.js deleted file mode 100644 index 5fb393e40..000000000 --- a/examples/javascript/grovevdiv.js +++ /dev/null @@ -1,51 +0,0 @@ -/* -* Author: Zion Orent -* 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); -}); diff --git a/examples/javascript/grovewater.js b/examples/javascript/grovewater.js deleted file mode 100644 index d953106e7..000000000 --- a/examples/javascript/grovewater.js +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Author: Zion Orent - * 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); -}); diff --git a/examples/javascript/grovewfs.js b/examples/javascript/grovewfs.js deleted file mode 100644 index 48b96104b..000000000 --- a/examples/javascript/grovewfs.js +++ /dev/null @@ -1,66 +0,0 @@ -/* -* Author: Zion Orent -* 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); -}); diff --git a/examples/python/button.py b/examples/python/button.py index 43ab72975..99b930547 100755 --- a/examples/python/button.py +++ b/examples/python/button.py @@ -23,11 +23,11 @@ # 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: diff --git a/examples/python/grovebutton.py b/examples/python/grovebutton.py deleted file mode 100755 index 71bbcaa7d..000000000 --- a/examples/python/grovebutton.py +++ /dev/null @@ -1,41 +0,0 @@ -#!/usr/bin/env python -from __future__ import print_function -# Author: Sarah Knepper -# 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() diff --git a/examples/python/grovecollision.py b/examples/python/grovecollision.py deleted file mode 100755 index 67c0eba57..000000000 --- a/examples/python/grovecollision.py +++ /dev/null @@ -1,60 +0,0 @@ -#!/usr/bin/env python -# Author: Zion Orent -# 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() diff --git a/examples/python/groveehr.py b/examples/python/groveehr.py deleted file mode 100755 index 142db0fee..000000000 --- a/examples/python/groveehr.py +++ /dev/null @@ -1,70 +0,0 @@ -#!/usr/bin/env python -# Author: Zion Orent -# 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() diff --git a/examples/python/groveeldriver.py b/examples/python/groveeldriver.py deleted file mode 100755 index 08fa8fc4e..000000000 --- a/examples/python/groveeldriver.py +++ /dev/null @@ -1,60 +0,0 @@ -#!/usr/bin/env python -# Author: Zion Orent -# 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() diff --git a/examples/python/groveelectromagnet.py b/examples/python/groveelectromagnet.py deleted file mode 100755 index b9b17d546..000000000 --- a/examples/python/groveelectromagnet.py +++ /dev/null @@ -1,63 +0,0 @@ -#!/usr/bin/env python -# Author: Zion Orent -# 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() diff --git a/examples/python/groveemg.py b/examples/python/groveemg.py deleted file mode 100755 index b08fb7481..000000000 --- a/examples/python/groveemg.py +++ /dev/null @@ -1,55 +0,0 @@ -#!/usr/bin/env python -# Author: Zion Orent -# 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() diff --git a/examples/python/grovegprs.py b/examples/python/grovegprs.py deleted file mode 100755 index f403cc8f7..000000000 --- a/examples/python/grovegprs.py +++ /dev/null @@ -1,89 +0,0 @@ -#!/usr/bin/env python -# Author: Jon Trulson -# 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() diff --git a/examples/python/grovegsr.py b/examples/python/grovegsr.py deleted file mode 100755 index d2c51cdd3..000000000 --- a/examples/python/grovegsr.py +++ /dev/null @@ -1,56 +0,0 @@ -#!/usr/bin/env python -# Author: Zion Orent -# 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() diff --git a/examples/python/groveled.py b/examples/python/groveled.py deleted file mode 100755 index 05a8622ea..000000000 --- a/examples/python/groveled.py +++ /dev/null @@ -1,47 +0,0 @@ -#!/usr/bin/env python -from __future__ import print_function -# Author: Sarah Knepper -# 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() diff --git a/examples/python/grovelight.py b/examples/python/grovelight.py deleted file mode 100755 index f440719f3..000000000 --- a/examples/python/grovelight.py +++ /dev/null @@ -1,43 +0,0 @@ -#!/usr/bin/env python -from __future__ import print_function -# Author: Sarah Knepper -# 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() diff --git a/examples/python/grovelinefinder.py b/examples/python/grovelinefinder.py deleted file mode 100755 index 2fad2e353..000000000 --- a/examples/python/grovelinefinder.py +++ /dev/null @@ -1,54 +0,0 @@ -#!/usr/bin/env python -# Author: Zion Orent -# 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() diff --git a/examples/python/grovemd-stepper.py b/examples/python/grovemd-stepper.py deleted file mode 100755 index 9b9a7707b..000000000 --- a/examples/python/grovemd-stepper.py +++ /dev/null @@ -1,55 +0,0 @@ -#!/usr/bin/env python -# Author: Jon Trulson -# 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() diff --git a/examples/python/grovemd.py b/examples/python/grovemd.py deleted file mode 100755 index 63cdee0a1..000000000 --- a/examples/python/grovemd.py +++ /dev/null @@ -1,51 +0,0 @@ -#!/usr/bin/env python -# Author: Zion Orent -# 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() diff --git a/examples/python/grovemoisture.py b/examples/python/grovemoisture.py deleted file mode 100755 index 13bf7e207..000000000 --- a/examples/python/grovemoisture.py +++ /dev/null @@ -1,64 +0,0 @@ -#!/usr/bin/env python -# Author: Zion Orent -# 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() diff --git a/examples/python/groveo2.py b/examples/python/groveo2.py deleted file mode 100755 index cce2bfc9c..000000000 --- a/examples/python/groveo2.py +++ /dev/null @@ -1,54 +0,0 @@ -#!/usr/bin/env python -# Author: Zion Orent -# 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() diff --git a/examples/python/groverelay.py b/examples/python/groverelay.py deleted file mode 100755 index b1e7f9bed..000000000 --- a/examples/python/groverelay.py +++ /dev/null @@ -1,50 +0,0 @@ -#!/usr/bin/env python -from __future__ import print_function -# Author: Sarah Knepper -# 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() diff --git a/examples/python/groverotary.py b/examples/python/groverotary.py deleted file mode 100755 index 8cec63c53..000000000 --- a/examples/python/groverotary.py +++ /dev/null @@ -1,50 +0,0 @@ -#!/usr/bin/env python -from __future__ import print_function -# Author: Mihai Tudor Panu -# 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() diff --git a/examples/python/grovescam.py b/examples/python/grovescam.py deleted file mode 100755 index ed24d9950..000000000 --- a/examples/python/grovescam.py +++ /dev/null @@ -1,66 +0,0 @@ -#!/usr/bin/env python -# -# Author: Jon Trulson -# 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() diff --git a/examples/python/groveslide.py b/examples/python/groveslide.py deleted file mode 100755 index d2d72ae6e..000000000 --- a/examples/python/groveslide.py +++ /dev/null @@ -1,44 +0,0 @@ -#!/usr/bin/env python -from __future__ import print_function -# Author: Mihai Tudor Panu -# 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() diff --git a/examples/python/grovespeaker.py b/examples/python/grovespeaker.py deleted file mode 100755 index 58f2be2e1..000000000 --- a/examples/python/grovespeaker.py +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/env python -# Author: Zion Orent -# 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() diff --git a/examples/python/grovetemp.py b/examples/python/grovetemp.py deleted file mode 100755 index 59adc03f7..000000000 --- a/examples/python/grovetemp.py +++ /dev/null @@ -1,47 +0,0 @@ -#!/usr/bin/env python -from __future__ import print_function -# Author: Brendan Le Foll -# Contributions: Sarah Knepper -# 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() diff --git a/examples/python/grovevdiv.py b/examples/python/grovevdiv.py deleted file mode 100755 index fc3b0b22d..000000000 --- a/examples/python/grovevdiv.py +++ /dev/null @@ -1,57 +0,0 @@ -#!/usr/bin/env python -# Author: Zion Orent -# 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() diff --git a/examples/python/grovewater.py b/examples/python/grovewater.py deleted file mode 100755 index 1ed8508df..000000000 --- a/examples/python/grovewater.py +++ /dev/null @@ -1,54 +0,0 @@ -#!/usr/bin/env python -# Author: Zion Orent -# 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() diff --git a/examples/python/grovewfs.py b/examples/python/grovewfs.py deleted file mode 100755 index 907c3be07..000000000 --- a/examples/python/grovewfs.py +++ /dev/null @@ -1,67 +0,0 @@ -#!/usr/bin/env python -# Author: Zion Orent -# 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_grovewfs as upmGrovewfs - -def main(): - # Instantiate a Grove Water Flow Sensor on digital pin D2 - myWaterFlow = upmGrovewfs.GroveWFS(2) - - ## 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 myWaterFlow - def exitHandler(): - myWaterFlow.stopFlowCounter() - print("Exiting") - sys.exit(0) - - # Register exit handlers - atexit.register(exitHandler) - signal.signal(signal.SIGINT, SIGINTHandler) - - # set the flow counter to 0 and start counting - myWaterFlow.clearFlowCounter() - myWaterFlow.startFlowCounter() - - while (1): - # we grab these (millis and flowCount) just for display - # purposes in this example - millis = myWaterFlow.getMillis() - flowCount = myWaterFlow.flowCounter() - - fr = myWaterFlow.flowRate() - - # output milliseconds passed, flow count, and computed flow rate - outputStr = "Millis: {0} Flow Count: {1} Flow Rate: {2} LPM".format( - millis, flowCount, fr) - print(outputStr) - time.sleep(2) - -if __name__ == '__main__': - main() diff --git a/examples/python/relay.py b/examples/python/relay.py index b51e308a0..34d05a65e 100755 --- a/examples/python/relay.py +++ b/examples/python/relay.py @@ -23,11 +23,11 @@ # 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_relay as upmrelay def main(): # Create the relay switch object using GPIO pin 0 - relay = grove.Relay(0) + relay = upmrelay.Relay(0) # Close and then open the relay switch 3 times, # waiting one second each time. The LED on the relay switch diff --git a/examples/python/rotary.py b/examples/python/rotary.py index 8042a7775..327225ef7 100755 --- a/examples/python/rotary.py +++ b/examples/python/rotary.py @@ -23,11 +23,11 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. from time import sleep -from upm import pyupm_grove as grove +from upm import pyupm_rotary as upmrotary def main(): # New knob on AIO pin 0 - knob = grove.Rotary(0) + knob = upmrotary.Rotary(0) # Loop indefinitely while True: diff --git a/src/grove/CMakeLists.txt b/src/grove/CMakeLists.txt deleted file mode 100644 index 0d2c59356..000000000 --- a/src/grove/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -set (libname "grove") -set (libdescription "Grove Starter Kit Sensor Library") -set (module_src grovebutton.cxx groveled.cxx grovelight.cxx groverelay.cxx groverotary.cxx groveslide.cxx grovetemp.cxx) -set (module_hpp grovebutton.hpp groveled.hpp grovelight.hpp groverelay.hpp groverotary.hpp groveslide.hpp grovetemp.hpp grovebase.hpp grove.hpp) -set (module_iface iLight.hpp) -upm_module_init(mraa) diff --git a/src/grove/grove.cxx b/src/grove/grove.cxx deleted file mode 100644 index 8b1378917..000000000 --- a/src/grove/grove.cxx +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/grove/grove.hpp b/src/grove/grove.hpp deleted file mode 100644 index a7da8758e..000000000 --- a/src/grove/grove.hpp +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Authors: Brendan Le Foll - * Mihai Tudor Panu - * Sarah Knepper - * Copyright (c) 2014 - 2016 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. - */ -#pragma once - -#include -#include -#include -#include -#include -#include -#include diff --git a/src/grove/grove.i b/src/grove/grove.i deleted file mode 100644 index b588984cf..000000000 --- a/src/grove/grove.i +++ /dev/null @@ -1,43 +0,0 @@ -#ifdef SWIGPYTHON -%module (package="upm") htu21d -#endif - -%import "interfaces/interfaces.i" - -%include "../common_top.i" - -/* BEGIN Java syntax ------------------------------------------------------- */ -#ifdef SWIGJAVA -%typemap(javaimports) SWIGTYPE %{ -import upm_interfaces.*; -%} - -%apply int {mraa::Edge} - -JAVA_ADD_INSTALLISR_EDGE(upm::GroveButton) -JAVA_JNI_LOADLIBRARY(javaupm_grove) -#endif -/* END Java syntax */ - -/* BEGIN Common SWIG syntax ------------------------------------------------- */ -%{ -#include "grovebase.hpp" -#include "grove.hpp" -#include "grovebutton.hpp" -#include "groveled.hpp" -#include "grovelight.hpp" -#include "groverelay.hpp" -#include "groverotary.hpp" -#include "groveslide.hpp" -#include "grovetemp.hpp" -%} -%include "grovebase.hpp" -%include "grove.hpp" -%include "grovebutton.hpp" -%include "groveled.hpp" -%include "grovelight.hpp" -%include "groverelay.hpp" -%include "groverotary.hpp" -%include "groveslide.hpp" -%include "grovetemp.hpp" -/* END Common SWIG syntax */ diff --git a/src/grove/grove.json b/src/grove/grove.json deleted file mode 100644 index cd5f68ea9..000000000 --- a/src/grove/grove.json +++ /dev/null @@ -1,381 +0,0 @@ -{ - "Library": "grove", - "Description": "Generic library for basic Grove sensors", - "Sensor Class": { - "Grove": { - "Name": "Generic library for basic Grove sensors", - "Description": "This is the Generic UPM Module for basic Grove sensors. This library is now deprecated and replaced by individual libraries for every sensor.", - "Aliases": ["grove", "libupm-grove"], - "Categories": ["LED", "light", "relay", "temperature", "touch"], - "Connections": ["i2c", "gpio", "pwm", "ainput"], - "Project Type": ["prototyping", "commercial"], - "Manufacturers": ["Seeed"], - "Kits": ["gsk", "eak", "hak"], - "Examples": { - "C++": ["grove-grovebutton.cxx"] - }, - "Urls": { - "Product Pages": ["https://github.com/intel-iot-devkit/upm/tree/master/src/grove"] - } - }, - "GroveButton": { - "Name": "API for the Grove Button", - "Description": "This is the UPM Module for the Grove button. This class is being replaced by the upm-button library and the Button class.", - "Aliases": ["Grove Touch Sensor", "Grove button"], - "Categories": ["touch"], - "Connections": ["gpio"], - "Project Type": ["prototyping"], - "Manufacturers": ["Seeed"], - "Kits": ["gsk"], - "Image": "grovebutton.jpg", - "Examples": { - "Java": ["GroveButton_Example.java", "GroveButton_intr_Example.java"], - "Python": ["grovebutton.py"], - "Node.js": ["grovebutton.js"], - "C++": ["grove-grovebutton.cxx"] - }, - "Specifications": { - "Vsource": { - "unit": "V", - "min": 3.3, - "max": 12.0 - }, - "Supply Current Digital": { - "unit": "mA", - "min" : 5, - "max" : 25 - }, - "Operating Temperature": { - "unit": "°C", - "min": -40, - "max": 85 - } - }, - "Platforms": { - "Intel Edison": { - "Notes": ["Might need Grove base shield"] - }, - "Arduino 101": { - "Notes": ["Might need Grove base shield"] - } - }, - "Urls": { - "Product Pages": ["https://www.seeedstudio.com/Grove-Button-p-766.html", "http://wiki.seeed.cc/Grove-Button/"], - "Schematics": ["https://github.com/SeeedDocument/Grove_Button/raw/master/resources/Grove_-_Button_v1.0_Source_File.zip"] - } - }, - "GroveLed": { - "Name": "API for the Grove LED", - "Description": "This is the UPM Module for the Grove LED. This class is being replaced by the upm-led library and the Led class.", - "Aliases": ["Grove LED", "Grove – Chainable RGB Led V2.0"], - "Categories": ["LED"], - "Connections": ["gpio"], - "Project Type": ["prototyping"], - "Manufacturers": ["Seeed"], - "Kits": ["gsk"], - "Image": "groveled.jpg", - "Examples": { - "Java": ["GroveLED_Example.java", "GroveLed_multi_Example.java"], - "Python": ["groveled.py"], - "Node.js": ["groveled.js"], - "C++": ["grove-groveled.cxx", "grove-groveled-multi.cxx"] - }, - "Specifications": { - "Vsource": { - "unit": "V", - "min": 4.5, - "max": 7.5 - }, - "Supply Current": { - "unit": "mA", - "min" : 20, - "max" : 60 - }, - "Operating Temperature": { - "unit": "°C", - "min": -40, - "max": 85 - } - }, - "Platforms": { - "Intel Edison": { - "Notes": ["Might need Grove base shield"] - }, - "Arduino 101": { - "Notes": ["Might need Grove base shield"] - } - }, - "Urls": { - "Product Pages": ["https://www.seeedstudio.com/Grove-%E2%80%93-Chainable-RGB-Led-V2.0-p-2903.html", "http://wiki.seeed.cc/Grove-Chainable_RGB_LED/"], - "Datasheets": ["https://raw.githubusercontent.com/SeeedDocument/Grove-Chainable_RGB_LED/master/res/P9813_datasheet.pdf"], - "Schematics": ["https://github.com/SeeedDocument/Grove-Chainable_RGB_LED/raw/master/res/Grove%20-%20Chainable%20RGB%20LED%20v2.0.zip"] - } - }, - "GroveLight": { - "Name": "API for the Grove Light Sensor", - "Description": "This is the UPM Module for the Grove Light Sensor. This class is being replaced by the upm-light library and the Light class.", - "Aliases": ["grovelight", "Grove - Light Sensor(P)"], - "Categories": ["light"], - "Connections": ["analog"], - "Project Type": ["prototyping"], - "Manufacturers": ["Seeed"], - "Kits": ["gsk"], - "Image": "grovelight.jpg", - "Examples": { - "Java": ["GroveLight_Example.java"], - "Python": ["grovelight.py"], - "Node.js": ["grovelight.js"], - "C++": ["grove-grovelight.cxx"] - }, - "Specifications": { - "Vsource": { - "unit": "V", - "min": 3, - "max": 5 - }, - "Supply Current": { - "unit": "mA", - "min" : 0.5, - "max" : 3.0 - }, - "Operating Temperature": { - "unit": "°C", - "min": -40, - "max": 85 - }, - "Response Time": { - "unit": "ms", - "min" : 20, - "max" : 30 - } - }, - "Platforms": { - "Intel Edison": { - "Notes": ["Might need Grove base shield"] - }, - "Arduino 101": { - "Notes": ["Might need Grove base shield"] - } - }, - "Urls": { - "Product Pages": ["https://www.seeedstudio.com/Grove-Light-Sensor(P)-p-1253.html", "http://wiki.seeed.cc/Grove-Light_Sensor/"], - "Datasheets": ["https://github.com/SeeedDocument/Grove_Light_Sensor/raw/master/res/LM358.pdf"], - "Schematics": ["https://github.com/SeeedDocument/Grove_Light_Sensor/raw/master/resources/Grove%20-%20Light%20Sensor%28P%29%20v1.1.zip"] - } - }, - "GroveRelay": { - "Name": "API for the Grove Relay", - "Description": "This is the UPM Module for the Grove relay switch. This class is being replaced by the upm-relay library and the Relay class.", - "Aliases": ["groverelay", "Grove - Relay"], - "Categories": ["relay"], - "Connections": ["gpio"], - "Project Type": ["prototyping"], - "Manufacturers": ["Seeed"], - "Kits": ["gsk", "eak", "hak"], - "Image": "groverelay.jpg", - "Examples": { - "Java": ["GroveRelay_Example.java"], - "Python": ["groverelay.py"], - "Node.js": ["groverelay.js"], - "C++": ["grove-groverelay.cxx"] - }, - "Specifications": { - "Vsource": { - "unit": "V", - "min": 3.3, - "max": 5.0 - }, - "Supply Current": { - "unit": "mA", - "typ" : 100 - }, - "Operating Temperature": { - "unit": "°C", - "min": -40, - "max": 85 - }, - "Relay Life": { - "unit": "Cycle", - "cycles": 100000 - }, - "Max Switching Voltage":{ - "AC": { - "unit" : "V", - "max" : 250 - }, - "DC": { - "unit": "V", - "max" : 30 - } - }, - "Max Switching Current": { - "unit": "A", - "max" : 5 - } - }, - "Platforms": { - "Intel Edison": { - "Notes": ["Might need Grove base shield"] - }, - "Arduino 101": { - "Notes": ["Might need Grove base shield"] - } - }, - "Urls": { - "Product Pages": ["https://www.seeedstudio.com/Grove-Relay-p-769.html", "http://wiki.seeed.cc/Grove-Relay/"], - "Datasheets": ["https://raw.githubusercontent.com/SeeedDocument/Grove-Relay/master/res/Relay_Datasheet.pdf"], - "Schematics": ["https://github.com/SeeedDocument/Grove-Relay/raw/master/res/Grove%20-%20Relay%20Schematic.pdf", "https://github.com/SeeedDocument/Grove-Relay/raw/master/res/Grove%20-%20Relay%20PCB.pdf", "https://raw.githubusercontent.com/SeeedDocument/Grove-Relay/master/res/Grove-Relay_Eagle_Files.zip"] - } - }, - "GroveRotary": { - "Name": "API for the Grove Rotary Angle Sensor (Knob)", - "Description": "This is the UPM Module for the Grove Rotary Angle Sensor (Knob). This class is being replaced by the upm-rotary library and the Rotary class.", - "Aliases": ["groverotary", "Grove - Rotary Angle Sensor"], - "Categories": ["ainput"], - "Connections": ["analog"], - "Project Type": ["prototyping"], - "Manufacturers": ["Seeed"], - "Kits": ["gsk"], - "Image": "groverotary.jpg", - "Examples": { - "Java": ["GroveRotary_Example.java"], - "Python": ["groverotary.py"], - "Node.js": ["groverotary.js"], - "C++": ["grove-groverotary.cxx"] - }, - "Specifications": { - "Vsource": { - "unit": "V", - "min": 4.75, - "max": 5.25 - }, - "Supply Current": { - "unit": "mA", - "typ" : 20 - }, - "Operating Temperature": { - "unit": "°C", - "min": -40, - "max": 85 - }, - "Rotary Angle":{ - "unit": "°", - "min" : 0, - "max" : 300 - } - }, - "Platforms": { - "Intel Edison": { - "Notes": ["Might need Grove base shield"] - }, - "Arduino 101": { - "Notes": ["Might need Grove base shield"] - } - }, - "Urls": { - "Product Pages": ["https://www.seeedstudio.com/Grove-Rotary-Angle-Sensor-p-770.html", "http://wiki.seeed.cc/Grove-Rotary_Angle_Sensor/"], - "Schematics": ["https://raw.githubusercontent.com/SeeedDocument/Grove-Rotary_Angle_Sensor/master/res/Grove-Rotary_Angle_Sensor_Eagle_File.zip", "https://raw.githubusercontent.com/SeeedDocument/Grove-Rotary_Angle_Sensor/master/res/Grove-Rotary_Angle_Sensor_v1.2.zip"] - } - }, - "GroveSlide": { - "Name": "API for the Grove Slide Potentiometer", - "Description": "This is the UPM Module for the Grove Slide Potentiometer. This class is being replaced by the upm-slide library and the Slide class.", - "Aliases": ["groveslide", "Grove - Slide Potentiometer"], - "Categories": ["ainput"], - "Connections": ["analog"], - "Project Type": ["prototyping"], - "Manufacturers": ["Seeed"], - "Images": "slide.jpg", - "Examples": { - "Java": ["GroveSlide_Example.java"], - "Python": ["groveslide.py"], - "Node.js": ["groveslide.js"], - "C++": ["grove-groveslide.cxx"] - }, - "Specifications": { - "Vsource": { - "unit": "V", - "min": 3.3, - "max": 30 - }, - "Supply Current": { - "unit": "mA", - "max" : 30 - }, - "Operating Temperature": { - "unit": "°C", - "min": -40, - "max": 85 - }, - "Sroke Length": { - "unit": "mm", - "min" : 0, - "max" : 30 - } - }, - "Platforms": { - "Intel Edison": { - "Notes": ["Might need Grove base shield"] - }, - "Arduino 101": { - "Notes": ["Might need Grove base shield"] - } - }, - "Urls": { - "Product Pages": ["https://www.seeedstudio.com/Grove-Slide-Potentiometer-p-1196.html?gclid=Cj0KCQjw5arMBRDzARIsAAqmJexy5Nrps6rpUqNFk4iIL6mVfHQt7EYfly4NbdhC7wBl4p3AxQZNkjIaAuN2EALw_wcB", "http://wiki.seeed.cc/Grove-Slide_Potentiometer/"], - "Datasheets": ["https://raw.githubusercontent.com/SeeedDocument/Grove-Slide_Potentiometer/master/res/Sliding_potentiometer_datasheet.pdf"], - "Schematics": ["https://raw.githubusercontent.com/SeeedDocument/Grove-Slide_Potentiometer/master/res/Sliding_Potentiometer.rar"] - } - }, - "GroveTemp": { - "Name": "API for the Grove Temperature Sensor", - "Description": "This is the UPM Module for the Grove Temperature Sensor. This class is being replaced by the upm-temperature library and the Temperature class.", - "Aliases": ["groverelay", "Grove - Temperature Sensor"], - "Categories": ["temperature"], - "Connections": ["analog"], - "Project Type": ["prototyping"], - "Manufacturers": ["Seeed"], - "Kits": ["gsk"], - "Image": "grovetemp.jpg", - "Examples": { - "Java": ["GroveTemp_Example.java"], - "Python": ["grovetemp.py"], - "Node.js": ["grovetemp.js"], - "C++": ["grove-grovetemp.cxx"] - }, - "Specifications": { - "Vsource": { - "unit": "V", - "min": 3.3, - "max": 5.0 - }, - "Supply Current": { - "unit": "mA", - "typ" : 50 - }, - "Operating Temperature": { - "unit": "°C", - "min": -40, - "max": 125 - }, - "Accuracy": { - "unit": "+/- °C", - "accuracy": 1.5 - } - }, - "Platforms": { - "Intel Edison": { - "Notes": ["Might need Grove base shield"] - }, - "Arduino 101": { - "Notes": ["Might need Grove base shield"] - } - }, - "Urls": { - "Product Pages": ["https://www.seeedstudio.com/Grove-Temperature-Sensor-p-774.html?gclid=Cj0KCQjw5arMBRDzARIsAAqmJexygEDSrIieYoG1C37j3HmOOx7PHjXlPsWxnQo7g1sCctC_VErW2IAaAvIHEALw_wcB", "http://wiki.seeed.cc/Grove-Temperature_Sensor_V1.2/"], - "Datasheets": ["https://github.com/SeeedDocument/Grove-Temperature_Sensor_V1.2/raw/master/res/NCP18WF104F03RC.pdf"], - "Schematics": ["https://github.com/SeeedDocument/Grove-Temperature_Sensor_V1.2/raw/master/res/Grove_-_Temperature_sensor_v1.1.zip"] - } - } - } -} diff --git a/src/grove/grovebase.hpp b/src/grove/grovebase.hpp deleted file mode 100644 index d51e8d525..000000000 --- a/src/grove/grovebase.hpp +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Authors: Brendan Le Foll - * Mihai Tudor Panu - * Sarah Knepper - * Copyright (c) 2014 - 2016 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. - */ -#pragma once - -#include - -namespace upm { - -/** - * @deprecated This library is now deprecated and replaced by individual - * libraries for every sensor. - * @brief Generic Library for Basic Grove Sensors - * @defgroup grove libupm-grove - * @ingroup seeed gpio pwm ainput button led light relay temp touch gsk eak hak - */ -class Grove { - public: - virtual ~Grove() {} - std::string name() - { - return m_name; - } - protected: - std::string m_name; -}; -} diff --git a/src/grove/grovebutton.cxx b/src/grove/grovebutton.cxx deleted file mode 100644 index b606d8d55..000000000 --- a/src/grove/grovebutton.cxx +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Authors: Brendan Le Foll - * Mihai Tudor Panu - * Sarah Knepper - * Copyright (c) 2014 - 2016 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 -#include -#include - -#include "grovebutton.hpp" - -using namespace upm; - -GroveButton::GroveButton(unsigned int pin) -{ - if ( !(m_gpio = mraa_gpio_init(pin)) ) { - throw std::invalid_argument(std::string(__FUNCTION__) + - ": mraa_gpio_init() failed, invalid pin?"); - return; - } - mraa_gpio_dir(m_gpio, MRAA_GPIO_IN); - m_name = "Button Sensor"; -} - -GroveButton::~GroveButton() -{ - mraa_gpio_close(m_gpio); -} - -std::string GroveButton::name() -{ - return m_name; -} - -int GroveButton::value() -{ - return mraa_gpio_read(m_gpio); -} - -bool GroveButton::isPressed() -{ - return (bool) GroveButton::value(); -} - -void GroveButton::installISR(mraa::Edge level, void (*isr)(void *), void *arg) -{ - if (m_isrInstalled) - uninstallISR(); - - // install our interrupt handler - mraa_gpio_isr(m_gpio, (mraa_gpio_edge_t) level, isr, arg); - m_isrInstalled = true; -} - -void GroveButton::uninstallISR() -{ - mraa_gpio_isr_exit(m_gpio); - m_isrInstalled = false; -} diff --git a/src/grove/grovebutton.hpp b/src/grove/grovebutton.hpp deleted file mode 100644 index d11817cd4..000000000 --- a/src/grove/grovebutton.hpp +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Authors: Brendan Le Foll - * Mihai Tudor Panu - * Sarah Knepper - * Copyright (c) 2014 - 2016 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. - */ - -#pragma once - -#include -#include -#include "grovebase.hpp" -#include - -namespace upm { - -/** - * @deprecated This class is being replaced by the upm-button library and the - * Button class. - * @library grove - * @sensor grovebutton - * @comname Button - * @altname Grove Touch Sensor - * @type button touch - * @man seeed - * @con gpio - * @kit gsk - * - * @brief API for the Grove Button - * - * Basic UPM module for the Grove button - * - * @image html grovebutton.jpg - * @snippet grove-grovebutton.cxx Interesting - */ -class GroveButton: public Grove, virtual public iButton { - public: - /** - * Grove button constructor - * - * @param pin Pin to use - */ - GroveButton(unsigned int pin); - /** - * Grove button destructor - */ - ~GroveButton(); - /** - * Gets the name of the sensor - * - * @return Name of this sensor - */ - std::string name(); - /** - * Gets the value from the GPIO pin - * - * @return Value from the GPIO pin - */ - int value(); - - /** - * Gets the current button press state. - * - * @returns Button state - */ - virtual bool isPressed(); - - /** - * Installs an interrupt service routine (ISR) to be called when - * the button is activated or deactivated. - * - * @param fptr Pointer to a function to be called on interrupt - * @param arg Pointer to an object to be supplied as an - * argument to the ISR. - */ - void installISR(mraa::Edge level, void (*isr)(void *), void *arg); - - /** - * Uninstalls the previously installed ISR - * - */ - void uninstallISR(); - - private: - bool m_isrInstalled; - std::string m_name; - mraa_gpio_context m_gpio; -}; -} diff --git a/src/grove/groveled.cxx b/src/grove/groveled.cxx deleted file mode 100644 index 68f107dac..000000000 --- a/src/grove/groveled.cxx +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Authors: Brendan Le Foll - * Mihai Tudor Panu - * Sarah Knepper - * Copyright (c) 2014 - 2016 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 -#include -#include - -#include "groveled.hpp" - -using namespace upm; - -GroveLed::GroveLed(int pin) -{ - if ( !(m_gpio = mraa_gpio_init(pin)) ) { - throw std::invalid_argument(std::string(__FUNCTION__) + - ": mraa_gpio_init() failed, invalid pin?"); - return; - } - mraa_gpio_dir(m_gpio, MRAA_GPIO_OUT); - m_name = "LED Socket"; -} - -GroveLed::~GroveLed() -{ - mraa_gpio_close(m_gpio); -} - -mraa_result_t GroveLed::write(int value) -{ - if (value >= 1) { - return mraa_gpio_write(m_gpio, 1); - } - return mraa_gpio_write(m_gpio, 0); -} - -mraa_result_t GroveLed::on() -{ - return write(1); -} - -mraa_result_t GroveLed::off() -{ - return write(0); -} diff --git a/src/grove/groveled.hpp b/src/grove/groveled.hpp deleted file mode 100644 index b91bd4df3..000000000 --- a/src/grove/groveled.hpp +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Authors: Brendan Le Foll - * Mihai Tudor Panu - * Sarah Knepper - * Copyright (c) 2014 - 2016 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. - */ - -#pragma once - -#include -#include -#include "grovebase.hpp" - -namespace upm { - -/** - * @deprecated This class is being replaced by the upm-led library and the - * Led class. - * @library grove - * @sensor groveled - * @comname LED - * @type led - * @man seeed - * @con gpio - * @kit gsk - * - * @brief API for the Grove LED - * - * UPM module for the Grove LED (or other similar light-emitting diodes). - * An LED is a small lightbulb that emits light in - * response to a small current. The longer wire of an LED connects - * to the positive seat (anode); the shorter wire connects to the - * negative seat (cathode). The flat side of the bulb corresponds - * to the cathode, while the rounded side corresponds to the anode. - * - * @image html groveled.jpg - * @snippet grove-groveled.cxx Interesting - * @snippet grove-groveled-multi.cxx Interesting - */ -class GroveLed: public Grove { - public: - /** - * Grove LED constructor - * - * @param pin Pin to use - */ - GroveLed(int pin); - /** - * Grove LED destructor - */ - ~GroveLed(); - /** - * Turns the LED on or off, depending on the value. - * If the value is positive (greater than or equal - * to 1), the LED is turned on. Otherwise, for 0 - * or negative values, the LED is turned off. - * - * @param value Tells the LED to turn on (for values >=1) - * or off (for values <1) - * - * @return 0 if successful, non-zero otherwise - */ - mraa_result_t write(int value); - /** - * Turns the LED off - * - * @return 0 if successful, non-zero otherwise - */ - mraa_result_t off(); - /** - * Turns the LED on - * - * @return 0 if successful, non-zero otherwise - */ - mraa_result_t on(); - private: - mraa_gpio_context m_gpio; -}; -} diff --git a/src/grove/grovelight.cxx b/src/grove/grovelight.cxx deleted file mode 100644 index 1ef2adfcb..000000000 --- a/src/grove/grovelight.cxx +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Authors: Brendan Le Foll - * Mihai Tudor Panu - * Sarah Knepper - * Copyright (c) 2014 - 2016 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 -#include -#include - -#include "grovelight.hpp" -#include "math.h" - -using namespace upm; - -GroveLight::GroveLight(unsigned int pin) -{ - if ( !(m_aio = mraa_aio_init(pin)) ) { - throw std::invalid_argument(std::string(__FUNCTION__) + - ": mraa_aio_init() failed, invalid pin?"); - return; - } - m_name = "Light Sensor"; -} - -GroveLight::~GroveLight() -{ - mraa_aio_close(m_aio); -} - -int GroveLight::value() -{ - // rough conversion to lux, using formula from Grove Starter Kit booklet - float a = (float) mraa_aio_read(m_aio); - if (a == -1.0) return -1; - a = 10000.0/pow(((1023.0-a)*10.0/a)*15.0,4.0/3.0); - return (int) round(a); -} - -float GroveLight::getLuminance() -{ - return value(); -} - -float GroveLight::raw_value() -{ - return (float) mraa_aio_read(m_aio); -} diff --git a/src/grove/grovelight.hpp b/src/grove/grovelight.hpp deleted file mode 100644 index c79d48eec..000000000 --- a/src/grove/grovelight.hpp +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Authors: Brendan Le Foll - * Mihai Tudor Panu - * Sarah Knepper - * Copyright (c) 2014 - 2016 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. - */ - -#pragma once - -#include -#include -#include -#include "grovebase.hpp" - -namespace upm { - -/** - * @deprecated This class is being replaced by the upm-light library and the - * Light class. - * @library grove - * @sensor grovelight - * @comname Light Sensor - * @type light - * @man seeed - * @con analog - * @kit gsk - * - * @brief API for the Grove Light Sensor - * - * The Grove light sensor detects the intensity of the ambient light. - * As the light intensity of the environment increases, the resistance - * of the sensor decreases. This means the raw value from the - * analog pin is larger in bright light and smaller in the dark. - * An approximate lux value can also be returned. - * - * @image html grovelight.jpg - * @snippet grove-grovelight.cxx Interesting - */ -class GroveLight: public Grove, virtual public iLight { - public: - /** - * Grove analog light sensor constructor - * - * @param pin Analog pin to use - */ - GroveLight(unsigned int pin); - /** - * GroveLight destructor - */ - ~GroveLight(); - /** - * Gets the raw value from the AIO pin - * - * @return Raw value from the ADC - */ - float raw_value(); - /** - * Gets an approximate light value, in lux, from the sensor - * - * @return Normalized light reading in lux - */ - int value(); - - /** - * Gets an approximate light value, in lux, from the sensor - * - * @return Normalized light reading in lux - */ - virtual float getLuminance(); - private: - mraa_aio_context m_aio; -}; -} diff --git a/src/grove/groverelay.cxx b/src/grove/groverelay.cxx deleted file mode 100644 index 53fba212a..000000000 --- a/src/grove/groverelay.cxx +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Authors: Brendan Le Foll - * Mihai Tudor Panu - * Sarah Knepper - * Copyright (c) 2014 - 2016 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 -#include -#include - -#include "groverelay.hpp" - -using namespace upm; - -GroveRelay::GroveRelay(unsigned int pin) -{ - if ( !(m_gpio = mraa_gpio_init(pin)) ) { - throw std::invalid_argument(std::string(__FUNCTION__) + - ": mraa_gpio_init() failed, invalid pin?"); - return; - } - mraa_gpio_dir(m_gpio, MRAA_GPIO_OUT); - m_name = "Relay Switch"; -} - -GroveRelay::~GroveRelay() -{ - mraa_gpio_close(m_gpio); -} - -mraa_result_t GroveRelay::on() -{ - return mraa_gpio_write(m_gpio, 1); -} - -mraa_result_t GroveRelay::off() -{ - return mraa_gpio_write(m_gpio, 0); -} - -bool GroveRelay::isOn() -{ - return mraa_gpio_read(m_gpio) == 1; -} - -bool GroveRelay::isOff() -{ - return mraa_gpio_read(m_gpio) == 0; -} diff --git a/src/grove/groverelay.hpp b/src/grove/groverelay.hpp deleted file mode 100644 index 9232c9513..000000000 --- a/src/grove/groverelay.hpp +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Authors: Brendan Le Foll - * Mihai Tudor Panu - * Sarah Knepper - * Copyright (c) 2014 - 2016 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. - */ - -#pragma once - -#include -#include -#include "grovebase.hpp" - -namespace upm { - -/** - * @deprecated This class is being replaced by the upm-relay library and the - * Relay class. - * @library grove - * @sensor groverelay - * @comname Relay - * @type relay - * @man seeed - * @con gpio - * @kit gsk eak hak - * - * @brief API for the Grove Relay - * - * UPM module for the Grove relay switch. The Grove relay is a - * digital normally-open switch that uses low voltage or current to - * control a higher voltage and/or higher current. When closed, - * the indicator LED lights up and current is allowed to flow. - * - * @image html groverelay.jpg - * @snippet grove-groverelay.cxx Interesting - */ -class GroveRelay: public Grove { - public: - /** - * Grove relay constructor - * - * @param pin Pin to use - */ - GroveRelay(unsigned int pin); - /** - * Grove relay destructor - */ - ~GroveRelay(); - /** - * Sets the relay switch to on (closed). This allows current - * to flow and lights up the indicator LED. - * - * @return 0 if successful, non-zero otherwise - */ - mraa_result_t on(); - /** - * Sets the relay switch to off (open). This stops current - * from flowing and the indicator LED is not lit. - * - * @return 0 if successful, non-zero otherwise - */ - mraa_result_t off(); - /** - * Defines whether the relay switch is closed. - * - * @return True if the switch is on (closed), false otherwise - */ - bool isOn(); - /** - * Defines whether the relay switch is open. - * - * @return True if the switch is off (open), false otherwise - */ - bool isOff(); - private: - mraa_gpio_context m_gpio; -}; -} diff --git a/src/grove/groverotary.cxx b/src/grove/groverotary.cxx deleted file mode 100644 index 3c280e46f..000000000 --- a/src/grove/groverotary.cxx +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Authors: Brendan Le Foll - * Mihai Tudor Panu - * Sarah Knepper - * Copyright (c) 2014 - 2016 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 -#include -#include - -#include "groverotary.hpp" -#include "math.h" - -using namespace upm; - -GroveRotary::GroveRotary(unsigned int pin) -{ - if ( !(m_aio = mraa_aio_init(pin)) ) { - throw std::invalid_argument(std::string(__FUNCTION__) + - ": mraa_aio_init() failed, invalid pin?"); - return; - } - m_name = "Rotary Angle Sensor"; -} - -GroveRotary::~GroveRotary() -{ - mraa_aio_close(m_aio); -} - -float GroveRotary::abs_value() -{ - return (float) mraa_aio_read(m_aio); -} - -float GroveRotary::abs_deg() -{ - return GroveRotary::abs_value() * (float) m_max_angle / 1023.0; -} - -float GroveRotary::abs_rad() -{ - return GroveRotary::abs_deg() * M_PI / 180.0; -} - -float GroveRotary::rel_value() -{ - return GroveRotary::abs_value() - 512.0; -} - -float GroveRotary::rel_deg() -{ - return GroveRotary::rel_value() * (float) m_max_angle / 1023.0; -} - -float GroveRotary::rel_rad() -{ - return GroveRotary::rel_deg() * M_PI / 180.0; -} - -float GroveRotary::getAngle() -{ - return GroveRotary::abs_deg(); -} diff --git a/src/grove/groverotary.hpp b/src/grove/groverotary.hpp deleted file mode 100644 index e9326750d..000000000 --- a/src/grove/groverotary.hpp +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Authors: Brendan Le Foll - * Mihai Tudor Panu - * Sarah Knepper - * Copyright (c) 2014 - 2016 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. - */ - -#pragma once - -#include -#include -#include "grovebase.hpp" -#include - -namespace upm { - -/** - * @deprecated This class is being replaced by the upm-rotary library and the - * Rotary class. - * @library grove - * @sensor groverotary - * @comname Rotary Angle Sensor - * @altname Rotary Potentiometer - * @type ainput - * @man seeed - * @con analog - * @kit gsk - * - * @brief API for the Grove Rotary Angle Sensor (Knob) - * - * Basic UPM module for the Grove rotary angle sensor (knob) on analog. Provides - * a set of functions to read the absolute pin value, degrees or radians, and another set - * to do the same relative to the center of the knob's range. - * - * @image html rotaryencoder.jpg - * @snippet grove-groverotary.cxx Interesting - */ -class GroveRotary: public Grove, virtual public iAngle { - public: - /** - * Grove rotary angle sensor constructor - * - * @param pin Number of the analog pin to use - */ - GroveRotary(unsigned int pin); - /** - * GroveRotary destructor - */ - ~GroveRotary(); - /** - * Gets the absolute raw value from the AIO pin - * - * @return Unsigned value from the ADC - */ - float abs_value(); - /** - * Gets absolute raw degrees from the AIO pin - * - * @return Unsigned degrees from the ADC - */ - float abs_deg(); - /** - * Gets absolute raw radians from the AIO pin - * - * @return Unsigned radians from the ADC - */ - float abs_rad(); - /** - * Gets the relative value from the AIO pin - * - * @return Signed value from the ADC - */ - float rel_value(); - /** - * Gets relative degrees from the AIO pin - * - * @return Signed degrees from the ADC - */ - float rel_deg(); - /** - * Gets relative radians from the AIO pin - * - * @return Signed radians from the ADC - */ - float rel_rad(); - - /** - * Get rotation value as raw degrees from the AIO pin. - * - * @return rotation value. - */ - virtual float getAngle(); - - private: - mraa_aio_context m_aio; - static const int m_max_angle = 300; -}; -} diff --git a/src/grove/groveslide.cxx b/src/grove/groveslide.cxx deleted file mode 100644 index d3c511fb9..000000000 --- a/src/grove/groveslide.cxx +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Authors: Brendan Le Foll - * Mihai Tudor Panu - * Sarah Knepper - * Copyright (c) 2014 - 2016 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 -#include -#include - -#include "groveslide.hpp" -#include "math.h" - -using namespace upm; - -GroveSlide::GroveSlide(unsigned int pin, float ref_voltage) -{ - if ( !(m_aio = mraa_aio_init(pin)) ) { - throw std::invalid_argument(std::string(__FUNCTION__) + - ": mraa_aio_init() failed, invalid pin?"); - return; - } - m_ref_voltage = ref_voltage; - m_name = "Slide Potentiometer"; -} - -GroveSlide::~GroveSlide() -{ - mraa_aio_close(m_aio); -} - -float GroveSlide::raw_value() -{ - return (float) mraa_aio_read(m_aio); -} - -float GroveSlide::voltage_value() -{ - // conversion to Volts - float a = GroveSlide::raw_value(); - a = m_ref_voltage * a / 1023.0 ; - return a; -} - -float GroveSlide::ref_voltage() -{ - return m_ref_voltage; -} diff --git a/src/grove/groveslide.hpp b/src/grove/groveslide.hpp deleted file mode 100644 index 8dffa1e34..000000000 --- a/src/grove/groveslide.hpp +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Authors: Brendan Le Foll - * Mihai Tudor Panu - * Sarah Knepper - * Copyright (c) 2014 - 2016 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. - */ - -#pragma once - -#include -#include -#include "grovebase.hpp" - -namespace upm { - -/** - * @deprecated This class is being replaced by the upm-slide library and the - * Slide class. - * @library grove - * @sensor groveslide - * @comname Slide Potentiometer - * @type ainput - * @man seeed - * @con analog - * - * @brief API for the Grove Slide Potentiometer - * - * Basic UPM module for the Grove slide potentiometer on analog that - * returns either a raw value or a scaled voltage value. - * - * @image html slide.jpg - * @snippet grove-groveslide.cxx Interesting - */ -class GroveSlide: public Grove { - public: - /** - * Grove analog slide potentiometer constructor - * - * @param pin Number of the analog pin to use - * - * @param ref_voltage Reference voltage the board is set to, as a floating-point value; default is 5.0V - */ - GroveSlide(unsigned int pin, float ref_voltage = 5.0); - /** - * GroveSlide destructor - */ - ~GroveSlide(); - /** - * Gets the raw value from the AIO pin - * - * @return Raw value from the ADC - */ - float raw_value(); - /** - * Gets the voltage value from the pin - * - * @return Voltage reading based on the reference voltage - */ - float voltage_value(); - /** - * Gets the board's reference voltage passed on object initialization - * - * @return Reference voltage the class was set for - */ - float ref_voltage(); - private: - mraa_aio_context m_aio; - float m_ref_voltage; -}; -} diff --git a/src/grove/grovetemp.cxx b/src/grove/grovetemp.cxx deleted file mode 100644 index ac0fc869c..000000000 --- a/src/grove/grovetemp.cxx +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Authors: Brendan Le Foll - * Mihai Tudor Panu - * Sarah Knepper - * Copyright (c) 2014 - 2016 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 -#include -#include - -#include "grovetemp.hpp" -#include "math.h" - -using namespace upm; - -GroveTemp::GroveTemp(unsigned int pin, float scale, int r0, int b) -{ - if ( !(m_aio = mraa_aio_init(pin)) ) { - throw std::invalid_argument(std::string(__FUNCTION__) + - ": mraa_aio_init() failed, invalid pin?"); - return; - } - m_name = "Temperature Sensor"; - m_scale = scale; - m_r0 = r0; - m_b = b; -} - -GroveTemp::~GroveTemp() -{ - mraa_aio_close(m_aio); -} - -int GroveTemp::value () -{ - float a = (float) mraa_aio_read(m_aio); - if (a == -1.0) return -1; - // Apply scale factor after error check - a *= m_scale; - float r = (float)(1023.0-a)*(float)m_r0/a; - float t = 1.0/(log(r/(float)m_r0)/(float)m_b + 1.0/298.15)-273.15; - return (int) round(t); -} - -float GroveTemp::getTemperature () -{ - return value(); -} - -float GroveTemp::raw_value() -{ - return (float) mraa_aio_read(m_aio); -} diff --git a/src/grove/grovetemp.hpp b/src/grove/grovetemp.hpp deleted file mode 100644 index 17402a3b6..000000000 --- a/src/grove/grovetemp.hpp +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Authors: Brendan Le Foll - * Mihai Tudor Panu - * Sarah Knepper - * Copyright (c) 2014 - 2016 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. - */ - -#pragma once - -#include -#include -#include "grovebase.hpp" -#include - -namespace upm { - -/** - * @deprecated This class is being replaced by the upm-temperature library and - * the Temperature class. - * @library grove - * @sensor grovetemp - * @comname Temperature Sensor - * @type temp - * @man seeed - * @con analog - * @kit gsk - * - * @brief API for the Grove Temperature Sensor - * - * Basic UPM module for the Grove temperature sensor on analog. This sensor - * uses a thermistor to measure ambient temperature. The conversion formula has - * been updated to work with versions 1.1 and 1.2 of the sensor. For the older - * v1.0 sensor you will have to specify R0 and B values when initializing the - * device. The range of this sensor is -40 to 125 C and accuracy is +/- 1.5 C. - * - * @image html grovetemp.jpg - * @snippet grove-grovetemp.cxx Interesting - */ -class GroveTemp: public Grove, virtual public iTemperature { - public: - /** - * Grove analog temperature sensor constructor - * - * @param pin Analog pin to use - * @param scale Scaling factor for raw analog value from the ADC, - * useful for mixed 3.3V/5V boards, default 1.0 - * @param r0 zero power resistance, this is 100K (default) for - * v1.1-v1.2 and 10K for v1.0 of the sensor - * @param b thermistor nominal B constant, this is 4275 (default) for - * v1.1-v1.2 and 3975 for v1.0 of the sensor - */ - GroveTemp(unsigned int pin, float scale = 1.0, int r0 = 100000, int b = 4275); - /** - * GroveTemp destructor - */ - ~GroveTemp(); - /** - * Gets the raw value from the AIO pin - * - * @return Raw value from the ADC - */ - float raw_value(); - /** - * Gets the temperature in Celsius from the sensor - * - * @return Normalized temperature in Celsius - */ - int value(); - - virtual float getTemperature(); - private: - mraa_aio_context m_aio; - float m_scale; - int m_r0; - int m_b; - -}; -} diff --git a/src/grovecollision/CMakeLists.txt b/src/grovecollision/CMakeLists.txt deleted file mode 100644 index fdc9019d3..000000000 --- a/src/grovecollision/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -set (libname "grovecollision") -set (libdescription "Collision Sensor") -set (module_src ${libname}.cxx) -set (module_hpp ${libname}.hpp) -set (module_iface iCollision.hpp) -upm_module_init(mraa) diff --git a/src/grovecollision/grovecollision.cxx b/src/grovecollision/grovecollision.cxx deleted file mode 100644 index d83e02eab..000000000 --- a/src/grovecollision/grovecollision.cxx +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Author: Zion Orent - * 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 -#include - -#include "grovecollision.hpp" - -using namespace upm; - -GroveCollision::GroveCollision(int pin) -{ - - if ( !(m_gpio = mraa_gpio_init(pin)) ) - { - throw std::invalid_argument(std::string(__FUNCTION__) + - ": mraa_gpio_init() failed, invalid pin?"); - return; - } - mraa_gpio_dir(m_gpio, MRAA_GPIO_IN); -} - -GroveCollision::~GroveCollision() -{ - mraa_gpio_close(m_gpio); -} - -bool GroveCollision::isColliding() -{ - // Collisions cause 0; no collision is 1 - return (!(bool)mraa_gpio_read(m_gpio)); -} diff --git a/src/grovecollision/grovecollision.hpp b/src/grovecollision/grovecollision.hpp deleted file mode 100644 index e37428b87..000000000 --- a/src/grovecollision/grovecollision.hpp +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Author: Zion Orent - * 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. - */ -#pragma once - -#include -#include - -namespace upm { - /** - * @deprecated This library is being replaced by libupm-collision - * @brief Grove Collision Sensor - * @defgroup grovecollision libupm-grovecollision - * @ingroup seeed gpio accelerometer - */ - - /** - * @deprecated This class is being replaced by Collision - * @library grovecollision - * @sensor grovecollision - * @comname Collision Sensor - * @type accelerometer - * @man seeed - * @con gpio - * - * @brief API for the Grove Collision Sensor - * - * The Grove Collision Sensor can detect whether any - * collision movement or vibration happens. - * It outputs a low pulse signal when vibration is detected. - * - * @image html grovecollision.jpg - * @snippet grovecollision.cxx Interesting - */ - class GroveCollision : virtual public iCollision { - public: - /** - * Grove collision sensor constructor - * - * @param pin Digital pin to use - */ - GroveCollision(int pin); - /** - * GroveCollision destructor - */ - ~GroveCollision(); - /** - * @return boolean value defining whether something is colliding with sensor - */ - virtual bool isColliding(); - - private: - mraa_gpio_context m_gpio; - }; -} diff --git a/src/grovecollision/grovecollision.json b/src/grovecollision/grovecollision.json deleted file mode 100644 index 591d5d9b7..000000000 --- a/src/grovecollision/grovecollision.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "Library": "grovecollision", - "Description": "API for the Grove Collision Sensor", - "Sensor Class": - { - "GroveCollision": - { - "Name": "Grove Collision Sensor", - "Description": "The Grove Collision Sensor can detect whether any collision movement or vibration happens. It outputs a low pulse signal when vibration is detected.", - "Aliases": ["grovecollision"], - "Categories": ["collision", "deprecated"], - "Connections": ["gpio"], - "Project Type": ["prototyping", "robotics"], - "Manufacturers": ["seeed"], - "Kits": [], - "Image": "grovecollision.jpg", - "Examples": - { - "Java": ["GroveCollision_Example.java"], - "Python": ["grovecollision.py"], - "Node.js": ["grovecollision.js"], - "C++": ["grovecollision.cxx"], - "C": [] - }, - "Specifications": - { - "Operating Voltage": {"unit": "V", "low": 3.3, "high": 5}, - "Operating Current": {"unit": "mA", "max": 2}, - "Reaction Point": {"unit": "mg", "typ": 50}, - "Off Resistance": {"unit": "MOhms", "min": 30}, - "On Resistance": {"unit": "Ohms", "max": 100} - }, - "Urls" : - { - "Product Pages": ["https://www.seeedstudio.com/Grove-Collision-Sensor-p-1132.html"], - "Datasheets": ["https://raw.githubusercontent.com/SeeedDocument/Grove-Collision_Sensor/master/res/DataSheet-MVS0608_02-v2_1.pdf", "http://wiki.seeed.cc/Grove-Collision_Sensor/"], - "Schematics": [] - } - } - } -} diff --git a/src/groveehr/CMakeLists.txt b/src/groveehr/CMakeLists.txt deleted file mode 100644 index 4a2a6333c..000000000 --- a/src/groveehr/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -set (libname "groveehr") -set (libdescription "Ear-clip Heart Rate Sensor") -set (module_src ${libname}.cxx) -set (module_hpp ${libname}.hpp) -set (module_iface iHeartRate.hpp) -upm_module_init(mraa) diff --git a/src/groveehr/groveehr.cxx b/src/groveehr/groveehr.cxx deleted file mode 100644 index cea08dbc9..000000000 --- a/src/groveehr/groveehr.cxx +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Author: Jon Trulson - * 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 -#include -#include - -#include "groveehr.hpp" - -using namespace upm; -using namespace std; - -GroveEHR::GroveEHR(int pin) -{ - if ( !(m_gpio = mraa_gpio_init(pin)) ) - { - throw std::invalid_argument(std::string(__FUNCTION__) + - ": mraa_aio_init() failed, invalid pin?"); - return; - } - - mraa_gpio_dir(m_gpio, MRAA_GPIO_IN); - - initClock(); - m_beatCounter = 0; -} - -GroveEHR::~GroveEHR() -{ - mraa_gpio_close(m_gpio); -} - -void GroveEHR::initClock() -{ - gettimeofday(&m_startTime, NULL); -} - -uint32_t GroveEHR::getMillis() -{ - struct timeval elapsed, now; - uint32_t elapse; - - // get current time - gettimeofday(&now, NULL); - - // compute the delta since m_startTime - if( (elapsed.tv_usec = now.tv_usec - m_startTime.tv_usec) < 0 ) - { - elapsed.tv_usec += 1000000; - elapsed.tv_sec = now.tv_sec - m_startTime.tv_sec - 1; - } - else - { - elapsed.tv_sec = now.tv_sec - m_startTime.tv_sec; - } - - elapse = (uint32_t)((elapsed.tv_sec * 1000) + (elapsed.tv_usec / 1000)); - - // never return 0 - if (elapse == 0) - elapse = 1; - - return elapse; -} - -void GroveEHR::clearBeatCounter() -{ - m_beatCounter = 0; -} - -void GroveEHR::startBeatCounter() -{ - // install our interrupt handler - mraa_gpio_isr(m_gpio, MRAA_GPIO_EDGE_RISING, - &beatISR, this); -} - -void GroveEHR::stopBeatCounter() -{ - // remove the interrupt handler - mraa_gpio_isr_exit(m_gpio); -} - -uint32_t GroveEHR::beatCounter() -{ - return m_beatCounter; -} - -void GroveEHR::beatISR(void *ctx) -{ - upm::GroveEHR *This = (upm::GroveEHR *)ctx; - This->m_beatCounter++; -} - -int GroveEHR::heartRate() -{ - uint32_t millis = getMillis(); - uint32_t beats = beatCounter(); - - float heartRate = 0; - // wait at least 5 seconds before attempting to compute the - // heart rate - if (millis > 5000) - { - heartRate = (float(beats) / (float(millis) / 1000.0)) * 60.0; - } - - return int(heartRate); -} - -int GroveEHR::getHeartRate() -{ - return GroveEHR::heartRate(); -} diff --git a/src/groveehr/groveehr.hpp b/src/groveehr/groveehr.hpp deleted file mode 100644 index f4b680f82..000000000 --- a/src/groveehr/groveehr.hpp +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Author: Jon Trulson - * 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. - */ -#pragma once - -#include -#include -#include -#include -#include - -namespace upm { - /** - * @deprecated This library is being replaced by libupm-ehr - * @brief Grove Ear-clip Heart Rate Sensor - * @defgroup groveehr libupm-groveehr - * @ingroup seeed gpio medical - */ - - /** - * @deprecated This class is being replaced by EHR - * @library groveehr - * @sensor groveehr - * @comname Ear-clip Heart Rate Sensor - * @type medical - * @man seeed - * @con gpio - * - * @brief API for the Grove Ear-clip Heart Rate Sensor - * - * UPM module for the Grove ear-clip heart rate sensor. It is used to measure your - * heart rate. - * - * @image html groveehr.jpg - * @snippet groveehr.cxx Interesting - */ - class GroveEHR : virtual public iHeartRate { - public: - /** - * GroveEHR constructor - * - * @param pin Digital pin to use - */ - GroveEHR(int pin); - /** - * GroveEHR destructor - */ - ~GroveEHR(); - /** - * Returns the time of milliseconds elapsed since initClock() - * was last called. - * - * @return Elapsed milliseconds - */ - uint32_t getMillis(); - - /** - * Resets the clock - * - */ - void initClock(); - - /** - * Resets the beat counter to 0. The beat counter should be - * stopped via stopBeatCounter() prior to calling this function. - * - */ - void clearBeatCounter(); - - /** - * Starts the beat counter - * - */ - void startBeatCounter(); - - /** - * Stops the beat counter - * - */ - void stopBeatCounter(); - - /** - * Gets the beat Counter - * - * @return Beat counter - */ - uint32_t beatCounter(); - - /** - * Computes the heart rate - * - * @return Computed heart rate - */ - int heartRate(); - - /** - * Retrieve the computed heart rate - * - * @return Computed heart rate - */ - virtual int getHeartRate(); - - private: - /** - * Beat interrupt service routine (ISR) - * - */ - static void beatISR(void *ctx); - - volatile uint32_t m_beatCounter; - struct timeval m_startTime; - mraa_gpio_context m_gpio; - }; -} diff --git a/src/groveehr/groveehr.i b/src/groveehr/groveehr.i deleted file mode 100644 index 7936b98dc..000000000 --- a/src/groveehr/groveehr.i +++ /dev/null @@ -1,26 +0,0 @@ -#ifdef SWIGPYTHON -%module (package="upm") ehr -#endif - -%import "interfaces/interfaces.i" - -%include "../common_top.i" - -/* BEGIN Java syntax ------------------------------------------------------- */ -#ifdef SWIGJAVA -%typemap(javaimports) SWIGTYPE %{ -import upm_interfaces.*; -%} - -%ignore beatISR; - -JAVA_JNI_LOADLIBRARY(javaupm_groveehr) -#endif -/* END Java syntax */ - -/* BEGIN Common SWIG syntax ------------------------------------------------- */ -%{ -#include "groveehr.hpp" -%} -%include "groveehr.hpp" -/* END Common SWIG syntax */ diff --git a/src/groveehr/groveehr.json b/src/groveehr/groveehr.json deleted file mode 100644 index 0aa4e6fcb..000000000 --- a/src/groveehr/groveehr.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "Library": "groveehr", - "Description": "API for the Ear-clip Heart Rate Sensor", - "Sensor Class": - { - "GroveEHR": - { - "Name": "Ear-clip Heart Rate Sensor", - "Description": "UPM module for the ear-clip heart rate sensor. It is used to measure your heart rate.", - "Aliases": ["groveehr"], - "Categories": ["heartrate", "deprecated"], - "Connections": ["gpio"], - "Project Type": ["medical", "wearables", "prototyping"], - "Manufacturers": ["seeed"], - "Kits": [], - "Image": "groveehr.jpg", - "Examples": - { - "Java": ["GroveEHR_Example.java"], - "Python": ["groveehr.py"], - "Node.js": ["groveehr.js"], - "C++": ["groveehr.cxx"], - "C": [] - }, - "Specifications": - { - "Operating Voltage": {"unit": "V", "low": 3, "high": 5}, - "Operating Current": {"unit": "mA", "typ": 6.5}, - "Measurement Range": {"unit": "bpm", "min": 30} - - }, - "Urls" : - { - "Product Pages": ["https://www.seeedstudio.com/Grove-Ear-clip-Heart-Rate-Sensor-p-1116.html"], - "Datasheets": ["http://wiki.seeedstudio.com/wiki/Grove_-_Heart_rate_ear_clip_kit"], - "Schematics": [] - } - } - } -} diff --git a/src/groveeldriver/CMakeLists.txt b/src/groveeldriver/CMakeLists.txt deleted file mode 100644 index 0945bcc50..000000000 --- a/src/groveeldriver/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -set (libname "groveeldriver") -set (libdescription "Electroluminescent (EL) Driver") -set (module_src ${libname}.cxx) -set (module_hpp ${libname}.hpp) -upm_module_init(mraa) diff --git a/src/groveeldriver/groveeldriver.cxx b/src/groveeldriver/groveeldriver.cxx deleted file mode 100644 index 322d6660e..000000000 --- a/src/groveeldriver/groveeldriver.cxx +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Author: Zion Orent - * 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 -#include - -#include "groveeldriver.hpp" - -using namespace upm; - -GroveElDriver::GroveElDriver(int pin) -{ - if ( !(m_gpio = mraa_gpio_init(pin)) ) - { - throw std::invalid_argument(std::string(__FUNCTION__) + - ": mraa_gpio_init() failed, invalid pin?"); - return; - } - mraa_gpio_dir(m_gpio, MRAA_GPIO_OUT); -} - -GroveElDriver::~GroveElDriver() -{ - mraa_gpio_close(m_gpio); -} - -void GroveElDriver::on() -{ - mraa_result_t error = MRAA_SUCCESS; - error = mraa_gpio_write (m_gpio, HIGH); - if (error != MRAA_SUCCESS) - mraa_result_print(error); -} - -void GroveElDriver::off() -{ - mraa_result_t error = MRAA_SUCCESS; - error = mraa_gpio_write (m_gpio, LOW); - if (error != MRAA_SUCCESS) - mraa_result_print(error); -} diff --git a/src/groveeldriver/groveeldriver.hpp b/src/groveeldriver/groveeldriver.hpp deleted file mode 100644 index 458ac6a19..000000000 --- a/src/groveeldriver/groveeldriver.hpp +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Author: Zion Orent - * 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. - */ -#pragma once - -#include - -#define HIGH 1 -#define LOW 0 - -namespace upm { - /** - * @deprecated This library is being replaced by libupm-eldriver - * @brief Grove EL Driver Module - * @defgroup groveeldriver libupm-groveeldriver - * @ingroup seeed gpio electric - */ - - /** - * @deprecated This class is being replaced by ElDriver - * @library groveeldriver - * @sensor groveeldriver - * @comname Electroluminescent (EL) Driver - * @type electric - * @man seeed - * @con gpio - * - * @brief API for the Grove EL Driver Module - * - * The Grove EL Driver allows you to easily light up an - * EL wire with just one single Grove cable. - * - * @image html groveeldriver.jpg - * @snippet groveeldriver.cxx Interesting - */ - class GroveElDriver { - public: - /** - * Grove EL Driver constructor - * - * @param pin Digital pin to use - */ - GroveElDriver(int pin); - /** - * Grove EL Driver destructor - */ - ~GroveElDriver(); - /** - * Turns the EL wire on - */ - void on(); - /** - * Turns the EL wire off - */ - void off(); - - private: - mraa_gpio_context m_gpio; - }; -} diff --git a/src/groveeldriver/groveeldriver.json b/src/groveeldriver/groveeldriver.json deleted file mode 100644 index c993aa948..000000000 --- a/src/groveeldriver/groveeldriver.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "Library": "groveeldriver", - "Description": "API for the Grove EL Driver Module", - "Sensor Class": - { - "GroveElDriver": - { - "Name": "Grove Electroluminescent Wire (EL) Driver", - "Description": "The Grove EL Driver allows you to easily light up an EL wire with just one single cable.", - "Aliases": ["groveeldriver"], - "Categories": ["lighting", "deprecated"], - "Connections": ["gpio"], - "Project Type": ["prototyping", "commercial", "wearables"], - "Manufacturers": ["seeed"], - "Kits": [], - "Image": "groveeldriver.jpg", - "Examples": - { - "Java": [], - "Python": ["groveeldriver.py"], - "Node.js": ["groveeldriver.js"], - "C++": ["groveeldriver.cxx"], - "C": [] - }, - "Specifications": - { - "Operating Voltage": {"unit": "V", "low": 3.3, "high": 5}, - "Operating Current": {"unit": "mA", "max": 300}, - "Supported EL Capacitance": {"unit": "nF", "max": 15} - - }, - "Urls" : - { - "Product Pages": ["https://www.seeedstudio.com/Grove-EL-Driver-p-2269.html"], - "Datasheets": ["http://wiki.seeed.cc/Grove-EL_Driver/"], - "Schematics": ["https://raw.githubusercontent.com/SeeedDocument/Grove-EL_Driver/master/res/Grove-EL_Driver_v1.0.pdf"] - } - } - } -} diff --git a/src/groveelectromagnet/CMakeLists.txt b/src/groveelectromagnet/CMakeLists.txt deleted file mode 100644 index 0757c7855..000000000 --- a/src/groveelectromagnet/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -set (libname "groveelectromagnet") -set (libdescription "Electromagnet") -set (module_src ${libname}.cxx) -set (module_hpp ${libname}.hpp) -set (module_iface iElectromagnet.hpp) -upm_module_init(mraa) diff --git a/src/groveelectromagnet/groveelectromagnet.cxx b/src/groveelectromagnet/groveelectromagnet.cxx deleted file mode 100644 index e7206f7e6..000000000 --- a/src/groveelectromagnet/groveelectromagnet.cxx +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Author: Zion Orent - * 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 -#include - -#include "groveelectromagnet.hpp" - -using namespace upm; - -GroveElectromagnet::GroveElectromagnet(int pin) -{ - if ( !(m_gpio = mraa_gpio_init(pin)) ) - { - throw std::invalid_argument(std::string(__FUNCTION__) + - ": mraa_gpio_init() failed, invalid pin?"); - return; - } - mraa_gpio_dir(m_gpio, MRAA_GPIO_OUT); -} - -GroveElectromagnet::~GroveElectromagnet() -{ - mraa_gpio_close(m_gpio); -} - -void GroveElectromagnet::on() -{ - mraa_result_t error = MRAA_SUCCESS; - error = mraa_gpio_write (m_gpio, HIGH); - if (error != MRAA_SUCCESS) - mraa_result_print(error); -} - -void GroveElectromagnet::off() -{ - mraa_result_t error = MRAA_SUCCESS; - error = mraa_gpio_write (m_gpio, LOW); - if (error != MRAA_SUCCESS) - mraa_result_print(error); -} diff --git a/src/groveelectromagnet/groveelectromagnet.hpp b/src/groveelectromagnet/groveelectromagnet.hpp deleted file mode 100644 index 4ab6942f8..000000000 --- a/src/groveelectromagnet/groveelectromagnet.hpp +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Author: Zion Orent - * 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. - */ -#pragma once - -#include -#include - -#define HIGH 1 -#define LOW 0 - -namespace upm { - /** - * @deprecated This library is being replaced by libupm-electromagnet - * @brief Grove Electromagnet Library - * @defgroup groveelectromagnet libupm-groveelectromagnet - * @ingroup seeed gpio electric - */ - - /** - * @deprecated This class is being replaced by Electromagnet - * @library groveelectromagnet - * @sensor groveelectromagnet - * @comname Electromagnet - * @type electric - * @man seeed - * @con gpio - * - * @brief API for the Grove Electromagnet - * - * The Grove Electromagnet can hold up to 1 kg (approximately 2.2 lbs) - * - * @image html groveelectromagnet.jpg - * @snippet groveelectromagnet.cxx Interesting - */ - class GroveElectromagnet : virtual public iElectromagnet { - public: - /** - * Grove Electromagnet constructor - * - * @param pin Digital pin to use - */ - GroveElectromagnet(int pin); - /** - * Grove Electromagnet destructor - */ - ~GroveElectromagnet(); - /** - * Turns the magnet on - */ - virtual void on(); - /** - * Turns the magnet off - */ - virtual void off(); - - private: - mraa_gpio_context m_gpio; - }; -} diff --git a/src/groveelectromagnet/groveelectromagnet.json b/src/groveelectromagnet/groveelectromagnet.json deleted file mode 100644 index 49794ac04..000000000 --- a/src/groveelectromagnet/groveelectromagnet.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "Library": "groveelectromagnet", - "Description": "Grove Electromagnet Library", - "Sensor Class": - { - "GroveElectromagnet": - { - "Name": "API for the Grove Electromagnet", - "Description": "The Grove Electromagnet can hold up to 1 kg (approximately 2.2 lbs)", - "Aliases": ["groveelectromagnet"], - "Categories": ["electric", "magnetic", "deprecated"], - "Connections": ["gpio"], - "Project Type": ["prototyping"], - "Manufacturers": ["seeed"], - "Kits": [], - "Image": "groveelectromagnet.jpg", - "Examples": - { - "Java": [], - "Python": ["groveelectromagnet.py"], - "Node.js": ["groveelectromagnet.js"], - "C++": ["groveelectromagnet.cxx"], - "C": [] - }, - "Specifications": - { - "Operating Voltage": {"unit": "V", "typ": 5}, - "Operating Current": {"unit": "mA", "typ": 400}, - "Standby Current": {"unit": "uA", "typ": 200}, - "Max Load Weight": {"unit": "kgs", "typ": 1} - - }, - "Urls" : - { - "Product Pages": ["https://www.seeedstudio.com/Grove-Electromagnet-p-1820.html"], - "Datasheets": ["https://raw.githubusercontent.com/SeeedDocument/Grove-Electromagnet/master/res/ZYE1-P20-15.pdf", "http://wiki.seeed.cc/Grove-Electromagnet/"], - "Schematics": [] - } - } - } -} diff --git a/src/groveemg/CMakeLists.txt b/src/groveemg/CMakeLists.txt deleted file mode 100644 index 0eb63befc..000000000 --- a/src/groveemg/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -set (libname "groveemg") -set (libdescription "Electromyography (EMG) Sensor") -set (module_src ${libname}.cxx) -set (module_hpp ${libname}.hpp) -set (module_iface iEmg.hpp) -upm_module_init(mraa) diff --git a/src/groveemg/groveemg.cxx b/src/groveemg/groveemg.cxx deleted file mode 100644 index 19bc41982..000000000 --- a/src/groveemg/groveemg.cxx +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Author: Zion Orent - * 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 -#include -#include - -#include "groveemg.hpp" - -using namespace upm; -using namespace std; - -GroveEMG::GroveEMG(int pin) -{ - if (!(m_aio = mraa_aio_init(pin))) { - throw std::invalid_argument(std::string(__FUNCTION__) + - ": mraa_aio_init() failed, invalid pin?"); - return; - } -} - -GroveEMG::~GroveEMG() -{ - mraa_aio_close(m_aio); -} - -void -GroveEMG::calibrate() -{ - int val, sum = 0; - - for (int i = 0; i < 1100; i++) { - val = mraa_aio_read(m_aio); - if (val != -1) - throw std::runtime_error(std::string(__FUNCTION__) + ": Failed to do an aio read."); - sum += val; - usleep(1000); - } - sum /= 1100; - cout << "Static analog data = " << sum << endl; -} - -int -GroveEMG::value() -{ - int val = mraa_aio_read(m_aio); - return val; -} - -float -GroveEMG::getVolts() -{ - float val = mraa_aio_read_float(m_aio); - if (val < 0) - return val; - - /* Apply raw scale */ - val *= this->m_scale; - - /* Scale to aRef */ - val *= this->m_aRef; - - /* Apply the offset in volts */ - val += this->m_offset; - - return val; -} \ No newline at end of file diff --git a/src/groveemg/groveemg.hpp b/src/groveemg/groveemg.hpp deleted file mode 100644 index 1111b1146..000000000 --- a/src/groveemg/groveemg.hpp +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Author: Zion Orent - * 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. - */ -#pragma once - -#include -#include -#include "interfaces/iEmg.hpp" - -namespace upm { - /** - * @deprecated This library is being replaced by libupm-emg - * @brief Grove EMG Muscle Signal Reader - * @defgroup groveemg libupm-groveemg - * @ingroup seeed analog electric - */ - - /** - * @deprecated This class is being replaced by EMG - * @library groveemg - * @sensor groveemg - * @comname Electromyography (EMG) Sensor - * @type electric - * @man seeed - * @con analog - * - * @brief API for the Grove EMG Muscle Signal Reader - * - * Grove EMG muscle signal reader gathers small muscle signals, - * then processes them, and returns the result - * - * @image html emg.jpg - * @snippet groveemg.cxx Interesting - */ - class GroveEMG : virtual public iEmg { - public: - /** - * Grove EMG reader constructor - * - * @param pin Analog pin to use - */ - GroveEMG(int pin); - /** - * GroveEMG destructor - */ - ~GroveEMG(); - - /** - * Calibrates the Grove EMG reader - */ - virtual void calibrate(); - - /** - * Measures muscle signals from the reader - * - * @return Muscle output as analog voltage - */ - virtual int value(); - - virtual float getVolts(); - - private: - mraa_aio_context m_aio; - /* Analog voltage reference */ - float m_aRef = 5.0; - /* Scale */ - float m_scale = 1.0; - /* Offset in sensor units */ - float m_offset = 0.0; - }; -} diff --git a/src/groveemg/groveemg.json b/src/groveemg/groveemg.json deleted file mode 100644 index 3b7dc8080..000000000 --- a/src/groveemg/groveemg.json +++ /dev/null @@ -1,37 +0,0 @@ -{ - "Library": "groveemg", - "Description": "Grove EMG Muscle Signal Reader Library", - "Sensor Class": - { - "GroveEMG": - { - "Name": "Grove Electromyography (EMG) Sensor", - "Description": "Grove EMG muscle signal reader gathers small muscle signals, then processes them, and returns the result.", - "Aliases": ["groveemg"], - "Categories": ["electromyography", "medical", "deprecated"], - "Connections": ["analog"], - "Project Type": ["wearables", "computer interfacing", "prototyping"], - "Manufacturers": ["seeed"], - "Kits": [], - "Examples": - { - "Java": ["GroveEmg_Example.java"], - "Python": ["groveemg.py"], - "Node.js": ["groveemg.js"], - "C++": ["groveemg.cxx"], - "C": [] - }, - "Specifications": - { - "Operating Voltage": {"unit": "V", "low": 3.3, "high": 5} - - }, - "Urls" : - { - "Product Pages": ["https://www.seeedstudio.com/Grove-EMG-Detector-p-1737.html"], - "Datasheets": ["http://wiki.seeed.cc/Grove-EMG_Detector/"], - "Schematics": ["https://raw.githubusercontent.com/SeeedDocument/Grove-EMG_Detector/master/res/Grove-EMG_Sensor_v1.1_SCH.pdf"] - } - } - } -} diff --git a/src/grovegprs/CMakeLists.txt b/src/grovegprs/CMakeLists.txt deleted file mode 100644 index 233d5cae6..000000000 --- a/src/grovegprs/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -set (libname "grovegprs") -set (libdescription "GPRS Module") -set (module_src ${libname}.cxx) -set (module_hpp ${libname}.hpp) -upm_module_init(mraa) diff --git a/src/grovegprs/grovegprs.cxx b/src/grovegprs/grovegprs.cxx deleted file mode 100644 index 4347d5f1f..000000000 --- a/src/grovegprs/grovegprs.cxx +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Author: Jon Trulson - * 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 - -#include "grovegprs.hpp" - -using namespace upm; -using namespace std; - -GroveGPRS::GroveGPRS(int uart) : - m_uart(uart) -{ -} - -GroveGPRS::~GroveGPRS() -{ -} - -bool GroveGPRS::dataAvailable(unsigned int millis) -{ - return m_uart.dataAvailable(millis); -} - -int GroveGPRS::readData(char *buffer, unsigned int len) -{ - return m_uart.read(buffer, len); -} - -std::string GroveGPRS::readDataStr(int len) -{ - return m_uart.readStr(len); -} - -int GroveGPRS::writeData(char *buffer, unsigned int len) -{ - m_uart.flush(); - return m_uart.write(buffer, len); -} - -int GroveGPRS::writeDataStr(std::string data) -{ - m_uart.flush(); - return m_uart.writeStr(data); -} - -int GroveGPRS::setBaudRate(int baud) -{ - int ret_code = m_uart.setBaudRate(baud); - if (ret_code != mraa::SUCCESS) { - return ret_code; - } else { - return 0; - } - //return m_uart.setBaudRate(baud); -} - diff --git a/src/grovegprs/grovegprs.hpp b/src/grovegprs/grovegprs.hpp deleted file mode 100644 index cad7e7dd2..000000000 --- a/src/grovegprs/grovegprs.hpp +++ /dev/null @@ -1,156 +0,0 @@ -/* - * Author: Jon Trulson - * Copyright (c) 2015 Intel Corporation. - * - * Thanks to Adafruit for supplying a google translated version of the - * Chinese datasheet and some clues in their code. - * - * 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. - */ -#pragma once - -#include -#include - -#include -#include -#include - -#include -#include - -#define GROVEGPRS_DEFAULT_UART 0 - -namespace upm { - /** - * @deprecated This library is being replaced by libupm-gprs - * @brief Grove GPRS Module - * @defgroup grovegprs libupm-grovegprs - * @ingroup seeed uart wifi - */ - - /** - * @deprecated This class is being replaced by GPRS - * @library grovegprs - * @sensor grovegprs - * @comname GPRS Module - * @type wifi - * @man seeed - * @con uart - * @web http://www.seeedstudio.com/wiki/GPRS_Shield_V2.0 - * - * @brief API for the Grove GPRS Module - * - * The driver was tested with the Grove GPRS Module, V2. It's a - * GSM GPRS module based on the SIM900. This module uses a - * standard 'AT' command set. See the datasheet for a full list - * of available commands and their possible responses: - * - * http://www.seeedstudio.com/wiki/images/7/72/AT_Commands_v1.11.pdf - * - * It is connected via a UART at 19200 baud. - * - * @image html gprs.jpg - * @snippet grovegprs.cxx Interesting - */ - - class GroveGPRS { - public: - - /** - * GroveGPRS object constructor - * - * @param uart Default UART to use (0 or 1). Default is 0. - */ - GroveGPRS(int uart=GROVEGPRS_DEFAULT_UART); - - /** - * GroveGPRS object destructor - */ - ~GroveGPRS(); - - /** - * Checks to see if there is data available for reading - * - * @param millis Number of milliseconds to wait; 0 means no waiting - * @return true if there is data available for reading - */ - bool dataAvailable(unsigned int millis); - - /** - * Reads any available data into a user-supplied buffer. Note: the - * call blocks until data is available for reading. Use - * dataAvailable() to determine whether there is data available - * beforehand, to avoid blocking. - * - * @param buffer Buffer to hold the data read - * @param len Length of the buffer - * @return Number of bytes read - */ - int readData(char *buffer, unsigned int len); - - /** - * Reads any available data and returns it in a std::string. Note: - * the call blocks until data is available for reading. Use - * dataAvailable() to determine whether there is data available - * beforehand, to avoid blocking. - * - * @param len Maximum length of the data to be returned - * @return Number of bytes read - */ - std::string readDataStr(int len); - - /** - * Writes the data in the buffer to the device. If you are - * writing a command, be sure to terminate it with a carriage - * return (\r) - * - * @param buffer Buffer to hold the data to write - * @param len Length of the buffer - * @return Number of bytes written - */ - int writeData(char *buffer, unsigned len); - - /** - * Writes the std:string data to the device. If you are writing a - * command, be sure to terminate it with a carriage return (\r) - * - * @param data Buffer to write to the device - * @return Number of bytes written - */ - int writeDataStr(std::string data); - - /** - * Sets the baud rate for the device. The default is 19200. - * - * @param baud Desired baud rate. - * @return true if successful - */ - int setBaudRate(int baud=19200); - - - protected: - mraa::Uart m_uart; - - private: - }; -} - - diff --git a/src/grovegprs/grovegprs.i b/src/grovegprs/grovegprs.i deleted file mode 100644 index dcedefeb3..000000000 --- a/src/grovegprs/grovegprs.i +++ /dev/null @@ -1,16 +0,0 @@ -%include "../common_top.i" - -/* BEGIN Java syntax ------------------------------------------------------- */ -#ifdef SWIGJAVA -JAVA_JNI_LOADLIBRARY(javaupm_grovegprs) -#endif -/* END Java syntax */ - -/* BEGIN Common SWIG syntax ------------------------------------------------- */ -%include "carrays.i" -%{ -#include "grovegprs.hpp" -%} -%include "grovegprs.hpp" -%array_class(char, charArray); -/* END Common SWIG syntax */ diff --git a/src/grovegprs/grovegprs.json b/src/grovegprs/grovegprs.json deleted file mode 100644 index 462e380a6..000000000 --- a/src/grovegprs/grovegprs.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "Library": "grovegprs", - "Description": "API for the Grove GPRS Module", - "Sensor Class": - { - "GroveGPRS": - { - "Name": "Grove General Packet Radio Service (GPRS) Module", - "Description": "The driver was tested with the Grove GPRS Module, V2. It's a GSM GPRS module based on the SIM900. This module uses a standard 'AT' command set. See the datasheet for a full list of available commands and their possible responses.", - "Aliases": ["grovegprs"], - "Categories": ["wireless"], - "Connections": ["uart"], - "Project Type": ["prototyping", "wireless"], - "Manufacturers": ["seeed"], - "Kits": [], - "Image": "grovegprs.jpg", - "Examples": - { - "Java": [], - "Python": ["grovegprs.py"], - "Node.js": ["grovegprs.js"], - "C++": ["grovegprs.cxx"], - "C": [] - }, - "Specifications": - { - "Input Voltage (5v Pin)": {"unit": "V", "Typ": 5}, - "Input Voltage (Vin Pin)": {"unit": "V", "low": 6.5, "high": 12}, - "Power Consumption": {"unit": "mA", "low": 1.5}, - "Operating Temperature": {"unit": "degC", "low": -40, "high": 85} - }, - "Urls" : - { - "Product Pages": ["https://www.seeedstudio.com/GPRS-Shield-V3.0-p-2333.html"], - "Datasheets": ["http://www.seeedstudio.com/document/SIM900datasheeet.zip", "http://wiki.seeedstudio.com/wiki/GPRS_Shield_V3.0", "http://www.seeedstudio.com/wiki/images/7/72/AT_Commands_v1.11.pdf", "http://garden.seeedstudio.com/images/a/a8/SIM900_AT_Command_Manual_V1.03.pdf", "http://garden.seeedstudio.com/images/a/a0/SIM900_ATC_V1_00.pdf"], - "Schematics": ["http://www.seeedstudio.com/wiki/File:GPRS_Shield_v3.0.pdf"] - } - } - } -} diff --git a/src/grovegsr/CMakeLists.txt b/src/grovegsr/CMakeLists.txt deleted file mode 100644 index 2bc1143cb..000000000 --- a/src/grovegsr/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -set (libname "grovegsr") -set (libdescription "Galvanic Skin Response (GSR) Sensor") -set (module_src ${libname}.cxx) -set (module_hpp ${libname}.hpp) -set (module_iface iEC.hpp) -upm_module_init(mraa) diff --git a/src/grovegsr/grovegsr.cxx b/src/grovegsr/grovegsr.cxx deleted file mode 100644 index 64a9a9fc6..000000000 --- a/src/grovegsr/grovegsr.cxx +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Author: Zion Orent - * 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 -#include -#include - -#include "grovegsr.hpp" - -using namespace upm; -using namespace std; - -GroveGSR::GroveGSR(int pin) -{ - if ( !(m_aio = mraa_aio_init(pin)) ) - { - throw std::invalid_argument(std::string(__FUNCTION__) + - ": mraa_aio_init() failed, invalid pin?"); - return; - } -} - -GroveGSR::~GroveGSR() -{ - mraa_aio_close(m_aio); -} - -void GroveGSR::calibrate() -{ - sleep(1); - int val, threshold, sum = 0; - - for(int i=0; i<500; i++) - { - val = mraa_aio_read(m_aio); - if (val != -1) throw std::runtime_error(std::string(__FUNCTION__) + - ": Failed to do an aio read."); - sum += val; - usleep(5000); - } - threshold = sum / 500; - cout << "Threshold = " << threshold << endl; -} - -int GroveGSR::value() -{ - int val = mraa_aio_read(m_aio); - return val; -} - -float GroveGSR::getECValue() -{ - return (float) GroveGSR::value(); -} diff --git a/src/grovegsr/grovegsr.hpp b/src/grovegsr/grovegsr.hpp deleted file mode 100644 index d56649dcc..000000000 --- a/src/grovegsr/grovegsr.hpp +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Author: Zion Orent - * 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. - */ -#pragma once - -#include -#include -#include - -namespace upm { - /** - * @deprecated This library is being replaced by libupm-gsr - * @brief Grove GSR Galvanic Skin Response Sensor - * @defgroup grovegsr libupm-grovegsr - * @ingroup seeed analog electric - */ - - /** - * @deprecated This class is being replaced by GSR - * @library grovegsr - * @sensor grovegsr - * @comname Galvanic Skin Response (GSR) Sensor - * @type electric - * @man seeed - * @con analog - * - * @brief API for the Grove GSR Galvanic Skin Response Sensor - * - * Measures the electrical conductance of skin - * to measure strong emotional reactions. - * In other words, it measures sweat on your fingers - * as an indicator of strong emotional reactions. - * - * @image html gsr.jpg - * @snippet grovegsr.cxx Interesting - */ - class GroveGSR : virtual public iEC { - public: - /** - * Grove GSR sensor constructor - * - * @param pin Analog pin to use - */ - GroveGSR(int pin); - /** - * GroveGSR destructor - */ - ~GroveGSR(); - - /** - * Calibrates the Grove GSR sensor - */ - void calibrate(); - - /** - * Gets the electrical conductance of the skin from the sensor - * - * @return Electrical conductance of the skin - */ - int value(); - - /** - * Gets the electrical conductance of the skin from the sensor - * - * @return Electrical conductance of the skin - */ - virtual float getECValue(); - - private: - mraa_aio_context m_aio; - }; -} diff --git a/src/grovegsr/grovegsr.json b/src/grovegsr/grovegsr.json deleted file mode 100644 index a1e1ddcfc..000000000 --- a/src/grovegsr/grovegsr.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "Library": "grovegsr", - "Description": "API for the Grove GSR Galvanic Skin Response Sensor", - "Sensor Class": - { - "GroveGSR": - { - "Name": "Galvanic Skin Response (GSR) Sensor", - "Description": "Measures the electrical conductance of skin to measure strong emotional reactions. In other words, it measures sweat on your fingers as an indicator of strong emotional reactions.", - "Aliases": ["grovegsr"], - "Categories": ["skinresponse"], - "Connections": ["analog"], - "Project Type": ["medical", "interface", "wearables", "prototyping"], - "Manufacturers": ["seeed"], - "Kits": [], - "Examples": - { - "Java": ["GroveGsr_Example.java"], - "Python": ["grovegsr.py"], - "Node.js": ["grovegsr.js"], - "C++": ["grovegsr.cxx"], - "C": [] - }, - "Specifications": - { - "Operating Voltage": {"unit": "V", "low": 3.3, "high": 5}, - "Operating Current": {"unit": "mA", "low": 0.7, "high": 3}, - "Operating Temperature": {"unit": "degC", "min": 0, "max": 70} - }, - "Urls" : - { - "Product Pages": ["https://www.seeedstudio.com/Grove-GSR-sensor-p-1614.html"], - "Datasheets": ["http://wiki.seeed.cc/Grove-GSR_Sensor/", "file:///C:/Users/Malachai/Downloads/Lm324.pdf"], - "Schematics": ["https://github.com/SeeedDocument/Grove-GSR_Sensor/raw/master/res/Grove%20-%20GSR_v1.2_SCH.pdf", "https://github.com/SeeedDocument/Grove-GSR_Sensor/raw/master/res/Grove%20-%20GSR%20v1.0%20SCH.pdf"] - } - } - } -} diff --git a/src/grovelinefinder/CMakeLists.txt b/src/grovelinefinder/CMakeLists.txt deleted file mode 100644 index ed7ffcff6..000000000 --- a/src/grovelinefinder/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -set (libname "grovelinefinder") -set (libdescription "Line Finder") -set (module_src ${libname}.cxx) -set (module_hpp ${libname}.hpp) -set (module_iface iLineFinder.hpp) -upm_module_init(mraa) diff --git a/src/grovelinefinder/grovelinefinder.cxx b/src/grovelinefinder/grovelinefinder.cxx deleted file mode 100644 index 3f4f55ced..000000000 --- a/src/grovelinefinder/grovelinefinder.cxx +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Author: Jon Trulson - * 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 -#include -#include - -#include "grovelinefinder.hpp" - -using namespace upm; -using namespace std; - -GroveLineFinder::GroveLineFinder(int pin) -{ - if ( !(m_gpio = mraa_gpio_init(pin)) ) - { - throw std::invalid_argument(std::string(__FUNCTION__) + - ": mraa_gpio_init() failed, invalid pin?"); - return; - } - - mraa_gpio_dir(m_gpio, MRAA_GPIO_IN); -} - -GroveLineFinder::~GroveLineFinder() -{ - mraa_gpio_close(m_gpio); -} - -bool GroveLineFinder::whiteDetected() -{ - return (!mraa_gpio_read(m_gpio) ? true : false); -} - -bool GroveLineFinder::blackDetected() -{ - return (mraa_gpio_read(m_gpio) ? true : false); -} diff --git a/src/grovelinefinder/grovelinefinder.hpp b/src/grovelinefinder/grovelinefinder.hpp deleted file mode 100644 index cb00289b2..000000000 --- a/src/grovelinefinder/grovelinefinder.hpp +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Author: Jon Trulson - * 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. - */ -#pragma once - -#include -#include -#include - -namespace upm { - /** - * @deprecated This library is being replaced by libupm-linefinder - * @brief Grove Line Finder Sensor - * @defgroup grovelinefinder libupm-grovelinefinder - * @ingroup seeed gpio color robok - */ - - /** - * @deprecated This class is being replaced by LineFinder - * @library grovelinefinder - * @sensor grovelinefinder - * @comname Line Finder - * @type color - * @man seeed - * @con gpio - * @kit robok - * - * @brief API for the Grove Line Finder Sensor - * - * UPM module for the Grove Line Finder sensor. It outputs a - * digital signal indicating whether it is detecting black on a - * white background, or white on a black background. - * - * @image html grovelinefinder.jpg - * @snippet grovelinefinder.cxx Interesting - */ - class GroveLineFinder : virtual public iLineFinder { - public: - /** - * Grove Line Finder digital sensor constructor - * - * @param pin Digital pin to use - */ - GroveLineFinder(int pin); - /** - * GroveLineFinder destructor - */ - ~GroveLineFinder(); - /** - * Determines whether white has been detected - * - * @return True if white is detected - */ - virtual bool whiteDetected(); - /** - * Determines whether black has been detected - * - * @return True if black is detected - */ - virtual bool blackDetected(); - - private: - mraa_gpio_context m_gpio; - }; -} diff --git a/src/grovelinefinder/grovelinefinder.json b/src/grovelinefinder/grovelinefinder.json deleted file mode 100644 index 8976b8ed5..000000000 --- a/src/grovelinefinder/grovelinefinder.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "Library": "grovelinefinder", - "Description": "Grove Line Finder Sensor Library", - "Sensor Class": - { - "GroveLineFinder": - { - "Name": "Infrared (IR) Based Line Finder", - "Description": "UPM module for the Line Finder sensor. It outputs a digital signal indicating whether it is detecting black on a white background, or white on a black background.", - "Aliases": ["grovelinefinder"], - "Categories": ["grovelinefinder"], - "Connections": ["gpio"], - "Project Type": ["robotics", "prototyping"], - "Manufacturers": ["seeed", "dfrobot"], - "Kits": ["robok"], - "Image": "grovelinefinder.jpg", - "Examples": - { - "Java": ["GroveLineFinder_Example.java"], - "Python": ["grovelinefinder.py"], - "Node.js": ["grovelinefinder.js"], - "C++": ["grovelinefinder.cxx"], - "C": [] - }, - "Specifications": - { - "Operating Voltage": {"unit": "V", "low": 2.7, "high": 5.5}, - "Operating Current": {"unit": "uA", "typ": 210}, - "Operating Temperature": {"unit": "degC", "low": -40, "high": 125} - - }, - "Urls" : - { - "Product Pages": ["https://www.seeedstudio.com/Grove-Line-Finder-v1.1-p-2712.html"], - "Datasheets": ["file:///C:/Users/Malachai/Downloads/Lmv358.pdf", "http://wiki.seeed.cc/Grove-Line_Finder/"], - "Schematics": ["https://easyeda.com/Seeed/Grove_Line_Finder_v1_1-dfc99c72325e41ff93a451882fd2e143"] - } - } - } -} diff --git a/src/grovemd/CMakeLists.txt b/src/grovemd/CMakeLists.txt deleted file mode 100644 index 4885bceb7..000000000 --- a/src/grovemd/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -set (libname "grovemd") -set (libdescription "I2C Motor Driver") -set (module_src ${libname}.cxx) -set (module_hpp ${libname}.hpp) -upm_module_init(mraa) diff --git a/src/grovemd/grovemd.cxx b/src/grovemd/grovemd.cxx deleted file mode 100644 index fcf83ac31..000000000 --- a/src/grovemd/grovemd.cxx +++ /dev/null @@ -1,244 +0,0 @@ -/* - * Author: Jon Trulson - * 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 -#include -#include -#include - -#include "grovemd.hpp" - -using namespace upm; -using namespace std; - - -GroveMD::GroveMD(int bus, uint8_t address) : - m_i2c(bus) -{ - m_addr = address; - - // this board *requires* 100Khz i2c bus only - mraa::Result rv; - if ( (rv = m_i2c.frequency(mraa::I2C_STD)) != mraa::SUCCESS ) - { - throw std::invalid_argument(std::string(__FUNCTION__) + - ": I2c.frequency(I2C_STD) failed"); - return; - } - - if (m_i2c.address(m_addr)) - { - throw std::runtime_error(std::string(__FUNCTION__) + - ": I2c.address() failed"); - return; - } - - initClock(); - // default to mode1 stepper operation, 200 steps per rev. - configStepper(200, STEP_MODE1); -} - -GroveMD::~GroveMD() -{ - setMotorSpeeds(0, 0); - writePacket(SET_DIRECTION, 0, GROVEMD_NOOP); -} - -bool GroveMD::writePacket(REG_T reg, uint8_t data1, uint8_t data2) -{ - uint8_t buf[3]; - - buf[0] = reg; - buf[1] = data1; - buf[2] = data2; - - if ( m_i2c.write(buf, 3) != mraa::SUCCESS ) - { - throw std::runtime_error(std::string(__FUNCTION__) + - ": I2c.write() failed"); - return false; - } - - // This sleep appears to be required. Without it, writes randomly - // fail (no ACK received). This happens most often on the SET_SPEED - // packet. I am guessing that there is a timing problem and/or bug - // in the motor driver's firmware. - - usleep(100); - - return true; -} - -bool GroveMD::setMotorSpeeds(uint8_t speedA, uint8_t speedB) -{ - return writePacket(SET_SPEED, speedA, speedB); -} - -bool GroveMD::setPWMFrequencyPrescale(uint8_t freq) -{ - return writePacket(SET_PWM_FREQ, freq, GROVEMD_NOOP); -} - -bool GroveMD::setMotorDirections(DC_DIRECTION_T dirA, DC_DIRECTION_T dirB) -{ - uint8_t dir = ((dirB & 0x03) << 2) | (dirA & 0x03); - return writePacket(SET_DIRECTION, dir, GROVEMD_NOOP); -} - -bool GroveMD::enableStepper(STEP_DIRECTION_T dir, uint8_t speed) -{ - // If mode 2, send the command and return immediately - if (m_stepMode == STEP_MODE2) - return writePacket(STEPPER_ENABLE, dir, speed); - - // otherwise, mode 1, setup the basics and start stepping. - - m_stepDelay = 60 * 1000 / m_stepsPerRev / speed; - m_stepDirection = ((dir == STEP_DIR_CW) ? 1 : -1); - - // seeed says speed should always be 255,255 for stepper operation - setMotorSpeeds(255, 255); - - while (m_totalSteps > 0) - { - if (getMillis() >= m_stepDelay) - { - // reset the clock - initClock(); - - m_currentStep += m_stepDirection; - - if (m_stepDirection == 1) - { - if (m_currentStep >= m_stepsPerRev) - m_currentStep = 0; - } - else - { - if (m_currentStep <= 0) - m_currentStep = m_stepsPerRev; - } - - m_totalSteps--; - stepperStep(); - } - } - - // and... we're done - return true; -} - -bool GroveMD::disableStepper() -{ - if (m_stepMode == STEP_MODE2) - return writePacket(STEPPER_DISABLE, GROVEMD_NOOP, GROVEMD_NOOP); - - // else, mode 1 - writePacket(SET_DIRECTION, 0, GROVEMD_NOOP); - return setMotorSpeeds(0, 0); -} - -bool GroveMD::setStepperSteps(unsigned int steps) -{ - if (m_stepMode == STEP_MODE2) - { - if (steps == 0) - { - // invalid - throw std::out_of_range(std::string(__FUNCTION__) + - ": invalid number of steps. " + - "Valid values are between 1 and 255."); - return false; - } - return writePacket(STEPPER_NUM_STEPS, steps, GROVEMD_NOOP); - } - - // for mode one, just store it for future use by enableStepper() - m_totalSteps = steps; - return true; -} - -void GroveMD::initClock() -{ - gettimeofday(&m_startTime, NULL); -} - -uint32_t GroveMD::getMillis() -{ - struct timeval elapsed, now; - uint32_t elapse; - - // get current time - gettimeofday(&now, NULL); - - // compute the delta since m_startTime - if( (elapsed.tv_usec = now.tv_usec - m_startTime.tv_usec) < 0 ) - { - elapsed.tv_usec += 1000000; - elapsed.tv_sec = now.tv_sec - m_startTime.tv_sec - 1; - } - else - { - elapsed.tv_sec = now.tv_sec - m_startTime.tv_sec; - } - - elapse = (uint32_t)((elapsed.tv_sec * 1000) + (elapsed.tv_usec / 1000)); - - // never return 0 - if (elapse == 0) - elapse = 1; - - return elapse; -} - -void GroveMD::configStepper(unsigned int stepsPerRev, STEP_MODE_T mode) -{ - m_stepsPerRev = stepsPerRev; - m_stepMode = mode; - m_currentStep = 0; - m_stepDelay = 0; - m_stepDirection = 1; - m_totalSteps = 0; -} - -void GroveMD::stepperStep() -{ - int step = m_currentStep % 4; - - switch (step) - { - case 0: - writePacket(SET_DIRECTION, 0b0101, GROVEMD_NOOP); - break; - case 1: - writePacket(SET_DIRECTION, 0b0110, GROVEMD_NOOP); - break; - case 2: - writePacket(SET_DIRECTION, 0b1010, GROVEMD_NOOP); - break; - case 3: - writePacket(SET_DIRECTION, 0b1001, GROVEMD_NOOP); - break; - } -} diff --git a/src/grovemd/grovemd.hpp b/src/grovemd/grovemd.hpp deleted file mode 100644 index 8f3439f81..000000000 --- a/src/grovemd/grovemd.hpp +++ /dev/null @@ -1,257 +0,0 @@ -/* - * Author: Jon Trulson - * 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. - */ -#pragma once - -#include -#include -#include -#include -#include - -#define GROVEMD_I2C_BUS 0 -#define GROVEMD_DEFAULT_I2C_ADDR 0x0f - -namespace upm { - /** - * @deprecated This library is being replaced by libupm-md - * @brief Grove I2C Motor Driver - * @defgroup grovemd libupm-grovemd - * @ingroup seeed i2c motor robok - */ - - /** - * @deprecated This class is being replaced by MD - * @library grovemd - * @sensor grovemd - * @comname I2C Motor Driver - * @type motor - * @man seeed - * @con i2c - * @kit robok - * - * @brief API for the Grove I2C Motor Driver - * - * This class implements support for the Grove I2C Motor Driver. - * This device can support a single 4-wire stepper motor, or two - * 2-wire DC motors. The device contains an Atmel* ATmega8L - * microcontroller that manages an L298N H-bridge driver chip. - * - * This device supports an I2C bus speed of 100Khz only. - * - * The module does not provide any telemetry or status - it only - * accepts I2C commands for its various operations. - * - * This module was tested with version 1.3 of the Grove I2C Motor - * Driver. - * - * For stepper operation, this driver can run in one of two modes - - * Mode 1, where this driver handles the stepping operation, and - * Mode 2, where this driver simply sends commands to the Grove - * Motor Driver, and it handles the stepping operation. Mode2 - * requires updated (and working) firmware to be loaded onto the - * device. - * - * The default stepper operation mode is Mode1, which is generally - * more flexible and is supported on all firmware revisions. - * - * @image html grovemd.jpg - * An example showing the use of a DC motor - * @snippet grovemd.cxx Interesting - * An example showing the use of a 4-wire stepper - * @snippet grovemd-stepper.cxx Interesting - */ - class GroveMD { - - public: - // GroveMD registers - typedef enum { SET_SPEED = 0x82, - SET_PWM_FREQ = 0x84, - SET_DIRECTION = 0xaa, - SET_MOTOR_A = 0xa1, // not documented - SET_MOTOR_B = 0xa5, // not documented - STEPPER_ENABLE = 0x1a, - STEPPER_DISABLE = 0x1b, - STEPPER_NUM_STEPS = 0x1c - } REG_T; - - // legal directions for the stepper - typedef enum { STEP_DIR_CCW = 0x01, - STEP_DIR_CW = 0x00 - } STEP_DIRECTION_T; - - // legal directions for individual DC motors - typedef enum { DIR_CCW = 0x02, - DIR_CW = 0x01 - } DC_DIRECTION_T; - - // stepper modes - typedef enum { STEP_MODE1 = 0x00, - STEP_MODE2 = 0x01 - } STEP_MODE_T; - - /** - * GroveMD constructor - * - * @param bus I2C bus to use - * @param address I2C address to use - */ - GroveMD(int bus=GROVEMD_I2C_BUS, - uint8_t address=GROVEMD_DEFAULT_I2C_ADDR); - - /** - * GroveMD destructor - */ - ~GroveMD(); - - /** - * Composes and writes a 3-byte packet to the controller - * - * @param reg Register location - * @param data1 First byte of data - * @param data2 Second byte of data - * @return True if successful - */ - bool writePacket(REG_T reg, uint8_t data1, uint8_t data2); - - /** - * To control DC motors, sets the speed of motors A & B. - * Valid values are 0-255. - * - * @param speedA Speed of motor A - * @param speedB Speed of motor B - * @return True if successful - */ - bool setMotorSpeeds(uint8_t speedA, uint8_t speedB); - - /** - * To control DC motors, sets the PWM frequency prescale - * factor. Note: this register is not ducumented other than to say - * the default value is 0x03. Presumably, this is the timer - * prescale factor used on the ATMega MCU timer driving the PWM. - * - * @param freq PWM prescale frequency; default is 0x03 - * @return True if successful - */ - bool setPWMFrequencyPrescale(uint8_t freq=0x03); - - /** - * To control DC motors, sets the directions of motors A & B - * - * @param dirA Direction for motor A, DIR_CW or DIR_CCW - * @param dirB Direction for motor B, DIR_CW or DIR_CCW - * @return True if successful - */ - bool setMotorDirections(DC_DIRECTION_T dirA, DC_DIRECTION_T dirB); - - /** - * To control a stepper motor, sets its direction and speed, and - * then starts operation. For Mode2, this method will return - * immediately. For Mode1 (the default) this method returns when - * the number of steps specified by setStepperSteps() has - * completed. - * - * @param dir Direction, STEP_DIR_CW or STEP_DIR_CCW - * @param speed Motor speed. Valid range is 1-255. For Mode 1 - * (default), this specifies the speed in RPM's. For Mode 2, - * speed is multiplied by 4ms by the board, so higher numbers - * will mean a slower speed. - * @return True if successful - */ - bool enableStepper(STEP_DIRECTION_T dir, uint8_t speed); - - /** - * To control a stepper motor, stops the stepper motor. - * - * @return True if successful - */ - bool disableStepper(); - - /** - * To control a stepper motor, specifies the number of steps to - * execute. For Mode2, valid values are between 1-255, 255 means - * continuous rotation. - * - * For Mode1 (the default) steps can be any positive integer. - * - * @param steps Number of steps to execute. 255 (only in Mode2) - * means continuous rotation. - * @return True if successful - */ - bool setStepperSteps(unsigned int steps); - - /** - * Configure the initial Stepper parameters. This should be - * called before any other stepper method. - * - * @param stepsPerRev The number of steps required to complete one - * full revolution. - * @param mode The stepper operating mode, default STEP_MODE1 - * @return Elapsed milliseconds - */ - void configStepper(unsigned int stepsPerRev, STEP_MODE_T mode=STEP_MODE1); - - protected: - mraa::I2c m_i2c; - uint8_t m_addr; - - private: - // steps per revolution - int m_stepsPerRev; - int m_currentStep; - uint32_t m_stepDelay; - uint32_t m_totalSteps; - STEP_MODE_T m_stepMode; - - /** - * Steps the motor one tick - * - */ - void stepperStep(); - - // step direction: - 1 = forward, -1 = backward - int m_stepDirection; - - // This is a NOOP value used to pad packets - static const uint8_t GROVEMD_NOOP = 0x01; - // our timer - struct timeval m_startTime; - - /** - * Returns the number of milliseconds elapsed since initClock() - * was last called. - * - * @return Elapsed milliseconds - */ - uint32_t getMillis(); - - /** - * Resets the clock - * - */ - void initClock(); - - }; -} - - diff --git a/src/grovemoisture/CMakeLists.txt b/src/grovemoisture/CMakeLists.txt deleted file mode 100644 index 8be2d2efb..000000000 --- a/src/grovemoisture/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -set (libname "grovemoisture") -set (libdescription "Moisture Sensor") -set (module_src ${libname}.cxx) -set (module_hpp ${libname}.hpp) -set (module_iface iMoisture.hpp) -upm_module_init(mraa) diff --git a/src/grovemoisture/grovemoisture.cxx b/src/grovemoisture/grovemoisture.cxx deleted file mode 100644 index 18dcc0749..000000000 --- a/src/grovemoisture/grovemoisture.cxx +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Author: Jon Trulson - * 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 -#include -#include - -#include "grovemoisture.hpp" - -using namespace upm; - -GroveMoisture::GroveMoisture(int pin) -{ - if ( !(m_aio = mraa_aio_init(pin)) ) - throw std::invalid_argument(std::string(__FUNCTION__) + - ": mraa_aio_init() failed, invalid pin?"); -} - -GroveMoisture::~GroveMoisture() -{ - mraa_aio_close(m_aio); -} - -int GroveMoisture::value() -{ - return mraa_aio_read(m_aio); -} - -int GroveMoisture::getMoisture() -{ - return value(); -} diff --git a/src/grovemoisture/grovemoisture.hpp b/src/grovemoisture/grovemoisture.hpp deleted file mode 100644 index 8d23aac4e..000000000 --- a/src/grovemoisture/grovemoisture.hpp +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Author: Jon Trulson - * 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. - */ -#pragma once - -#include -#include -#include - -namespace upm { - /** - * @deprecated This library is being replaced by libupm-moisture - * @brief Grove Moisture Sensor - * @defgroup grovemoisture libupm-grovemoisture - * @ingroup seeed analog liquid eak hak - */ - - /** - * @deprecated This class is being replaced by Moisture - * @library grovemoisture - * @sensor grovemoisture - * @comname Moisture Sensor - * @type liquid - * @man seeed - * @con analog - * @kit eak hak - * - * @brief API for the Grove Moisture Sensor - * - * UPM module for the Grove Moisture Sensor. - * This sensor can be used to detect the moisture content - * of soil or whether there is water around the sensor. - * As the moisture content increases, so does the value that is read. - * Note: this sensor is not designed to be left in soil - * nor to be used outdoors. - * - * @image html grovemoisture.jpg - * @snippet grovemoisture.cxx Interesting - */ - class GroveMoisture : virtual public iMoisture { - public: - /** - * Grove analog moisture sensor constructor - * - * @param pin Analog pin to use - */ - GroveMoisture(int pin); - /** - * GroveMoisture destructor - */ - ~GroveMoisture(); - /** - * Gets the moisture value from the sensor - * - * @return Moisture reading - */ - int value(); - - /** - * Gets the moisture value from the sensor - * - * @return Moisture reading - */ - virtual int getMoisture(); - - private: - mraa_aio_context m_aio; - }; -} - - diff --git a/src/grovemoisture/grovemoisture.json b/src/grovemoisture/grovemoisture.json deleted file mode 100644 index 97ed506e5..000000000 --- a/src/grovemoisture/grovemoisture.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "Library": "grovemoisture", - "Description": "API for the Grove Moisture Sensor", - "Sensor Class": - { - "GroveMoisture": - { - "Name": "Grove Moisture Sensor", - "Description": "UPM module for the Grove Moisture Sensor. This sensor can be used to detect the moisture content of soil or whether there is water around the sensor. As the moisture content increases, so does the value that is read. Note: this sensor is not designed to be left in soil nor to be used outdoors.", - "Aliases": ["grovemoisture"], - "Categories": ["moisture"], - "Connections": ["analog"], - "Project Type": ["liquid", "prototyping"], - "Manufacturers": ["seeed"], - "Kits": ["eak", "hak"], - "Image": "grovemoisture.jpg", - "Examples": - { - "Java": ["GroveMoisture_Example.java"], - "Python": ["grovemoisture.py"], - "Node.js": ["grovemoisture.js"], - "C++": ["grovemoisture.cxx"], - "C": [] - }, - "Specifications": { - "Vsource": {"unit": "V", "min": 3.3, "max": 5 }, - "Operating Temperature": {"unit": "°C", "min": -40, "max": 85 }, - "Supply Current": {"unit": "mA", "min" : 0, "max" : 35 } - }, - "Urls" : - { - "Product Pages": ["https://www.seeedstudio.com/Grove-Moisture-Sensor-p-955.html"], - "Datasheets": ["http://wiki.seeed.cc/Grove-Moisture_Sensor/"], - "Schematics": [] - } - } - } -} diff --git a/src/groveo2/CMakeLists.txt b/src/groveo2/CMakeLists.txt deleted file mode 100644 index 823091255..000000000 --- a/src/groveo2/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -set (libname "groveo2") -set (libdescription "Oxygen (O2) Concentration Sensor") -set (module_src ${libname}.cxx) -set (module_hpp ${libname}.hpp) -set (module_iface iGas.hpp) -upm_module_init(mraa) diff --git a/src/groveo2/groveo2.cxx b/src/groveo2/groveo2.cxx deleted file mode 100644 index 3ddfa9f10..000000000 --- a/src/groveo2/groveo2.cxx +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Author: Zion Orent - * 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 -#include -#include - -#include "groveo2.hpp" - -using namespace upm; -using namespace std; - -GroveO2::GroveO2(int pin) -{ - if ( !(m_aio = mraa_aio_init(pin)) ) - { - throw std::invalid_argument(std::string(__FUNCTION__) + - ": mraa_aio_init() failed, invalid pin?"); - return; - } -} - -GroveO2::~GroveO2() -{ - mraa_aio_close(m_aio); -} - -float GroveO2::voltageValue() -{ - int val = mraa_aio_read(m_aio); - if (val == -1) return -1.0f; - float sensorVoltage = (val/1024.0) * 5.0; - sensorVoltage = (sensorVoltage/201.0) * 10000.0; - return sensorVoltage; -} - -float GroveO2::getConcentration() -{ - float value; - /* Read normalized value */ - value = mraa_aio_read_float(m_aio); - if (value < 0.0) - return -1; - - /* Convert to %oxygen - Datasheet for grove o2 shows a linear response for the sensor. Assuming - 20.5% oxygen @ 25 celsius, with an gain = 1 + 12k/100 = 121, a - dynamic range of 0->25% oxygen, and opamp rails of 0->3.3v (the grove o2 - sensor uses a high-accuracy 3.3v regulator), - */ - value *= 25 * 5 / 3.3; - - return value; -} - diff --git a/src/groveo2/groveo2.hpp b/src/groveo2/groveo2.hpp deleted file mode 100644 index 7f9acee15..000000000 --- a/src/groveo2/groveo2.hpp +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Author: Zion Orent - * 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. - */ -#pragma once - -#include -#include -#include - -namespace upm { - /** - * @deprecated This library is being replaced by libupm-o2 - * @brief Grove O2 Oxygen Gas Sensor - * @defgroup groveo2 libupm-groveo2 - * @ingroup seeed analog gaseous - */ - - /** - * @deprecated This class is being replaced by O2 - * @library groveo2 - * @sensor groveo2 - * @comname Oxygen (O2) Concentration Sensor - * @type gaseous - * @man seeed - * @con analog - * - * @brief API for the Grove O2 Oxygen Gas Sensor - * - * The Grove O2 Oxygen Gas sensor measures the oxygen concentration in the air - * - * @image html groveo2.jpg - * @snippet groveo2.cxx Interesting - */ - class GroveO2: virtual public iGas { - public: - /** - * Grove O2 Oxygen Gas sensor constructor - * - * @param pin Analog pin to use - */ - GroveO2(int pin); - /** - * GroveO2 destructor - */ - ~GroveO2(); - /** - * Measures O2 from the sensor - * - * @return Oxygen concentration as voltage - */ - float voltageValue(); - - /** - * Measures O2 from the sensor - * - * @return Oxygen concentration as PPM - */ - float getConcentration(); - - private: - mraa_aio_context m_aio; - }; -} diff --git a/src/groveo2/groveo2.json b/src/groveo2/groveo2.json deleted file mode 100644 index de9706190..000000000 --- a/src/groveo2/groveo2.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "Library": "groveo2", - "Description": "Grove O2 Oxygen Gas Sensor Library", - "Sensor Class": - { - "GroveO2": - { - "Name": "Grove Oxygen (O2) Concentration Sensor", - "Description": "The Grove O2 Oxygen Gas sensor measures the oxygen concentration in the air.", - "Aliases": ["groveo2"], - "Categories": ["gas", "oxygen", "deprecated"], - "Connections": ["analog"], - "Project Type": ["environmental", "prototyping"], - "Manufacturers": ["seeed"], - "Kits": [], - "Image": "groveo2.jpg", - "Examples": - { - "Java": ["GroveO2_Example.java"], - "Python": ["groveo2.py"], - "Node.js": ["groveo2.js"], - "C++": ["groveo2.cxx"], - "C": [] - }, - "Specifications": - { - "Measurement Range": {"unit": "% Vol", "low": 0, "high": 25}, - "Sensitivity": {"unit": "mA (in air)", "low": 0.1, "high": 0.3}, - "Operating Temperature": {"unit": "degC", "low": -20, "high": 50} - }, - "Urls" : - { - "Product Pages": ["https://www.seeedstudio.com/grove-gas-sensoro2-p-1541.html"], - "Datasheets": ["http://wiki.seeed.cc/Grove-Gas_Sensor-O2/"], - "Schematics": ["https://github.com/SeeedDocument/Grove_Gas_Sensor_O2/raw/master/resources/Schematics_O2.zip"] - } - } - } -} diff --git a/src/grovescam/CMakeLists.txt b/src/grovescam/CMakeLists.txt deleted file mode 100644 index 0d4e7867c..000000000 --- a/src/grovescam/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -set (libname "grovescam") -set (libdescription "Serial Camera Module") -set (module_src ${libname}.cxx) -set (module_hpp ${libname}.hpp) -upm_module_init(mraa) diff --git a/src/grovescam/grovescam.cxx b/src/grovescam/grovescam.cxx deleted file mode 100644 index e7890761a..000000000 --- a/src/grovescam/grovescam.cxx +++ /dev/null @@ -1,490 +0,0 @@ -/* - * Author: Jon Trulson - * Copyright (c) 2015 Intel Corporation. - * - * 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 -#include -#include -#include - -#include "grovescam.hpp" - -using namespace upm; -using namespace std; - -static const int maxRetries = 100; - -GROVESCAM::GROVESCAM(int uart, uint8_t camAddr) -{ - m_ttyFd = -1; - - // save our shifted camera address, we'll need it a lot - m_camAddr = (camAddr << 5); - - m_picTotalLen = 0; - - if ( !(m_uart = mraa_uart_init(uart)) ) - { - throw std::invalid_argument(std::string(__FUNCTION__) + - ": mraa_uart_init() failed"); - return; - } - - // This requires a recent MRAA (1/2015) - const char *devPath = mraa_uart_get_dev_path(m_uart); - - if (!devPath) - { - throw std::runtime_error(std::string(__FUNCTION__) + - ": mraa_uart_get_dev_path() failed"); - return; - } - - // now open the tty - if ( (m_ttyFd = open(devPath, O_RDWR)) == -1) - { - throw std::runtime_error(std::string(__FUNCTION__) + - ": open of " + - string(devPath) + " failed:" + - string(strerror(errno))); - return; - } -} - -GROVESCAM::~GROVESCAM() -{ - if (m_ttyFd != -1) - close(m_ttyFd); -} - -bool GROVESCAM::dataAvailable(unsigned int millis) -{ - if (m_ttyFd == -1) - return false; - - struct timeval timeout; - - if (millis == 0) - { - // no waiting - timeout.tv_sec = 0; - timeout.tv_usec = 0; - } - else - { - timeout.tv_sec = millis / 1000; - timeout.tv_usec = (millis % 1000) * 1000; - } - - fd_set readfds; - - FD_ZERO(&readfds); - - FD_SET(m_ttyFd, &readfds); - - if (select(m_ttyFd + 1, &readfds, NULL, NULL, &timeout) > 0) - return true; // data is ready - else - return false; -} - -int GROVESCAM::readData(uint8_t *buffer, int len) -{ - if (m_ttyFd == -1) - return(-1); - - int rv = read(m_ttyFd, (char *)buffer, len); - - if (rv < 0) - { - throw std::runtime_error(std::string(__FUNCTION__) + - ": read() failed: " + - string(strerror(errno))); - return rv; - } - - return rv; -} - -int GROVESCAM::writeData(uint8_t *buffer, int len) -{ - if (m_ttyFd == -1) - return(-1); - - // first, flush any pending but unread input - - tcflush(m_ttyFd, TCIFLUSH); - - int rv = write(m_ttyFd, (char *)buffer, len); - - if (rv < 0) - { - throw std::runtime_error(std::string(__FUNCTION__) + - ": write() failed: " + - string(strerror(errno))); - return rv; - } - - tcdrain(m_ttyFd); - - return rv; -} - -bool GROVESCAM::setupTty(speed_t baud) -{ - if (m_ttyFd == -1) - return(false); - - struct termios termio; - - // get current modes - tcgetattr(m_ttyFd, &termio); - - // setup for a 'raw' mode. 81N, no echo or special character - // handling, such as flow control. - cfmakeraw(&termio); - - // set our baud rates - cfsetispeed(&termio, baud); - cfsetospeed(&termio, baud); - - // make it so - if (tcsetattr(m_ttyFd, TCSAFLUSH, &termio) < 0) - { - throw std::runtime_error(std::string(__FUNCTION__) + - ": tcsetattr() failed: " + - string(strerror(errno))); - return false; - } - - return true; -} - -void GROVESCAM::drainInput() -{ - uint8_t ch; - - while (dataAvailable(0)) - readData(&ch, 1); -} - -bool GROVESCAM::init() -{ - const unsigned int pktLen = 6; - uint8_t cmd[pktLen] = {0xaa, static_cast(0x0d|m_camAddr), 0x00, - 0x00, 0x00, 0x00}; - uint8_t resp[pktLen]; - int retries = 0; - - while (true) - { - if (retries++ > maxRetries) - { - throw std::runtime_error(std::string(__FUNCTION__) + - ": maximum retries exceeded"); - return false; - } - - writeData(cmd, pktLen); - - if (!dataAvailable(500)) - continue; - - if (readData(resp, pktLen) != pktLen) - continue; - - if (resp[0] == 0xaa - && resp[1] == (0x0e | m_camAddr) - && resp[2] == 0x0d - && resp[4] == 0 - && resp[5] == 0) - { - if (readData(resp, pktLen) != pktLen) - continue; - else - { - if (resp[0] == 0xaa - && resp[1] == (0x0d | m_camAddr) - && resp[2] == 0 - && resp[3] == 0 - && resp[4] == 0 - && resp[5] == 0) - break; - } - } - } - - cmd[1] = 0x0e | m_camAddr; - cmd[2] = 0x0d; - writeData(cmd, pktLen); - - return true; -} - -bool GROVESCAM::preCapture(PIC_FORMATS_T fmt) -{ - const unsigned int pktLen = 6; - uint8_t cmd[pktLen] = { 0xaa, static_cast(0x01 | m_camAddr), 0x00, - 0x07, 0x00, static_cast(fmt) }; - uint8_t resp[pktLen]; - int retries = 0; - - while (true) - { - if (retries++ > maxRetries) - { - throw std::runtime_error(std::string(__FUNCTION__) + - ": maximum retries exceeded"); - return false; - } - - drainInput(); - - writeData(cmd, pktLen); - - if (!dataAvailable(100)) - continue; - - if (readData(resp, pktLen) != pktLen) - continue; - - if (resp[0] == 0xaa - && resp[1] == (0x0e | m_camAddr) - && resp[2] == 0x01 - && resp[4] == 0 - && resp[5] == 0) break; - } - - return true; -} - -bool GROVESCAM::doCapture() -{ - const unsigned int pktLen = 6; - uint8_t cmd[pktLen] = { 0xaa, static_cast(0x06 | m_camAddr), 0x08, - static_cast(MAX_PKT_LEN & 0xff), - static_cast((MAX_PKT_LEN >> 8)) & 0xff, 0}; - uint8_t resp[pktLen]; - int retries = 0; - - m_picTotalLen = 0; - - while (true) - { - if (retries++ > maxRetries) - { - throw std::runtime_error(std::string(__FUNCTION__) + - ": maximum retries exceeded"); - return false; - } - - drainInput(); - writeData(cmd, pktLen); - usleep(100000); - - if (!dataAvailable(100)) - continue; - - if (readData(resp, pktLen) != pktLen) - continue; - - if (resp[0] == 0xaa - && resp[1] == (0x0e | m_camAddr) - && resp[2] == 0x06 - && resp[4] == 0 - && resp[5] == 0) - break; - } - - cmd[1] = 0x05 | m_camAddr; - cmd[2] = 0; - cmd[3] = 0; - cmd[4] = 0; - cmd[5] = 0; - - retries = 0; - while (true) - { - if (retries++ > maxRetries) - { - throw std::runtime_error(std::string(__FUNCTION__) + - ": maximum retries exceeded"); - return false; - } - - drainInput(); - writeData(cmd, pktLen); - if (readData(resp, pktLen) != pktLen) - continue; - - if (resp[0] == 0xaa - && resp[1] == (0x0e | m_camAddr) - && resp[2] == 0x05 - && resp[4] == 0 - && resp[5] == 0) - break; - } - - cmd[1] = 0x04 | m_camAddr; - cmd[2] = 0x01; - - retries = 0; - while (true) - { - if (retries++ > maxRetries) - { - throw std::runtime_error(std::string(__FUNCTION__) + - ": maximum retries exceeded"); - return false; - } - - drainInput(); - writeData(cmd, 6); - - if (readData(resp, pktLen) != pktLen) - continue; - - if (resp[0] == 0xaa - && resp[1] == (0x0e | m_camAddr) - && resp[2] == 0x04 - && resp[4] == 0 - && resp[5] == 0) - { - if (!dataAvailable(1000)) - continue; - - if (readData(resp, pktLen) != pktLen) - continue; - - if (resp[0] == 0xaa - && resp[1] == (0x0a | m_camAddr) - && resp[2] == 0x01) - { - m_picTotalLen = (resp[3]) | (resp[4] << 8) | (resp[5] << 16); - break; - } - } - } - - return true; -} - -bool GROVESCAM::storeImage(const char *fname) -{ - if (!fname) - { - throw std::invalid_argument(std::string(__FUNCTION__) + - ": filename is NULL"); - return false; - } - - if (!m_picTotalLen) - { - throw std::runtime_error(std::string(__FUNCTION__) + - ": Picture length is zero, you need to capture first."); - - return false; - } - - FILE *file = fopen(fname, "wb"); - - if (!file) - { - throw std::runtime_error(std::string(__FUNCTION__) + - ": fopen() failed: " + - string(strerror(errno))); - return false; - } - - /// let the games begin... - const unsigned int pktLen = 6; - unsigned int pktCnt = (m_picTotalLen) / (MAX_PKT_LEN - 6); - if ((m_picTotalLen % (MAX_PKT_LEN-6)) != 0) - pktCnt += 1; - - uint8_t cmd[pktLen] = { 0xaa, static_cast(0x0e | m_camAddr), 0x00, - 0x00, 0x00, 0x00 }; - uint8_t pkt[MAX_PKT_LEN]; - int retries = 0; - - for (unsigned int i = 0; i < pktCnt; i++) - { - cmd[4] = i & 0xff; - cmd[5] = (i >> 8) & 0xff; - - retries = 0; - - retry: - - usleep(10000); - - drainInput(); - writeData(cmd, pktLen); - - if (!dataAvailable(1000)) - { - if (retries++ > maxRetries) - { - throw std::runtime_error(std::string(__FUNCTION__) + - ": timeout, maximum retries exceeded"); - return false; - } - goto retry; - } - - uint16_t cnt = readData(pkt, MAX_PKT_LEN); - - unsigned char sum = 0; - for (int y = 0; y < cnt - 2; y++) - { - sum += pkt[y]; - } - if (sum != pkt[cnt-2]) - { - if (retries++ <= maxRetries) - goto retry; - else - { - fclose(file); - throw std::runtime_error(std::string(__FUNCTION__) + - ": cksum error, maximum retries exceeded"); - return false; - } - } - - fwrite((const uint8_t *)&pkt[4], cnt - 6, 1, file); - } - - cmd[4] = 0xf0; - cmd[5] = 0xf0; - writeData(cmd, pktLen); - - fclose(file); - - // reset the pic length to 0 for another run. - m_picTotalLen = 0; - - return true; -} diff --git a/src/grovescam/grovescam.hpp b/src/grovescam/grovescam.hpp deleted file mode 100644 index 3ad69dbc2..000000000 --- a/src/grovescam/grovescam.hpp +++ /dev/null @@ -1,196 +0,0 @@ -/* - * Author: Jon Trulson - * Copyright (c) 2015 Intel Corporation. - * - * 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. - */ -#pragma once - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#define GROVESCAM_DEFAULT_UART 0 - -#define GROVESCAM_DEFAULT_CAMERA_ADDR 0 - -namespace upm { - /** - * @deprecated This library is being replaced by libupm-scam - * @brief Grove Serial Camera - * @defgroup grovescam libupm-grovescam - * @ingroup seeed uart other - */ - - /** - * @deprecated This class is being replaced by SCAM - * @library grovescam - * @sensor grovescam - * @comname Serial Camera Module - * @type other - * @man seeed - * @con uart - * @web http://www.seeedstudio.com/wiki/Grove_-_Serial_Camera_Kit - * - * @brief API for the Grove Serial Camera - * - * The driver was tested with the Grove Serial Camera. There is - * no protocol documentation currently available, so this module - * was developed based completely on the Seeed Studio* Arduino* - * sketch. - * - * It is connected via a UART at 115,200 baud. - * - * @image html grovescam.jpg - * @snippet grovescam.cxx Interesting - */ - - class GROVESCAM { - public: - - static const unsigned int MAX_PKT_LEN = 128; - - typedef enum { - FORMAT_VGA = 7, // 640x480 - FORMAT_CIF = 5, // 352*288 - FORMAT_OCIF = 3 // ??? (maybe they meant QCIF?) - } PIC_FORMATS_T; - - /** - * Grove Serial Camera constructor - * - * @param uart Default UART to use (0 or 1) - * @param camAddr 3-bit address identifier of the camera; default is 0 - */ - GROVESCAM(int uart, uint8_t camAddr=GROVESCAM_DEFAULT_CAMERA_ADDR); - - /** - * GROVESCAM destructor - */ - ~GROVESCAM(); - - /** - * Checks to see if there is data available for reading - * - * @param millis Number of milliseconds to wait; 0 means no waiting. - * @return True if there is data available for reading - */ - bool dataAvailable(unsigned int millis); - - /** - * Reads any available data into a user-supplied buffer. Note: the - * call blocks until data is available to be read. Use - * dataAvailable() to determine whether there is data available - * beforehand, to avoid blocking. - * - * @param buffer Buffer to hold the data read - * @param len Length of the buffer - * @return Number of bytes read - */ - int readData(uint8_t *buffer, int len); - - /** - * Writes the data in the buffer to the device - * - * @param buffer Buffer to hold the data read - * @param len Length of the buffer - * @return Number of bytes written - */ - int writeData(uint8_t *buffer, int len); - - /** - * Sets up proper tty I/O modes and the baud rate. For this device, the default - * baud rate is 9,600 (B9600). - * - * @param baud Desired baud rate - * @return True if successful - */ - bool setupTty(speed_t baud=B115200); - - /** - * Reads serial input and discards until no more characters are available - * - */ - void drainInput(); - - /** - * Initializes the camera - * - */ - bool init(); - - /** - * Tells the camera to prepare for a capture - * - * @param fmt One of the PIC_FORMATS_T values - */ - bool preCapture(PIC_FORMATS_T fmt=FORMAT_VGA); - - /** - * Starts the capture - * - * @return True if successful - */ - bool doCapture(); - - /** - * Stores the captured image in a file - * - * @param fname Name of the file to write - * @return True if successful - */ - bool storeImage(const char *fname); - - /** - * Returns the picture length. Note: this is only valid after - * doCapture() has run successfully. - * - * @return Image length - */ - int getImageSize() { return m_picTotalLen; }; - - protected: - int ttyFd() { return m_ttyFd; }; - - private: - mraa_uart_context m_uart; - int m_ttyFd; - - uint8_t m_camAddr; - int m_picTotalLen; - }; -} - - diff --git a/src/grovescam/grovescam.i b/src/grovescam/grovescam.i deleted file mode 100644 index 3bdf15115..000000000 --- a/src/grovescam/grovescam.i +++ /dev/null @@ -1,16 +0,0 @@ -%include "../common_top.i" - -/* BEGIN Java syntax ------------------------------------------------------- */ -#ifdef SWIGJAVA -%include "../java_buffer.i" - -JAVA_JNI_LOADLIBRARY(javaupm_grovescam) -#endif -/* END Java syntax */ - -/* BEGIN Common SWIG syntax ------------------------------------------------- */ -%{ -#include "grovescam.hpp" -%} -%include "grovescam.hpp" -/* END Common SWIG syntax */ diff --git a/src/grovescam/grovescam.json b/src/grovescam/grovescam.json deleted file mode 100644 index 82f3771a4..000000000 --- a/src/grovescam/grovescam.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "Library": "grovescam", - "Description": "Grove Serial Camera Library", - "Sensor Class": - { - "GROVESCAM": - { - "Name": "Serial Camera Module", - "Description": "UPM module for the ear-clip heart rate sensor. It is used to measure your heart rate.", - "Aliases": ["grovescam"], - "Categories": ["imaging", "deprecated"], - "Connections": ["uart"], - "Project Type": ["prototyping", "access control", "security"], - "Manufacturers": ["seeed"], - "Kits": [], - "Image": "grovescam.jpg", - "Examples": - { - "Java": ["GROVESCAM_Example.java"], - "Python": ["grovescam.py"], - "Node.js": ["grovescam.js"], - "C++": ["grovescam.cxx"], - "C": [] - }, - "Specifications": - { - "Operating Voltage": {"unit": "V", "typ": 5}, - "Resolution": {"unit": "", "max": "640x480"} - - }, - "Urls" : - { - "Product Pages": ["https://www.seeedstudio.com/Grove-Serial-Camera-Kit-p-1608.html"], - "Datasheets": ["http://www.seeedstudio.com/wiki/Grove_-_Serial_Camera_Kit"], - "Schematics": [] - } - } - } -} diff --git a/src/grovespeaker/CMakeLists.txt b/src/grovespeaker/CMakeLists.txt deleted file mode 100644 index d8b076551..000000000 --- a/src/grovespeaker/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -set (libname "grovespeaker") -set (libdescription "Speaker Module") -set (module_src ${libname}.cxx) -set (module_hpp ${libname}.hpp) -upm_module_init(mraa) diff --git a/src/grovespeaker/grovespeaker.cxx b/src/grovespeaker/grovespeaker.cxx deleted file mode 100644 index 61d25481d..000000000 --- a/src/grovespeaker/grovespeaker.cxx +++ /dev/null @@ -1,150 +0,0 @@ -/* - * Author: Zion Orent - * 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 -#include -#include - -#include "grovespeaker.hpp" - -using namespace upm; - -GroveSpeaker::GroveSpeaker(int pin) -{ - if ( !(m_gpio = mraa_gpio_init(pin)) ) - throw std::invalid_argument(std::string(__FUNCTION__) + - ": mraa_gpio_init() failed, invalid pin?"); - - mraa_gpio_dir(m_gpio, MRAA_GPIO_OUT); - m_note_list['a'] = storeNote(1136, 1073, 568, 536, 284, 268); - m_note_list['b'] = storeNote(1012, 0, 506, 0, 253, 0); - m_note_list['c'] = storeNote(1911, 1804, 956, 902, 478, 451); - m_note_list['d'] = storeNote(1703, 1607, 851, 804, 426, 402); - m_note_list['e'] = storeNote(1517, 0, 758, 0, 379, 0); - m_note_list['f'] = storeNote(1432, 1351, 716, 676, 358, 338); - m_note_list['g'] = storeNote(1276, 1204, 638, 602, 319, 301); -} - -GroveSpeaker::~GroveSpeaker() -{ - mraa_gpio_close(m_gpio); -} - -NoteData GroveSpeaker::storeNote(int noteDelayLow, int noteDelayLowSharp, - int noteDelayMed, int noteDelayMedSharp, - int noteDelayHigh, int noteDelayHighSharp) -{ - NoteData note; - note.delayTimeLow = noteDelayLow; - note.delayTimeLowSharp = noteDelayLowSharp; - note.delayTimeMed = noteDelayMed; - note.delayTimeMedSharp = noteDelayMedSharp; - note.delayTimeHigh = noteDelayHigh; - note.delayTimeHighSharp = noteDelayHighSharp; - return note; -} - -void GroveSpeaker::playAll() -{ - playSound('c', false, "low"); - usleep(200000); - playSound('d', false, "low"); - usleep(200000); - playSound('e', false, "low"); - usleep(200000); - playSound('f', false, "low"); - usleep(200000); - playSound('g', false, "low"); - usleep(500000); - playSound('a', false, "low"); - usleep(500000); - playSound('b', false, "low"); - usleep(500000); -} - -void GroveSpeaker::playSound(char letter, bool sharp, std::string vocalWeight) -{ - std::map::iterator it = m_note_list.find(letter); - if(it == m_note_list.end()) - { - std::cout << "The key " << letter << " doesn't exist." << std::endl; - return; - } - NoteData nd = it->second; - int delayTime; - if (sharp) - { - if (vocalWeight.compare("low") == 0) - delayTime = nd.delayTimeLowSharp; - else if (vocalWeight.compare("med") == 0) - delayTime = nd.delayTimeMedSharp; - else if (vocalWeight.compare("high") == 0) - delayTime = nd.delayTimeHighSharp; - else - { - std::cout << "Correct voice weight values are low, med, or high" - << std::endl; - return; - } - } - else - { - if (vocalWeight.compare("low") == 0) - delayTime = nd.delayTimeLow; - else if (vocalWeight.compare("med") == 0) - delayTime = nd.delayTimeMed; - else if (vocalWeight.compare("high") == 0) - delayTime = nd.delayTimeHigh; - else - { - std::cout << "Correct voice weight values are low, med, or high" - << std::endl; - return; - } - } - // If delayTime is zero, that means you tried to choose a sharp note - // for a note that has no sharp - if (sharp && !delayTime) - { - std::cout << "The key " << letter << " doesn't have a sharp note." - << std::endl; - return; - } - sound(delayTime); -} - -void GroveSpeaker::sound(int note_delay) -{ - mraa_result_t error = MRAA_SUCCESS; - for (int i = 0; i < 100; i++) - { - error = mraa_gpio_write (m_gpio, HIGH); - usleep(note_delay); - error = mraa_gpio_write (m_gpio, LOW); - usleep(note_delay); - } - if (error != MRAA_SUCCESS) - mraa_result_print(error); -} - diff --git a/src/grovespeaker/grovespeaker.hpp b/src/grovespeaker/grovespeaker.hpp deleted file mode 100644 index ba61a39b8..000000000 --- a/src/grovespeaker/grovespeaker.hpp +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Author: Zion Orent - * 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. - */ -#pragma once - -#include -#include -#include -#include - -#define HIGH 1 -#define LOW 0 - -namespace upm { - /** - * @deprecated This library is being replaced by libupm-speaker - * @brief Grove Speaker - * @defgroup grovespeaker libupm-grovespeaker - * @ingroup seeed gpio sound hak - */ -typedef struct -{ - int delayTimeLow; - int delayTimeLowSharp; - int delayTimeMed; - int delayTimeMedSharp; - int delayTimeHigh; - int delayTimeHighSharp; -} NoteData; - /** - * @deprecated This class is being replaced by Speaker - * @library grovespeaker - * @sensor grovespeaker - * @comname Speaker Module - * @type sound - * @man seeed - * @con gpio - * @kit hak - * - * @brief API for the Grove Speaker - * - * UPM module for the Grove Speaker. - * This sensor can generate different tones and sounds depending on the - * frequency of the input signal. - * - * @image html grovespeaker.jpg - * @snippet grovespeaker.cxx Interesting - */ - class GroveSpeaker { - public: - /** - * Grove Speaker constructor - * - * @param pin Digital pin to use - */ - GroveSpeaker(int pin); - /** - * GroveSpeaker destructor - */ - ~GroveSpeaker(); - /** - * Plays all alto notes (lowest notes) - * - */ - void playAll(); - /** - * Plays a sound and a note whether it's sharp or not - * - * @param letter Character name of the note - * ('a', 'b', 'c', 'd', 'e', 'f', or 'g') - * @param sharp If true, plays a sharp version of the note; otherwise, does not play the note - * @param vocalWeight String to determine whether to play a low ("low"), - * a medium ("med"), or a high ("high") note - */ - void playSound(char letter, bool sharp, std::string vocalWeight); - - private: - mraa_gpio_context m_gpio; - std::map m_note_list; - void sound(int note_delay); - NoteData storeNote(int noteDelayLow, int noteDelayLowSharp, - int noteDelayMed, int noteDelayMedSharp, - int noteDelayHigh, int noteDelayHighSharp); - }; -} diff --git a/src/grovespeaker/grovespeaker.json b/src/grovespeaker/grovespeaker.json deleted file mode 100644 index d4573eb4a..000000000 --- a/src/grovespeaker/grovespeaker.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "Library": "grovespeaker", - "Description": "API for the Grove Speaker", - "Sensor Class": - { - "GroveSpeaker": - { - "Name": "Grove Speaker Module", - "Description": "UPM module for the Grove Speaker. This sensor can generate different tones and sounds depending on the frequency of the input signal.", - "Aliases": ["grovespeaker"], - "Categories": ["sound", "deprecated"], - "Connections": ["gpio"], - "Project Type": ["sound", "prototyping"], - "Manufacturers": ["seeed"], - "Kits": ["hak"], - "Image": "grovespeaker.jpg", - "Examples": - { - "Java": ["GroveSpeaker_Example.java"], - "Python": ["grovespeaker.py"], - "Node.js": ["grovespeaker.js"], - "C++": ["grovespeaker.cxx"], - "C": [] - }, - "Specifications": - { - "Operating Voltage": {"unit": "V", "low": 4, "high": 5.5}, - "Voltage Gain": {"unit": "dB", "typ": 46}, - "Bandwidth": {"unit": "KHz", "min": 20} - - }, - "Urls" : - { - "Product Pages": ["https://www.seeedstudio.com/Grove-Speaker-p-1445.html"], - "Datasheets": ["http://wiki.seeed.cc/Grove-Speaker/", "https://raw.githubusercontent.com/SeeedDocument/Grove-Speaker/master/res/LM386_Low_Voltage_Audio_Power_Amplifier_Datasheet.pdf"], - "Schematics": ["https://raw.githubusercontent.com/SeeedDocument/Grove-Speaker/master/res/Grove-Speaker_v1.0_sch.pdf"] - } - } - } -} diff --git a/src/groveultrasonic/CMakeLists.txt b/src/groveultrasonic/CMakeLists.txt deleted file mode 100644 index b4447f17a..000000000 --- a/src/groveultrasonic/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -set (libname "groveultrasonic") -set (libdescription "Ultrasonic Proximity Sensor") -set (module_src ${libname}.cxx) -set (module_hpp ${libname}.hpp) -upm_module_init(mraa) diff --git a/src/groveultrasonic/groveultrasonic.cxx b/src/groveultrasonic/groveultrasonic.cxx deleted file mode 100644 index 8611d5802..000000000 --- a/src/groveultrasonic/groveultrasonic.cxx +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Author: Jun Kato - * 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 -#include -#include -#include - -#include "groveultrasonic.hpp" - -using namespace upm; - -GroveUltraSonic::GroveUltraSonic(int pin) -{ - m_name = "GroveUltraSonic"; - - mraa_init(); - - // setup pin - m_pinCtx = mraa_gpio_init(pin); - if (m_pinCtx == NULL) { - fprintf(stderr, "Are you sure that pin%d you requested is valid on your platform?", pin); - exit(1); - } - mraa_gpio_isr (m_pinCtx, MRAA_GPIO_EDGE_BOTH, - &signalISR, this); -} - -GroveUltraSonic::~GroveUltraSonic() -{ - // close pin - mraa_gpio_isr_exit(m_pinCtx); - mraa_gpio_close(m_pinCtx); -} - -float -GroveUltraSonic::getDistance() -{ - // output trigger signal - mraa_gpio_dir(m_pinCtx, MRAA_GPIO_OUT); - mraa_gpio_write(m_pinCtx, LOW); - usleep(2); - mraa_gpio_write(m_pinCtx, HIGH); - usleep(5); - mraa_gpio_write(m_pinCtx, LOW); - - // wait for the pulse, - m_doWork = true; - m_InterruptCounter = 0; - mraa_gpio_dir(m_pinCtx, MRAA_GPIO_IN); - - // though do not wait over 25 [ms]. - int timer = 0; - while (m_doWork && timer++ < 5) { - // in 25 [ms], sound travels 25000 / 29 / 2 = 431 [cm], - // which is more than 400 [cm], the max distance measurable with this sensor. - usleep(5 * 1000); // 5 [ms] - } - - // calc diff - long diff = m_FallingTimeStamp.tv_usec - m_RisingTimeStamp.tv_usec; - diff += (m_FallingTimeStamp.tv_sec - m_RisingTimeStamp.tv_sec) * 1000000; - return timer >= 5 ? 0 : diff; -} - -void -GroveUltraSonic::signalISR(void* ctx) -{ - upm::GroveUltraSonic* This = (upm::GroveUltraSonic*) ctx; - This->ackEdgeDetected(); -} - -void -GroveUltraSonic::ackEdgeDetected() -{ - if (++m_InterruptCounter % 2 == 0) { - gettimeofday(&m_FallingTimeStamp, NULL); - m_doWork = false; - } else { - gettimeofday(&m_RisingTimeStamp, NULL); - } -} diff --git a/src/groveultrasonic/groveultrasonic.hpp b/src/groveultrasonic/groveultrasonic.hpp deleted file mode 100644 index 0a35dcb78..000000000 --- a/src/groveultrasonic/groveultrasonic.hpp +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Author: Jun Kato - * 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. - */ -#pragma once - -#include -#include -#include -#include - -#define HIGH 1 -#define LOW 0 - -namespace upm { - -/** - * @deprecated This library is being replaced by libupm-ultrasonic - * @brief Grove Ultrasonic Sensor - * @defgroup groveultrasonic libupm-groveultrasonic - * @ingroup seeed gpio sound - */ - -/** - * @deprecated This class is being replaced by UltraSonic - * @library groveultrasonic - * @sensor groveultrasonic - * @comname Ultrasonic Proximity Sensor - * @type sound - * @man seeed - * @con gpio - * - * @brief API for Grove Ultrasonic Ranger - * - * This Grove Ultrasonic sensor is a non-contact distance measurement module - * which is compatible with the Grove system. It is designed for easy modular - * project usage with industrial performance. Detection ranges from 3 cm (1.2") - * to 4 m (13'1.5") and works best when the object is within a 30 degree angle - * relative to the sensor. - * - * @image html groveultrasonic.jpg - * @snippet groveultrasonic.cxx Interesting - */ -class GroveUltraSonic { - public: - /** - * Instantiates a GroveUltraSonic object - * - * @param pin pin for triggering the sensor for distance and for receiving pulse response - */ - GroveUltraSonic (int pin); - - /** - * GroveUltraSonic object destructor. - */ - ~GroveUltraSonic (); - - /** - * Returns the echo's pulse width from the sensor in microseconds. - * Divide by 58 to convert distance to centimetres. - * Divide by 148 to convert distance to inches. - */ - float getDistance (); - - /** - * Return name of the component - */ - std::string name() - { - return m_name; - } - - /** - * Returns true while the sensor is busy waiting for the echo pulse - */ - bool working() - { - return m_doWork; - } - - private: - bool m_doWork; /* Flag to control blocking function while waiting for falling edge interrupt */ - mraa_gpio_context m_pinCtx; - uint8_t m_InterruptCounter; - struct timeval m_RisingTimeStamp; - struct timeval m_FallingTimeStamp; - std::string m_name; - - /** - * ISR for the pulse signal - */ - static void signalISR(void *ctx); - - /** - * On each interrupt this function will detect if the interrupt - * was falling edge or rising. - * Should be called from the interrupt handler. - */ - void ackEdgeDetected (); -}; - -} diff --git a/src/groveultrasonic/groveultrasonic.i b/src/groveultrasonic/groveultrasonic.i deleted file mode 100644 index 035c0657f..000000000 --- a/src/groveultrasonic/groveultrasonic.i +++ /dev/null @@ -1,16 +0,0 @@ -%include "../common_top.i" - -/* BEGIN Java syntax ------------------------------------------------------- */ -#ifdef SWIGJAVA -%ignore signalISR; - -JAVA_JNI_LOADLIBRARY(javaupm_groveultrasonic) -#endif -/* END Java syntax */ - -/* BEGIN Common SWIG syntax ------------------------------------------------- */ -%{ -#include "groveultrasonic.hpp" -%} -%include "groveultrasonic.hpp" -/* END Common SWIG syntax */ diff --git a/src/groveultrasonic/groveultrasonic.json b/src/groveultrasonic/groveultrasonic.json deleted file mode 100644 index 6bee48f80..000000000 --- a/src/groveultrasonic/groveultrasonic.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "Library": "groveultrasonic", - "Description": "Grove Ultrasonic Sensor Library", - "Sensor Class": - { - "GroveUltraSonic": - { - "Name": "Ultrasonic Proximity Sensor", - "Description": "This Grove Ultrasonic sensor is a non-contact distance measurement module which is compatible with the Grove system. It is designed for easy modular project usage with industrial performance. Detection ranges from 3 cm (1.2\") to 4 m (13'1.5\") and works best when the object is within a 30 degree angle relative to the sensor.", - "Aliases": ["groveultrasonic"], - "Categories": ["proximity", "deprecated"], - "Connections": ["gpio"], - "Project Type": ["robotics", "prototyping"], - "Manufacturers": ["seeed"], - "Kits": [], - "Image": "groveultrasonic.jpg", - "Examples": - { - "Java": [], - "Python": [], - "Node.js": ["groveultrasonic.js"], - "C++": ["groveultrasonic.cxx"], - "C": [] - }, - "Specifications": - { - "Operating Voltage": {"unit": "V", "low": 3.2, "high": 5.2}, - "Operating Current": {"unit": "mA", "typ": 8}, - "Measurement Range": {"unit": "cm", "low": 2, "high": 350} - - }, - "Urls" : - { - "Product Pages": ["https://www.seeedstudio.com/Grove-Ultrasonic-Ranger-p-960.html"], - "Datasheets": ["http://wiki.seeed.cc/Grove-Ultrasonic_Ranger/"], - "Schematics": [] - } - } - } -} diff --git a/src/grovevdiv/CMakeLists.txt b/src/grovevdiv/CMakeLists.txt deleted file mode 100644 index ddab90ce3..000000000 --- a/src/grovevdiv/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -set (libname "grovevdiv") -set (libdescription "Voltage Divider") -set (module_src ${libname}.cxx) -set (module_hpp ${libname}.hpp) -set (module_iface iVDiv.hpp) -upm_module_init(mraa) diff --git a/src/grovevdiv/grovevdiv.cxx b/src/grovevdiv/grovevdiv.cxx deleted file mode 100644 index 73038ceeb..000000000 --- a/src/grovevdiv/grovevdiv.cxx +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Author: Jon Trulson - * 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 -#include -#include - -#include "grovevdiv.hpp" - -using namespace upm; -using namespace std; - -GroveVDiv::GroveVDiv(int pin) -{ - if ( !(m_aio = mraa_aio_init(pin)) ) - { - throw std::invalid_argument(std::string(__FUNCTION__) + - ": mraa_aio_init() failed, invalid pin?"); - return; - } -} - -GroveVDiv::~GroveVDiv() -{ - mraa_aio_close(m_aio); -} - -unsigned int GroveVDiv::value(unsigned int samples) -{ - int sum = 0; - - for (unsigned int i=0; i - * 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. - */ -#pragma once - -#include -#include -#include -#include -#include - -// reference voltage in millivolts -#define GROVEVDIV_VREF 4980 - -// default ADC resolution -#define GROVEVDIV_ADC_RES 1024 - -namespace upm { - /** - * @deprecated This library is being replaced by libupm-vdiv - * @brief Grove Voltage Divider Sensor - * @defgroup grovevdiv libupm-grovevdiv - * @ingroup seeed analog electric robok - */ - - /** - * @deprecated This class is being replaced by VDiv - * @library grovevdiv - * @sensor grovevdiv - * @comname Voltage Divider - * @type electric - * @man seeed - * @con analog - * @kit robok - * - * @brief API for the Grove Voltage Divider Sensor - * - * UPM module for the Grove Voltage Divider sensor - * - * @image html grovevdiv.jpg - * @snippet grovevdiv.cxx Interesting - */ - class GroveVDiv : virtual public iVDiv { - public: - /** - * Grove Voltage Divider sensor constructor - * - * @param pin Analog pin to use - */ - GroveVDiv(int pin); - - /** - * Grove Voltage Divider destructor - */ - ~GroveVDiv(); - - /** - * Gets the conversion value from the sensor - * - * @param samples Specifies how many samples to average over - * @return Average ADC conversion value - */ - unsigned int value(unsigned int samples); - - /** - * Gets the conversion value from the sensor - * - * @return ADC conversion value - */ - virtual unsigned int getValue(); - - /** - * Computes the measured voltage - * - * @param gain Gain switch, either 3 or 10 for Grove - * @param val Measured voltage (from value()) - * @param vref Reference voltage in millivolts - * @param res ADC resolution - * - * @return Measured voltage - */ - float computedValue(uint8_t gain, unsigned int val, int vref=GROVEVDIV_VREF, - int res=GROVEVDIV_ADC_RES); - - private: - mraa_aio_context m_aio; - }; -} diff --git a/src/grovevdiv/grovevdiv.json b/src/grovevdiv/grovevdiv.json deleted file mode 100644 index da8928a2e..000000000 --- a/src/grovevdiv/grovevdiv.json +++ /dev/null @@ -1,37 +0,0 @@ -{ - "Library": "grovevdiv", - "Description": "API for the Grove Voltage Divider Sensor", - "Sensor Class": - { - "GroveVDiv": - { - "Name": "Grove Voltage Divider Sensor", - "Description": "UPM module for the Grove Voltage Divider sensor.", - "Aliases": ["grovevdiv"], - "Categories": ["electric", "deprecated"], - "Connections": ["gpio"], - "Project Type": ["robotics", "prototyping"], - "Manufacturers": ["seeed"], - "Kits": ["robok"], - "Image": "grovevdiv.jpg", - "Examples": - { - "Java": ["GroveVDiv_Example.java"], - "Python": ["grovevdiv.py"], - "Node.js": ["grovevdiv.js"], - "C++": ["grovevdiv.cxx"], - "C": [] - }, - "Specifications": - { - "Operating Voltage": {"unit": "V", "typ": 5} - }, - "Urls" : - { - "Product Pages": ["https://www.seeedstudio.com/Grove-Voltage-Divider-p-1472.html"], - "Datasheets": ["http://wiki.seeed.cc/Grove-Voltage_Divider/"], - "Schematics": ["https://github.com/SeeedDocument/Grove-Voltage_Divider/raw/master/res/LMV358ID_Datasheet.pdf"] - } - } - } -} diff --git a/src/grovewater/CMakeLists.txt b/src/grovewater/CMakeLists.txt deleted file mode 100644 index 6fdc698a1..000000000 --- a/src/grovewater/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -set (libname "grovewater") -set (libdescription "Water Sensor") -set (module_src ${libname}.cxx) -set (module_hpp ${libname}.hpp) -upm_module_init(mraa) diff --git a/src/grovewater/grovewater.cxx b/src/grovewater/grovewater.cxx deleted file mode 100644 index 9220adcf2..000000000 --- a/src/grovewater/grovewater.cxx +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Author: Jon Trulson - * 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 -#include -#include - -#include "grovewater.hpp" - -using namespace upm; -using namespace std; - -GroveWater::GroveWater(int pin) -{ - if ( !(m_gpio = mraa_gpio_init(pin)) ) - { - throw std::invalid_argument(std::string(__FUNCTION__) + - ": mraa_gpio_init() failed, invalid pin?"); - return; - } - - mraa_gpio_dir(m_gpio, MRAA_GPIO_IN); -} - -GroveWater::~GroveWater() -{ - mraa_gpio_close(m_gpio); -} - -bool GroveWater::isWet() -{ - return (!mraa_gpio_read(m_gpio) ? true : false); -} diff --git a/src/grovewater/grovewater.hpp b/src/grovewater/grovewater.hpp deleted file mode 100644 index 5728ddc4e..000000000 --- a/src/grovewater/grovewater.hpp +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Author: Jon Trulson - * 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. - */ -#pragma once - -#include -#include - -namespace upm { - /** - * @deprecated This library is being replaced by libupm-water - * @brief Grove Water Sensor - * @defgroup grovewater libupm-grovewater - * @ingroup seeed gpio liquid eak - */ - - /** - * @deprecated This class is being replaced by Water - * @library grovewater - * @sensor grovewater - * @comname Water Sensor - * @type liquid - * @man seeed - * @con gpio - * @kit eak - * - * @brief API for the Grove Water Sensor - * - * UPM module for the Grove Water sensor - * - * @image html water.jpg - * @snippet grovewater.cxx Interesting - */ - class GroveWater { - public: - /** - * Grove digital water sensor constructor - * - * @param pin Digital pin to use - */ - GroveWater(int pin); - /** - * GroveWater destructor - */ - ~GroveWater(); - /** - * Gets the water (wet/not wet) value from the sensor - * - * @return True if the sensor is wet, false otherwise - */ - bool isWet(); - - private: - mraa_gpio_context m_gpio; - }; -} diff --git a/src/grovewater/grovewater.json b/src/grovewater/grovewater.json deleted file mode 100644 index d41c72a58..000000000 --- a/src/grovewater/grovewater.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "Library": "grovewater", - "Description": "Grove Water Sensor Library", - "Sensor Class": - { - "GroveWater": - { - "Name": "Grove Water Sensor", - "Description": "UPM module for the Grove Water sensor.", - "Aliases": ["grovewater"], - "Categories": ["liquid", "deprecated"], - "Connections": ["gpio"], - "Project Type": ["agriculture", "environmental", "prototyping"], - "Manufacturers": ["seeed"], - "Kits": ["eak"], - "Examples": - { - "Java": ["GroveWater_Example.java"], - "Python": ["grovewater.py"], - "Node.js": ["grovewater.js"], - "C++": ["grovewater.cxx"], - "C": [] - }, - "Specifications": - { - "Operating Voltage": {"unit": "V", "low": 4.7, "high": 5.25}, - "Operating Current": {"unit": "mA", "max": 20}, - "Working Temperature": {"unit": "degC", "low": 10, "high": 30} - - }, - "Urls" : - { - "Product Pages": ["https://www.seeedstudio.com/Grove-Water-Sensor-p-748.html"], - "Datasheets": ["http://wiki.seeed.cc/Grove-Water_Sensor/"], - "Schematics": [] - } - } - } -} diff --git a/src/grovewfs/CMakeLists.txt b/src/grovewfs/CMakeLists.txt deleted file mode 100644 index 89b1ac1f3..000000000 --- a/src/grovewfs/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -set (libname "grovewfs") -set (libdescription "Water Flow Sensor") -set (module_src ${libname}.cxx) -set (module_hpp ${libname}.hpp) -upm_module_init(mraa) diff --git a/src/grovewfs/grovewfs.cxx b/src/grovewfs/grovewfs.cxx deleted file mode 100644 index 2b6f4baa9..000000000 --- a/src/grovewfs/grovewfs.cxx +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Author: Jon Trulson - * 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 -#include -#include - -#include "grovewfs.hpp" - -using namespace upm; -using namespace std; - -GroveWFS::GroveWFS(int pin) -{ - if ( !(m_gpio = mraa_gpio_init(pin)) ) - { - throw std::invalid_argument(std::string(__FUNCTION__) + - ": mraa_gpio_init() failed, invalid pin?"); - return; - } - - mraa_gpio_dir(m_gpio, MRAA_GPIO_IN); - - initClock(); - m_flowCounter = 0; - m_isrInstalled = false; -} - -GroveWFS::~GroveWFS() -{ - if (m_isrInstalled) - stopFlowCounter(); - - mraa_gpio_close(m_gpio); -} - -void GroveWFS::initClock() -{ - gettimeofday(&m_startTime, NULL); -} - -uint32_t GroveWFS::getMillis() -{ - struct timeval elapsed, now; - uint32_t elapse; - - // get current time - gettimeofday(&now, NULL); - - // compute the delta since m_startTime - if( (elapsed.tv_usec = now.tv_usec - m_startTime.tv_usec) < 0 ) - { - elapsed.tv_usec += 1000000; - elapsed.tv_sec = now.tv_sec - m_startTime.tv_sec - 1; - } - else - { - elapsed.tv_sec = now.tv_sec - m_startTime.tv_sec; - } - - elapse = (uint32_t)((elapsed.tv_sec * 1000) + (elapsed.tv_usec / 1000)); - - // never return 0 - if (elapse == 0) - elapse = 1; - - return elapse; -} - -void GroveWFS::startFlowCounter() -{ - initClock(); - // install our interrupt handler - mraa_gpio_isr(m_gpio, MRAA_GPIO_EDGE_RISING, - &flowISR, this); - - m_isrInstalled = true; -} - -void GroveWFS::stopFlowCounter() -{ - // remove the interrupt handler - mraa_gpio_isr_exit(m_gpio); - - m_isrInstalled = false; -} - -void GroveWFS::flowISR(void *ctx) -{ - upm::GroveWFS *This = (upm::GroveWFS *)ctx; - This->m_flowCounter++; -} - -float GroveWFS::flowRate() -{ - uint32_t millis = getMillis(); - uint32_t flow = flowCounter(); - - // 7.5 comes from the seeedstudio page, see the confusing datasheet :) - float flowRate = (float(flow) * 7.5) / ((float(millis) / 1000.0) * 60.0); - - return flowRate; -} diff --git a/src/grovewfs/grovewfs.hpp b/src/grovewfs/grovewfs.hpp deleted file mode 100644 index f4d230ef6..000000000 --- a/src/grovewfs/grovewfs.hpp +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Author: Jon Trulson - * 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. - */ -#pragma once - -#include -#include -#include -#include - -namespace upm { - - /** - * @deprecated This library is being replaced by libupm-wfs - * @brief Grove Water Flow Sensor - * @defgroup grovewfs libupm-grovewfs - * @ingroup seeed gpio liquid eak - */ - - /** - * @deprecated This class is being replaced by WFS - * @library grovewfs - * @sensor grovewfs - * @comname Water Flow Sensor - * @type liquid - * @man seeed - * @web http://wiki.seeedstudio.com/wiki/G1/2_Water_Flow_sensor - * @con gpio - * @kit eak - * - * @brief API for the Grove Water Flow Sensor - * - * This sensor is used to measure water flow in liters per - * minute (LPM). It incorporates a Hall Effect sensor. The UPM module - * defines an interrupt routine to be triggered on each low pulse, - * keeping count. This device requires a 10K pull-up resistor for - * the signal line (yellow wire). There is a schematic diagram on - * the SeeedStudio site (3/2015): - * http://www.seeedstudio.com/wiki/index.php?title=G1/2_Water_Flow_sensor - * - * However, be careful when wiring this up - the schematic appears to - * have a bug in it: the lower left connection of the signal line - * (yellow) to Vcc (red) should not be there. The sensor can work - * with this connection, but probably not for very long. - * - * @image html grovewfs.jpg - * @snippet grovewfs.cxx Interesting - */ - class GroveWFS { - public: - /** - * Grove Water Flow sensor constructor - * - * @param pin Digital pin to use - */ - GroveWFS(int pin); - /** - * GroveWFS destructor - */ - ~GroveWFS(); - /** - * Returns the number of milliseconds elapsed since initClock() - * was last called. - * - * @return Elapsed milliseconds - */ - uint32_t getMillis(); - - /** - * Resets the clock - * - */ - void initClock(); - - /** - * Resets the flow counter to 0. The flow counter should be - * stopped via stopFlowCounter() prior to calling this function. - * - */ - void clearFlowCounter() { m_flowCounter = 0; }; - - /** - * Starts the flow counter - * - */ - void startFlowCounter(); - - /** - * Stops the flow counter - * - */ - void stopFlowCounter(); - - /** - * Gets the flow counter - * - * @return Flow counter - */ - uint32_t flowCounter() { return m_flowCounter; }; - - /** - * Computes the flow rate in liters per minute (LPM) - * - * @return Computed flow rate - */ - float flowRate(); - - private: - /** - * Flow interrupt service routine (ISR) - * - */ - static void flowISR(void *ctx); - - volatile uint32_t m_flowCounter; - struct timeval m_startTime; - mraa_gpio_context m_gpio; - bool m_isrInstalled; - }; -} - - diff --git a/src/grovewfs/grovewfs.i b/src/grovewfs/grovewfs.i deleted file mode 100644 index 62595e95b..000000000 --- a/src/grovewfs/grovewfs.i +++ /dev/null @@ -1,16 +0,0 @@ -%include "../common_top.i" - -/* BEGIN Java syntax ------------------------------------------------------- */ -#ifdef SWIGJAVA -%ignore flowISR; - -JAVA_JNI_LOADLIBRARY(javaupm_grovewfs) -#endif -/* END Java syntax */ - -/* BEGIN Common SWIG syntax ------------------------------------------------- */ -%{ -#include "grovewfs.hpp" -%} -%include "grovewfs.hpp" -/* END Common SWIG syntax */ diff --git a/src/grovewfs/grovewfs.json b/src/grovewfs/grovewfs.json deleted file mode 100644 index 7d6e72357..000000000 --- a/src/grovewfs/grovewfs.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "Library": "grovewfs", - "Description": "API for the Grove Water Flow Sensor", - "Sensor Class": - { - "GroveWFS": - { - "Name": "Water Flow Sensor", - "Description": "This sensor is used to measure water flow in liters per minute (LPM). It incorporates a Hall Effect sensor. The UPM module defines an interrupt routine to be triggered on each low pulse, keeping count. This device requires a 10K pull-up resistor for the signal line (yellow wire). There is a schematic diagram on the SeeedStudio site (3/2015): http://www.seeedstudio.com/wiki/index.php?title=G1/2_Water_Flow_sensor However, be careful when wiring this up - the schematic appears to have a bug in it: the lower left connection of the signal line (yellow) to Vcc (red) should not be there. The sensor can work with this connection, but probably not for very long.", - "Aliases": ["grovewfs"], - "Categories": ["liquid", "deprecated"], - "Connections": ["gpio"], - "Project Type": ["agriculture", "monitoring", "prototyping"], - "Manufacturers": ["seeed"], - "Kits": ["eak"], - "Image": "grovewfs.jpg", - "Examples": - { - "Java": ["GroveWFS_Example.java"], - "Python": ["grovewfs.py"], - "Node.js": ["grovewfs.js"], - "C++": ["grovewfs.cxx"], - "C": [] - }, - "Specifications": - { - "Operating Voltage": {"unit": "V", "low": 5, "high": 24}, - "Operating Current": {"unit": "mA", "typ": 15}, - "Water Pressure": {"unit": "MPa", "max": 2}, - "Water Temperature": {"unit": "degC", "max": 120} - }, - "Urls" : - { - "Product Pages": ["https://www.seeedstudio.com/G1%26amp%3B2%26quot%3B-Water-Flow-Sensor-p-635.html"], - "Datasheets": ["http://wiki.seeedstudio.com/wiki/G1/2_Water_Flow_sensor", "http://www.seeedstudio.com/wiki/images/b/b7/Water_flow_sensor_datasheet.pdf"], - "Schematics": [] - } - } - } -}