1. Thread posting restricted: Only the BeamNG team members can post new threads in this sub-forum in order to prevent spam. Posting is available on unlocked threads.

Unified in-car dashboard code

Discussion in 'Microblogs' started by Diamondback, Sep 24, 2021.

  1. Diamondback

    Diamondback
    Expand Collapse
    Vehicle Systems Lead
    BeamNG Team

    Joined:
    Apr 8, 2014
    Messages:
    1,957
    Over the past weeks, I've made some effort to unify our in-car dashboard lua code base.

    Up until now, they all used their own lua controllers to do their job. While that works, it's not very efficient (or elegant), they mostly do the same job with just slight differences in which data they display or what specific functions they offer.

    In a strive to reduce complexity and to also increase the approachability for modders, all our dashboards now use the same lua code and are configured via jbeam.

    As usual, this is not a static system, the dashboard configuration tells the game which values to send over and which specific functions to execute. Of course there's also plenty opportunity to still use custom lua code for super fancy things, but for "standard" dashboards, that need is hopefully very small.

    Here's an example of a jbeam config from the ICE Vivace:
    Code:
    "controller": [
            ["fileName"],
            ["gauges/genericGauges", {"name":"gauge", }],
            ["gauges/customModules/environmentData"],
            ["gauges/customModules/combustionEngineData"],
        ],
    
        "gauge": {
            "configuration": {
                "materialName": "@vivace_gauges_screen"
                "htmlPath": "local://local/vehicles/vivace/gauges_screen/gauges_screen_basic.html"
                "displayWidth":1024
                "displayHeight":256
            }
            "displayData": {
                "electrics": [
                    "signal_L",
                    "signal_R",
                    "lights",
                    "highbeam",
                    "lowpressure",
                    "lowfuel",
                    "parkingbrake",
                    "checkengine",
                    "hazard",
                    "oil",
                    "cruiseControlActive",
                    "gear",
                    "rpmTacho",
                    "fuel",
                    "watertemp",
                    "engineRunning",
                    "wheelspeed",
                    "esc",
                    "escActive",
                    "tcs",
                    "tcsActive"
                    "fog",
                ]
                "powertrain": [
                    ["deviceName", "property"]
                    //["mainEngine", "outputTorque1"]
                    //["mainEngine", "outputAV1"]
                    //["gearbox", "outputAV1"]
                ]
                "customModules": [
                    ["moduleName", "property"]
                    ["environmentData", "temperatureEnv",]
                    ["environmentData", "time",]
                ]
            }
        }
    As you can see, it consists of two major sections, the screen configuration and info about what data it needs.
    The data itself can be split in three main parts:
    • Electrics values
    • Powertrain values
    • Custom modules
    The first two are fairly self explanatory, the custom modules however might not be.
    Custom modules are a way of providing custom (ha!) data to the dashboard if the need arises. This can be literally anything you can do in lua as these modules are controllers themselves at their heart.

    Here are some examples of custom modules that will come with the game:
    • combustionEngineData: Provides info on fuel consumption, generates data for the pretty info bar of the ETK800, calculates remaining range etc
    • electricMotorData: similiar to above, just tailor-fit for electric motors
    • environmentData: Provides info like time and outside temperature
    • navgiationData: Takes care of built-in navigation screens
    • accelerationData: Handles acceleration values, used in the SBR screen for example
    We hope to make creating your own screens a little more approachable with this while also increasing performance somewhat (no need to send lots of unused electrics data if you are just after a few values...)

    The JS code of the screens will remain specific per screen as that includes a lot of design and layout things and can't be made generic easily.

    As you are used to, the old way of doing things will continue to work, but I highly suggest to all modders with screens in their cars to upgrade to this new system once it's released.
     
    • Like Like x 38
    • Staff Pick Staff Pick x 1
  2. S.Ali.M

    S.Ali.M
    Expand Collapse

    Joined:
    Jan 12, 2021
    Messages:
    1,079
    There's a typo:
    Screenshot_20210924-223800_Chrome.jpg
     
    • Like Like x 2
  3. Agent_Y

    Agent_Y
    Expand Collapse
    Jbeam/QA support
    BeamNG Team

    Joined:
    Jul 10, 2020
    Messages:
    10,060
    This is what we needed, creating custom gauges used to be kinda messy and people would just copy them directly from official cars, this solution is WAY better!
     
    • Like Like x 2
    • Agree Agree x 1
  4. Theo Wilkinson

    Theo Wilkinson
    Expand Collapse

    Joined:
    Feb 18, 2020
    Messages:
    1,274
    my life just got a whole lot easier on the CCF2..


    Does this already work or is it going to in a future update?
     
  5. Diamondback

    Diamondback
    Expand Collapse
    Vehicle Systems Lead
    BeamNG Team

    Joined:
    Apr 8, 2014
    Messages:
    1,957
    This will be released with the next big update. :)
     
    • Like Like x 7
  6. DaddelZeit

    DaddelZeit
    Expand Collapse

    Joined:
    Jul 17, 2019
    Messages:
    3,319
    This will definitely make people's lives easier; good work and idea!
     
    • Agree Agree x 2
  7. Arcanox

    Arcanox
    Expand Collapse

    Joined:
    Aug 22, 2018
    Messages:
    290
    Does this offer accurate fuel economy data to be sent to the dashboard? I've noticed that the average fuel economy calculations on the stock "Trip Computer" UI app and the stock ETK800 dashboard both use an arithmetic mean for measuring average fuel economy (i.e., every X amount of time, it takes a reading of instantaneous fuel economy, adds the fuel economy to a rolling sum, and the next "average" reading is that sum divided by the number of measurements). I have found that method to be somewhat imprecise, and in my ETK800 Hybrid mod, I have a custom version of the dashboard (with lots of changes, not just fuel economy) that calculates average fuel economy by keeping a rolling sum of "distance traveled" and "fuel consumed", and the average at any given point is the former divided by the latter (or the latter divided by the former, for metric measurements), which is how the average fuel economy would be tracked on a real vehicle. It'd be nice if this new unified dashboard system could provide a true average to the dash UI without the dash code needing to do its own work in that regard.
     
    • Agree Agree x 10
  8. ItsTheLittleAcura!

    ItsTheLittleAcura!
    Expand Collapse

    Joined:
    Feb 9, 2018
    Messages:
    116
    Hyper-miler here: I agree and think the trip computer app should do this as well.
     
  9. FFIVGUY

    FFIVGUY
    Expand Collapse

    Joined:
    Feb 21, 2018
    Messages:
    559
    Will there be a way of increasing or decreasing the rpm range on the dashboard?
     
  10. Diamondback

    Diamondback
    Expand Collapse
    Vehicle Systems Lead
    BeamNG Team

    Joined:
    Apr 8, 2014
    Messages:
    1,957
    This is already possible in public versions in the cases where it makes sense.
     
    • Like Like x 2
    • Agree Agree x 1
  11. Jsap20

    Jsap20
    Expand Collapse

    Joined:
    Jun 26, 2016
    Messages:
    630
    I believe that's how the datapack is spelled
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice