Skip to content

Commit

Permalink
feat:AA Add Gas Gauge to Performance screen
Browse files Browse the repository at this point in the history
  • Loading branch information
tzebrowski committed Dec 27, 2024
1 parent 4791611 commit ab5fcfe
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,13 @@ private const val DISTANCE_PID_ID = 7076L
private const val IBS_PID_ID = 7020L
private const val BATTERY_VOLTAGE_PID_ID = 7019L
private const val OIL_PRESSURE_PID_ID = 7018L
private const val GAS_PID_ID = 7007L


class PIDsNamesRegistry {

fun getGasPedalPID(): Long = GAS_PID_ID

fun getIbsPID(): Long = IBS_PID_ID
fun getBatteryVoltagePID(): Long = BATTERY_VOLTAGE_PID_ID
fun getOilPressurePID(): Long = OIL_PRESSURE_PID_ID
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ internal class PerformanceQueryStrategy : QueryStrategy() {
namesRegistry.getIntakePressurePID(),
namesRegistry.getDynamicSelectorPID(),
namesRegistry.getOilPressurePID(),
namesRegistry.getGasPedalPID()
)
override fun getDefaults() = defaults

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,26 +84,41 @@ internal class PerformanceDrawer(context: Context, settings: ScreenSettings) : A
canvas = canvas,
left = area.left.toFloat(),
top = rowTop,
width = area.width() / 2.2f,
width = area.width() / 2.6f,
metric = it,
labelCenterYPadding = 22f,
fontSize = settings.getDynamicScreenSettings().fontSize
fontSize = settings.getDynamicScreenSettings().fontSize,
scaleEnabled = false
)
}

performanceInfoDetails.gas?.let {
gaugeDrawer.drawGauge(
canvas = canvas,
left = (area.left + area.width() / 2.8f) - 6f,
top = rowTop - 4f,
width = area.width() / 3.8f,
metric = it,
labelCenterYPadding = 26f,
fontSize = settings.getDynamicScreenSettings().fontSize,
scaleEnabled = false
)
}

performanceInfoDetails.intakePressure?.let {
gaugeDrawer.drawGauge(
canvas = canvas,
left = (area.left + area.width() / 2f) - 10,
left = (area.left + area.width() / 1.65f) ,
top = rowTop,
width = area.width() / 2.2f,
width = area.width() / 2.6f,
metric = it,
labelCenterYPadding = 22f,
fontSize = settings.getDynamicScreenSettings().fontSize
fontSize = settings.getDynamicScreenSettings().fontSize,
scaleEnabled = false
)
}
}


private inline fun calculateFontSize(
area: Rect
): Pair<Float, Float> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ data class PerformanceInfoDetails(
var intakePressure: Metric? = null,
var torque: Metric? = null,
var oilPressure: Metric? = null,
var gas: Metric? = null
)
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ internal class PerformanceSurfaceRenderer(
left = left,
top = top,
performanceInfoDetails = performanceInfoDetails.apply {
gas = metricsCollector.getMetric(namesRegistry.getGasPedalPID())
airTemp = metricsCollector.getMetric(namesRegistry.getAirTempPID())
ambientTemp = metricsCollector.getMetric(namesRegistry.getAmbientTempPID())
atmPressure = metricsCollector.getMetric(namesRegistry.getAtmPressurePID())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ internal class GaugeDrawer(

fun drawGauge(canvas: Canvas, metric: Metric, left: Float, top: Float, width: Float,
fontSize: Int = settings.getGaugeRendererSetting().getFontSize(),
labelCenterYPadding: Float = 0f) {
labelCenterYPadding: Float = 0f, scaleEnabled: Boolean = settings.isScaleEnabled()) {
paint.shader = null

val rect = calculateRect(left, width, top)
Expand Down Expand Up @@ -145,7 +145,7 @@ internal class GaugeDrawer(
rect
)

if (settings.isScaleEnabled()) {
if (scaleEnabled) {
drawNumerals(
metric,
canvas,
Expand Down

0 comments on commit ab5fcfe

Please sign in to comment.