SunSPOT API V5.0


com.sun.spot.peripheral
Class Battery

java.lang.Object
  extended by com.sun.spot.peripheral.Battery
All Implemented Interfaces:
IBattery

public class Battery
extends Object
implements IBattery


Field Summary
 
Fields inherited from interface com.sun.spot.peripheral.IBattery
CHARGETIME, CHARGING, DEAD_BATTERY, DISCHARGING, EXT_POWERED, LOW_BATTERY, NO_BATTERY, OUT_OF_RANGE_TEMP, RUNTIME, SLEEPTIME
 
Constructor Summary
Battery(SpiPcs chipSelectPin, ISpiMaster spiMaster)
          Battery constructor for obtaining information about the SPOT rechargeable battery this can throw a RuntimeException if it is created with a pre-rev6 eSPOT or version earlier than PCTRL-1.99
 
Method Summary
 boolean calibrationCycleDetected()
          Returns true when the battery has been depleted to low battery and then charged fully.
 double getAvailableCapacity()
          Get the batteries remaining capacity in maHr.
 int getBatteryLevel()
          Battery level returns an integer indicating remaining capacity in percentage (0 is empty, 100 is fully charged)
 short getChargeCount()
          Return the number of times the SPOT has seen a full charge.
 double getMaximumCapacity()
          Get the batteries measured maximum capacity in maHr.
 String getModelNumber()
          Battery model must match battery used for accurate measurements.
 double getRatedCapacity()
          Returns rated capacity of the battery (as written on the label) .
 int getSleepCurrent()
          Sleepcurrent is microamps written to the SPOT for use in calculating sleep current.
 byte getState()
          The state of battery is returned.
 String getStateAsString(int state)
          The state of battery is returned as a string: no battery, dead battery, low battery, discharging, charging, fully charged
 long[] getTime()
          Battery time measurements of sleeping since last charge, running since last charge and length of charge time.
 boolean hasBattery()
          Attempts to detect the presence of the battery.
 boolean hasTemperatureSensor()
          Returns true if the SPOT has detected a temperature sensor.
 String rawBatteryData()
          All raw battery data as colon separated one entry per line string.
 void setSleepCurrent(int microamps)
          SetSleepcurrent writes the sleep current in ADC units to estimate how much power is being consumed while the SPOT is in deep sleep.
 void updatePersistantInfo()
          force write of battery data from SRAM into EEPROM.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Battery

public Battery(SpiPcs chipSelectPin,
               ISpiMaster spiMaster)
        throws RuntimeException
Battery constructor for obtaining information about the SPOT rechargeable battery this can throw a RuntimeException if it is created with a pre-rev6 eSPOT or version earlier than PCTRL-1.99

Parameters:
chipSelectPin - chip select pin for power controller (PeripheralChipSelect.SPI_PCS_POWER_CONTROLLER)
spiMaster - SPI object (usually from Spot.getInstance().getSPI())
Throws:
RuntimeException - if pre-rev6 eSPOT, pctrl-1.98 or earlier firmware or invalid spot.battery.model property
Method Detail

getModelNumber

public String getModelNumber()
Description copied from interface: IBattery
Battery model must match battery used for accurate measurements. Use the BattSet.java program to set the battery information.

Specified by:
getModelNumber in interface IBattery
Returns:
the battery model number as a string

rawBatteryData

public String rawBatteryData()
Description copied from interface: IBattery
All raw battery data as colon separated one entry per line string.

Specified by:
rawBatteryData in interface IBattery
Returns:
a string of all raw values from the SPOT.

getAvailableCapacity

public double getAvailableCapacity()
Description copied from interface: IBattery
Get the batteries remaining capacity in maHr.

Specified by:
getAvailableCapacity in interface IBattery
Returns:
the capacity in milliamphours

getMaximumCapacity

public double getMaximumCapacity()
Description copied from interface: IBattery
Get the batteries measured maximum capacity in maHr. This value is set to the measured capacity when the battery is fully charged.

Specified by:
getMaximumCapacity in interface IBattery
Returns:
the maximum capacity in milliamphours

getRatedCapacity

public double getRatedCapacity()
Description copied from interface: IBattery
Returns rated capacity of the battery (as written on the label) .

Specified by:
getRatedCapacity in interface IBattery
Returns:
the rated capacity in milliamphour (maHr)

getBatteryLevel

public int getBatteryLevel()
Description copied from interface: IBattery
Battery level returns an integer indicating remaining capacity in percentage (0 is empty, 100 is fully charged)

Specified by:
getBatteryLevel in interface IBattery
Returns:
percentage of battery level

getTime

public long[] getTime()
Description copied from interface: IBattery
Battery time measurements of sleeping since last charge, running since last charge and length of charge time.

Specified by:
getTime in interface IBattery
Returns:
long array of three indexed by SLEEPTIME, RUNTIME or CHARGETIME, each value is time in seconds

getChargeCount

public short getChargeCount()
Description copied from interface: IBattery
Return the number of times the SPOT has seen a full charge. This value is reset to zero when the battery is replaced or removed.

Specified by:
getChargeCount in interface IBattery
Returns:
count of charge cycles

getSleepCurrent

public int getSleepCurrent()
Description copied from interface: IBattery
Sleepcurrent is microamps written to the SPOT for use in calculating sleep current. This is added to temperature self discharge current during deep sleep.

Specified by:
getSleepCurrent in interface IBattery
Returns:
the value written by setSleepCurrent or default value (32uA). Value is microamps and does not inlcude temperature self discharge

setSleepCurrent

public void setSleepCurrent(int microamps)
Description copied from interface: IBattery
SetSleepcurrent writes the sleep current in ADC units to estimate how much power is being consumed while the SPOT is in deep sleep. The method will convert to ADC units (uA * 65536)/25000 and send that to the SPOT to use until changed again Default value is 32uA as typical sleep current of an eSPOT. If eDemo board is jumpered to run on standby power, this value should be increased to 102uA. Other add on boards will have to adjust this value accordingly.

Specified by:
setSleepCurrent in interface IBattery
Parameters:
microamps - current consumed during deep sleep in microamps

getState

public byte getState()
Description copied from interface: IBattery
The state of battery is returned. States are static final ints: NO_BATTERY, DEAD_BATTERY, LOW_BATTERY, DISCHARGING, CHARGING, EXT_POWERED, TEMPERATURE_OUT_OF_RANGE

Specified by:
getState in interface IBattery
Returns:
state of battery

hasTemperatureSensor

public boolean hasTemperatureSensor()
Description copied from interface: IBattery
Returns true if the SPOT has detected a temperature sensor. Rev 5 and before did not have built in temperature sensors. A sensor can be added to the rev 5 SPOT with a simple modification. The temperature sensor can change the state of battery to indicate out of range temperature

Specified by:
hasTemperatureSensor in interface IBattery
Returns:
true if eSPOT has a temperature sensor

hasBattery

public boolean hasBattery()
Description copied from interface: IBattery
Attempts to detect the presence of the battery. Either battery is charging while externally powered or no external power.

Specified by:
hasBattery in interface IBattery
Returns:
true if battery detected

calibrationCycleDetected

public boolean calibrationCycleDetected()
Description copied from interface: IBattery
Returns true when the battery has been depleted to low battery and then charged fully. This cycle will set the measuredCapacity. The measured capacity is originally set to the rated capacity until it detects this cycle.

Specified by:
calibrationCycleDetected in interface IBattery
Returns:
true if SPOT has detected a complete calibration cycle

getStateAsString

public String getStateAsString(int state)
Description copied from interface: IBattery
The state of battery is returned as a string: no battery, dead battery, low battery, discharging, charging, fully charged

Specified by:
getStateAsString in interface IBattery
Parameters:
state - enumerated value returned by getState()
Returns:
state of battery as a string

updatePersistantInfo

public void updatePersistantInfo()
                          throws IOException
Description copied from interface: IBattery
force write of battery data from SRAM into EEPROM. This should be done whenever the SPOT is reset and tries to reinitialize with the same battery. This is done when using the pctrl bootloader which forces a reset.

Specified by:
updatePersistantInfo in interface IBattery
Throws:
IOException - if the power controller does not respond within 10 seconds

SunSPOT API V5.0


Copyright � 2006-2008 Sun Microsystems, Inc. All Rights Reserved.