HapticLib
0.7
Haptic Feedback Library for embedded systems
|
Pattern Generator Module definitions More...
#include "hapticLib.h"
Go to the source code of this file.
Macros | |
#define | HL_SYSTEM_FILE |
Used to indicate this module is a System one. |
Functions | |
uint8_t | genericPatternGenerator (pattern_desc *) |
Pattern generator initiator | |
uint8_t | testPatternGenerator (pattern_desc *) |
Test Pattern generator initiator | |
uint8_t | impactPatternGenerator (pattern_desc *) |
Pattern generator initiator | |
uint8_t | constantPatternGenerator (pattern_desc *) |
Pattern generator initiator | |
void | patternScheduler (void) |
Updates all the active patterns' progress. | |
void | cleanList (haptor_desc *haptor) |
Utility function to clean the pattern list of haptors. | |
uint16_t | dutyConverter (uint16_t duty, haptor_desc *haptor) |
Utility function to convert duty-cycles. |
Variables | |
system_desc | SystemDesc |
Global variable to describe the haptic system. | |
pattern_initiator | patternMap [Num_Patterns_Available] |
Pattern Generators Functions Map. |
Pattern Generator Module definitions
hl_patterns.c is part of the Pattern Generator Module of HapticLib.
This file lists of all the pattern generators initiators, and uses them to fill the patternMap array.
The technique used by HapticLib make it possible to decouple the User API Module and the Pattern Generator Module.
The User API Module only knows the signature of a generic pattern generator function (that is always the same) regardless of what the actual function will be.
Definition in file hl_patterns.c.
#define HL_SYSTEM_FILE |
Used to indicate this module is a System one.
Declaring this symbol, some internal data structures will be available to the module.
Definition at line 57 of file hl_patterns.c.
void cleanList | ( | haptor_desc * | haptor | ) |
Utility function to clean the pattern list of haptors.
This function holds the frequently used code to free the haptor list form the attached pattern.
[out] | haptor | The haptor_desc * hold by activeHaptorList inside pattern_desc structure. |
Definition at line 131 of file hl_patterns.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.
uint16_t dutyConverter | ( | uint16_t | duty, |
haptor_desc * | haptor | ||
) |
Utility function to convert duty-cycles.
Given the absolute duty-cycle (0-65535) and the haptor this function will return the actual duty cycle honoring min_duty and max_duty values of the haptor.
[in] | duty | A uint16_t value representing the absolute duty cycle. |
[out] | haptor | A haptor_desc * holding the reference to the haptor for which the duty has to be scaled. |
Definition at line 163 of file hl_patterns.c.
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 |
uint8_t impactPatternGenerator | ( | 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 =
&impactContinuator;
), 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 |
void patternScheduler | ( | void | ) |
Updates all the active patterns' progress.
patternScheduler() checks for all the patterns configured in the system. If the pattern is running, its continuator is called.
patternScheduler() is called by the Platform Specific Module ( for example in the STM32VLDISCOVERY platform, SysTick_Handler() is the caller).
Definition at line 100 of file hl_patterns.c.
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 |
pattern_initiator patternMap[Num_Patterns_Available] |
Pattern Generators Functions Map.
This array contains the addresses of all the pattern generator initiator functions.
The index of the array locate the specific pattern using one of the Pattern Generator Functions Index Names defined in the pattern_name enumeration type definition. (e.g. Test, Impact)
Definition at line 79 of file hl_patterns.c.
system_desc SystemDesc |
Global variable to describe the haptic system.
The Library uses this global variable to describe the system and to keep track of the haptic devices' status and active patterns' progress at any time.
The SystemDesc variable holds a lot of informations, and its members allow the system to access almost all the informations needed.
Definition at line 70 of file hapticLib.c.