[Ovmsdev] New Metric Units
Michael Geddes
frog at bunyip.wheelycreek.net
Sat Nov 5 18:22:56 HKT 2022
Hi all,
Some of the code I copied from Kona/Kia code had both kwh/100km and km/kwh
metrics in the code as 'Other'.
Adding the various power consumption Units is not particularly hard (I will
have a pull-request soon) - though the conversions between them all
required some thought!
... but it also made me think these two metrics that are (with the
consumption units added) defined like this:
m_v_trip_consumption1 =
MyMetrics.InitFloat("xiq.v.trip.consumption.KWh/100km", 10, 0, kWHP100K);
m_v_trip_consumption2 = MyMetrics.InitFloat("xiq.v.trip.consumption.km/kWh",
10, 0, kPkWH);
These are effectively the same metric but in different units!
I'm wondering if we would be better to have scripting and Duktape support
for converting metrics to different unit! This might be also quite useful
for those strange countries that insist on using miles as a measurement.
On top of the 'metric list' and 'metric set' we could add a 'metric get'
which gets a single value.. and add unit support for get/set.
I've also got a pull request that improves the precision of the km<->mi
conversions and factors it out.
//.ichael
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openvehicles.com/pipermail/ovmsdev/attachments/20221105/fe913dbb/attachment.htm>
More information about the OvmsDev
mailing list