Skip to content

feat: JSONC templates, schema alignment, and N-stage redline support - #25

Draft
mikeev261 wants to merge 30 commits into
Lovely-Sim-Racing:mainfrom
mikeev261:2nd_redline
Draft

feat: JSONC templates, schema alignment, and N-stage redline support#25
mikeev261 wants to merge 30 commits into
Lovely-Sim-Racing:mainfrom
mikeev261:2nd_redline

Conversation

@mikeev261

@mikeev261 mikeev261 commented Mar 29, 2026

Copy link
Copy Markdown
Collaborator

Overview

This PR significantly reduces maintenance overhead for the LMU car database by introducing a JSONC templating system to deduplicate identical cars. It also introduces major schema updates to support N-stage redlines, string-based RPM ranges, and pattern overrides.

Schema Changes

  • N-Stage Redline & Blink intervals: Added support for N redline LED stages and per-stage redlineBlinkInterval (Int|Array) to better reflect complex dash displays (e.g., used by the Corvette Z06 GT3.R).
    "redlineBlinkInterval": [0, 250], // Stage 1 is solid (0), Stage 2 blinks at 250ms
  • RPM Ranges: Added support for string-based RPM ranges (e.g., "6600-7015") in the ledRpm configuration, allowing a single LED to map to a dynamic RPM band (e.g., used extensively by the BMW M Hybrid V8).
    "ledRpm": [
      {
        "1": [7635, 7840, "6600-7015", "6600-7222", "6800-7428"]
      }
    ]
  • Redline Color Pattern Overrides: Introduced the ability to define custom redline pattern aliases (e.g., "redline2") mapped to an array of colors, allowing complex per-LED redline color animations (e.g., used to create the sweeping redline on the BMW M Hybrid V8).
    "redline2": ["#FF0000FF","#00000000","#FF0000FF","#00000000","#FF0000FF"],
    "ledColor": ["#FFFF0000", "redline2", "#FF00FF00", "#FF00FF00", "#FF00FF00"]
  • Variant Schema: Added a variants array to the base templates. Cars that share identical RPM profiles but have different visual properties (such as ledColor) or team names can now be grouped into a single base template, with their differences cleanly overridden inside the variants array (e.g., grouping dozens of individual LMP2 Oreca 07 and GT3 Aston Martin team profiles under single respective templates).
    {
      "ledNumber": 8,
      "ledColor": ["#FFFF0000", "#FF00FF00", "#FFFFFF00"],
      "variants": [
        {
          "carName": "GT3_TF Sport 2025",
          "carId": "GT3_TF Sport 2025",
          "fileName": "gt3-tf-sport-2025.json",
          "carClass": "GT3",
          "ledColor": ["#FF0000FF", "#FFFFFF00", "#FFFF0000"] // Cleanly overrides base color
        }
      ]
    }

Templating & Tooling

  • JSONC Templates: Migrated the lmu source files from .json to .jsonc, allowing the use of // comments.
  • Consolidated Redundant Profiles: We found 14 identical profiles across 7 Hypercar groups and consolidated them down to 7 canonical base templates. We consolidated 71 LMP2 profiles into just 2 base templates, 68 GT3 profiles into 11 base templates, and similarly grouped LMP3 profiles. In total, we reduced the number of profiles that need to be actively managed from 245 individual car files down to just 34 base templates.
  • Fixed Alpine A424 RPMs: The hyper-alpine-2024.json file was incorrectly using the LMP2 Oreca RPM limits. This has been corrected by moving the team entry into the hyper-a424-2024.jsonc file.
  • Build Scripts:
    • scripts/build_profiles.py: New compiler script that processes the .jsonc templates, expands all variants, drops comments, and natively exports the final .json files to data/lmu/.
    • scripts/rpm_shadow.py: Upgraded helper script that maintains shadow tables. Added a --log flag that allows maintainers to snapshot RPM data to track BOP updates over time.

All 245 original profiles in data/lmu/ continue to build accurately without regressions.

@mikeev261 mikeev261 changed the title Add support for N redline LED stages Feat: Add support for N redline LED stages Apr 1, 2026
mikeev261 added a commit to mikeev261/lovely-car-data that referenced this pull request Apr 5, 2026
@mikeev261 mikeev261 self-assigned this May 9, 2026
@mikeev261
mikeev261 marked this pull request as draft May 9, 2026 12:29
mikeev261 added 25 commits May 31, 2026 09:20
This commit captures the recent schema documentation update (ledNrpm Int|Str ranges) and refactors LMU profiles to eliminate duplication. Templates are maintained in src_data/lmu/ and build_profiles.py generates the downstream data/lmu files.
Removed custom array compression and disabled ensure_ascii so that output exactly matches pre-commit's pretty-format-json tool.
The repo's convention is to use inline arrays for telemetry thresholds to save space. However, pre-commit-hooks' pretty-format-json expands them. We added a custom format_json.py script to handle this properly, excluded these directories from pretty-format-json, and integrated it directly into build_profiles.py.
…to variants

- Renamed all src_data/lmu templates to reflect the actual base car being profiled rather than an arbitrary team variant.
- Updated build_profiles.py so that any property defined in a variant overrides the root template.
- Pushed 'carClass' from the template roots down to their individual variants.
- Merged the ELMS LMP2 Custom Team profile directly into the ELMS LMP2 group since its differing carClass is now properly overridden at the variant level.
- Merged redundant Glickenhaus and Vanwall templates.
Added a script (rpm_shadow.py) with options to add, refresh, and remove visual shadow tables containing RPM percentage values directly inside the src_data templates. The tables use mock-keys (//GEAR) which keeps JSON strictly valid while simulating comments. They are grouped coherently below the original arrays. Updated format_json.py to compress these mock-keys natively, and updated build_profiles.py to actively strip them out during generation so downstream data/lmu profiles remain entirely clean.
…cision calculation

- Updated rpm_shadow.py to algorithmically determine the minimum precision required to flawlessly round-trip the RPM percentages back to the original integers per-car.
- Replaced the mock-key workaround with true JSONC comments (// ...) for the shadow tables.
- Updated build_profiles.py to strip true comments before parsing templates so generated output remains perfectly valid JSON.
- Excluded src_data from the check-json pre-commit hook.
Renamed all src_data/lmu templates from .json to .jsonc to natively support JSON with Comments across all major IDEs. This globally eliminates the syntax errors flagged by local language servers regarding the true comments injected by rpm_shadow.py. Updated build_profiles.py, rpm_shadow.py, and format_json.py to gracefully handle the new .jsonc extensions while ensuring standard .json files are still correctly output to data/lmu for SimHub consumption.
Merged lmp3-ligier-js-p320.jsonc and lmp3-duqueine-d09-p3-2025-397.jsonc into a single lmp3.jsonc template. Since all 3 LMP3 cars share the identical RPM mappings and settings, it's cleaner to maintain a single file. The only divergence is the ledColor array (Ligier uses #FF00c6fd while Duqueine/Ginetta use #FF0080FF), which is cleanly handled by overriding ledColor inside the Duqueine/Ginetta variants.
Merged 14 redundant LMU car templates down to 7 canonical base templates. Found 7 groups of completely identical cars (or seasons of the same car) and consolidated them, storing any minor differences directly into their variant mappings. This dramatically reduces maintenance overhead and clutter. Additionally, fixed a major data bug where the hyper-alpine-2024.jsonc file was accidentally using LMP2 RPM values instead of the correct A424 Hypercar RPM values. The Alpine variants have now been correctly relocated into hyper-a424-2024.jsonc.
…d include comprehensive manifest generation tests
@mikeev261 mikeev261 changed the title Feat: Add support for N redline LED stages feat: JSONC templates, schema alignment, and N-stage redline support Jun 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant