mirror of
https://github.com/eclipse/upm.git
synced 2025-03-14 20:47:30 +03:00
Button: Removed grove dependency
* Renamed all files from groverrotary to rotary * Replaced all instances of groverrotary with rotary * Updated all CMake files Signed-off-by: Sisinty Sasmita Patra <sisinty.s.patra@intel.com>
This commit is contained in:
parent
6a6a572069
commit
3753a1be5c
Before Width: | Height: | Size: 164 KiB After Width: | Height: | Size: 164 KiB |
@ -10,7 +10,7 @@ cjq4435.cxx CJQ4435Sample.java
|
||||
ds1307.cxx DS1307Sample.java
|
||||
enc03r.cxx ENC03RSample.java
|
||||
es08a.cxx ES08ASample.java
|
||||
grovebutton.cxx GroveButtonSample.java
|
||||
button.cxx ButtonSample.java
|
||||
groveehr.cxx GroveEHRSample.java
|
||||
groveled.cxx GroveLEDSample.java
|
||||
grovelinefinder.cxx GroveLineFinderSample.java
|
||||
|
@ -91,7 +91,7 @@ add_example (led)
|
||||
add_example (relay)
|
||||
add_example (light)
|
||||
add_example (temperature)
|
||||
add_example (grovebutton)
|
||||
add_example (button)
|
||||
add_example (rotary)
|
||||
add_example (slide)
|
||||
add_example (buzzer-sound)
|
||||
|
@ -33,7 +33,7 @@ main(int argc, char **argv)
|
||||
//! [Interesting]
|
||||
|
||||
// Create the button object using GPIO pin 0
|
||||
upm::GroveButton* button = new upm::GroveButton(0);
|
||||
upm::Button* button = new upm::Button(0);
|
||||
|
||||
// Read the input and print, waiting one second between readings
|
||||
while( 1 ) {
|
@ -22,12 +22,12 @@
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
public class GroveButtonSample {
|
||||
public class ButtonSample {
|
||||
|
||||
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);
|
||||
upm_button.Button button = new upm_button.Button(2);
|
||||
|
||||
while (true) {
|
||||
System.out.println(button.name() + " value is " + button.value());
|
||||
@ -37,4 +37,4 @@ public class GroveButtonSample {
|
||||
// ! [Interesting]
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -22,13 +22,13 @@
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
public class GroveButton_intrSample {
|
||||
public class Button_intrSample {
|
||||
|
||||
public static int counter = 0;
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
// ! [Interesting]
|
||||
upm_grove.GroveButton b = new upm_grove.GroveButton(2);
|
||||
upm_button.Button b = new upm_button.Button(2);
|
||||
|
||||
ButtonISR callback = new ButtonISR();
|
||||
b.installISR(2, callback);
|
||||
@ -47,7 +47,7 @@ class ButtonISR implements Runnable {
|
||||
}
|
||||
|
||||
public void run() {
|
||||
GroveButton_intrSample.counter++;
|
||||
Button_intrSample.counter++;
|
||||
System.out.println("Button pressed!");
|
||||
}
|
||||
}
|
||||
}
|
@ -30,8 +30,8 @@ add_example(CJQ4435Sample cjq4435)
|
||||
add_example(DS1307Sample ds1307)
|
||||
add_example(ENC03RSample enc03r)
|
||||
add_example(ES08ASample servo)
|
||||
add_example(GroveButtonSample grove)
|
||||
add_example(GroveButton_intrSample grove)
|
||||
add_example(ButtonSample button)
|
||||
add_example(Button_intrSample button)
|
||||
add_example(Collision collision)
|
||||
add_example(EHRSample ehr)
|
||||
add_example(Emg emg)
|
||||
|
@ -26,7 +26,7 @@
|
||||
var groveSensor = require('jsupm_grove');
|
||||
|
||||
// Create the button object using GPIO pin 0
|
||||
var button = new groveSensor.GroveButton(0);
|
||||
var button = new groveSensor.Button(0);
|
||||
|
||||
// Read the input and print, waiting one second between readings
|
||||
function readButtonValue() {
|
@ -24,7 +24,7 @@ import time
|
||||
import pyupm_grove as grove
|
||||
|
||||
# Create the button object using GPIO pin 0
|
||||
button = grove.GroveButton(0)
|
||||
button = grove.Button(0)
|
||||
|
||||
# Read the input and print, waiting one second between readings
|
||||
while 1:
|
5
src/button/CMakeLists.txt
Normal file
5
src/button/CMakeLists.txt
Normal file
@ -0,0 +1,5 @@
|
||||
upm_mixed_module_init (NAME button
|
||||
DESCRIPTION "UPM Button Module: button"
|
||||
CPP_HDR button.hpp
|
||||
CPP_SRC button.cxx
|
||||
REQUIRES mraa)
|
@ -28,11 +28,11 @@
|
||||
#include <string>
|
||||
#include <stdexcept>
|
||||
|
||||
#include "grovebutton.hpp"
|
||||
#include "button.hpp"
|
||||
|
||||
using namespace upm;
|
||||
|
||||
GroveButton::GroveButton(unsigned int pin)
|
||||
Button::Button(unsigned int pin)
|
||||
{
|
||||
if ( !(m_gpio = mraa_gpio_init(pin)) ) {
|
||||
throw std::invalid_argument(std::string(__FUNCTION__) +
|
||||
@ -43,29 +43,29 @@ GroveButton::GroveButton(unsigned int pin)
|
||||
m_name = "Button Sensor";
|
||||
}
|
||||
|
||||
GroveButton::~GroveButton()
|
||||
Button::~Button()
|
||||
{
|
||||
mraa_gpio_close(m_gpio);
|
||||
}
|
||||
|
||||
std::string GroveButton::name()
|
||||
std::string Button::name()
|
||||
{
|
||||
return m_name;
|
||||
}
|
||||
|
||||
int GroveButton::value()
|
||||
int Button::value()
|
||||
{
|
||||
return mraa_gpio_read(m_gpio);
|
||||
}
|
||||
|
||||
#ifdef JAVACALLBACK
|
||||
void GroveButton::installISR(mraa::Edge level, jobject runnable)
|
||||
void Button::installISR(mraa::Edge level, jobject runnable)
|
||||
{
|
||||
installISR(level, mraa_java_isr_callback, runnable);
|
||||
}
|
||||
#endif
|
||||
|
||||
void GroveButton::installISR(mraa::Edge level, void (*isr)(void *), void *arg)
|
||||
void Button::installISR(mraa::Edge level, void (*isr)(void *), void *arg)
|
||||
{
|
||||
if (m_isrInstalled)
|
||||
uninstallISR();
|
||||
@ -75,7 +75,7 @@ void GroveButton::installISR(mraa::Edge level, void (*isr)(void *), void *arg)
|
||||
m_isrInstalled = true;
|
||||
}
|
||||
|
||||
void GroveButton::uninstallISR()
|
||||
void Button::uninstallISR()
|
||||
{
|
||||
mraa_gpio_isr_exit(m_gpio);
|
||||
m_isrInstalled = false;
|
@ -28,39 +28,38 @@
|
||||
|
||||
#include <string>
|
||||
#include <mraa/gpio.hpp>
|
||||
#include "grovebase.hpp"
|
||||
|
||||
namespace upm {
|
||||
|
||||
/**
|
||||
* @library grove
|
||||
* @sensor grovebutton
|
||||
* @comname Grove Button
|
||||
* @library button
|
||||
* @sensor button libupm-button
|
||||
* @comname Button
|
||||
* @altname Grove Touch Sensor
|
||||
* @type button touch
|
||||
* @man seeed
|
||||
* @con gpio
|
||||
* @kit gsk
|
||||
*
|
||||
* @brief API for the Grove Button
|
||||
* @brief API for the Button
|
||||
*
|
||||
* Basic UPM module for the Grove button
|
||||
* Basic UPM module for the button sensor
|
||||
*
|
||||
* @image html grovebutton.jpg
|
||||
* @snippet grovebutton.cxx Interesting
|
||||
* @image html button.jpg
|
||||
* @snippet button.cxx Interesting
|
||||
*/
|
||||
class GroveButton: public Grove {
|
||||
class Button{
|
||||
public:
|
||||
/**
|
||||
* Grove button constructor
|
||||
*
|
||||
* @param gpio Pin to use
|
||||
*/
|
||||
GroveButton(unsigned int pin);
|
||||
Button(unsigned int pin);
|
||||
/**
|
||||
* Grove button destructor
|
||||
*/
|
||||
~GroveButton();
|
||||
~Button();
|
||||
/**
|
||||
* Gets the name of the sensor
|
||||
*
|
19
src/button/javaupm_button.i
Normal file
19
src/button/javaupm_button.i
Normal file
@ -0,0 +1,19 @@
|
||||
%module javaupm_button
|
||||
%include "../upm.i"
|
||||
|
||||
%{
|
||||
#include "button.hpp"
|
||||
%}
|
||||
|
||||
%include "button.hpp"
|
||||
|
||||
%pragma(java) jniclasscode=%{
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("javaupm_button");
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
System.err.println("Native code library failed to load. \n" + e);
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
%}
|
8
src/button/jsupm_button.i
Normal file
8
src/button/jsupm_button.i
Normal file
@ -0,0 +1,8 @@
|
||||
%module jsupm_button
|
||||
%include "../upm.i"
|
||||
|
||||
%{
|
||||
#include "button.hpp"
|
||||
%}
|
||||
|
||||
%include "button.hpp"
|
11
src/button/pyupm_button.i
Normal file
11
src/button/pyupm_button.i
Normal file
@ -0,0 +1,11 @@
|
||||
// Include doxygen-generated documentation
|
||||
%include "pyupm_doxy2swig.i"
|
||||
%module pyupm_button
|
||||
%include "../upm.i"
|
||||
|
||||
%feature("autodoc", "3");
|
||||
|
||||
%include "button.hpp"
|
||||
%{
|
||||
#include "button.hpp"
|
||||
%}
|
@ -1,7 +1,7 @@
|
||||
upm_mixed_module_init (NAME grove
|
||||
DESCRIPTION "upm grove module"
|
||||
CPP_HDR grovebutton.hpp groveled.hpp
|
||||
CPP_HDR groveled.hpp
|
||||
grovetemp.hpp grovebase.hpp grove.hpp
|
||||
CPP_SRC grovebutton.cxx groveled.cxx
|
||||
CPP_SRC groveled.cxx
|
||||
grovetemp.cxx
|
||||
REQUIRES mraa)
|
||||
|
@ -25,6 +25,6 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <grovebutton.hpp>
|
||||
#include <button.hpp>
|
||||
#include <groveled.hpp>
|
||||
#include <grovetemp.hpp>
|
||||
|
@ -14,9 +14,9 @@
|
||||
#include "grovebase.hpp"
|
||||
%}
|
||||
|
||||
%include "grovebutton.hpp"
|
||||
%include "button.hpp"
|
||||
%{
|
||||
#include "grovebutton.hpp"
|
||||
#include "button.hpp"
|
||||
%}
|
||||
|
||||
%include "groveled.hpp"
|
||||
|
@ -11,9 +11,9 @@
|
||||
#include "grovebase.hpp"
|
||||
%}
|
||||
|
||||
%include "grovebutton.hpp"
|
||||
%include "button.hpp"
|
||||
%{
|
||||
#include "grovebutton.hpp"
|
||||
#include "button.hpp"
|
||||
%}
|
||||
|
||||
%include "groveled.hpp"
|
||||
|
@ -15,9 +15,9 @@
|
||||
#include "grovebase.hpp"
|
||||
%}
|
||||
|
||||
%include "grovebutton.hpp"
|
||||
%include "button.hpp"
|
||||
%{
|
||||
#include "grovebutton.hpp"
|
||||
#include "button.hpp"
|
||||
%}
|
||||
|
||||
%include "groveled.hpp"
|
||||
|
Loading…
x
Reference in New Issue
Block a user