19 lines
943 B
JavaScript
19 lines
943 B
JavaScript
export const profiles = ['route', 'ville', 'arret'];
|
|
|
|
// All displays use the same clock: no GPIO, CAN or vehicle commands here.
|
|
export function telemetry(profile = 'route', now = Date.now()) {
|
|
if (!profiles.includes(profile)) throw new RangeError('Profil inconnu');
|
|
const t = now / 1000;
|
|
const speed = profile === 'arret' ? 0 : Math.round(profile === 'ville'
|
|
? 23 + 23 * Math.sin(t / 18) : 82 + 12 * Math.sin(t / 15));
|
|
const gear = speed === 0 ? 'N' : String(Math.min(6, Math.max(1, Math.ceil(speed / 20))));
|
|
return {
|
|
schemaVersion: 1, source: 'demo', timestamp: now, profile,
|
|
speedKph: speed, rpm: speed === 0 ? 850 : Math.round(1400 + speed * 13 + 100 * Math.sin(t / 3)),
|
|
fuelPercent: 68, coolantCelsius: profile === 'arret' ? 76 : 89,
|
|
batteryVolts: 14.2, outsideCelsius: 21, rangeKm: 540,
|
|
tripKm: 42.6, consumptionL100: 5.8, gear,
|
|
weather: { source: 'demo', label: 'Éclaircies', celsius: 21 }
|
|
};
|
|
}
|