1 package lejos.nxt.remote;
\r
3 import lejos.nxt.comm.*;
\r
7 * Battery readings from a remote NXT.
\r
9 public class RemoteBattery implements NXTProtocol {
\r
11 private NXTCommand nxtCommand;
\r
13 public RemoteBattery(NXTCommand nxtCommand) {
\r
14 this.nxtCommand = nxtCommand;
\r
18 * The NXT uses 6 batteries of 1500 mV each.
\r
19 * @return Battery voltage in mV. ~9000 = full.
\r
21 public int getVoltageMilliVolt() {
\r
23 * calculation from LEGO firmware
\r
26 return nxtCommand.getBatteryLevel();
\r
27 } catch (IOException ioe) {
\r
33 * The NXT uses 6 batteries of 1.5 V each.
\r
34 * @return Battery voltage in Volt. ~9V = full.
\r
36 public float getVoltage() {
\r
37 return (float)(getVoltageMilliVolt() * 0.001);
\r