MakeBlock Drive Updated
Updated library for MakeBlock Ranger
Loading...
Searching...
No Matches
MeSmartServo Class Reference

Driver for Me Smart Servo device. More...

#include <src/MeSmartServo.h>

Inheritance diagram for MeSmartServo:
Collaboration diagram for MeSmartServo:

Public Member Functions

 MeSmartServo ()
 
 MeSmartServo (uint8_t port)
 
uint8_t readByte (uint8_t *argv, int16_t idx)
 
short readShort (uint8_t *argv, int16_t idx, boolean ignore_high)
 
float readFloat (uint8_t *argv, int16_t idx)
 
long readLong (uint8_t *argv, int idx)
 
uint8_t sendByte (uint8_t val)
 
uint8_t sendShort (int16_t val, boolean ignore_high)
 
uint8_t sendFloat (float val)
 
uint8_t sendLong (long val)
 
boolean assignDevIdRequest (void)
 
boolean moveTo (uint8_t dev_id, long angle_value, float speed, smartServoCb callback=NULL)
 
boolean move (uint8_t dev_id, long angle_value, float speed, smartServoCb callback=NULL)
 
boolean setZero (uint8_t dev_id)
 
boolean setBreak (uint8_t dev_id, uint8_t breakStatus)
 
boolean setRGBLed (uint8_t dev_id, uint8_t r_value, uint8_t g_value, uint8_t b_value)
 
boolean handSharke (uint8_t dev_id)
 
boolean setPwmMove (uint8_t dev_id, int16_t pwm_value)
 
boolean setInitAngle (uint8_t dev_id, uint8_t=0, int16_t=40)
 
long getAngleRequest (uint8_t devId)
 
float getSpeedRequest (uint8_t devId)
 
float getVoltageRequest (uint8_t devId)
 
float getTempRequest (uint8_t devId)
 
float getCurrentRequest (uint8_t devId)
 
void assignDevIdResponse (void *arg)
 
void errorCodeCheckResponse (void *arg)
 
void smartServoCmdResponse (void *arg)
 
void processSysexMessage (void)
 
void smartServoEventHandle (void)
 
- Public Member Functions inherited from MeSerial
 MeSerial (void)
 
 MeSerial (uint8_t port)
 
 MeSerial (uint8_t receivePin, uint8_t transmitPin, bool inverse_logic=false)
 
void setHardware (bool mode)
 
void begin (long baudrate)
 
size_t write (uint8_t byte)
 
int read ()
 
int available ()
 
int16_t poll (void)
 
void end (void)
 
bool listen (void)
 
bool isListening (void)
 
void sendString (char *str)
 
void printf (char *fmt,...)
 
boolean dataLineAvailable (void)
 
String readDataLine (void)
 
String concatenateWith (String s1, String s2)
 
char letterOf (int i, String s)
 
int stringLength (String s)
 
boolean equalString (String s1, String s2)
 
float getValue (String key)
 
- Public Member Functions inherited from MePort
 MePort (void)
 
 MePort (uint8_t port)
 
 MePort (uint8_t port, uint8_t slot)
 
uint8_t getPort (void)
 
uint8_t getSlot (void)
 
bool dRead1 (uint8_t mode=INPUT)
 
bool dRead2 (uint8_t mode=INPUT)
 
bool dpRead1 (void)
 
bool dpRead2 (void)
 
void dWrite1 (bool value)
 
void dWrite2 (bool value)
 
int16_t aRead1 (void)
 
int16_t aRead2 (void)
 
void aWrite1 (int16_t value)
 
void aWrite2 (int16_t value)
 
void reset (uint8_t port)
 
void reset (uint8_t port, uint8_t slot)
 
uint8_t pin1 (void)
 
uint8_t pin2 (void)
 
uint8_t pin (void)
 
uint8_t pin (uint8_t port, uint8_t slot)
 
- Public Member Functions inherited from SoftwareSerial
 SoftwareSerial (uint8_t receivePin, uint8_t transmitPin, bool inverse_logic=false)
 
void begin (long speed)
 
bool listen ()
 
void end ()
 
bool isListening ()
 
bool stopListening ()
 
bool overflow ()
 
int peek ()
 
virtual void flush ()
 
 operator bool ()
 

Additional Inherited Members

- Static Public Member Functions inherited from SoftwareSerial
static void handle_interrupt () __attribute__((__always_inline__))
 
- Protected Attributes inherited from MeSerial
bool _hard
 
bool _polling
 
bool _scratch
 
int16_t _bitPeriod
 
int16_t _byte
 
long _lastTime
 
char buffer [64]
 
String lastLine
 
int bufferIndex
 
- Protected Attributes inherited from MePort
uint8_t s1
 
uint8_t s2
 
uint8_t _port
 
uint8_t _slot
 

Detailed Description

Driver for Me Smart Servo device.

Class: MeSmartServo

Description
Declaration of Class MeSmartServo.
Copyright (C), 2012-2016, MakeBlock

Constructor & Destructor Documentation

◆ MeSmartServo() [1/2]

MeSmartServo::MeSmartServo ( )

Alternate Constructor which can call your own function to map the Me Smart Servo to arduino port, no pins are used or initialized here.

Parameters
[in]None

◆ MeSmartServo() [2/2]

MeSmartServo::MeSmartServo ( uint8_t  port)

Alternate Constructor which can call your own function to map the Me Smart Servo to arduino port, If the hardware serial was selected, it will used the hardware serial.

Parameters
[in]port- RJ25 port from PORT_1 to M2

Alternate Constructor which can call your own function to map the Me Smart Servo to arduino port, If the hardware serial was selected, it will used the hardware serial.

Parameters
[in]port- RJ25 port from PORT_1 to M2.

Member Function Documentation

◆ assignDevIdRequest()

boolean MeSmartServo::assignDevIdRequest ( void  )
Function
assignDevIdRequest
Description
distribution device ID number to the smart servo link.
Parameters
[in]None
Output
None
Returns
If the assignment is successful, return true.
Others
None

◆ assignDevIdResponse()

void MeSmartServo::assignDevIdResponse ( void *  arg)
Function
assignDevIdResponse
Description
distribution device ID number return packet processing.
Parameters
[in]None
Output
None
Returns
None
Others
None
Function
assignDevIdResponse
Description
distribution device ID number return packet processing.
Parameters
[in]*arg- address of input parameter.
Output
None
Returns
None
Others
None

◆ errorCodeCheckResponse()

void MeSmartServo::errorCodeCheckResponse ( void *  arg)
Function
errorCodeCheckResponse
Description
This function is used to process the error response message of smart servo.
Parameters
[in]*arg- address of input parameter.
Output
None
Returns
None
Others
None

◆ getAngleRequest()

long MeSmartServo::getAngleRequest ( uint8_t  devId)
Function
getAngleRequest
Description
This function used to get the smart servo's angle.
Parameters
[in]devId- the device id of servo that we want to read its angle.
Output
None
Returns
the angle of smart servo.
Others
None

◆ getCurrentRequest()

float MeSmartServo::getCurrentRequest ( uint8_t  devId)
Function
getCurrentRequest
Description
This function used to get the smart servo's current.
Parameters
[in]devId- the device id of servo that we want to read its current.
Output
None
Returns
the current of smart servo.
Others
None

◆ getSpeedRequest()

float MeSmartServo::getSpeedRequest ( uint8_t  devId)
Function
getSpeedRequest
Description
This function used to get the smart servo's speed.
Parameters
[in]devId- the device id of servo that we want to read its speed.
Output
None
Returns
the speed of smart servo.
Others
None

◆ getTempRequest()

float MeSmartServo::getTempRequest ( uint8_t  devId)
Function
getTempRequest
Description
This function used to get the smart servo's temperature.
Parameters
[in]devId- the device id of servo that we want to read its temperature.
Output
None
Returns
the temperature of smart servo.
Others
None

◆ getVoltageRequest()

float MeSmartServo::getVoltageRequest ( uint8_t  devId)
Function
getVoltageRequest
Description
This function used to get the smart servo's voltage.
Parameters
[in]devId- the device id of servo that we want to read its voltage.
Output
None
Returns
the voltage of smart servo.
Others
None

◆ handSharke()

boolean MeSmartServo::handSharke ( uint8_t  dev_id)
Function
handSharke
Description
This function is used MCU and servo handshake.
Parameters
[in]dev_id- the device id of servo that we want to handsharke.
Output
None
Returns
If the assignment is successful, return true.
Others
None

◆ move()

boolean MeSmartServo::move ( uint8_t  dev_id,
long  angle_value,
float  speed,
smartServoCb  callback = NULL 
)
Function
move
Description
smart servo moves to the relative angle.
Parameters
[in]dev_id- the device id of servo that we want to move.
[in]angle_value- the relative angle value we want move to.
[in]speed- move speed value(The unit is rpm).
[in]callback- callback function when the target position has been reached(Optional parameters).
Output
None
Returns
If the assignment is successful, return true.
Others
None

◆ moveTo()

boolean MeSmartServo::moveTo ( uint8_t  dev_id,
long  angle_value,
float  speed,
smartServoCb  callback = NULL 
)
Function
moveTo
Description
smart servo moves to the absolute angle.
Parameters
[in]dev_id- the device id of servo that we want to move.
[in]angle_value- the absolute angle value we want move to.
[in]speed- move speed value(The unit is rpm).
[in]callback- callback function when the target position has been reached(Optional parameters).
Output
None
Returns
If the assignment is successful, return true.
Others
None

◆ processSysexMessage()

void MeSmartServo::processSysexMessage ( void  )
Function
processSysexMessage
Description
This function is used to process protocol messages of smart servo.
Parameters
[in]None
Output
None
Returns
None
Others
None

◆ readByte()

uint8_t MeSmartServo::readByte ( uint8_t *  argv,
int16_t  idx 
)
Function
readByte
Description
change 2byte 7bit read date to 1byte byte data.
Parameters
[in]*argv- the buffer for input data.
[in]idx- the index used to identify the first address of read data.
Output
return the converted data.
Returns
None
Others
None

◆ readFloat()

float MeSmartServo::readFloat ( uint8_t *  argv,
int16_t  idx 
)
Function
readFloat
Description
change (5byte 7bit) read date to 4byte float data.
Parameters
[in]*argv- the buffer for input data.
[in]idx- the index used to identify the first address of read data.
Output
return the converted data.
Returns
None
Others
None

◆ readLong()

long MeSmartServo::readLong ( uint8_t *  argv,
int  idx 
)
Function
readLong
Description
change (5byte 7bit) read date to 4byte long data.
Parameters
[in]*argv- the buffer for input data.
[in]idx- the index used to identify the first address of read data.
Output
return the converted data.
Returns
None
Others
None

◆ readShort()

short MeSmartServo::readShort ( uint8_t *  argv,
int16_t  idx,
boolean  ignore_high 
)
Function
readShort
Description
change (2byte 7bit) or (3byte 7bit) read date to 2byte short data.
Parameters
[in]*argv- the buffer for input data.
[in]idx- the index used to identify the first address of read data.
[in]ignore_high- is there have third byte high-level data.
Output
return the converted data.
Returns
None
Others
None

◆ sendByte()

uint8_t MeSmartServo::sendByte ( uint8_t  val)
Function
sendByte
Description
send (1byte 8bit) date to 2byte 7bit data.
Parameters
[in]val- the byte data to be converted.
Output
return the checksum data.
Returns
None
Others
None

◆ sendFloat()

uint8_t MeSmartServo::sendFloat ( float  val)
Function
sendFloat
Description
send (4byte float) date to 5byte 7bit data.
Parameters
[in]val- the short data to be converted.
Output
return the checksum data.
Returns
None
Others
None

◆ sendLong()

uint8_t MeSmartServo::sendLong ( long  val)
Function
sendLong
Description
send (4byte long) date to 5byte 7bit data.
Parameters
[in]val- the short data to be converted.
Output
return the checksum data.
Returns
None
Others
None

◆ sendShort()

uint8_t MeSmartServo::sendShort ( int16_t  val,
boolean  ignore_high 
)
Function
sendShort
Description
send (2byte short) date to 2byte or 3byte 7bit data.
Parameters
[in]val- the short data to be converted.
[in]ignore_high- is there have third byte high-level data.
Output
return the checksum data.
Returns
None
Others
None

◆ setBreak()

boolean MeSmartServo::setBreak ( uint8_t  dev_id,
uint8_t  breakStatus 
)
Function
setBreak
Description
set smart servo break status.
Parameters
[in]dev_id- the device id of servo that we want to set.
[in]breakStatus- the break status of servo.
Output
None
Returns
If the assignment is successful, return true.
Others
None

◆ setInitAngle()

boolean MeSmartServo::setInitAngle ( uint8_t  dev_id,
uint8_t  mode = 0,
int16_t  speed = 40 
)
Function
setInitAngle
Description
This function is used to move smart servo to its 0 degrees.
Parameters
[in]dev_id- the device id of servo that we want to set.
[in]mode- the return mode, 0 is the quick return mode.
[in]speed- the speed value return to init angle.
Output
None
Returns
If the assignment is successful, return true.
Others
None

◆ setPwmMove()

boolean MeSmartServo::setPwmMove ( uint8_t  dev_id,
int16_t  pwm_value 
)
Function
setPwmMove
Description
This function is used to set the pwm motion of smart servo.
Parameters
[in]dev_id- the device id of servo that we want to set.
[in]pwm_value- the pwm value we wan't set the servo motor.
Output
None
Returns
If the assignment is successful, return true.
Others
None

◆ setRGBLed()

boolean MeSmartServo::setRGBLed ( uint8_t  dev_id,
uint8_t  r_value,
uint8_t  g_value,
uint8_t  b_value 
)
Function
setRGBLed
Description
set the color of smart servo's RGB LED.
Parameters
[in]dev_id- the device id of servo that we want to set.
[in]r_value- Red component.
[in]g_value- green component.
[in]B_value- Blue component.
Output
None
Returns
If the assignment is successful, return true.
Others
None

◆ setZero()

boolean MeSmartServo::setZero ( uint8_t  dev_id)
Function
setZero
Description
set smart servo current angle zero postion.
Parameters
[in]dev_id- the device id of servo that we want to initialization position.
Output
None
Returns
If the assignment is successful, return true.
Others
None

◆ smartServoCmdResponse()

void MeSmartServo::smartServoCmdResponse ( void *  arg)
Function
smartServoCmdResponse
Description
This function is used to process the response message of smart servo.
Parameters
[in]*arg- address of input parameter.
Output
None
Returns
None
Others
None

◆ smartServoEventHandle()

void MeSmartServo::smartServoEventHandle ( void  )
Function
smartServoEventHandle
Description
This function is used to process protocol messages of smart servo.
Parameters
[in]None
Output
None
Returns
None
Others
None

The documentation for this class was generated from the following files: