HapticLib
0.7
Haptic Feedback Library for embedded systems
|
Generic Pattern generator function definition [TEMPLATE] More...
#include "hapticLib.h"
Go to the source code of this file.
Macros | |
#define | HL_DEBUG |
Generator function Debugging Capabilities. |
Functions | |
uint8_t | genericContinuator (pattern_desc *pattern) |
Pattern generator continuator | |
uint8_t | genericPatternGenerator (pattern_desc *pattern) |
Pattern generator initiator |
Generic Pattern generator function definition [TEMPLATE]
[TEMPLATE]
This is a template file; copy and rename it as starting point for the implementation of a new Pattern Generator.
Follow the structure of this example pattern (code and documentation formats) while implementing a new pattern generator.
The initiator and the continuator need to be implemented and documented. First read the documentation and the code of both and the implement your own pattern code and document it.
mypattern.c
: Documentation, initiator and continuator.mypattern.h
: Pattern specific definitions, user and status parameters definitions[TEMPLATE]
Implementation code of the Generic Pattern.
Description with main features only mentioned.
Reference to theoretical documentation on which the pattern is based.
Link to optional tools used on pattern development.
Description of main results.
Detailed description of parameters needed and structure defined to contain them.
Parameters values ranges MUST be explained here.
Put some code snippets to illustrate how to use the pattern.
Explain (if any) the behavior of optional debugging features present inside the generator.
Add some optional notes.
Definition in file generic.c.
#define HL_DEBUG |
Generator function Debugging Capabilities.
The HapticLib Debugging Features are available on the pattern generator function too.
The Debugging Features are enabled based on the presence of the symbol HL_DEBUG.
The code must have conditional inclusion of debugging code.
... #ifdef HL_DEBUG ... send_string("Debug Message...\n\r\0"); ... #endif ...
uint8_t genericContinuator | ( | 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 |
uint8_t genericPatternGenerator | ( | 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.
The 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 =
&genericContinuator;
), 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 |