-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20818 from osmandapp/add_obd_plugin
Add obd plugin
- Loading branch information
Showing
25 changed files
with
1,765 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
OsmAnd-shared/src/commonMain/kotlin/net/osmand/shared/obd/FuelType.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package net.osmand.shared.obd | ||
|
||
import net.osmand.shared.util.Localization | ||
|
||
enum class FuelType(val code: String, val screenNamId: String) { | ||
NO_PROVIDED("00", "obd_fuel_type_not_provided"), | ||
GASOLINE("01", "obd_fuel_type_gasoline"), | ||
METHANOL("02", "obd_fuel_type_methanol"), | ||
ETHANOL("03", "obd_fuel_type_ethanol"), | ||
DIESEL("04", "obd_fuel_type_diesel"), | ||
LPG("05", "obd_fuel_type_lpg"), | ||
CNG("06", "obd_fuel_type_cng"), | ||
PROPANE("07", "obd_fuel_type_propane"), | ||
ELECTRIC("08", "obd_fuel_type_electric"), | ||
BIFUEL_RUNNING_GASOLINE("09", "obd_fuel_type_bifuel_gasoline"), | ||
BIFUEL_RUNNING_METHANOL("0A", "obd_fuel_type_bifuel_methanol"), | ||
BIFUEL_RUNNING_ETHANOL("0B", "obd_fuel_type_bifuel_ethanol"), | ||
BIFUEL_RUNNING_LPG("0C", "obd_fuel_type_bifuel_lpg"), | ||
BIFUEL_RUNNING_CNG("0D", "obd_fuel_type_bifuel_cng"), | ||
BIFUEL_RUNNING_PROPANE("0E", "obd_fuel_type_bifuel_propane"), | ||
BIFUEL_RUNNING_ELECTRICITY("0F", "obd_fuel_type_bifuel_electricity"), | ||
BIFUEL_RUNNING_ELECTRIC_COMBUSTION_ENGINE("10", "obd_fuel_type_bifuel_electric_combustion"), | ||
HYBRID_GASOLINE("11", "obd_fuel_type_hybrid_gasoline"), | ||
HYBRID_ETHANOL("12", "obd_fuel_type_hybrid_ethanol"), | ||
HYBRID_DIESEL("13", "obd_fuel_type_hybrid_diesel"), | ||
HYBRID_ELECTRIC("14", "obd_fuel_type_hybrid_electric"), | ||
HYBRID_ELECTRIC_COMBUSTION_ENGINE("15", "obd_fuel_type_hybrid_electric_combustion"), | ||
HYBRID_REGENERATIVE("16", "obd_fuel_type_hybrid_regenerative"), | ||
BIFUEL_RUNNING_HYDROGEN("17", "obd_fuel_type_bifuel_hydrogen"), | ||
HYBRID_HYDROGEN("18", "obd_fuel_type_hybrid_hydrogen"), | ||
HYDROGEN("19", "obd_fuel_type_hydrogen"), | ||
UNKNOWN("FF", "obd_fuel_type_unknown"); | ||
|
||
fun getDisplayName(): String { | ||
return Localization.getString(screenNamId) | ||
} | ||
|
||
companion object { | ||
fun fromCode(code: String): FuelType { | ||
return FuelType.entries.find { it.code == code.uppercase()} ?: UNKNOWN | ||
} | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
OsmAnd-shared/src/commonMain/kotlin/net/osmand/shared/obd/OBDCommand.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package net.osmand.shared.obd | ||
|
||
enum class OBDCommand( | ||
val command: String, | ||
private val responseParser: (String) -> String, | ||
val isStale: Boolean = false) { | ||
OBD_SUPPORTED_LIST1_COMMAND("00", OBDUtils::parseSupportedCommandsResponse, true), | ||
OBD_SUPPORTED_LIST2_COMMAND("20", OBDUtils::parseSupportedCommandsResponse, true), | ||
OBD_SUPPORTED_LIST3_COMMAND("40", OBDUtils::parseSupportedCommandsResponse, true), | ||
OBD_BATTERY_VOLTAGE_COMMAND("42", OBDUtils::parseBatteryVoltageResponse), | ||
OBD_AMBIENT_AIR_TEMPERATURE_COMMAND("46", OBDUtils::parseAmbientTempResponse), | ||
OBD_RPM_COMMAND("0C", OBDUtils::parseRpmResponse), | ||
OBD_SPEED_COMMAND("0D", OBDUtils::parseSpeedResponse), | ||
OBD_AIR_INTAKE_TEMP_COMMAND("0F", OBDUtils::parseIntakeAirTempResponse), | ||
OBD_ENGINE_COOLANT_TEMP_COMMAND("05", OBDUtils::parseEngineCoolantTempResponse), | ||
OBD_FUEL_CONSUMPTION_RATE_COMMAND("5E", OBDUtils::parseFuelConsumptionRateResponse), | ||
OBD_FUEL_TYPE_COMMAND("51", OBDUtils::parseFuelTypeResponse, true), | ||
OBD_FUEL_LEVEL_COMMAND("2F", OBDUtils::parseFuelLevelResponse); | ||
|
||
fun parseResponse(response: String): String { | ||
return responseParser.invoke(response.lowercase()) | ||
} | ||
} |
Oops, something went wrong.