• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /******************************************************************************
2  * $Id: AKFS_Disp.c 580 2012-03-29 09:56:21Z yamada.rj $
3  ******************************************************************************
4  *
5  * Copyright (C) 2012 Asahi Kasei Microdevices Corporation, Japan
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 #include "AKFS_Disp.h"
20 #include "AKFS_Common.h"
21 
22 /*!
23  Print startup message to Android Log daemon.
24  */
Disp_StartMessage(void)25 void Disp_StartMessage(void)
26 {
27 	ALOGI("AK8975 Daemon for Open Source v20120329.");
28 	ALOGI("Debug: %s", ((ENABLE_AKMDEBUG)?("ON"):("OFF")));
29 	ALOGI("Debug level: %d", DBG_LEVEL);
30 }
31 
32 /*!
33  Print ending message to Android Log daemon.
34  */
Disp_EndMessage(int ret)35 void Disp_EndMessage(int ret)
36 {
37 	ALOGI("AK8975 for Android end (%d).", ret);
38 }
39 
40 /*!
41  Print result
42  */
Disp_Result(int buf[YPR_DATA_SIZE])43 void Disp_Result(int buf[YPR_DATA_SIZE])
44 {
45 	AKMDEBUG(DBG_LEVEL1,
46 		"Flag=%d\n", buf[0]);
47 	AKMDEBUG(DBG_LEVEL1,
48 		"Acc(%d):%8.2f, %8.2f, %8.2f\n",
49 		buf[4], REVERT_ACC(buf[1]), REVERT_ACC(buf[2]), REVERT_ACC(buf[3]));
50 	AKMDEBUG(DBG_LEVEL1,
51 		"Mag(%d):%8.2f, %8.2f, %8.2f\n",
52 		buf[8], REVERT_MAG(buf[5]), REVERT_MAG(buf[6]), REVERT_MAG(buf[7]));
53 	AKMDEBUG(DBG_LEVEL1,
54 		"Ori(%d)=%8.2f, %8.2f, %8.2f\n",
55 		buf[8], REVERT_ORI(buf[9]), REVERT_ORI(buf[10]), REVERT_ORI(buf[11]));
56 }
57 
58 /*!
59  Output main menu to stdout and wait for user input from stdin.
60  @return Selected mode.
61  */
Menu_Main(void)62 MODE Menu_Main(void)
63 {
64 	char msg[20];
65 	memset(msg, 0, sizeof(msg));
66 
67 	AKMDEBUG(DBG_LEVEL1,
68 	" --------------------  AK8975 Console Application -------------------- \n"
69 	"   1. Start measurement. \n"
70 	"   2. Self-test. \n"
71 	"   Q. Quit application. \n"
72 	" --------------------------------------------------------------------- \n"
73 	" Please select a number.\n"
74 	"   ---> ");
75 	fgets(msg, 10, stdin);
76 	AKMDEBUG(DBG_LEVEL1, "\n");
77 
78 	/* BUG : If 2-digits number is input, */
79 	/*    only the first character is compared. */
80 	if (!strncmp(msg, "1", 1)) {
81 		return MODE_Measure;
82 	} else if (!strncmp(msg, "2", 1)) {
83 		return MODE_SelfTest;
84 	} else if (strncmp(msg, "Q", 1) == 0 || strncmp(msg, "q", 1) == 0) {
85 		return MODE_Quit;
86 	} else {
87 		return MODE_ERROR;
88 	}
89 }
90 
91