summaryrefslogtreecommitdiff
path: root/peripheral/libupm/src/servo
diff options
context:
space:
mode:
Diffstat (limited to 'peripheral/libupm/src/servo')
-rw-r--r--peripheral/libupm/src/servo/CMakeLists.txt5
-rw-r--r--peripheral/libupm/src/servo/es08a.cxx41
-rw-r--r--peripheral/libupm/src/servo/es08a.h68
-rw-r--r--peripheral/libupm/src/servo/es9257.cxx41
-rw-r--r--peripheral/libupm/src/servo/es9257.h65
-rw-r--r--peripheral/libupm/src/servo/javaupm_servo.i28
-rw-r--r--peripheral/libupm/src/servo/jsupm_servo.i17
-rw-r--r--peripheral/libupm/src/servo/pyupm_servo.i19
-rw-r--r--peripheral/libupm/src/servo/servo.cxx164
-rw-r--r--peripheral/libupm/src/servo/servo.h168
10 files changed, 0 insertions, 616 deletions
diff --git a/peripheral/libupm/src/servo/CMakeLists.txt b/peripheral/libupm/src/servo/CMakeLists.txt
deleted file mode 100644
index 923c09c..0000000
--- a/peripheral/libupm/src/servo/CMakeLists.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-set (libname "servo")
-set (libdescription "upm servo")
-set (module_src servo.cxx es08a.cxx es9257.cxx)
-set (module_h servo.h es08a.h es9257.h)
-upm_module_init()
diff --git a/peripheral/libupm/src/servo/es08a.cxx b/peripheral/libupm/src/servo/es08a.cxx
deleted file mode 100644
index b7d72d3..0000000
--- a/peripheral/libupm/src/servo/es08a.cxx
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Author: Yevgeniy Kiveisha <yevgeniy.kiveisha@intel.com>
- * Copyright (c) 2014 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-#include <iostream>
-#include <unistd.h>
-
-#include "es08a.h"
-
-using namespace upm;
-
-ES08A::ES08A (int pin) : Servo(pin) {
- m_name = "ES08A";
- m_maxAngle = 180.0;
- m_minPulseWidth = 600;
- m_maxPulseWidth = 2200;
-}
-
-ES08A::~ES08A() {
-
-}
diff --git a/peripheral/libupm/src/servo/es08a.h b/peripheral/libupm/src/servo/es08a.h
deleted file mode 100644
index 2c28096..0000000
--- a/peripheral/libupm/src/servo/es08a.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Author: Yevgeniy Kiveisha <yevgeniy.kiveisha@intel.com>
- * Copyright (c) 2014 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-#pragma once
-
-#include <string>
-#include "servo.h"
-
-namespace upm {
-
-/**
- * @library servo
- * @sensor es08a
- * @comname ES08A Servo
- * @altname Grove Servo
- * @type servos
- * @man emax
- * @web http://www.seeedstudio.com/wiki/Grove_-_Servo
- * @con pwm
- * @kit gsk
- *
- * @brief API for the ES08A Servo
- *
- * This module defines the ES08A interface for ES08A servos.
- * Like other servos, the ES08A servo has a shaft that can be controlled
- * by setting the desired angle. There are also routines for setting
- * and getting the minimum and maximum pulse width as well as the
- * maximum period.
- *
- * @image html es08a.jpg
- * @snippet es08a.cxx Interesting
- */
- class ES08A : public Servo {
- public:
- /**
- * Instantiates an ES08A object
- *
- * @param pin Servo pin number
- */
- ES08A (int pin);
-
- /**
- * ES08A object destructor
- */
- ~ES08A ();
-};
-
-}
diff --git a/peripheral/libupm/src/servo/es9257.cxx b/peripheral/libupm/src/servo/es9257.cxx
deleted file mode 100644
index b7edf0f..0000000
--- a/peripheral/libupm/src/servo/es9257.cxx
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Author: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
- * Copyright (c) 2015 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-#include <iostream>
-#include <unistd.h>
-
-#include "es9257.h"
-
-using namespace upm;
-
-ES9257::ES9257 (int pin) : Servo(pin) {
- m_name = "ES9257";
- m_maxAngle = 180.0;
- m_minPulseWidth = 475;
- m_maxPulseWidth = 2100;
-}
-
-ES9257::~ES9257() {
-
-}
diff --git a/peripheral/libupm/src/servo/es9257.h b/peripheral/libupm/src/servo/es9257.h
deleted file mode 100644
index 51b41ef..0000000
--- a/peripheral/libupm/src/servo/es9257.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Author: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
- * Copyright (c) 2015 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-#pragma once
-
-#include <string>
-#include "servo.h"
-
-namespace upm {
-
-/**
- * @library servo
- * @sensor es9257
- * @comname ES9257 Servo
- * @altname Grove Servo
- * @type servos
- * @man emax
- * @web http://www.seeedstudio.com/wiki/Grove_-_Servo
- * @con pwm
- * @kit gsk
- *
- * @brief API for the ES9257 Servo
- *
- * This module defines the ES9257 interface for ES9257 servos.
- * The ES9257 servo is a fast, heavy duty servo that is popular for moving the
- * control surfaces on RC models.
- *
- * @image html es9257.jpg
- */
- class ES9257 : public Servo {
- public:
- /**
- * Instantiates an ES9257 object
- *
- * @param pin Servo pin number
- */
- ES9257 (int pin);
-
- /**
- * ES9257 object destructor
- */
- ~ES9257 ();
-};
-
-}
diff --git a/peripheral/libupm/src/servo/javaupm_servo.i b/peripheral/libupm/src/servo/javaupm_servo.i
deleted file mode 100644
index 38e0436..0000000
--- a/peripheral/libupm/src/servo/javaupm_servo.i
+++ /dev/null
@@ -1,28 +0,0 @@
-%module javaupm_servo
-%include "../upm.i"
-
-%include "servo.h"
-%{
- #include "servo.h"
-%}
-
-%include "es08a.h"
-%{
- #include "es08a.h"
-%}
-
-%include "es9257.h"
-%{
- #include "es9257.h"
-%}
-
-%pragma(java) jniclasscode=%{
- static {
- try {
- System.loadLibrary("javaupm_servo");
- } catch (UnsatisfiedLinkError e) {
- System.err.println("Native code library failed to load. \n" + e);
- System.exit(1);
- }
- }
-%} \ No newline at end of file
diff --git a/peripheral/libupm/src/servo/jsupm_servo.i b/peripheral/libupm/src/servo/jsupm_servo.i
deleted file mode 100644
index 6b17bc2..0000000
--- a/peripheral/libupm/src/servo/jsupm_servo.i
+++ /dev/null
@@ -1,17 +0,0 @@
-%module jsupm_servo
-%include "../upm.i"
-
-%include "servo.h"
-%{
- #include "servo.h"
-%}
-
-%include "es08a.h"
-%{
- #include "es08a.h"
-%}
-
-%include "es9257.h"
-%{
- #include "es9257.h"
-%}
diff --git a/peripheral/libupm/src/servo/pyupm_servo.i b/peripheral/libupm/src/servo/pyupm_servo.i
deleted file mode 100644
index 8db40d6..0000000
--- a/peripheral/libupm/src/servo/pyupm_servo.i
+++ /dev/null
@@ -1,19 +0,0 @@
-// Include doxygen-generated documentation
-%include "pyupm_doxy2swig.i"
-%module pyupm_servo
-%include "../upm.i"
-
-%include "servo.h"
-%{
- #include "servo.h"
-%}
-
-%include "es08a.h"
-%{
- #include "es08a.h"
-%}
-
-%include "es9257.h"
-%{
- #include "es9257.h"
-%}
diff --git a/peripheral/libupm/src/servo/servo.cxx b/peripheral/libupm/src/servo/servo.cxx
deleted file mode 100644
index b956ec4..0000000
--- a/peripheral/libupm/src/servo/servo.cxx
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
- * Author: Yevgeniy Kiveisha <yevgeniy.kiveisha@intel.com>
- * Copyright (c) 2014 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-#include <iostream>
-#include <sstream>
-#include <string>
-#include <stdexcept>
-#include <unistd.h>
-#include <stdlib.h>
-#include <math.h>
-
-#include "servo.h"
-
-using namespace upm;
-
-Servo::Servo (int pin) {
- init(pin, MIN_PULSE_WIDTH, MAX_PULSE_WIDTH, DEFAULT_WAIT_DISABLE_PWM);
-}
-
-Servo::Servo (int pin, int minPulseWidth, int maxPulseWidth) {
- init(pin, minPulseWidth, maxPulseWidth, DEFAULT_WAIT_DISABLE_PWM);
-}
-
-Servo::Servo (int pin, int minPulseWidth, int maxPulseWidth, int waitAndDisablePwm) {
- init(pin, minPulseWidth, maxPulseWidth, waitAndDisablePwm);
-}
-
-Servo::~Servo () {
- haltPwm();
- mraa_pwm_close (m_pwmServoContext);
-}
-
-/*
- * X = between (MIN_PULSE_WIDTH , MAX_PULSE_WIDTH)
- *
- * X usec
- * _______
- * |_______________________________________
- * m_period usec
- *
- * */
-mraa_result_t Servo::setAngle (int angle) {
- if (angle > m_maxAngle || angle < 0) {
- // C++11 std::to_string() would be nice, but...
- std::ostringstream str;
- str << m_maxAngle;
- throw std::out_of_range(std::string(__FUNCTION__) +
- ": angle must be between 0 and " +
- str.str());
-
- return MRAA_ERROR_UNSPECIFIED;
- }
-
- mraa_pwm_enable (m_pwmServoContext, 1);
- mraa_pwm_period_us (m_pwmServoContext, m_period);
- mraa_pwm_pulsewidth_us (m_pwmServoContext, calcPulseTraveling(angle));
-
- if (m_waitAndDisablePwm) {
- sleep(1); // we must make sure that we don't turn off PWM before the servo is done moving.
- haltPwm();
- }
-
- m_currAngle = angle;
- return MRAA_SUCCESS;
-}
-
-mraa_result_t Servo::haltPwm () {
- return mraa_pwm_enable (m_pwmServoContext, 0);
-}
-
-/*
- * Calculating relative pulse time to the value.
- * */
-int Servo::calcPulseTraveling (int value) {
- // if bigger than the boundaries
- if (value > m_maxAngle) {
- return m_maxPulseWidth;
- }
-
- // if less than the boundaries
- if (value < 0) {
- return m_minPulseWidth;
- }
-
- // the conversion
- return (int) ((float)m_minPulseWidth + ((float)value / m_maxAngle) * ((float)m_maxPulseWidth - (float)m_minPulseWidth));
-}
-
-void
-Servo::setMinPulseWidth (int width) {
- m_minPulseWidth = width;
-}
-
-void
-Servo::setMaxPulseWidth (int width) {
- m_maxPulseWidth = width;
-}
-
-void
-Servo::setPeriod (int period) {
- m_period = period;
-}
-
-int
-Servo::getMinPulseWidth () {
- return m_minPulseWidth;
-}
-
-int
-Servo::getMaxPulseWidth () {
- return m_maxPulseWidth;
-}
-
-int
-Servo::getPeriod () {
- return m_period;
-}
-
-/**
- * private mathod: would like to use delegating constructors instead but that requires C++11
- */
-void
-Servo::init (int pin, int minPulseWidth, int maxPulseWidth, int waitAndDisablePwm) {
- m_minPulseWidth = minPulseWidth;
- m_maxPulseWidth = maxPulseWidth;
- m_period = PERIOD;
-
- m_waitAndDisablePwm = waitAndDisablePwm;
-
- m_maxAngle = 180.0;
- m_servoPin = pin;
-
- if ( !(m_pwmServoContext = mraa_pwm_init (m_servoPin)) )
- {
- throw std::invalid_argument(std::string(__FUNCTION__) +
- ": mraa_pwm_init() failed, invalid pin?");
- return;
- }
-
- m_currAngle = 180;
-
- setAngle (0);
-}
diff --git a/peripheral/libupm/src/servo/servo.h b/peripheral/libupm/src/servo/servo.h
deleted file mode 100644
index 17bdf13..0000000
--- a/peripheral/libupm/src/servo/servo.h
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- * Author: Yevgeniy Kiveisha <yevgeniy.kiveisha@intel.com>
- * Copyright (c) 2014 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-#pragma once
-
-#include <string>
-#include <mraa/pwm.h>
-
-namespace upm {
-
-#define MIN_PULSE_WIDTH 600
-#define MAX_PULSE_WIDTH 2500
-#define PERIOD 20000
-
-#define HIGH 1
-#define LOW 0
-
-#define DEFAULT_WAIT_DISABLE_PWM 0
-
-/**
- * @brief Servo library
- *
- * The base Servo class provides routines for setting the angle of the shaft
- * as well as setting and getting the minimum and maximum pulse width and
- * the maximum period.
- *
- * @defgroup servo libupm-servo
- * @ingroup seeed emax pwm servos gsk
- */
-class Servo {
- public:
- /**
- * Instantiates a Servo object
- *
- * @param pin Servo pin number
- */
- Servo (int pin);
-
- /**
- * Instantiates a Servo object
- *
- * @param pin Servo pin number
- * @param minPulseWidth Minimum pulse width, in microseconds
- * @param maxPulseWidth Maximum pulse width, in microseconds
- */
- Servo (int pin, int minPulseWidth, int maxPulseWidth);
-
- /**
- * Instantiates a Servo object
- *
- * @param pin Servo pin number
- * @param minPulseWidth Minimum pulse width, in microseconds
- * @param maxPulseWidth Maximum pulse width, in microseconds
- * @param waitAndDisablePwm If 1, PWM is enabled only during the setAngle() execution
- * for a period of 1 second, and then turned back off. If 0, PWM remains on afterward.
- */
- Servo (int pin, int minPulseWidth, int maxPulseWidth, int waitAndDisablePwm);
-
- /**
- * Servo object destructor
- */
- ~Servo();
-
- /**
- * Sets the angle of the servo engine.
- *
- * @param angle Number between 0 and 180
- * @return 0 if successful, non-zero otherwise
- */
- mraa_result_t setAngle (int angle);
-
- /**
- * Halts PWM for this servo and allows it to move freely.
- */
- mraa_result_t haltPwm ();
-
- /**
- * Returns the name of the component
- *
- * @return Name of the component
- */
- std::string name()
- {
- return m_name;
- }
-
- /**
- * Sets the minimum pulse width
- *
- * @param width Minimum HIGH signal width
- */
- void setMinPulseWidth (int width);
-
- /**
- * Sets the maximum pulse width
- *
- * @param width Maximum HIGH signal width
- */
- void setMaxPulseWidth (int width);
-
- /**
- * Sets the maximum period width
- *
- * @param period PWM period width
- */
- void setPeriod (int period);
-
- /**
- * Returns the minimum pulse width
- *
- * @return Minimum pulse width
- */
- int getMinPulseWidth ();
-
- /**
- * Returns the maximum pulse width
- *
- * @return Maximum pulse width
- */
- int getMaxPulseWidth ();
-
- /**
- * Returns the maximum PWM period width
- *
- * @return Maximum PWM period width
- */
- int getPeriod ();
-
- protected:
- int calcPulseTraveling (int value);
-
- std::string m_name;
- int m_servoPin;
- float m_maxAngle;
- mraa_pwm_context m_pwmServoContext;
- int m_currAngle;
-
- int m_minPulseWidth;
- int m_maxPulseWidth;
- int m_period;
-
- int m_waitAndDisablePwm;
-
- private:
- void init (int pin, int minPulseWidth, int maxPulseWidth, int waitAndDisablePwm);
-};
-
-}