HapticLib
0.7
Haptic Feedback Library for embedded systems
|
Constant Pattern generator function definition More...
#include "hapticLib.h"
Go to the source code of this file.
Functions | |
uint8_t | constantContinuator (pattern_desc *pattern) |
Pattern generator continuator | |
uint8_t | constantPatternGenerator (pattern_desc *pattern) |
Pattern generator initiator |
Constant Pattern generator function definition
Constant Pattern can be used to shake haptors providing the shaking magnitude.
Simply a on/off pattern.
Link to optional tools used on pattern development.
No other tools needed.
User must provide a constant value from 0 to 65000:
... //start one haptor shaking @ 35000 haptor_desc *myHaptor = hl_configure(24000000,15,1); user_param myParams; // param must use struct of user_param_t type myParams.constant.constant = 35000; pattern_desc *myConstantPattern = hl_initPattern(Constant,&myParams); hl_addHaptor(myHaptor,myConstantPattern); hl_startPattern(myConstantPattern); ... hl_stopPattern(myConstantPattern); ...
Parameters can't be NULL. It NULL is passed return an error. If HL_DEBUG symbol defined a "NULL found" string will sent to UART.
The constant
parameter can be used to change the duty-cycle even after the pattern has started! At ever continuator pass, it will poll the actual value of the user parameter constant
and update the duty-cycle accordingly.
Definition in file constant.c.
uint8_t constantContinuator | ( | pattern_desc * | pattern | ) |
Pattern generator continuator
This function is called back from the patternScheduler() every SystemDesc.samples_delay ms.
At every call, this continuator will decide what to do.
For a simple and static pattern, the action could be to simply point to the next element of an array of samples, or to generate it on the fly through a certain formula.
For more complex scenarios, this pattern continuator callback should be able to deliver a good degree of flexibility.
[out] | pattern | A pattern_desc* holding the reference to the running pattern instance to work with. Through this reference, the continuator can extract the user and status parameters in order to execute the haptic pattern. |
0 | Success |
1 | Error |
Definition at line 127 of file constant.c.
uint8_t constantPatternGenerator | ( | pattern_desc * | pattern | ) |
Pattern generator initiator
This function is called by the User API Module of HapticLib, when the library user calls hl_startPattern().
The first task for the pattern generator initiator is to validate the user provided inputs, this cannot be done anywhere else.
This pattern initiator then sets up all the status parameters.
If the pattern accept user parameters, the status setting can be based on the user provided parameters.
The last duty of this function is to put the pattern continuator up for scheduling ( setting pattern->continuator =
&constantContinuator;
), so the next time patternScheduler() will check for active patterns, it will find this pattern.
[out] | pattern | A pattern_desc* holding the running instance of the pattern being started. |
0 | Success |
1 | Error |
Definition at line 184 of file constant.c.