Moved SWIG code from C++ files (hpp and cxx) to SWIG interface files (.i). Added getter/setter methods for classes with protected or private vars.

This commit is contained in:
Serban Waltter
2018-01-17 14:20:32 +02:00
committed by Noel Eck
parent 2551596309
commit 63b2b33df7
39 changed files with 351 additions and 367 deletions

View File

@ -11,4 +11,13 @@
%include "ttp223.hpp"
#%ignore installISR(mraa::Edge , void *, void *)
%extend upm::TTP223 {
void installISR(mraa::Edge level, jobject runnable)
{
$self->installISR(level, mraa_java_isr_callback, runnable);
}
}
JAVA_JNI_LOADLIBRARY(javaupm_ttp223)

View File

@ -31,7 +31,7 @@ using namespace upm;
TTP223::TTP223(unsigned int pin) {
// initialize gpio input
if ( !(m_gpio = mraa_gpio_init(pin)) )
if ( !(m_gpio = mraa_gpio_init(pin)) )
{
throw std::invalid_argument(std::string(__FUNCTION__) +
": mraa_gpio_init() failed, invalid pin?");
@ -59,12 +59,6 @@ bool TTP223::isPressed() {
return this->value() == 1;
}
#ifdef JAVACALLBACK
void TTP223::installISR(mraa::Edge level, jobject runnable)
{
installISR(level, mraa_java_isr_callback, runnable);
}
#endif
void TTP223::installISR(mraa::Edge level, void (*isr)(void *), void *arg)
{

View File

@ -43,10 +43,10 @@ namespace upm {
* @con gpio
*
* @brief API for the TTP223 Touch Sensor
*
*
* This touch sensor detects when a finger is near the metallic pad
* by the change in capacitance. It can replace a more traditional push
* button. The touch sensor can still function when placed under a
* button. The touch sensor can still function when placed under a
* non-metallic surface like glass or plastic.
*
* @image html ttp223.jpg
@ -95,11 +95,8 @@ class TTP223 {
* @param arg Pointer to an object to be supplied as an
* argument to the ISR.
*/
#if defined(SWIGJAVA) || defined(JAVACALLBACK)
void installISR(mraa::Edge level, jobject runnable);
#else
void installISR(mraa::Edge level, void (*isr)(void *), void *arg);
#endif
/**
* Uninstalls the previously installed ISR
*
@ -107,9 +104,6 @@ class TTP223 {
void uninstallISR();
protected:
#if defined(SWIGJAVA) || defined(JAVACALLBACK)
void installISR(mraa::Edge level, void (*isr)(void *), void *arg);
#endif
std::string m_name; //!< name of this sensor
mraa_gpio_context m_gpio; //!< GPIO pin
bool m_isrInstalled;