HapticLib
0.7
Haptic Feedback Library for embedded systems
|
Test Pattern generator function definition More...
#include "hapticLib.h"
Go to the source code of this file.
Functions | |
uint8_t | testContinuator (pattern_desc *pattern) |
Test Pattern generator continuator | |
uint8_t | testPatternGenerator (pattern_desc *pattern) |
Test Pattern generator initiator |
Test Pattern generator function definition
Implementation code of the Test Pattern.
This pattern reproduce two linear ramp from 0% to 100% duty-cycle.
Simple pattern with sawtooth profile.
No optional parameters.
Here is a typical usage scenario for the Test Pattern:
... haptor_desc *myHaptor = hl_configure(24000000,15,1); pattern_desc *myTestPattern = hl_initPattern(Test,NULL); hl_addHaptor(myHaptor, myTestPattern); hl_startPattern(myTestPattern); ...
A condensed version of the same code is the follow:
... haptor_desc *myHaptor = hl_configure(24000000,15,1); hl_startPattern(hl_addHaptor(myHaptor, hl_initPattern(Test,NULL) ) ); ...
testPatternGenerator doesn't need optional parameter, just pass a NULL. If any are passed, an error occurs and if HL_DEBUG is defined this error will be sent on UART.
No additional notes.
Definition in file test.c.
uint8_t testContinuator | ( | pattern_desc * | pattern | ) |
Test Pattern generator continuator
This function is called back from the SysTick_Handler every SystemDesc.samples_delay ms.
At every call, this continuator will calculate the next value of PWM duty-cycle.
After two positive ramps the pattern is finished and remove itself from the scheduling patterns.
uint8_t testPatternGenerator | ( | pattern_desc * | pattern | ) |
Test Pattern generator initiator
This function is called by the User API Module of HapticLib, when the library user calls hl_sendPattern().
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 =
&testContinuator;
), so the next time patternScheduler() will check for active patterns, it will find this pattern.
[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 |