diff --git a/src/components/Details.svelte b/src/components/Details.svelte
index 734c1f7..7e3eccc 100644
--- a/src/components/Details.svelte
+++ b/src/components/Details.svelte
@@ -23,7 +23,7 @@
let voltsPerCell = $derived(batterySpecs.cellCount ? data.voltage / batterySpecs.cellCount : NaN);
let cellVoltsLow = $derived(voltsPerCell && batterySpecs.cellMinVolt && voltsPerCell < batterySpecs.cellMinVolt);
- let formatSpeed = $derived((x: number) => mapSpeed(x).toFixed(1));
+ let formatSpeed = $derived((x: number) => (Number.isNaN(x) ? '??' : mapSpeed(x).toFixed(1)));
const getStateColor = (state: string): string | undefined => {
switch (state.toLowerCase()) {
@@ -84,8 +84,16 @@
80 ? 'red' : ChartColours.DutyCycle },
- { label: 'Motor Current', value: `${data.current_motor} A`, color: ChartColours.CurrentMotor },
+ {
+ label: 'Duty',
+ value: `${Number.isNaN(data.duty) ? '?? ' : data.duty}%`,
+ color: data.duty > 80 ? 'red' : ChartColours.DutyCycle,
+ },
+ {
+ label: 'Motor Current',
+ value: `${Number.isNaN(data.current_motor) ? '??' : data.current_motor} A`,
+ color: ChartColours.CurrentMotor,
+ },
...(Number.isNaN(data.current_field_weakening)
? []
: [
@@ -107,13 +115,21 @@
items={[
{ label: 'Spec', value: batterySpecs.cellCount ? `${batterySpecs.cellCount}S` : configureButton },
'-',
- { label: 'Batt V (total)', value: `${data.voltage} V`, color: ChartColours.BatteryVoltage },
+ {
+ label: 'Batt V (total)',
+ value: `${Number.isNaN(data.voltage) ? '?? ' : data.voltage} V`,
+ color: ChartColours.BatteryVoltage,
+ },
{
label: 'Batt V (cell)',
value: `${voltsPerCell ? voltsPerCell.toFixed(1) : '??'} V`,
color: cellVoltsLow ? 'red' : ChartColours.BatteryVoltage,
},
- { label: 'Batt Current', value: `${data.current_battery} A`, color: ChartColours.CurrentBattery },
+ {
+ label: 'Batt Current',
+ value: `${Number.isNaN(data.current_battery) ? '??' : data.current_battery} A`,
+ color: ChartColours.CurrentBattery,
+ },
]}
/>
diff --git a/src/lib/parse/floaty.ts b/src/lib/parse/floaty.ts
index 4d5d2c7..07f068d 100644
--- a/src/lib/parse/floaty.ts
+++ b/src/lib/parse/floaty.ts
@@ -14,12 +14,12 @@ function rowsFromFloatyJson(json: ZFloatyJson): Row[] {
bms_fault: NaN,
bms_temp: NaN,
bms_temp_battery: NaN,
- current_battery: log.batteryCurrent,
+ current_battery: log.batteryCurrent ?? NaN,
current_booster: NaN,
current_field_weakening: NaN,
- current_motor: log.motorCurrent,
+ current_motor: log.motorCurrent ?? NaN,
distance: log.tripDistance,
- duty: log.dutyCycle,
+ duty: log.dutyCycle ?? NaN,
erpm: NaN,
gps_accuracy: location.accuracy,
gps_latitude: location.latitude,
@@ -34,7 +34,7 @@ function rowsFromFloatyJson(json: ZFloatyJson): Row[] {
setpoint_remote: NaN,
setpoint_torque_tilt: NaN,
setpoint: NaN,
- speed: log.speed,
+ speed: log.speed ?? NaN,
state_raw: log.state,
state: stateCodeMap[log.state] ?? '??',
temp_battery: NaN,
@@ -42,7 +42,7 @@ function rowsFromFloatyJson(json: ZFloatyJson): Row[] {
temp_motor: log.motorTemp,
time: (log.timestamp - json.startTime) / 1000,
true_pitch: log.truePitchAngle,
- voltage: log.batteryVolts,
+ voltage: log.batteryVolts ?? NaN,
wh_charged: NaN,
wh: log.wattHours,
});
diff --git a/src/lib/parse/floaty.types.ts b/src/lib/parse/floaty.types.ts
index 277e7b4..948ee51 100644
--- a/src/lib/parse/floaty.types.ts
+++ b/src/lib/parse/floaty.types.ts
@@ -13,12 +13,12 @@ export const LocationSchema = z.object({
export type ZLog = z.infer;
export const LogSchema = z.object({
timestamp: z.number(),
- speed: z.number(),
- dutyCycle: z.number(),
- batteryVolts: z.number(),
+ speed: z.number().nullable(),
+ dutyCycle: z.number().nullable(),
+ batteryVolts: z.number().nullable(),
batteryPercent: z.number(),
- batteryCurrent: z.number(),
- motorCurrent: z.number(),
+ batteryCurrent: z.number().nullable(),
+ motorCurrent: z.number().nullable(),
motorTemp: z.number(),
controllerTemp: z.number(),
tripDistance: z.number(),