com.github.pires.obd.commands.fuel.FuelLevelCommand Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of obd-java-api Show documentation
Show all versions of obd-java-api Show documentation
OBD Java API compatible with ELM327.
package com.github.pires.obd.commands.fuel;
import com.github.pires.obd.commands.PercentageObdCommand;
import com.github.pires.obd.enums.AvailableCommandNames;
/**
* Get fuel level in percentage
*
* @author pires
* @version $Id: $Id
*/
public class FuelLevelCommand extends PercentageObdCommand {
/**
* Constructor for FuelLevelCommand.
*/
public FuelLevelCommand() {
super("01 2F");
}
/** {@inheritDoc} */
@Override
protected void performCalculations() {
// ignore first two bytes [hh hh] of the response
percentage = 100.0f * buffer.get(2) / 255.0f;
}
/** {@inheritDoc} */
@Override
public String getName() {
return AvailableCommandNames.FUEL_LEVEL.getValue();
}
/**
* getFuelLevel.
*
* @return a float.
*/
public float getFuelLevel() {
return percentage;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy