Skip to content

Commit d68fc7a

Browse files
committed
computeDisplayString performance optimization
1 parent abbf774 commit d68fc7a

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

source/ForumsladerView.mc

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -82,49 +82,49 @@ class ForumsladerView extends SimpleDataField {
8282
{
8383
switch ($.UserSettings[i] as Number)
8484
{
85-
case 1: // trip energy
86-
_displayString += _data.FLdata[FL_tripEnergy] + "Wh";
85+
case 0: // off
8786
break;
8887

89-
case 2: // temperature
90-
_displayString += (_data.FLdata[FL_temperature] / 10.0).format("%.1f") + "°C";
88+
case 10: // remaining battery capacity
89+
_displayString += capacity + "%";
9190
break;
9291

93-
case 3: // dynamo power
94-
_displayString += (battVoltage * (_data.FLdata[FL_loadCurrent] + _data.FLdata[FL_battCurrent]) / 1000).toNumber() + "W";
92+
case 9: // speed
93+
var speed = _data.FLdata[FL_frequency] * _data.freq2speed as Float;
94+
_displayString += speed.format("%.1f") + $.speedunit;
9595
break;
9696

97-
case 4: // generator gear
98-
_displayString += _data.FLdata[FL_gear];
97+
case 8: // load current
98+
_displayString += (_data.FLdata[FL_loadCurrent] / 1000.0).format("%.1f") + "A";
9999
break;
100100

101-
case 5: // dynamo impulse frequency
102-
var freq = _data.FLdata[FL_frequency] / ($.isV6 ? 10.0 : 1.0) as Float;
103-
_displayString += freq.toNumber() + "Hz";
101+
case 7: // battery current
102+
_displayString += (_data.FLdata[FL_battCurrent] / 1000.0).format("%+.1f") + "A";
104103
break;
105104

106105
case 6: // battery voltage
107106
_displayString += battVoltage.format("%.1f") + "V";
108107
break;
109108

110-
case 7: // battery current
111-
_displayString += (_data.FLdata[FL_battCurrent] / 1000.0).format("%+.1f") + "A";
109+
case 5: // dynamo impulse frequency
110+
var freq = _data.FLdata[FL_frequency] / ($.isV6 ? 10.0 : 1.0) as Float;
111+
_displayString += freq.toNumber() + "Hz";
112112
break;
113113

114-
case 8: // load current
115-
_displayString += (_data.FLdata[FL_loadCurrent] / 1000.0).format("%.1f") + "A";
114+
case 4: // generator gear
115+
_displayString += _data.FLdata[FL_gear];
116116
break;
117117

118-
case 9: // speed
119-
var speed = _data.FLdata[FL_frequency] * _data.freq2speed as Float;
120-
_displayString += speed.format("%.1f") + $.speedunit;
118+
case 3: // dynamo power
119+
_displayString += (battVoltage * (_data.FLdata[FL_loadCurrent] + _data.FLdata[FL_battCurrent]) / 1000).toNumber() + "W";
121120
break;
122121

123-
case 10: // remaining battery capacity
124-
_displayString += capacity + "%";
122+
case 2: // temperature
123+
_displayString += (_data.FLdata[FL_temperature] / 10.0).format("%.1f") + "°C";
125124
break;
126125

127-
default: // off
126+
case 1: // trip energy
127+
_displayString += _data.FLdata[FL_tripEnergy] + "Wh";
128128
break;
129129
}
130130
_displayString += i < $.DisplayField4 ? " " : "";

0 commit comments

Comments
 (0)