Page 1 of 1

Bug in sxCfgLinearGraph scaling?

Posted: Wed Oct 09, 2019 11:05 pm
by GTIspirit
It seems like there is a bug in the sxCfgLinearGraph scaling. It only seems to work as expected with zero to something scaling. If I want to start scaling at say 5000rpm, it doesn't work as expected. Script is below.

Code: Select all

setTickRate(10) --TickRate is in Hz
--function onTick()
  local speed = getGpsSpeed()*1.6092*255  --convert to kph and rescale for increased precision
  speedL = bit.band(speed, 0xFF) --mask out high byte
  speedH = bit.rshift(speed, 8) --shift high byte to the right
  --format the speed in a CAN message. Speed is in the first two bytes
  local msg = {speedL,speedH} 
  txCAN(1, 1917, 0, msg)

-- Set ShiftX2 configuration parameters with default parameters
-- orientation: 0=normal, 1=inverted (display above LED bar)
-- brightness: 0-100%, 0 = auto brightness
-- can bus: 0=CAN1, 1=CAN2
sxSetConfig(0,0,1)
--config shift light
sxCfgLinearGraph(0,0,5000,7000) --left to right graph, smooth style, 0 - 7000 RPM range

sxSetLinearThresh(0,0,5000,0,255,0,0) --green at 2000 RPM
sxSetLinearThresh(1,0,6000,255,255,0,0) --yellow at 6000 RPM
sxSetLinearThresh(2,0,7000,255,0,0,10) --red+flash at 7000 RPM

function onTick()
  --sxUpdateLinearGraph(getChannel("rev"))
  local nmot = 6000
  sxUpdateLinearGraph(nmot)
end
If I scale 0 to 7000rpm then it works as expected. If I set "nmot" = 5000 then five of the seven LED's light up green. And so on.

But when I change the scaling to 5000 to 7000, I would expect the LED's to first start lighting up at 5000rpm, and then all to be lit up at 7000rpm. But that's not what happens.

What happens is, with nmot =
10000 all green,
1000 all red flashing (real head scratcher because 1000 is below 5000 so nothing should happen....)
11000 all yellow,
6000 none (here I would have expected half to light up, because 6000rpm is halfway between 5000rpm and 7000rpm.....)

Posted: Mon Oct 14, 2019 10:50 pm
by brentp
Hi, We will check this out and reply. Thanks!

Posted: Wed Mar 11, 2020 9:00 pm
by GTIspirit
@brentp what did you find out on this?

Posted: Mon Mar 16, 2020 12:11 am
by PrideList
I wonder what he found out on this. Still following.