-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvibrator_test.c
More file actions
771 lines (682 loc) · 23.1 KB
/
vibrator_test.c
File metadata and controls
771 lines (682 loc) · 23.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
/****************************************************************************
* Copyright (C) 2023 Xiaomi Corperation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <errno.h>
#include <inttypes.h>
#include <kvdb.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#ifdef CONFIG_VIBRATOR_UV_API
#include <uv.h>
#endif
#include <vibrator_api.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#define VIBRATOR_TEST_DEFAULT_AMPLITUDE 255
#define VIBRATOR_TEST_DEFAULT_INTENSITY 2
#define VIBRATOR_TEST_DEFAULT_EFFECT_ID 5
#define VIBRATOR_TEST_DEFAULT_TIME 3000
#define VIBRATOR_TEST_DEFAULT_REPEAT -1
#define VIBRATOR_TEST_DEFAULT_API 1
#define VIBRATOR_TEST_DEFAULT_STRENGTH 2
#define VIBRATOR_TEST_WAVEFORM_MAX 7
#define VIBRATOR_TEST_COMPOSE_MAX 4
#define VIBRATOR_TEST_DEFAULT_INTERVAL 1000
#define VIBRATOR_TEST_DEFAULT_COUNT 5
#define VIBRATOR_TEST_DEFAULT_DISABLED false
/****************************************************************************
* Private Types
****************************************************************************/
struct waveform_arrays_s {
uint32_t* timings;
uint8_t* amplitudes;
uint8_t length;
};
struct compose_arrays_s {
vibrator_composite_effect_t* composite_effects;
uint8_t length;
};
struct vibrator_test_s {
int api;
int time;
int amplitude;
int intensity;
int effectid;
int es;
int repeat;
int waveformid;
int composeid;
int interval;
int count;
int disable;
struct waveform_arrays_s waveform_args[VIBRATOR_TEST_WAVEFORM_MAX];
struct compose_arrays_s compose_args[VIBRATOR_TEST_COMPOSE_MAX];
};
enum vibrator_test_apino_e {
VIBRATOR_TEST_OENSHOT = 1,
VIBRATOR_TEST_WAVEFORM,
VIBRATOR_TEST_PREDEFINED,
VIBRATOR_TEST_PRIMITIVE,
VIBRATOR_TEST_SETAMPLITUDE,
VIBRATOR_TEST_START,
VIBRATOR_TEST_CANCEL,
VIBRATOR_TEST_GETCAPABILITIES,
VIBRATOR_TEST_SETINTENSITY,
VIBRATOR_TEST_GETINTENSITY,
VIBRATOR_TEST_INTERVAL,
VIBRATOR_TEST_CALIBRATE,
VIBRATOR_TEST_SET_CALIBVALUE,
VIBRATOR_TEST_COMPOSE,
VIBRATOR_TEST_SET_DISABLE,
VIBRATOR_TEST_IS_DISABLED,
VIBRATOR_TEST_GETDURATION,
VIBRATOR_TEST_CONTROL,
#ifdef CONFIG_VIBRATOR_UV_API
VIBRATOR_TEST_LONG_CONNECT
#endif
};
/****************************************************************************
* Private Functions
****************************************************************************/
static void usage(void)
{
printf("Utility to test vibrator API.\n"
"Usage: vibrator_test [arguments...] <apino>\n"
"\t<apino> Which api to be tested\n"
"\tArguments:\n"
"\t[-h ] Commands help\n"
"\t[-t <val> ] The number of milliseconds to vibrate, default: 3000\n"
"\t[-a <val> ] The amplitude of vibration, [0,255], default: 255\n"
"\t[-e <val> ] Effect id, default: 5\n"
"\t[-r <val> ] The index into the timings array at which to repeat,\n"
"\t -1 means no repeat, default: -1\n"
"\t[-i <val> ] The intensity of vibration[0,3], default: 2\n"
"\t[-s <val> ] The effect strength, [0, 2], default: 2\n"
"\t[-l <val> ] The waveform array id, [0, 6], default: 0\n"
"\t[-p <val> ] The compose array id, [0, 3], default: 0\n"
"\t[-d <val> ] The interval of vibration in milliseconds, default: 1000\n"
"\t[-c <val> ] The count of vibration, default: 5\n"
"\t[-b <val> ] The disabled flag, [0, 1] default: false\n");
}
static int test_play_predefined(uint8_t id, vibrator_effect_strength_e es)
{
int32_t play_length_ms;
int ret;
printf("id = %d, es = %d\n", id, es);
ret = vibrator_play_predefined(id, es, &play_length_ms);
printf("Effect(with strength) play length: %" PRIi32 "\n", play_length_ms);
return ret;
}
static int test_paly_waveform(int repeat, struct waveform_arrays_s waveform_args)
{
printf("repeat = %d, length = %d\n", repeat, waveform_args.length);
return vibrator_play_waveform(waveform_args.timings,
waveform_args.amplitudes, repeat, waveform_args.length);
}
static int test_play_interval(int duration, int interval, int count)
{
return vibrator_play_interval(duration, interval, count);
}
static int test_play_primitive(uint8_t id, uint16_t amplitude)
{
int32_t play_length_ms;
int ret;
float amplitude_f = (float)amplitude / 255.0;
ret = vibrator_play_primitive(id, amplitude_f, &play_length_ms);
printf("Effect(with amplitude) play length: %" PRIi32 "\n", play_length_ms);
return ret;
}
static int test_play_compose(int repeat, struct compose_arrays_s compose_args)
{
int ret;
ret = vibrator_play_compose(compose_args.composite_effects, repeat, compose_args.length);
// sleep(6);
printf("Play compose done: ret = %d\n", ret);
return ret;
}
static int test_get_intensity(void)
{
vibrator_intensity_e intensity;
int ret;
ret = vibrator_get_intensity(&intensity);
if (ret >= 0)
printf("vibrator server reporting current intensity: %d\n", intensity);
return ret;
}
static int test_is_disabled(void)
{
uint8_t disabled;
int ret;
ret = vibrator_is_disabled(&disabled);
if (ret >= 0)
printf("vibrator server reporting disabled: %d\n", disabled);
return ret;
}
static int test_set_disable(bool disable)
{
int ret;
ret = vibrator_set_disable(disable);
if (ret >= 0)
printf("vibrator server set disable: %d\n", disable);
return ret;
}
static int test_get_capabilities(void)
{
int32_t capabilities;
int ret;
ret = vibrator_get_capabilities(&capabilities);
if (ret < 0)
return ret;
printf("vibrator server reporting capalities: %" PRIi32 "\n", capabilities);
return ret;
}
static int test_calibrate(void)
{
uint8_t value[32] = { 0 };
char value_fmt[32] = { 0 };
uint8_t calib_finish = 0;
int* calib_value = (int*)value;
int ret;
ret = vibrator_calibrate(value);
if (ret >= 0) {
calib_finish = 1;
printf("vibrator calibrate finished calibrate value: ");
for (int i = 0; i < sizeof(value); i++) {
printf("%02x ", value[i]);
}
printf("\n");
}
sprintf(value_fmt, "%d,%d", calib_finish, calib_value[0]);
printf("calib_value[0]: %d, value_fmt: %s\n", calib_value[0], value_fmt);
property_set("calibvalue.testkey", (char*)value_fmt);
return ret;
}
static int test_set_calibvalue(void)
{
uint8_t value[PROP_VALUE_MAX] = { 0 };
int ret;
ret = property_get("calibvalue.testkey", (char*)value, "no_value");
printf("calibvalue.testkey: %s\n", value);
if (ret < 0 || strcmp((char*)value, "no_value") == 0) {
printf("get vibrator calib failed, errno = %d", errno);
return -1;
}
return vibrator_set_calibvalue(value);
}
static int test_control(void)
{
int ret;
uint32_t cmd = 0x1122;
uint8_t arg[1] = { 0 };
ret = vibrator_control(cmd, arg, sizeof(arg));
if (ret < 0) {
printf("vibrator_control failed: %d\n", ret);
} else {
printf("vibrator_control success: %d\n", ret);
}
return ret;
}
static int test_get_primitive_duration(int effectid)
{
int32_t duration;
int ret;
ret = vibrator_get_primitive_duration(effectid, &duration);
if (ret >= 0)
printf("Effectid %d play length: %" PRIi32 "\n", effectid, duration);
return ret;
}
#ifdef CONFIG_VIBRATOR_UV_API
static void on_playpredefined(void* handle, void* cookie, void* arg, int ret)
{
uint32_t* length = arg;
printf("on_playpredefined ret = %d, length = %" PRIu32 "\n", ret, *length);
vibrator_uv_disconnect(handle);
return;
}
static void on_open(void* handle, void* cookie, void* arg, int ret)
{
struct vibrator_test_s* test_data = cookie;
int32_t duration = 0;
printf("on_open status = %d\n", ret);
ret = vibrator_get_primitive_duration(test_data->effectid, &duration);
if (ret >= 0) {
printf("Effectid %d play length: %" PRIi32 "\n", test_data->effectid, duration);
} else {
printf("get effectid %d duration failed, ret = %d\n", test_data->effectid, ret);
}
ret = vibrator_uv_play_predefined(handle, test_data->effectid, test_data->es, on_playpredefined);
if (ret < 0) {
printf("play predefined effect failed, ret = %d\n", ret);
return;
}
}
static int test_long_connection_case(struct vibrator_test_s* test_data)
{
uv_loop_t* loop = uv_default_loop();
void* handle;
handle = vibrator_uv_connect(on_open, test_data);
if (handle == NULL) {
printf("open vibrator failed, errno = %d", errno);
return -1;
}
uv_run(loop, UV_RUN_DEFAULT);
printf("uv_run done\n");
uv_loop_close(loop);
return 0;
}
#endif
static int param_parse(int argc, char* argv[],
struct vibrator_test_s* test_data)
{
const char* apino;
int ch;
while ((ch = getopt(argc, argv, "t:a:e:r:i:s:l:p:d:c:h")) != EOF) {
switch (ch) {
case 't': {
printf("%s\n", optarg);
test_data->time = atoi(optarg);
printf("%d\n", test_data->time);
if (test_data->time < 0)
printf("NOTE: Invalid time, use positive integer\n");
break;
}
case 'a': {
test_data->amplitude = atoi(optarg);
if (test_data->amplitude < 0 || test_data->amplitude > 255)
printf("NOTE: amplitude should be in range [0,255]\n");
break;
}
case 'e': {
test_data->effectid = atoi(optarg);
if (test_data->effectid < 0)
printf("NOTE: effect id should be non-negative\n");
break;
}
case 'r': {
test_data->repeat = atoi(optarg);
printf("test_data->repeat = %d\n", test_data->repeat);
if (test_data->repeat < -1)
printf("NOTE: Invalid repeat, use -1 to disable \
repeat or index of timings array\n");
break;
}
case 'i': {
test_data->intensity = atoi(optarg);
if (test_data->intensity < VIBRATION_INTENSITY_LOW
|| test_data->intensity > VIBRATION_INTENSITY_HIGH)
printf("NOTE: Invalid intensity, use 0, 1, 2, 3\n");
break;
}
case 's': {
test_data->es = atoi(optarg);
if (test_data->es < VIBRATION_LIGHT
|| test_data->es > VIBRATION_STRONG)
printf("NOTE: Invalid effect strength, use 0, 1, 2\n");
break;
}
case 'l': {
test_data->waveformid = atoi(optarg);
printf("test_data->waveformid = %d\n", test_data->waveformid);
if (test_data->waveformid < 0
|| test_data->waveformid >= VIBRATOR_TEST_WAVEFORM_MAX) {
printf("NOTE: Invalid waveform id, use 0 to 6\n");
return -1;
}
break;
}
case 'p': {
test_data->composeid = atoi(optarg);
printf("test_data->composeid = %d\n", test_data->composeid);
if (test_data->composeid < 0
|| test_data->composeid >= VIBRATOR_TEST_COMPOSE_MAX) {
printf("NOTE: Invalid compose id, use 0 to 3\n");
return -1;
}
break;
}
case 'd': {
test_data->interval = atoi(optarg);
printf("test_data->interval = %d\n", test_data->interval);
if (test_data->interval < 0) {
printf("NOTE: Invalid interval, use non-negative value\n");
}
break;
}
case 'c': {
test_data->count = atoi(optarg);
printf("test_data->count = %d\n", test_data->count);
if (test_data->count < 0) {
printf("NOTE: Invalid count, use non-negative value\n");
}
break;
}
case 'b': {
test_data->disable = atoi(optarg);
printf("test_data->disable = %d\n", test_data->disable);
break;
}
case 'h':
default: {
return -1;
}
}
}
if (optind < argc) {
apino = argv[optind];
test_data->api = atoi(apino);
printf("cmd = %s, apino = %d\n", apino, test_data->api);
}
return 0;
}
static int do_vibrator_test(struct vibrator_test_s* test_data)
{
int ret;
switch (test_data->api) {
case VIBRATOR_TEST_OENSHOT:
printf("API TEST: vibrator_play_oneshot\n");
ret = vibrator_play_oneshot(test_data->time, test_data->amplitude);
if (ret < 0) {
printf("play_oneshot failed: %d\n", ret);
return ret;
}
break;
case VIBRATOR_TEST_WAVEFORM:
printf("API TEST: vibrator_play_waveform, id = %d\n", test_data->waveformid);
ret = test_paly_waveform(test_data->repeat, test_data->waveform_args[test_data->waveformid]);
if (ret < 0) {
printf("play_waveform failed: %d\n", ret);
return ret;
}
break;
case VIBRATOR_TEST_PREDEFINED:
printf("API TEST: vibrator_play_predefined\n");
ret = test_play_predefined(test_data->effectid, test_data->es);
if (ret < 0) {
printf("play_predefined failed: %d\n", ret);
return ret;
}
break;
case VIBRATOR_TEST_PRIMITIVE:
printf("API TEST: test_play_primitive\n");
ret = test_play_primitive(test_data->effectid, test_data->amplitude);
if (ret < 0) {
printf("play_predefined failed: %d\n", ret);
return ret;
}
break;
case VIBRATOR_TEST_COMPOSE:
printf("API TEST: vibrator_play_compose\n");
ret = test_play_compose(test_data->repeat, test_data->compose_args[test_data->composeid]);
if (ret < 0) {
printf("play_compose failed: %d\n", ret);
return ret;
}
break;
case VIBRATOR_TEST_SETAMPLITUDE:
printf("API TEST: vibrator_set_amplitude\n");
ret = vibrator_set_amplitude(test_data->amplitude);
if (ret < 0) {
printf("set_amplitude failed: %d\n", ret);
return ret;
}
break;
case VIBRATOR_TEST_START:
printf("API TEST: vibrator_start\n");
ret = vibrator_start(test_data->time);
if (ret < 0) {
printf("start failed: %d\n", ret);
return ret;
}
break;
case VIBRATOR_TEST_CANCEL:
printf("API TEST: vibrator_cancel\n");
ret = vibrator_cancel();
if (ret < 0) {
printf("cancel failed: %d\n", ret);
return ret;
}
break;
case VIBRATOR_TEST_GETCAPABILITIES:
printf("API TEST: vibrator_get_capabilities\n");
ret = test_get_capabilities();
if (ret < 0) {
printf("get_capabilities failed: %d\n", ret);
return ret;
}
break;
case VIBRATOR_TEST_SETINTENSITY:
printf("API TEST: vibrator_set_intensity\n");
ret = vibrator_set_intensity(test_data->intensity);
if (ret < 0) {
printf("set_intensity failed: %d\n", ret);
return ret;
}
break;
case VIBRATOR_TEST_GETINTENSITY:
printf("API TEST: vibrator_get_intensity\n");
ret = test_get_intensity();
if (ret < 0) {
printf("get_intensity failed: %d\n", ret);
return ret;
}
break;
case VIBRATOR_TEST_SET_DISABLE:
printf("API TEST: vibrator_set_disable\n");
ret = test_set_disable(test_data->disable);
if (ret < 0) {
printf("set_disable failed: %d\n", ret);
return ret;
}
break;
case VIBRATOR_TEST_IS_DISABLED:
printf("API TEST: vibrator_is_disabled\n");
ret = test_is_disabled();
if (ret < 0) {
printf("is_disabled failed: %d\n", ret);
return ret;
}
break;
case VIBRATOR_TEST_INTERVAL:
printf("API TEST: vibrator_play_interval\n");
ret = test_play_interval(test_data->time, test_data->interval, test_data->count);
if (ret < 0) {
printf("play_interval failed: %d\n", ret);
return ret;
}
break;
case VIBRATOR_TEST_CALIBRATE:
printf("API TEST: vibrator_calibrate\n");
ret = test_calibrate();
if (ret < 0) {
printf("calibrate failed: %d\n", ret);
return ret;
}
break;
case VIBRATOR_TEST_SET_CALIBVALUE:
printf("API TEST: vibrator_set_calibvalue\n");
ret = test_set_calibvalue();
if (ret < 0) {
printf("set_calibvalue failed: %d\n", ret);
return ret;
}
break;
case VIBRATOR_TEST_GETDURATION:
printf("API TEST: vibrator_get_primitive_duration\n");
ret = test_get_primitive_duration(test_data->effectid);
if (ret < 0) {
printf("get_primitive_duration failed: %d\n", ret);
return ret;
}
break;
case VIBRATOR_TEST_CONTROL:
printf("API TEST: vibrator_control\n");
ret = test_control();
if (ret < 0) {
printf("vibrator_control failed: %d\n", ret);
return ret;
}
break;
#ifdef CONFIG_VIBRATOR_UV_API
case VIBRATOR_TEST_LONG_CONNECT:
printf("API TEST: vibrator_under_long_connection\n");
ret = test_long_connection_case(test_data);
if (ret < 0) {
printf("vibrator_under_long_connection failed: %d\n", ret);
return ret;
}
break;
#endif
default:
printf("arg out of range\n");
break;
}
printf("PASSED\n");
return 0;
}
static void waveform_args_init(struct vibrator_test_s* test_data)
{
static uint32_t timings0[] = { 100, 100, 100, 100 };
static uint8_t amplitudes0[] = { 51, 0, 51, 0 };
static uint32_t timings1[] = { 200, 100, 0, 100, 200, 100, 1, 100, 200, 100, 200 };
static uint8_t amplitudes1[] = { 255, 0, 153, 0, 102, 0, 255, 0, 153, 0, 102 };
static uint32_t timings2[] = { 100, 100, 100, 100 };
static uint8_t amplitudes2[] = { 255, 0, 102, 0 };
static uint32_t timings3[] = { 200, 100, 200, 100 };
static uint8_t amplitudes3[] = { 255, 0, 51, 0 };
static uint32_t timings4[] = { 4294967295, 0 };
static uint8_t amplitudes4[] = { 255, 0 };
static uint32_t timings5[] = { 1000 };
static uint8_t amplitudes5[] = { 1 };
static uint32_t timings6[] = { 2000, 0, 0 };
static uint8_t amplitudes6[] = { 100, 0, 0 };
/* vaild waveform arrays */
test_data->waveform_args[0] = (struct waveform_arrays_s) { timings0, amplitudes0, 4 };
test_data->waveform_args[1] = (struct waveform_arrays_s) { timings1, amplitudes1, 11 };
/* invalid waveform arrays */
test_data->waveform_args[2] = (struct waveform_arrays_s) { timings2, amplitudes2, 10 };
test_data->waveform_args[3] = (struct waveform_arrays_s) { timings3, amplitudes3, 0 };
/* boundary waveform arrays */
test_data->waveform_args[4] = (struct waveform_arrays_s) { timings4, amplitudes4, 2 };
/* low amplitude waveform arrays */
test_data->waveform_args[5] = (struct waveform_arrays_s) { timings5, amplitudes5, 1 };
/* for -r invalid index test*/
test_data->waveform_args[6] = (struct waveform_arrays_s) { timings6, amplitudes6, 3 };
}
static void compose_args_init(struct vibrator_test_s* test_data)
{
static vibrator_composite_effect_t compose_effect1[] = {
{
.delay_ms = 0,
.primitive = 20,
.scale = 1,
},
{
.delay_ms = 0,
.primitive = 20,
.scale = 1,
}
};
static vibrator_composite_effect_t compose_effect2[] = {
{
.delay_ms = 0,
.primitive = 21,
.scale = 1,
},
{
.delay_ms = 0,
.primitive = 21,
.scale = 1,
}
};
static vibrator_composite_effect_t compose_effect3[] = {
{
.delay_ms = 0,
.primitive = 22,
.scale = 1,
}
};
static vibrator_composite_effect_t compose_effect4[] = {
{
.delay_ms = 0,
.primitive = 22,
.scale = 0.2,
},
{
.delay_ms = 0,
.primitive = 22,
.scale = 0.4,
},
{
.delay_ms = 0,
.primitive = 22,
.scale = 0.6,
},
{
.delay_ms = 0,
.primitive = 22,
.scale = 0.8,
},
{
.delay_ms = 0,
.primitive = 22,
.scale = 1,
},
};
test_data->compose_args[0] = (struct compose_arrays_s) { compose_effect1, 2 };
test_data->compose_args[1] = (struct compose_arrays_s) { compose_effect2, 2 };
test_data->compose_args[2] = (struct compose_arrays_s) { compose_effect3, 1 };
test_data->compose_args[3] = (struct compose_arrays_s) { compose_effect4, 5 };
}
/****************************************************************************
* Public Functions
****************************************************************************/
int main(int argc, char* argv[])
{
struct vibrator_test_s test_data;
/*Init test data using default value*/
test_data.intensity = VIBRATOR_TEST_DEFAULT_INTENSITY;
test_data.disable = VIBRATOR_TEST_DEFAULT_DISABLED;
test_data.amplitude = VIBRATOR_TEST_DEFAULT_AMPLITUDE;
test_data.effectid = VIBRATOR_TEST_DEFAULT_EFFECT_ID;
test_data.repeat = VIBRATOR_TEST_DEFAULT_REPEAT;
test_data.es = VIBRATOR_TEST_DEFAULT_STRENGTH;
test_data.time = VIBRATOR_TEST_DEFAULT_TIME;
test_data.api = VIBRATOR_TEST_DEFAULT_API;
test_data.interval = VIBRATOR_TEST_DEFAULT_TIME;
test_data.count = VIBRATOR_TEST_DEFAULT_COUNT;
/*Init waveform test arrays*/
waveform_args_init(&test_data);
test_data.waveformid = 0;
/* Init compose test arrays */
compose_args_init(&test_data);
test_data.composeid = 0;
/* Parse Argument */
if (param_parse(argc, argv, &test_data) < 0) {
goto error;
}
/* Do vibrator API test */
do_vibrator_test(&test_data);
return 0;
error:
usage();
return 1;
}