From 056c12580d1f9381f2e31bc846aa913efdd0444d Mon Sep 17 00:00:00 2001 From: Alexander Poletaev Date: Fri, 30 Jan 2026 00:45:25 +0300 Subject: [PATCH] add more information to flipper zero --- obd2_client/src/flipper/pages.py | 29 ++++++++++++++++++++++------- obd2_client/src/obd2/pids.py | 6 +++--- 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/obd2_client/src/flipper/pages.py b/obd2_client/src/flipper/pages.py index 8b3de4f..77041c4 100644 --- a/obd2_client/src/flipper/pages.py +++ b/obd2_client/src/flipper/pages.py @@ -331,23 +331,38 @@ class PageManager: lines = [] if state: - # Get all values - returns dict of PID -> PIDValue all_values = state.get_all() _logger.debug(f"Live data: got {len(all_values)} PIDs from state") if all_values: - # Priority order for display - priority_pids = [0x0C, 0x0D, 0x05, 0x11, 0x2F, 0x5C, 0x04, 0x0F, 0x10] + # Format functions for different value types + def fmt_int(val): + return f"{val.value:.0f} {val.unit}" + + def fmt_float(val): + return f"{val.value:.1f} {val.unit}" + + # Display order with custom formatting + display_order = [ + (0x0C, "RPM", fmt_int), # Engine RPM + (0x0D, "Speed", fmt_int), # Vehicle speed + (0x05, "Coolant", fmt_int), # Coolant temp + (0x5C, "Oil temp", fmt_int), # Oil temp + (0x0F, "Intake temp", fmt_int), # Intake temp + (0x11, "Throttle", fmt_float), # Throttle pos + (0x04, "Engine load", fmt_float), # Engine load + (0x2F, "Fuel level", fmt_float), # Fuel level + (0x10, "MAF", fmt_float), # MAF rate + ] - # Add priority PIDs first shown_pids = set() - for pid_code in priority_pids: + for pid_code, label, formatter in display_order: if pid_code in all_values: val = all_values[pid_code] - lines.append(f"{val.name}: {val.value:.1f} {val.unit}") + lines.append(f"{label}: {formatter(val)}") shown_pids.add(pid_code) - # Add any remaining PIDs + # Add any other PIDs not in the display order for pid_code, val in sorted(all_values.items()): if pid_code not in shown_pids: lines.append(f"{val.name}: {val.value:.1f} {val.unit}") diff --git a/obd2_client/src/obd2/pids.py b/obd2_client/src/obd2/pids.py index a370fae..9f3b59a 100644 --- a/obd2_client/src/obd2/pids.py +++ b/obd2_client/src/obd2/pids.py @@ -64,7 +64,7 @@ class PIDRegistry: self.register( PID( code=0x04, - name="ENGINE_LOAD", + name="Engine load", description="Calculated engine load", unit="%", min_value=0, @@ -134,7 +134,7 @@ class PIDRegistry: self.register( PID( code=0x10, - name="MAF_RATE", + name="MAF rate", description="Mass air flow rate", unit="g/s", min_value=0, @@ -204,7 +204,7 @@ class PIDRegistry: self.register( PID( code=0x5C, - name="OIL_TEMP", + name="Oil temperature", description="Engine oil temperature", unit="°C", min_value=-40,