#include <yocto_servo.h>
Public Member Functions | |
virtual int | _invokeValueCallback (string value) |
Y_ENABLED_enum | enabled (void) |
Y_ENABLEDATPOWERON_enum | enabledAtPowerOn (void) |
Y_ENABLED_enum | get_enabled (void) |
Y_ENABLEDATPOWERON_enum | get_enabledAtPowerOn (void) |
YMove | get_move (void) |
int | get_neutral (void) |
int | get_position (void) |
int | get_positionAtPowerOn (void) |
int | get_range (void) |
YMove | move (void) |
int | move (int target, int ms_duration) |
int | neutral (void) |
YServo * | next (void) |
YServo * | nextServo (void) |
int | position (void) |
int | positionAtPowerOn (void) |
int | range (void) |
virtual int | registerValueCallback (YServoValueCallback callback) |
int | set_enabled (Y_ENABLED_enum newval) |
int | set_enabledAtPowerOn (Y_ENABLEDATPOWERON_enum newval) |
int | set_move (YMove newval) |
int | set_neutral (int newval) |
int | set_position (int newval) |
int | set_positionAtPowerOn (int newval) |
int | set_range (int newval) |
int | setEnabled (Y_ENABLED_enum newval) |
int | setEnabledAtPowerOn (Y_ENABLEDATPOWERON_enum newval) |
int | setMove (YMove newval) |
int | setNeutral (int newval) |
int | setPosition (int newval) |
int | setPositionAtPowerOn (int newval) |
int | setRange (int newval) |
~YServo () | |
Public Member Functions inherited from YFunction | |
void | _clearDataStreamCache () |
string | _decode_json_string (const string &json) |
string | _download (const string &url) |
YDataStream * | _findDataStream (YDataSet &dataset, const string &def) |
string | _get_json_path (const string &json, const string &path) |
vector< string > | _json_get_array (const string &json) |
string | _json_get_key (const string &json, const string &data) |
string | _json_get_string (const string &json) |
int | _parseEx (yJsonStateMachine &j) |
virtual int | _parserHelper (void) |
string | _parseString (yJsonStateMachine &j) |
string | _request (const string &request) |
string | _requestEx (int tcpchan, const string &request, yapiRequestProgressCallback callback, void *context) |
void | _throw (YRETCODE errType, string errMsg) |
YRETCODE | _upload (const string &path, const string &content) |
YRETCODE | _uploadWithProgress (const string &path, const string &content, yapiRequestProgressCallback callback, void *context) |
string | advertisedValue (void) |
void | clearCache () |
string | describe (void) |
string | errMessage (void) |
string | errorMessage (void) |
YRETCODE | errorType (void) |
YRETCODE | errType (void) |
YFUN_DESCR | functionDescriptor (void) |
string | get_advertisedValue (void) |
string | get_errorMessage (void) |
YRETCODE | get_errorType (void) |
virtual string | get_friendlyName (void) |
YFUN_DESCR | get_functionDescriptor (void) |
string | get_functionId (void) |
string | get_hardwareId (void) |
string | get_hubSerial () |
string | get_logicalName (void) |
YModule * | get_module (void) |
void * | get_userData (void) |
bool | isOnline (void) |
YRETCODE | load (int msValidity) |
virtual string | loadAttribute (string attrName) |
string | logicalName (void) |
YModule * | module (void) |
virtual int | muteValueCallbacks (void) |
YFunction * | next (void) |
YFunction * | nextFunction (void) |
virtual int | registerValueCallback (YFunctionValueCallback callback) |
int | set_advertisedValue (const string &newval) |
int | set_logicalName (const string &newval) |
void | set_userData (void *data) |
int | setAdvertisedValue (const string &newval) |
int | setLogicalName (const string &newval) |
void | setUserData (void *data) |
virtual int | unmuteValueCallbacks (void) |
void * | userData (void) |
virtual | ~YFunction () |
Static Public Member Functions | |
static YServo * | Find (string func) |
static YServo * | FindServo (string func) |
static YServo * | First (void) |
static YServo * | FirstServo (void) |
Static Public Member Functions inherited from YFunction | |
static void | _ClearCache (void) |
static YFunction * | Find (string func) |
static YFunction * | FindFunction (string func) |
static YFunction * | First (void) |
static YFunction * | FirstFunction (void) |
Protected Member Functions | |
virtual int | _parseAttr (YJSONObject *json_val) |
YServo (const string &func) | |
Protected Member Functions inherited from YFunction | |
YRETCODE | _buildSetRequest (const string &changeattr, const string *changeval, string &request, string &errmsg) |
string | _escapeAttr (const string &changeval) |
YRETCODE | _getDescriptor (YFUN_DESCR &fundescr, string &errMsg) |
YRETCODE | _getDevice (YDevice *&dev, string &errMsg) |
YRETCODE | _load_unsafe (int msValidity) |
YRETCODE | _nextFunction (string &hwId) |
int | _parse (YJSONObject *j) |
YRETCODE | _setAttr (string attrname, string newvalue) |
YFunction (const string &func) | |
Protected Attributes | |
Y_ENABLED_enum | _enabled |
Y_ENABLEDATPOWERON_enum | _enabledAtPowerOn |
YMove | _move |
int | _neutral |
int | _position |
int | _positionAtPowerOn |
int | _range |
YServoValueCallback | _valueCallbackServo |
Protected Attributes inherited from YFunction | |
string | _advertisedValue |
u64 | _cacheExpiration |
string | _className |
std::map< string, YDataStream * > | _dataStreams |
string | _func |
YFUN_DESCR | _fundescr |
string | _funId |
string | _hwId |
string | _lastErrorMsg |
YRETCODE | _lastErrorType |
string | _logicalName |
string | _serial |
yCRITICAL_SECTION | _this_cs |
void * | _userData |
YFunctionValueCallback | _valueCallbackFunction |
Friends | |
YServo * | yFindServo (const string &func) |
YServo * | yFirstServo (void) |
Additional Inherited Members | |
Static Protected Member Functions inherited from YFunction | |
static void | _AddToCache (const string &classname, const string &func, YFunction *obj) |
static YFunction * | _FindFromCache (const string &classname, const string &func) |
static void | _UpdateTimedReportCallbackList (YFunction *func, bool add) |
static void | _UpdateValueCallbackList (YFunction *func, bool add) |
Static Protected Attributes inherited from YFunction | |
static std::map< string, YFunction * > | _cache |
YServo Class: Servo function interface
Yoctopuce application programming interface allows you not only to move a servo to a given position, but also to specify the time interval in which the move should be performed. This makes it possible to synchronize two servos involved in a same move.
Definition at line 103 of file yocto_servo.h.
|
protected |
Definition at line 51 of file yocto_servo.cpp.
YServo::~YServo | ( | ) |
Definition at line 66 of file yocto_servo.cpp.
|
virtual |
Reimplemented from YFunction.
Definition at line 583 of file yocto_servo.cpp.
|
protectedvirtual |
Reimplemented from YFunction.
Definition at line 75 of file yocto_servo.cpp.
|
inline |
Definition at line 180 of file yocto_servo.h.
|
inline |
Definition at line 315 of file yocto_servo.h.
|
inlinestatic |
Definition at line 378 of file yocto_servo.h.
|
static |
Retrieves a servo for a given identifier. The identifier can be specified using several formats:
This function does not require that the servo is online at the time it is invoked. The returned object is nevertheless valid. Use the method YServo.isOnline() to test if the servo is indeed online at a given time. In case of ambiguity when looking for a servo by logical name, no error is notified: the first instance found is returned. The search is performed first by hardware name, then by logical name.
If a call to this object's is_online() method returns FALSE although you are certain that the matching device is plugged, make sure that you did call registerHub() at application initialization time.
func | : a string that uniquely characterizes the servo |
Definition at line 532 of file yocto_servo.cpp.
|
inlinestatic |
Definition at line 402 of file yocto_servo.h.
|
static |
Starts the enumeration of servos currently accessible. Use the method YServo.nextServo() to iterate on next servos.
Definition at line 603 of file yocto_servo.cpp.
Y_ENABLED_enum YServo::get_enabled | ( | void | ) |
Returns the state of the servos.
On failure, throws an exception or returns Y_ENABLED_INVALID.
Definition at line 172 of file yocto_servo.cpp.
Y_ENABLEDATPOWERON_enum YServo::get_enabledAtPowerOn | ( | void | ) |
Returns the servo signal generator state at power up.
On failure, throws an exception or returns Y_ENABLEDATPOWERON_INVALID.
Definition at line 457 of file yocto_servo.cpp.
YMove YServo::get_move | ( | void | ) |
Definition at line 339 of file yocto_servo.cpp.
int YServo::get_neutral | ( | void | ) |
Returns the duration in microseconds of a neutral pulse for the servo.
On failure, throws an exception or returns Y_NEUTRAL_INVALID.
Definition at line 286 of file yocto_servo.cpp.
int YServo::get_position | ( | void | ) |
Returns the current servo position.
On failure, throws an exception or returns Y_POSITION_INVALID.
Definition at line 118 of file yocto_servo.cpp.
int YServo::get_positionAtPowerOn | ( | void | ) |
Returns the servo position at device power up.
On failure, throws an exception or returns Y_POSITIONATPOWERON_INVALID.
Definition at line 401 of file yocto_servo.cpp.
int YServo::get_range | ( | void | ) |
Returns the current range of use of the servo.
On failure, throws an exception or returns Y_RANGE_INVALID.
Definition at line 226 of file yocto_servo.cpp.
|
inline |
Definition at line 260 of file yocto_servo.h.
int YServo::move | ( | int | target, |
int | ms_duration | ||
) |
Performs a smooth move at constant speed toward a given position.
target | : new position at the end of the move |
ms_duration | : total duration of the move, in milliseconds |
On failure, throws an exception or returns a negative error code.
Definition at line 387 of file yocto_servo.cpp.
|
inline |
Definition at line 236 of file yocto_servo.h.
|
inline |
Definition at line 389 of file yocto_servo.h.
YServo * YServo::nextServo | ( | void | ) |
Continues the enumeration of servos started using yFirstServo().
Definition at line 593 of file yocto_servo.cpp.
|
inline |
Definition at line 155 of file yocto_servo.h.
|
inline |
Definition at line 288 of file yocto_servo.h.
|
inline |
Definition at line 205 of file yocto_servo.h.
|
virtual |
Registers the callback function that is invoked on every change of advertised value. The callback is invoked only during the execution of ySleep or yHandleEvents. This provides control over the time when the callback is triggered. For good responsiveness, remember to call one of these two functions periodically. To unregister a callback, pass a NULL pointer as argument.
callback | : the callback function to call, or a NULL pointer. The callback function should take two arguments: the function object of which the value has changed, and the character string describing the new advertised value. |
Definition at line 564 of file yocto_servo.cpp.
int YServo::set_enabled | ( | Y_ENABLED_enum | newval | ) |
Stops or starts the servo.
newval | : either Y_ENABLED_FALSE or Y_ENABLED_TRUE |
On failure, throws an exception or returns a negative error code.
Definition at line 203 of file yocto_servo.cpp.
int YServo::set_enabledAtPowerOn | ( | Y_ENABLEDATPOWERON_enum | newval | ) |
Configure the servo signal generator state at power up. Remember to call the matching module saveToFlash() method, otherwise this call will have no effect.
newval | : either Y_ENABLEDATPOWERON_FALSE or Y_ENABLEDATPOWERON_TRUE |
On failure, throws an exception or returns a negative error code.
Definition at line 489 of file yocto_servo.cpp.
int YServo::set_move | ( | YMove | newval | ) |
Definition at line 361 of file yocto_servo.cpp.
int YServo::set_neutral | ( | int | newval | ) |
Changes the duration of the pulse corresponding to the neutral position of the servo. The duration is specified in microseconds, and the standard value is 1500 [us]. This setting makes it possible to shift the range of use of the servo. Be aware that using a range higher than what is supported by the servo is likely to damage the servo. Remember to call the matching module saveToFlash() method, otherwise this call will have no effect.
newval | : an integer corresponding to the duration of the pulse corresponding to the neutral position of the servo |
On failure, throws an exception or returns a negative error code.
Definition at line 323 of file yocto_servo.cpp.
int YServo::set_position | ( | int | newval | ) |
Changes immediately the servo driving position.
newval | : an integer corresponding to immediately the servo driving position |
On failure, throws an exception or returns a negative error code.
Definition at line 149 of file yocto_servo.cpp.
int YServo::set_positionAtPowerOn | ( | int | newval | ) |
Configure the servo position at device power up. Remember to call the matching module saveToFlash() method, otherwise this call will have no effect.
newval | : an integer |
On failure, throws an exception or returns a negative error code.
Definition at line 433 of file yocto_servo.cpp.
int YServo::set_range | ( | int | newval | ) |
Changes the range of use of the servo, specified in per cents. A range of 100% corresponds to a standard control signal, that varies from 1 [ms] to 2 [ms], When using a servo that supports a double range, from 0.5 [ms] to 2.5 [ms], you can select a range of 200%. Be aware that using a range higher than what is supported by the servo is likely to damage the servo. Remember to call the matching module saveToFlash() method, otherwise this call will have no effect.
newval | : an integer corresponding to the range of use of the servo, specified in per cents |
On failure, throws an exception or returns a negative error code.
Definition at line 263 of file yocto_servo.cpp.
|
inline |
Definition at line 193 of file yocto_servo.h.
|
inline |
Definition at line 329 of file yocto_servo.h.
|
inline |
Definition at line 264 of file yocto_servo.h.
|
inline |
Definition at line 255 of file yocto_servo.h.
|
inline |
Definition at line 168 of file yocto_servo.h.
|
inline |
Definition at line 302 of file yocto_servo.h.
|
inline |
Definition at line 224 of file yocto_servo.h.
|
friend |
Retrieves a servo for a given identifier. The identifier can be specified using several formats:
This function does not require that the servo is online at the time it is invoked. The returned object is nevertheless valid. Use the method YServo.isOnline() to test if the servo is indeed online at a given time. In case of ambiguity when looking for a servo by logical name, no error is notified: the first instance found is returned. The search is performed first by hardware name, then by logical name.
If a call to this object's is_online() method returns FALSE although you are certain that the matching device is plugged, make sure that you did call registerHub() at application initialization time.
func | : a string that uniquely characterizes the servo |
Definition at line 439 of file yocto_servo.h.
|
friend |
Starts the enumeration of servos currently accessible. Use the method YServo.nextServo() to iterate on next servos.
Definition at line 450 of file yocto_servo.h.
|
protected |
Definition at line 112 of file yocto_servo.h.
|
protected |
Definition at line 117 of file yocto_servo.h.
|
protected |
Definition at line 115 of file yocto_servo.h.
|
protected |
Definition at line 114 of file yocto_servo.h.
|
protected |
Definition at line 111 of file yocto_servo.h.
|
protected |
Definition at line 116 of file yocto_servo.h.
|
protected |
Definition at line 113 of file yocto_servo.h.
|
protected |
Definition at line 118 of file yocto_servo.h.
|
static |
Definition at line 135 of file yocto_servo.h.
|
static |
Definition at line 137 of file yocto_servo.h.
|
static |
Definition at line 136 of file yocto_servo.h.
|
static |
Definition at line 142 of file yocto_servo.h.
|
static |
Definition at line 144 of file yocto_servo.h.
|
static |
Definition at line 143 of file yocto_servo.h.
Definition at line 140 of file yocto_servo.h.
|
static |
Definition at line 139 of file yocto_servo.h.
|
static |
Definition at line 134 of file yocto_servo.h.
|
static |
Definition at line 141 of file yocto_servo.h.
|
static |
Definition at line 138 of file yocto_servo.h.