1 /*
2 * Copyright 2007-2008 Volker Fritzsch
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package motej;
17
18 /**
19 * Status information as reported by the wiimote. Contains the currently lid
20 * LEDs, status of speaker, the battery level, if an extension is connected and
21 * if continuous reporting is enabled.
22 * <p>
23 *
24 * @author <a href="mailto:vfritzsch@users.sourceforge.net">Volker Fritzsch</a>
25 */
26 public class StatusInformationReport {
27
28 private boolean extensionControllerConnected;
29
30 private boolean speakerEnabled;
31
32 private boolean continuousReportingEnabled;
33
34 private boolean[] ledEnabled;
35
36 // fully charged might be 0xc8 (wiili.org)
37 private byte batteryLevel;
38
39 public StatusInformationReport(boolean[] ledEnabled,
40 boolean speakerEnabled, boolean continuousReportingEnabled,
41 boolean extensionControllerConnected, byte batteryLevel) {
42 this.ledEnabled = ledEnabled.clone();
43 this.speakerEnabled = speakerEnabled;
44 this.continuousReportingEnabled = continuousReportingEnabled;
45 this.extensionControllerConnected = extensionControllerConnected;
46 this.batteryLevel = batteryLevel;
47 }
48
49 /**
50 * The current battery level. Fully charged might be 0xc8 (see <a
51 * href="http://www.wiili.org/index.php/Wiimote#Batteries">www.wiili.org</a>).
52 *
53 * @return the battery level
54 */
55 public byte getBatteryLevel() {
56 return batteryLevel;
57 }
58
59 /**
60 * The currently lid LEDs
61 *
62 * @return enabled LEDs
63 */
64 public boolean[] getLedEnabled() {
65 return ledEnabled;
66 }
67
68 /**
69 * True, if continuous reporting is enabled.
70 *
71 * @return continuous reporting enabled
72 */
73 public boolean isContinuousReportingEnabled() {
74 return continuousReportingEnabled;
75 }
76
77 /**
78 * True, if an extension controller is connected.
79 *
80 * @return extension controller connected
81 */
82 public boolean isExtensionControllerConnected() {
83 return extensionControllerConnected;
84 }
85
86 /**
87 * True, if the speaker is enabled.
88 *
89 * @return speaker enabled
90 */
91 public boolean isSpeakerEnabled() {
92 return speakerEnabled;
93 }
94
95 @Override
96 public String toString() {
97 return "StatusInformation[BatteryLevel: " + batteryLevel
98 + ", ExtensionControllerConnected: "
99 + extensionControllerConnected + ", SpeakerEnabled: "
100 + speakerEnabled + ", ContinuousReportingEnabled: "
101 + continuousReportingEnabled + ", LedEnabled: {"
102 + ledEnabled[0] + ", " + ledEnabled[1] + ", " + ledEnabled[2]
103 + ", " + ledEnabled[3] + "}]";
104 }
105 }