emulator: sweep all 4 instruments to full scale maximums (120C, 6000RPM, 180km/h, 16.0V)

This commit is contained in:
Sebastián Nieto 2026-09-09 22:40:00 -03:00
parent 8887ab4265
commit 2f58b502ed

View file

@ -37,37 +37,42 @@ class VehicleState:
with self.lock:
if self.auto_simulate:
# 24-second cycle:
# 0 - 8s: Ramp up 800 -> 6000 RPM (Verde -> Amarillo -> Rojo)
# 8 - 12s: Hold at MAX (6000 RPM, redline/escala máxima) for 4s
# 12 - 20s: Ramp down 6000 -> 800 RPM (Rojo -> Amarillo -> Verde)
# 20 - 24s: Hold at IDLE (800 RPM) for 4s
# 0 - 8s: Ramp up to maximums
# 8 - 12s: Hold at absolute MAXIMUM on all instruments for 4s
# 12 - 20s: Ramp down to idle
# 20 - 24s: Hold at IDLE for 4s
cycle_period = 24.0
phase = t % cycle_period
if phase < 8.0:
p = phase / 8.0
self.rpm = 800.0 + p * (6000.0 - 800.0)
self.speed = p * 180.0
self.coolant_temp = 85.0 + p * (120.0 - 85.0)
self.pcm_volt = 13.2 + p * (16.0 - 13.2)
elif phase < 12.0:
# MAX SCALE ON ALL INSTRUMENTS
self.rpm = 6000.0
self.speed = 180.0
self.coolant_temp = 120.0
self.pcm_volt = 16.0
elif phase < 20.0:
p = (phase - 12.0) / 8.0
self.rpm = 6000.0 - p * (6000.0 - 800.0)
self.speed = 180.0 - p * 180.0
self.coolant_temp = 120.0 - p * (120.0 - 85.0)
self.pcm_volt = 16.0 - p * (16.0 - 13.2)
else:
self.rpm = 800.0
# MAP pressure correlates with RPM
self.map_psi = 10.0 + 16.0 * ((self.rpm - 800.0) / 5200.0)
# Engine load correlates with RPM
self.load = 15.0 + 75.0 * ((self.rpm - 800.0) / 5200.0)
# Vehicle speed correlates with RPM (up to 175 km/h, turning RED past 130 km/h)
self.speed = 15.0 + 160.0 * ((self.rpm - 800.0) / 5200.0)
if self.speed < 0:
self.speed = 0.0
# Coolant temp rises with engine load (88°C -> 108°C: Green <98, Yellow 98-105, Red >=106)
self.coolant_temp = 88.0 + 20.0 * ((self.rpm - 800.0) / 5200.0)
self.oil_temp = 90.0 + 12.0 * ((self.rpm - 800.0) / 5200.0)
self.coolant_temp = 88.0
self.pcm_volt = 13.8
# Correlated auxiliary telemetry
self.map_psi = 10.0 + 16.0 * ((self.rpm - 800.0) / 5200.0)
self.load = 15.0 + 75.0 * ((self.rpm - 800.0) / 5200.0)
self.oil_temp = self.coolant_temp + 3.0
self.trans_temp = 82.0 + 1.0 * math.cos(t * 0.09)
self.pcm_volt = 14.2 + 0.15 * math.sin(t * 0.5)
state = VehicleState()