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
test.c
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2012, Leonardo Guardati <leonardo@guardati.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
*/
85
#include "
hapticLib.h
"
86
100
uint8_t
testContinuator
(
pattern_desc
*pattern)
101
{
102
103
/*
104
* Create a handy reference for statusParameters
105
* Note:
106
* - userParams data are not needed, so user MUST
107
* pass NULL, and **initiator** check for it.
108
* - statusParams data reside on SystemDesc variable.
109
*/
110
testStatusParameters
*statusParams = &pattern->
statusParams
.
test
;
111
112
if
( statusParams->
flag
== 0 )
113
{
114
if
( statusParams->
duty
> 64500 )
115
{
116
statusParams->
flag
= 1;
117
statusParams->
duty
= 0 ;
118
}
119
}
120
else
121
{
122
if
( statusParams->
duty
> 64500 )
123
{
124
// Ensure finish without vibrations
125
TIM_Channel_DutyChanger
( 0, pattern->
activeHaptorList
->
id
);
126
127
// Removing pattern from scheduling
128
// and freeing all the haptors
129
130
cleanList
(pattern->
activeHaptorList
);
131
pattern->
name
=
Null
;
132
pattern->
userParams
= NULL;
133
pattern->
continuator
= NULL;
134
pattern->
activeHaptorList
= NULL;
135
136
return
0;
137
}
138
}
139
140
statusParams->
duty
+= 650;
141
142
TIM_Channel_DutyChanger
( statusParams->
duty
, pattern->
activeHaptorList
->
id
);
143
144
return
0;
145
}
146
189
uint8_t
testPatternGenerator
(
pattern_desc
*pattern)
190
{
191
192
/*
193
* Create a handy reference for userParameters and statusParameters
194
* Note:
195
* - userParams data reside on the user program module. (main.c)
196
* - statusParams data reside on SystemDesc variable.
197
*/
198
testStatusParameters
*statusParams = &pattern->
statusParams
.
test
;
199
200
// No User Parameters check it is NULL
201
if
( pattern->
userParams
!= NULL )
202
{
203
#ifdef HL_DEBUG
204
send_string
(
"Test Pattern generator doesn't need optional \0"
);
205
send_string
(
"parameters. Please pass userParameters=NULL\r\n\0"
);
206
#endif
207
return
1;
208
}
209
210
/* Status initialization */
211
statusParams->
flag
= 0;
212
statusParams->
duty
= 0;
213
214
/* Ready to schedule the pattern */
215
pattern->
continuator
= &
testContinuator
;
216
217
return
0;
218
}
HapticLib
patterns
test
test.c
Generated on Thu Jan 31 2013 02:03:32 for HapticLib by
1.8.1.1