7
7
*/
8
8
9
9
#include <main.h>
10
+ #include <interfaces/event.h>
10
11
#include "app.h"
11
12
12
13
#define MODULE_NAME "hmi"
@@ -47,10 +48,17 @@ static void com_task(void *p) {
47
48
static void input_task (void * p ) {
48
49
App * self = p ;
49
50
50
-
51
51
while (true) {
52
-
53
- vTaskDelay (1000 );
52
+ enum event_type type = EV_TYPE_NONE ;
53
+ enum event_code code = EV_CODE_NONE ;
54
+ int32_t value = 0 ;
55
+
56
+ if (self -> input -> vmt -> listen (self -> input , & type , & code , & value ) == EV_RET_OK ) {
57
+ if (value == 1 ) {
58
+ /* On key down. */
59
+ self -> speaker -> vmt -> start (self -> speaker );
60
+ }
61
+ }
54
62
}
55
63
vTaskDelete (NULL );
56
64
}
@@ -72,6 +80,19 @@ app_ret_t app_init(App *self) {
72
80
return APP_RET_FAILED ;
73
81
}
74
82
83
+ /** @todo configure which input device to use. */
84
+ self -> input = NULL ;
85
+ if (iservicelocator_query_type_id (locator , ISERVICELOCATOR_TYPE_EVENT , 0 , (Interface * * )& self -> input ) != ISERVICELOCATOR_RET_OK ) {
86
+ u_log (system_log , LOG_TYPE_ERROR , U_LOG_MODULE_PREFIX ("no suitable input device found" ));
87
+ return APP_RET_FAILED ;
88
+ }
89
+
90
+ self -> speaker = NULL ;
91
+ if (iservicelocator_query_type_id (locator , ISERVICELOCATOR_TYPE_WAVEFORM_SINK , 0 , (Interface * * )& self -> speaker ) != ISERVICELOCATOR_RET_OK ) {
92
+ u_log (system_log , LOG_TYPE_ERROR , U_LOG_MODULE_PREFIX ("no suitable speaker found" ));
93
+ return APP_RET_FAILED ;
94
+ }
95
+
75
96
xTaskCreate (com_task , "hmi-com" , configMINIMAL_STACK_SIZE + 256 , (void * )self , 1 , & (self -> com_task ));
76
97
if (self -> com_task == NULL ) {
77
98
u_log (system_log , LOG_TYPE_ERROR , U_LOG_MODULE_PREFIX ("cannot create application com task" ));
0 commit comments