mirror of
https://github.com/eclipse/upm.git
synced 2025-03-24 01:10:22 +03:00
Collision: Added C Src and Example
This module was initially known as GroveCollision. It has been now changed to Collision. C source and examples added. Signed-off-by: Abhishek Malik <abhishek.malik@intel.com>
This commit is contained in:
parent
2a63e97533
commit
0f7bb5573c
@ -167,7 +167,7 @@ add_example (adxl335)
|
|||||||
add_example (hmtrp)
|
add_example (hmtrp)
|
||||||
add_example (nunchuck)
|
add_example (nunchuck)
|
||||||
add_example (otp538u)
|
add_example (otp538u)
|
||||||
add_example (grovecollision)
|
add_example (collision)
|
||||||
add_example (groveelectromagnet)
|
add_example (groveelectromagnet)
|
||||||
add_example (emg)
|
add_example (emg)
|
||||||
add_example (o2)
|
add_example (o2)
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include "grovecollision.hpp"
|
#include "collision.hpp"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
@ -41,9 +41,9 @@ int main(int argc, char **argv)
|
|||||||
signal(SIGINT, sig_handler);
|
signal(SIGINT, sig_handler);
|
||||||
|
|
||||||
//! [Interesting]
|
//! [Interesting]
|
||||||
// The was tested with the Grove Collision Sensor
|
// The was tested with the Collision Sensor
|
||||||
// Instantiate a Grove Collision on digital pin D2
|
// Instantiate a Collision on digital pin D2
|
||||||
upm::GroveCollision* collision = new upm::GroveCollision(2);
|
upm::Collision* collision = new upm::Collision(2);
|
||||||
|
|
||||||
bool collisionState = false;
|
bool collisionState = false;
|
||||||
cout << "No collision" << endl;
|
cout << "No collision" << endl;
|
@ -113,6 +113,7 @@ add_example (gp2y0a)
|
|||||||
add_example (ttp223)
|
add_example (ttp223)
|
||||||
add_example (loudness)
|
add_example (loudness)
|
||||||
add_example (tsl2561)
|
add_example (tsl2561)
|
||||||
|
add_example (collision)
|
||||||
|
|
||||||
# Custom examples
|
# Custom examples
|
||||||
add_custom_example (nmea_gps_i2c-example-c nmea_gps_i2c.c nmea_gps)
|
add_custom_example (nmea_gps_i2c-example-c nmea_gps_i2c.c nmea_gps)
|
||||||
|
22
examples/c/collision.c
Normal file
22
examples/c/collision.c
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
//Modified: Abhishek Malik <abhishek.malik@intel.com>
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include "collision.h"
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
collision_context dev = collision_init(2);
|
||||||
|
bool abc = 0;
|
||||||
|
while(1){
|
||||||
|
if(collision_is_colliding(dev, &abc) != UPM_SUCCESS){
|
||||||
|
printf("an error has occured\n");
|
||||||
|
}
|
||||||
|
upm_delay(1);
|
||||||
|
printf("value retrieved: %d\n", abc);
|
||||||
|
}
|
||||||
|
collision_close(dev);
|
||||||
|
}
|
56
examples/c/main_mvs0608.c
Normal file
56
examples/c/main_mvs0608.c
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2012-2014 Wind River Systems, Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <zephyr.h>
|
||||||
|
#include <mvs0608.h>
|
||||||
|
#include <malloc.h>
|
||||||
|
#include <gpio.h>
|
||||||
|
#include <sys_clock.h>
|
||||||
|
|
||||||
|
#define SLEEPTICKS MSEC(200)
|
||||||
|
#if defined(CONFIG_STDOUT_CONSOLE)
|
||||||
|
#include <stdio.h>
|
||||||
|
#define PRINT printf
|
||||||
|
#else
|
||||||
|
#include <misc/printk.h>
|
||||||
|
#define PRINT printk
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @file
|
||||||
|
* @brief Hello World demo
|
||||||
|
* Nanokernel version of hello world demo
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
void main(void)
|
||||||
|
{
|
||||||
|
mraa_init();
|
||||||
|
struct nano_timer timer;
|
||||||
|
void *timer_data[1];
|
||||||
|
nano_timer_init(&timer, timer_data);
|
||||||
|
mvs0608_context dev = mvs0608_init(2);
|
||||||
|
bool abc = 0;
|
||||||
|
while(1){
|
||||||
|
if(mvs0608_is_colliding(dev, &abc) != UPM_SUCCESS){
|
||||||
|
printf("an error has occured\n");
|
||||||
|
}
|
||||||
|
nano_timer_start(&timer, SLEEPTICKS);
|
||||||
|
nano_timer_test(&timer, TICKS_UNLIMITED);
|
||||||
|
printf("value retrieved: %d\n", abc);
|
||||||
|
}
|
||||||
|
mvs0608_close(dev);
|
||||||
|
}
|
@ -32,7 +32,7 @@ add_example(ENC03RSample enc03r)
|
|||||||
add_example(ES08ASample servo)
|
add_example(ES08ASample servo)
|
||||||
add_example(GroveButtonSample grove)
|
add_example(GroveButtonSample grove)
|
||||||
add_example(GroveButton_intrSample grove)
|
add_example(GroveButton_intrSample grove)
|
||||||
add_example(GroveCollision grovecollision)
|
add_example(Collision collision)
|
||||||
add_example(GroveEHRSample groveehr)
|
add_example(GroveEHRSample groveehr)
|
||||||
add_example(Emg emg)
|
add_example(Emg emg)
|
||||||
add_example(Gsr gsr)
|
add_example(Gsr gsr)
|
||||||
|
@ -22,13 +22,13 @@
|
|||||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import upm_grovecollision.*;
|
import upm_collision.*;
|
||||||
|
|
||||||
public class GroveCollision {
|
public class Collision {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
// Initializing the sensor on D2 on the Base Shield
|
// Initializing the sensor on D2 on the Base Shield
|
||||||
upm_grovecollision.GroveCollision collision = new upm_grovecollision.GroveCollision(2);
|
upm_collision.Collision collision = new upm_collision.Collision(2);
|
||||||
boolean collisionState = false;
|
boolean collisionState = false;
|
||||||
|
|
||||||
// ! [Interesting]
|
// ! [Interesting]
|
@ -22,11 +22,11 @@
|
|||||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var collision_lib = require("jsupm_grovecollision");
|
var collision_lib = require("jsupm_collision");
|
||||||
|
|
||||||
// The was tested with the Grove Collision Sensor
|
// The was tested with the Collision Sensor
|
||||||
// Instantiate a Grove Collision on digital pin D2
|
// Instantiate a Collision on digital pin D2
|
||||||
var collision_obj = new collision_lib.GroveCollision(2);
|
var collision_obj = new collision_lib.Collision(2);
|
||||||
|
|
||||||
var collisionState = false;
|
var collisionState = false;
|
||||||
console.log("No collision");
|
console.log("No collision");
|
@ -22,11 +22,11 @@
|
|||||||
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
import time, sys, signal, atexit
|
import time, sys, signal, atexit
|
||||||
import pyupm_grovecollision as upmGrovecollision
|
import pyupm_collision as upmcollision
|
||||||
|
|
||||||
# The was tested with the Grove Collision Sensor
|
# The was tested with the Collision Sensor
|
||||||
# Instantiate a Grove Collision on digital pin D2
|
# Instantiate a Collision on digital pin D2
|
||||||
myGrovecollision = upmGrovecollision.GroveCollision(2)
|
mycollision = upmcollision.Collision(2)
|
||||||
|
|
||||||
|
|
||||||
## Exit handlers ##
|
## Exit handlers ##
|
||||||
@ -49,9 +49,9 @@ collisionState = False
|
|||||||
print "No collision"
|
print "No collision"
|
||||||
|
|
||||||
while(1):
|
while(1):
|
||||||
if (myGrovecollision.isColliding() and not collisionState):
|
if (mycollision.isColliding() and not collisionState):
|
||||||
print "Collision!"
|
print "Collision!"
|
||||||
collisionState = True
|
collisionState = True
|
||||||
elif (not myGrovecollision.isColliding() and collisionState):
|
elif (not mycollision.isColliding() and collisionState):
|
||||||
print "No collision"
|
print "No collision"
|
||||||
collisionState = False
|
collisionState = False
|
9
src/collision/CMakeLists.txt
Normal file
9
src/collision/CMakeLists.txt
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
upm_mixed_module_init (NAME collision
|
||||||
|
DESCRIPTION "upm collisionsensor module"
|
||||||
|
C_HDR collision.h
|
||||||
|
C_SRC collision.c
|
||||||
|
CPP_HDR collision.hpp
|
||||||
|
CPP_SRC collision.cxx
|
||||||
|
FTI_SRC collision_fti.c
|
||||||
|
CPP_WRAPS_C
|
||||||
|
REQUIRES mraa)
|
@ -23,11 +23,11 @@
|
|||||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
#include "grovecollision.h"
|
#include "collision.h"
|
||||||
|
|
||||||
mvs0608_context mvs0608_init(int pin){
|
collision_context collision_init(int pin){
|
||||||
mvs0608_context dev =
|
collision_context dev =
|
||||||
(mvs0608_context)malloc(sizeof(struct _mvs0608_context));
|
(collision_context)malloc(sizeof(struct _collision_context));
|
||||||
|
|
||||||
if (!dev)
|
if (!dev)
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -44,11 +44,11 @@ mvs0608_context mvs0608_init(int pin){
|
|||||||
return dev;
|
return dev;
|
||||||
}
|
}
|
||||||
|
|
||||||
void mvs0608_close(mvs0608_context dev){
|
void collision_close(collision_context dev){
|
||||||
free(dev);
|
free(dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
upm_result_t mvs0608_is_colliding(mvs0608_context dev, bool* collision_val){
|
upm_result_t collision_is_colliding(collision_context dev, bool* collision_val){
|
||||||
int value = mraa_gpio_read(dev->gpio);
|
int value = mraa_gpio_read(dev->gpio);
|
||||||
|
|
||||||
if(!value)
|
if(!value)
|
@ -25,11 +25,11 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
#include "grovecollision.hpp"
|
#include "collision.hpp"
|
||||||
|
|
||||||
using namespace upm;
|
using namespace upm;
|
||||||
|
|
||||||
GroveCollision::GroveCollision(int pin)
|
Collision::Collision(int pin)
|
||||||
{
|
{
|
||||||
|
|
||||||
if ( !(m_gpio = mraa_gpio_init(pin)) )
|
if ( !(m_gpio = mraa_gpio_init(pin)) )
|
||||||
@ -41,12 +41,12 @@ GroveCollision::GroveCollision(int pin)
|
|||||||
mraa_gpio_dir(m_gpio, MRAA_GPIO_IN);
|
mraa_gpio_dir(m_gpio, MRAA_GPIO_IN);
|
||||||
}
|
}
|
||||||
|
|
||||||
GroveCollision::~GroveCollision()
|
Collision::~Collision()
|
||||||
{
|
{
|
||||||
mraa_gpio_close(m_gpio);
|
mraa_gpio_close(m_gpio);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GroveCollision::isColliding()
|
bool Collision::isColliding()
|
||||||
{
|
{
|
||||||
// Collisions cause 0; no collision is 1
|
// Collisions cause 0; no collision is 1
|
||||||
return (!(bool)mraa_gpio_read(m_gpio));
|
return (!(bool)mraa_gpio_read(m_gpio));
|
@ -22,8 +22,8 @@
|
|||||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
#ifndef MVS0608_H_
|
#ifndef COLLISION_H_
|
||||||
#define MVS0608_H_
|
#define COLLISION_H_
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
@ -33,49 +33,50 @@
|
|||||||
#include "mraa/gpio.h"
|
#include "mraa/gpio.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief MVS0608 - Grove Collision Sensor library
|
* @brief MVS0608 - GPIO Collision Sensor library
|
||||||
* @ingroup gpio accelerometer
|
* @ingroup gpio accelerometer
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @library mvs0608
|
* @library collision
|
||||||
* @sensor mvs0608
|
* @sensor Collision
|
||||||
* @comname Grove Collision Sensor
|
* @comname Collision Sensor
|
||||||
|
* @altname Grove Collision Sensor
|
||||||
* @type accelerometer
|
* @type accelerometer
|
||||||
* @con gpio
|
* @con gpio
|
||||||
*
|
*
|
||||||
* @brief API for the mvs0608
|
* @brief API for the Collision Sensor
|
||||||
*
|
*
|
||||||
* MVS0608 can detect whether any
|
* MVS0608 can detect whether any
|
||||||
* collision movement or vibration happens.
|
* collision movement or vibration happens.
|
||||||
* It outputs a low pulse signal when vibration is detected.
|
* It outputs a low pulse signal when vibration is detected.
|
||||||
*
|
*
|
||||||
* @image html grovecollision.jpg
|
* @image html grovecollision.jpg
|
||||||
* @snippet grovecollision.cxx Interesting
|
* @snippet collision.c Interesting
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* device context
|
* device context
|
||||||
*/
|
*/
|
||||||
typedef struct _mvs0608_context {
|
typedef struct _collision_context {
|
||||||
mraa_gpio_context gpio;
|
mraa_gpio_context gpio;
|
||||||
uint8_t gpio_pin;
|
uint8_t gpio_pin;
|
||||||
} *mvs0608_context;
|
} *collision_context;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MVS0608 Initialization function
|
* Collision Initialization function
|
||||||
*
|
*
|
||||||
* @param pin number
|
* @param pin number
|
||||||
* @return void* pointer to the sensor struct
|
* @return void* pointer to the sensor struct
|
||||||
*/
|
*/
|
||||||
mvs0608_context mvs0608_init(int pin);
|
collision_context collision_init(int pin);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MVS0608 Initialization function
|
* Collision Initialization function
|
||||||
*
|
*
|
||||||
* @param void* pointer to the sensor struct
|
* @param void* pointer to the sensor struct
|
||||||
*/
|
*/
|
||||||
void mvs0608_close(mvs0608_context dev);
|
void collision_close(collision_context dev);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function tells you whether the sensor has
|
* This function tells you whether the sensor has
|
||||||
@ -85,6 +86,6 @@ void mvs0608_close(mvs0608_context dev);
|
|||||||
* @param bool* pointer to hold the collision value
|
* @param bool* pointer to hold the collision value
|
||||||
* @return upm_result_t UPM success/error code
|
* @return upm_result_t UPM success/error code
|
||||||
*/
|
*/
|
||||||
upm_result_t mvs0608_is_colliding(mvs0608_context dev, bool* collision_val);
|
upm_result_t collision_is_colliding(collision_context dev, bool* collision_val);
|
||||||
|
|
||||||
#endif /* MVS0608_H_ */
|
#endif /* COLLISION_H_ */
|
@ -27,40 +27,41 @@
|
|||||||
|
|
||||||
namespace upm {
|
namespace upm {
|
||||||
/**
|
/**
|
||||||
* @brief Grove Collision Sensor library
|
* @brief Collision Sensor library
|
||||||
* @defgroup grovecollision libupm-grovecollision
|
* @defgroup collision libupm-collision
|
||||||
* @ingroup seeed gpio accelerometer
|
* @ingroup seeed gpio accelerometer
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @library grovecollision
|
* @library collision
|
||||||
* @sensor grovecollision
|
* @sensor collision
|
||||||
* @comname Grove Collision Sensor
|
* @comname Collision Sensor
|
||||||
|
* @altname Grove Collision Sensor
|
||||||
* @type accelerometer
|
* @type accelerometer
|
||||||
* @man seeed
|
* @man seeed
|
||||||
* @con gpio
|
* @con gpio
|
||||||
*
|
*
|
||||||
* @brief API for the Grove Collision Sensor
|
* @brief API for the Collision Sensor
|
||||||
*
|
*
|
||||||
* The Grove Collision Sensor can detect whether any
|
* The Collision Sensor can detect whether any
|
||||||
* collision movement or vibration happens.
|
* collision movement or vibration happens.
|
||||||
* It outputs a low pulse signal when vibration is detected.
|
* It outputs a low pulse signal when vibration is detected.
|
||||||
*
|
*
|
||||||
* @image html grovecollision.jpg
|
* @image html grovecollision.jpg
|
||||||
* @snippet grovecollision.cxx Interesting
|
* @snippet collision.cxx Interesting
|
||||||
*/
|
*/
|
||||||
class GroveCollision {
|
class Collision {
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* Grove collision sensor constructor
|
* Collision sensor constructor
|
||||||
*
|
*
|
||||||
* @param pin Digital pin to use
|
* @param pin Digital pin to use
|
||||||
*/
|
*/
|
||||||
GroveCollision(int pin);
|
Collision(int pin);
|
||||||
/**
|
/**
|
||||||
* GroveCollision destructor
|
* Collision destructor
|
||||||
*/
|
*/
|
||||||
~GroveCollision();
|
~Collision();
|
||||||
/**
|
/**
|
||||||
* @return bool Defines whether something is colliding with sensor
|
* @return bool Defines whether something is colliding with sensor
|
||||||
*/
|
*/
|
@ -22,57 +22,57 @@
|
|||||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
#include "grovecollision.h"
|
#include "collision.h"
|
||||||
#include "upm_fti.h"
|
#include "upm_fti.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file implements the Function Table Interface (FTI) for this sensor
|
* This file implements the Function Table Interface (FTI) for this sensor
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const char upm_mvs0608_name[] = "MVS0608";
|
const char upm_collision_name[] = "Collision";
|
||||||
const char upm_mvs0608_description[] = "MVS0608 Grove Collision sensor";
|
const char upm_collision_description[] = "Collision sensor";
|
||||||
const upm_protocol_t upm_mvs0608_protocol[] = {UPM_GPIO};
|
const upm_protocol_t upm_collision_protocol[] = {UPM_GPIO};
|
||||||
const upm_sensor_t upm_mvs0608_category[] = {UPM_ELECTRICITY};
|
const upm_sensor_t upm_collision_category[] = {UPM_ELECTRICITY};
|
||||||
|
|
||||||
// forward declarations
|
// forward declarations
|
||||||
const upm_sensor_descriptor_t upm_mvs0608_get_descriptor();
|
const upm_sensor_descriptor_t upm_collision_get_descriptor();
|
||||||
const void* upm_mvs0608_get_ft(upm_sensor_t sensor_type);
|
const void* upm_collision_get_ft(upm_sensor_t sensor_type);
|
||||||
void* upm_mvs0608_init_name();
|
void* upm_collision_init_name();
|
||||||
void upm_mvs0608_close(void* dev);
|
void upm_collision_close(void* dev);
|
||||||
|
|
||||||
const upm_sensor_descriptor_t upm_mvs0608_get_descriptor(){
|
const upm_sensor_descriptor_t upm_collision_get_descriptor(){
|
||||||
upm_sensor_descriptor_t usd;
|
upm_sensor_descriptor_t usd;
|
||||||
usd.name = upm_mvs0608_name;
|
usd.name = upm_collision_name;
|
||||||
usd.description = upm_mvs0608_description;
|
usd.description = upm_collision_description;
|
||||||
usd.protocol_size = 1;
|
usd.protocol_size = 1;
|
||||||
usd.protocol = upm_mvs0608_protocol;
|
usd.protocol = upm_collision_protocol;
|
||||||
usd.category_size = 1;
|
usd.category_size = 1;
|
||||||
usd.category = upm_mvs0608_category;
|
usd.category = upm_collision_category;
|
||||||
return usd;
|
return usd;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const upm_sensor_ft ft =
|
static const upm_sensor_ft ft =
|
||||||
{
|
{
|
||||||
.upm_sensor_init_name = &upm_mvs0608_init_name,
|
.upm_sensor_init_name = &upm_collision_init_name,
|
||||||
.upm_sensor_close = &upm_mvs0608_close,
|
.upm_sensor_close = &upm_collision_close,
|
||||||
.upm_sensor_get_descriptor = &upm_mvs0608_get_descriptor
|
.upm_sensor_get_descriptor = &upm_collision_get_descriptor
|
||||||
};
|
};
|
||||||
|
|
||||||
const void* upm_mvs0608_get_ft(upm_sensor_t sensor_type){
|
const void* upm_collision_get_ft(upm_sensor_t sensor_type){
|
||||||
if(sensor_type == UPM_SENSOR){
|
if(sensor_type == UPM_SENSOR){
|
||||||
return &ft;
|
return &ft;
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void* upm_mvs0608_init_name(){
|
void* upm_collision_init_name(){
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void upm_mvs0608_close(void* dev){
|
void upm_collision_close(void* dev){
|
||||||
mvs0608_close((mvs0608_context)dev);
|
collision_close((collision_context)dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
upm_result_t upm_mvs0608_is_colliding(void* dev, bool* collision_val){
|
upm_result_t upm_collision_is_colliding(void* dev, bool* collision_val){
|
||||||
return mvs0608_is_colliding((mvs0608_context)dev, collision_val);
|
return collision_is_colliding((collision_context)dev, collision_val);
|
||||||
}
|
}
|
@ -1,16 +1,16 @@
|
|||||||
%module javaupm_grovecollision
|
%module javaupm_collision
|
||||||
%include "../upm.i"
|
%include "../upm.i"
|
||||||
|
|
||||||
%{
|
%{
|
||||||
#include "grovecollision.hpp"
|
#include "collision.hpp"
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%include "grovecollision.hpp"
|
%include "collision.hpp"
|
||||||
|
|
||||||
%pragma(java) jniclasscode=%{
|
%pragma(java) jniclasscode=%{
|
||||||
static {
|
static {
|
||||||
try {
|
try {
|
||||||
System.loadLibrary("javaupm_grovecollision");
|
System.loadLibrary("javaupm_collision");
|
||||||
} catch (UnsatisfiedLinkError e) {
|
} catch (UnsatisfiedLinkError e) {
|
||||||
System.err.println("Native code library failed to load. \n" + e);
|
System.err.println("Native code library failed to load. \n" + e);
|
||||||
System.exit(1);
|
System.exit(1);
|
8
src/collision/jsupm_collision.i
Normal file
8
src/collision/jsupm_collision.i
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
%module jsupm_collision
|
||||||
|
%include "../upm.i"
|
||||||
|
|
||||||
|
%{
|
||||||
|
#include "collision.hpp"
|
||||||
|
%}
|
||||||
|
|
||||||
|
%include "collision.hpp"
|
@ -1,11 +1,11 @@
|
|||||||
// Include doxygen-generated documentation
|
// Include doxygen-generated documentation
|
||||||
%include "pyupm_doxy2swig.i"
|
%include "pyupm_doxy2swig.i"
|
||||||
%module pyupm_grovecollision
|
%module pyupm_collision
|
||||||
%include "../upm.i"
|
%include "../upm.i"
|
||||||
|
|
||||||
%feature("autodoc", "3");
|
%feature("autodoc", "3");
|
||||||
|
|
||||||
%include "grovecollision.hpp"
|
%include "collision.hpp"
|
||||||
%{
|
%{
|
||||||
#include "grovecollision.hpp"
|
#include "collision.hpp"
|
||||||
%}
|
%}
|
@ -1,9 +0,0 @@
|
|||||||
upm_mixed_module_init (NAME grovecollision
|
|
||||||
DESCRIPTION "upm grovecollisionsensor module"
|
|
||||||
C_HDR grovecollision.h
|
|
||||||
C_SRC grovecollision.c
|
|
||||||
CPP_HDR grovecollision.hpp
|
|
||||||
CPP_SRC grovecollision.cxx
|
|
||||||
FTI_SRC grovecollision_fti.c
|
|
||||||
CPP_WRAPS_C
|
|
||||||
REQUIRES mraa)
|
|
@ -1,8 +0,0 @@
|
|||||||
%module jsupm_grovecollision
|
|
||||||
%include "../upm.i"
|
|
||||||
|
|
||||||
%{
|
|
||||||
#include "grovecollision.hpp"
|
|
||||||
%}
|
|
||||||
|
|
||||||
%include "grovecollision.hpp"
|
|
Loading…
x
Reference in New Issue
Block a user