HapticLib
0.7
Haptic Feedback Library for embedded systems
Main Page
Related Pages
Data Structures
Files
File List
Globals
All
Data Structures
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Pages
constant.c
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2012, Silvio Vallorani <silvio.vallorani@studio.unibo.it>
3
*
4
* Permission to use, copy, modify, and/or distribute this
5
* software for any purpose with or without fee is hereby
6
* granted, provided that the above copyright notice and this
7
* permission notice appear in all copies.
8
*
9
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS
10
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
11
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO
12
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
13
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
15
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
16
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE
17
* USE OR PERFORMANCE OF THIS SOFTWARE.
18
*
19
*/
91
#include "
hapticLib.h
"
92
127
uint8_t
constantContinuator
(
pattern_desc
*pattern)
128
{
129
130
/*
131
* Create a handy reference for userParameters and statusParameters
132
* Note:
133
* - userParams data reside on the user program module. (main.c)
134
* - statusParams data reside on SystemDesc variable.
135
*/
136
constantUserParameters
*userParams = &pattern->
userParams
->
constant
;
137
constantStatusParameters
*statusParams = &pattern->
statusParams
.
constant
;
138
139
statusParams->
duty
= userParams->
constant
;
140
141
TIM_Channel_DutyChanger
(
dutyConverter
(statusParams->
duty
, pattern->
activeHaptorList
), \
142
pattern->
activeHaptorList
->
id
);
143
144
return
0;
145
146
}
147
184
uint8_t
constantPatternGenerator
(
pattern_desc
*pattern)
185
{
186
/*
187
* Create a handy reference for userParameters
188
* and statusParameters
189
* Note:
190
* - userParams data reside on the user
191
* program module. (main.c)
192
* - statusParams data reside on SystemDesc
193
* variable.
194
*/
195
constantUserParameters
*userParams = &pattern->
userParams
->
constant
;
196
constantStatusParameters
*statusParams = &pattern->
statusParams
.
constant
;
197
198
199
// User Parameters Validation:
200
// Input validation must be made before attempting
201
// to use the provided parameters.
202
if
( userParams == NULL )
203
{
204
#ifdef HL_DEBUG
205
send_string
(
"constantPatternGenerator(): expecting optional Parameters, NULL found.\r\n\0"
);
206
#endif
207
return
1;
208
}
209
210
// Status initialization based on user provided parameters...
211
statusParams->
duty
= userParams->
constant
;
212
213
214
// Last duty: Set the continuator up for scheduling.
215
pattern->
continuator
= &
constantContinuator
;
216
217
return
0;
218
}
HapticLib
patterns
constant
constant.c
Generated on Thu Jan 31 2013 02:03:32 for HapticLib by
1.8.1.1