#include <yocto_anbutton.h>
Public Member Functions | |
virtual int | _invokeValueCallback (string value) |
Y_ANALOGCALIBRATION_enum | analogCalibration (void) |
int | calibratedValue (void) |
int | calibrationMax (void) |
int | calibrationMin (void) |
Y_ANALOGCALIBRATION_enum | get_analogCalibration (void) |
int | get_calibratedValue (void) |
int | get_calibrationMax (void) |
int | get_calibrationMin (void) |
Y_ISPRESSED_enum | get_isPressed (void) |
s64 | get_lastTimePressed (void) |
s64 | get_lastTimeReleased (void) |
s64 | get_pulseCounter (void) |
s64 | get_pulseTimer (void) |
int | get_rawValue (void) |
int | get_sensitivity (void) |
Y_ISPRESSED_enum | isPressed (void) |
s64 | lastTimePressed (void) |
s64 | lastTimeReleased (void) |
YAnButton * | next (void) |
YAnButton * | nextAnButton (void) |
s64 | pulseCounter (void) |
s64 | pulseTimer (void) |
int | rawValue (void) |
virtual int | registerValueCallback (YAnButtonValueCallback callback) |
virtual int | resetCounter (void) |
int | sensitivity (void) |
int | set_analogCalibration (Y_ANALOGCALIBRATION_enum newval) |
int | set_calibrationMax (int newval) |
int | set_calibrationMin (int newval) |
int | set_pulseCounter (s64 newval) |
int | set_sensitivity (int newval) |
int | setAnalogCalibration (Y_ANALOGCALIBRATION_enum newval) |
int | setCalibrationMax (int newval) |
int | setCalibrationMin (int newval) |
int | setPulseCounter (s64 newval) |
int | setSensitivity (int newval) |
~YAnButton () | |
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 YAnButton * | Find (string func) |
static YAnButton * | FindAnButton (string func) |
static YAnButton * | First (void) |
static YAnButton * | FirstAnButton (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) |
YAnButton (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_ANALOGCALIBRATION_enum | _analogCalibration |
int | _calibratedValue |
int | _calibrationMax |
int | _calibrationMin |
Y_ISPRESSED_enum | _isPressed |
s64 | _lastTimePressed |
s64 | _lastTimeReleased |
s64 | _pulseCounter |
s64 | _pulseTimer |
int | _rawValue |
int | _sensitivity |
YAnButtonValueCallback | _valueCallbackAnButton |
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 | |
YAnButton * | yFindAnButton (const string &func) |
YAnButton * | yFirstAnButton (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 |
YAnButton Class: AnButton function interface
Yoctopuce application programming interface allows you to measure the state of a simple button as well as to read an analog potentiometer (variable resistance). This can be use for instance with a continuous rotating knob, a throttle grip or a joystick. The module is capable to calibrate itself on min and max values, in order to compute a calibrated value that varies proportionally with the potentiometer position, regardless of its total resistance.
Definition at line 93 of file yocto_anbutton.h.
|
protected |
Definition at line 51 of file yocto_anbutton.cpp.
YAnButton::~YAnButton | ( | ) |
Definition at line 70 of file yocto_anbutton.cpp.
|
virtual |
Reimplemented from YFunction.
Definition at line 657 of file yocto_anbutton.cpp.
|
protectedvirtual |
Reimplemented from YFunction.
Definition at line 78 of file yocto_anbutton.cpp.
|
inline |
Definition at line 177 of file yocto_anbutton.h.
|
inline |
Definition at line 153 of file yocto_anbutton.h.
|
inline |
Definition at line 204 of file yocto_anbutton.h.
|
inline |
Definition at line 234 of file yocto_anbutton.h.
|
inlinestatic |
Definition at line 414 of file yocto_anbutton.h.
|
static |
Retrieves an analog input for a given identifier. The identifier can be specified using several formats:
This function does not require that the analog input is online at the time it is invoked. The returned object is nevertheless valid. Use the method YAnButton.isOnline() to test if the analog input is indeed online at a given time. In case of ambiguity when looking for an analog input 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 analog input |
Definition at line 606 of file yocto_anbutton.cpp.
|
inlinestatic |
Definition at line 438 of file yocto_anbutton.h.
|
static |
Starts the enumeration of analog inputs currently accessible. Use the method YAnButton.nextAnButton() to iterate on next analog inputs.
Definition at line 689 of file yocto_anbutton.cpp.
Y_ANALOGCALIBRATION_enum YAnButton::get_analogCalibration | ( | void | ) |
Tells if a calibration process is currently ongoing.
On failure, throws an exception or returns Y_ANALOGCALIBRATION_INVALID.
Definition at line 182 of file yocto_anbutton.cpp.
int YAnButton::get_calibratedValue | ( | void | ) |
Returns the current calibrated input value (between 0 and 1000, included).
On failure, throws an exception or returns Y_CALIBRATEDVALUE_INVALID.
Definition at line 124 of file yocto_anbutton.cpp.
int YAnButton::get_calibrationMax | ( | void | ) |
Returns the maximal value measured during the calibration (between 0 and 4095, included).
On failure, throws an exception or returns Y_CALIBRATIONMAX_INVALID.
Definition at line 238 of file yocto_anbutton.cpp.
int YAnButton::get_calibrationMin | ( | void | ) |
Returns the minimal value measured during the calibration (between 0 and 4095, included).
On failure, throws an exception or returns Y_CALIBRATIONMIN_INVALID.
Definition at line 297 of file yocto_anbutton.cpp.
Y_ISPRESSED_enum YAnButton::get_isPressed | ( | void | ) |
Returns true if the input (considered as binary) is active (closed contact), and false otherwise.
On failure, throws an exception or returns Y_ISPRESSED_INVALID.
Definition at line 417 of file yocto_anbutton.cpp.
s64 YAnButton::get_lastTimePressed | ( | void | ) |
Returns the number of elapsed milliseconds between the module power on and the last time the input button was pressed (the input contact transitioned from open to closed).
On failure, throws an exception or returns Y_LASTTIMEPRESSED_INVALID.
Definition at line 449 of file yocto_anbutton.cpp.
s64 YAnButton::get_lastTimeReleased | ( | void | ) |
Returns the number of elapsed milliseconds between the module power on and the last time the input button was released (the input contact transitioned from closed to open).
On failure, throws an exception or returns Y_LASTTIMERELEASED_INVALID.
Definition at line 481 of file yocto_anbutton.cpp.
s64 YAnButton::get_pulseCounter | ( | void | ) |
Returns the pulse counter value. The value is a 32 bit integer. In case of overflow (>=2^32), the counter will wrap. To reset the counter, just call the resetCounter() method.
On failure, throws an exception or returns Y_PULSECOUNTER_INVALID.
Definition at line 512 of file yocto_anbutton.cpp.
s64 YAnButton::get_pulseTimer | ( | void | ) |
Returns the timer of the pulses counter (ms).
On failure, throws an exception or returns Y_PULSETIMER_INVALID.
Definition at line 557 of file yocto_anbutton.cpp.
int YAnButton::get_rawValue | ( | void | ) |
Returns the current measured input value as-is (between 0 and 4095, included).
On failure, throws an exception or returns Y_RAWVALUE_INVALID.
Definition at line 153 of file yocto_anbutton.cpp.
int YAnButton::get_sensitivity | ( | void | ) |
Returns the sensibility for the input (between 1 and 1000) for triggering user callbacks.
On failure, throws an exception or returns Y_SENSITIVITY_INVALID.
Definition at line 356 of file yocto_anbutton.cpp.
|
inline |
Definition at line 296 of file yocto_anbutton.h.
|
inline |
Definition at line 311 of file yocto_anbutton.h.
|
inline |
Definition at line 326 of file yocto_anbutton.h.
|
inline |
Definition at line 425 of file yocto_anbutton.h.
YAnButton * YAnButton::nextAnButton | ( | void | ) |
Continues the enumeration of analog inputs started using yFirstAnButton().
Definition at line 679 of file yocto_anbutton.cpp.
|
inline |
Definition at line 340 of file yocto_anbutton.h.
|
inline |
Definition at line 356 of file yocto_anbutton.h.
|
inline |
Definition at line 165 of file yocto_anbutton.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 638 of file yocto_anbutton.cpp.
|
virtual |
Returns the pulse counter value as well as its timer.
On failure, throws an exception or returns a negative error code.
Definition at line 674 of file yocto_anbutton.cpp.
|
inline |
Definition at line 264 of file yocto_anbutton.h.
int YAnButton::set_analogCalibration | ( | Y_ANALOGCALIBRATION_enum | newval | ) |
Starts or stops the calibration process. Remember to call the saveToFlash() method of the module at the end of the calibration if the modification must be kept.
newval | : either Y_ANALOGCALIBRATION_OFF or Y_ANALOGCALIBRATION_ON |
On failure, throws an exception or returns a negative error code.
Definition at line 214 of file yocto_anbutton.cpp.
int YAnButton::set_calibrationMax | ( | int | newval | ) |
Changes the maximal calibration value for the input (between 0 and 4095, included), without actually starting the automated calibration. Remember to call the saveToFlash() method of the module if the modification must be kept.
newval | : an integer corresponding to the maximal calibration value for the input (between 0 and 4095, included), without actually starting the automated calibration |
On failure, throws an exception or returns a negative error code.
Definition at line 273 of file yocto_anbutton.cpp.
int YAnButton::set_calibrationMin | ( | int | newval | ) |
Changes the minimal calibration value for the input (between 0 and 4095, included), without actually starting the automated calibration. Remember to call the saveToFlash() method of the module if the modification must be kept.
newval | : an integer corresponding to the minimal calibration value for the input (between 0 and 4095, included), without actually starting the automated calibration |
On failure, throws an exception or returns a negative error code.
Definition at line 332 of file yocto_anbutton.cpp.
int YAnButton::set_pulseCounter | ( | s64 | newval | ) |
Definition at line 534 of file yocto_anbutton.cpp.
int YAnButton::set_sensitivity | ( | int | newval | ) |
Changes the sensibility for the input (between 1 and 1000) for triggering user callbacks. The sensibility is used to filter variations around a fixed value, but does not preclude the transmission of events when the input value evolves constantly in the same direction. Special case: when the value 1000 is used, the callback will only be thrown when the logical state of the input switches from pressed to released and back. Remember to call the saveToFlash() method of the module if the modification must be kept.
newval | : an integer corresponding to the sensibility for the input (between 1 and 1000) for triggering user callbacks |
On failure, throws an exception or returns a negative error code.
Definition at line 393 of file yocto_anbutton.cpp.
|
inline |
Definition at line 191 of file yocto_anbutton.h.
|
inline |
Definition at line 221 of file yocto_anbutton.h.
|
inline |
Definition at line 251 of file yocto_anbutton.h.
|
inline |
Definition at line 344 of file yocto_anbutton.h.
|
inline |
Definition at line 283 of file yocto_anbutton.h.
|
friend |
Retrieves an analog input for a given identifier. The identifier can be specified using several formats:
This function does not require that the analog input is online at the time it is invoked. The returned object is nevertheless valid. Use the method YAnButton.isOnline() to test if the analog input is indeed online at a given time. In case of ambiguity when looking for an analog input 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 analog input |
Definition at line 475 of file yocto_anbutton.h.
|
friend |
Starts the enumeration of analog inputs currently accessible. Use the method YAnButton.nextAnButton() to iterate on next analog inputs.
Definition at line 486 of file yocto_anbutton.h.
|
protected |
Definition at line 103 of file yocto_anbutton.h.
|
protected |
Definition at line 101 of file yocto_anbutton.h.
|
protected |
Definition at line 104 of file yocto_anbutton.h.
|
protected |
Definition at line 105 of file yocto_anbutton.h.
|
protected |
Definition at line 107 of file yocto_anbutton.h.
|
protected |
Definition at line 108 of file yocto_anbutton.h.
|
protected |
Definition at line 109 of file yocto_anbutton.h.
|
protected |
Definition at line 110 of file yocto_anbutton.h.
|
protected |
Definition at line 111 of file yocto_anbutton.h.
|
protected |
Definition at line 102 of file yocto_anbutton.h.
|
protected |
Definition at line 106 of file yocto_anbutton.h.
|
protected |
Definition at line 112 of file yocto_anbutton.h.
|
static |
Definition at line 132 of file yocto_anbutton.h.
|
static |
Definition at line 130 of file yocto_anbutton.h.
|
static |
Definition at line 131 of file yocto_anbutton.h.
|
static |
Definition at line 128 of file yocto_anbutton.h.
|
static |
Definition at line 133 of file yocto_anbutton.h.
|
static |
Definition at line 134 of file yocto_anbutton.h.
|
static |
Definition at line 136 of file yocto_anbutton.h.
|
static |
Definition at line 138 of file yocto_anbutton.h.
|
static |
Definition at line 137 of file yocto_anbutton.h.
|
static |
Definition at line 139 of file yocto_anbutton.h.
|
static |
Definition at line 140 of file yocto_anbutton.h.
|
static |
Definition at line 141 of file yocto_anbutton.h.
|
static |
Definition at line 142 of file yocto_anbutton.h.
|
static |
Definition at line 129 of file yocto_anbutton.h.
|
static |
Definition at line 135 of file yocto_anbutton.h.