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
|
/******************************************************************************
*
* Copyright (C) 2012 Asahi Kasei Microdevices Corporation, Japan
*
* 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.
*
******************************************************************************/
#include "AKFS_Disp.h"
#include "AKFS_Common.h"
/*!
Print startup message to Android Log daemon.
*/
void Disp_StartMessage(void)
{
ALOGI("AK8975 Daemon for Open Source v20120329.");
ALOGI("Debug: %s", ((ENABLE_AKMDEBUG)?("ON"):("OFF")));
ALOGI("Debug level: %d", DBG_LEVEL);
}
/*!
Print ending message to Android Log daemon.
*/
void Disp_EndMessage(int ret)
{
ALOGI("AK8975 for Android end (%d).", ret);
}
/*!
Print result
*/
void Disp_Result(int buf[YPR_DATA_SIZE])
{
AKMDEBUG(DBG_LEVEL1,
"Flag=%d\n", buf[0]);
AKMDEBUG(DBG_LEVEL1,
"Acc(%d):%8.2f, %8.2f, %8.2f\n",
buf[4], REVERT_ACC(buf[1]), REVERT_ACC(buf[2]), REVERT_ACC(buf[3]));
AKMDEBUG(DBG_LEVEL1,
"Mag(%d):%8.2f, %8.2f, %8.2f\n",
buf[8], REVERT_MAG(buf[5]), REVERT_MAG(buf[6]), REVERT_MAG(buf[7]));
AKMDEBUG(DBG_LEVEL1,
"Ori(%d)=%8.2f, %8.2f, %8.2f\n",
buf[8], REVERT_ORI(buf[9]), REVERT_ORI(buf[10]), REVERT_ORI(buf[11]));
}
/*!
Output main menu to stdout and wait for user input from stdin.
@return Selected mode.
*/
MODE Menu_Main(void)
{
char msg[20];
memset(msg, 0, sizeof(msg));
AKMDEBUG(DBG_LEVEL1,
" -------------------- AK8975 Console Application -------------------- \n"
" 1. Start measurement. \n"
" 2. Self-test. \n"
" Q. Quit application. \n"
" --------------------------------------------------------------------- \n"
" Please select a number.\n"
" ---> ");
fgets(msg, 10, stdin);
AKMDEBUG(DBG_LEVEL1, "\n");
/* BUG : If 2-digits number is input, */
/* only the first character is compared. */
if (!strncmp(msg, "1", 1)) {
return MODE_Measure;
} else if (!strncmp(msg, "2", 1)) {
return MODE_SelfTest;
} else if (strncmp(msg, "Q", 1) == 0 || strncmp(msg, "q", 1) == 0) {
return MODE_Quit;
} else {
return MODE_ERROR;
}
}
|