mirror of
https://github.com/eclipse/upm.git
synced 2025-07-08 04:41:12 +03:00
servo: Added new module servo
Signed-off-by: Kiveisha Yevgeniy <yevgeniy.kiveisha@intel.com>
This commit is contained in:

committed by
Kiveisha Yevgeniy

parent
f1cf463126
commit
aac51c4850
58
src/servo/servo.h
Normal file
58
src/servo/servo.h
Normal file
@ -0,0 +1,58 @@
|
||||
/*
|
||||
* 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 <maa/pwm.h>
|
||||
|
||||
namespace upm {
|
||||
|
||||
#define MIN_PULSE_WIDTH 600
|
||||
#define MAX_PULSE_WIDTH 2500
|
||||
#define MAX_PERIOD 7968
|
||||
|
||||
#define HIGH 1
|
||||
#define LOW 0
|
||||
|
||||
class Servo {
|
||||
public:
|
||||
Servo (int pin);
|
||||
~Servo();
|
||||
maa_result_t setAngle (int angle);
|
||||
|
||||
std::string name()
|
||||
{
|
||||
return m_name;
|
||||
}
|
||||
protected:
|
||||
int calcPulseTraveling (int value);
|
||||
|
||||
std::string m_name;
|
||||
int m_servoPin;
|
||||
float m_maxAngle;
|
||||
maa_pwm_context m_pwmServoContext;
|
||||
// maa_gpio_context m_servoPinCtx;
|
||||
};
|
||||
|
||||
}
|
Reference in New Issue
Block a user