com.github.pires.obd.commands.fuel.FuelTrimCommand 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.FuelTrim;
/**
* Fuel Trim.
*
* @author pires
* @version $Id: $Id
*/
public class FuelTrimCommand extends PercentageObdCommand {
private final FuelTrim bank;
/**
* Default ctor.
*
* Will read the bank from parameters and construct the command accordingly.
* Please, see FuelTrim enum for more details.
*
* @param bank a {@link com.github.pires.obd.enums.FuelTrim} object.
*/
public FuelTrimCommand(final FuelTrim bank) {
super(bank.buildObdCommand());
this.bank = bank;
}
/**
*
Constructor for FuelTrimCommand.
*/
public FuelTrimCommand() {
this(FuelTrim.SHORT_TERM_BANK_1);
}
/**
* @param value
* @return
*/
private float prepareTempValue(final int value) {
return (value - 128) * (100.0F / 128);
}
/**
* performCalculations.
*/
protected void performCalculations() {
// ignore first two bytes [hh hh] of the response
percentage = prepareTempValue(buffer.get(2));
}
/**
* getValue.
*
* @return the readed Fuel Trim percentage value.
* @deprecated use #getCalculatedResult()
*/
public final float getValue() {
return percentage;
}
/**
* Getter for the field bank
.
*
* @return the name of the bank in string representation.
*/
public final String getBank() {
return bank.getBank();
}
/** {@inheritDoc} */
@Override
public String getName() {
return bank.getBank();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy