Bug in sxCfgLinearGraph scaling?

Q&A For ShiftX2, RGB sequential shift light <a href="https://wiki.autosportlabs.com/ShiftX2">Installation and Operation Guide</a>
Post Reply
GTIspirit
Posts: 249
Joined: Wed Jan 09, 2013 11:20 am
Location: SE Michigan

Bug in sxCfgLinearGraph scaling?

Post 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&#40;10&#41; --TickRate is in Hz
--function onTick&#40;&#41;
  local speed = getGpsSpeed&#40;&#41;*1.6092*255  --convert to kph and rescale for increased precision
  speedL = bit.band&#40;speed, 0xFF&#41; --mask out high byte
  speedH = bit.rshift&#40;speed, 8&#41; --shift high byte to the right
  --format the speed in a CAN message. Speed is in the first two bytes
  local msg = &#123;speedL,speedH&#125; 
  txCAN&#40;1, 1917, 0, msg&#41;

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

sxSetLinearThresh&#40;0,0,5000,0,255,0,0&#41; --green at 2000 RPM
sxSetLinearThresh&#40;1,0,6000,255,255,0,0&#41; --yellow at 6000 RPM
sxSetLinearThresh&#40;2,0,7000,255,0,0,10&#41; --red+flash at 7000 RPM

function onTick&#40;&#41;
  --sxUpdateLinearGraph&#40;getChannel&#40;"rev"&#41;&#41;
  local nmot = 6000
  sxUpdateLinearGraph&#40;nmot&#41;
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.....)

brentp
Site Admin
Posts: 6282
Joined: Wed Jan 24, 2007 6:36 am

Post by brentp »

Hi, We will check this out and reply. Thanks!
Brent Picasso
CEO and Founder, Autosport Labs
Facebook | Twitter

GTIspirit
Posts: 249
Joined: Wed Jan 09, 2013 11:20 am
Location: SE Michigan

Post by GTIspirit »

@brentp what did you find out on this?

PrideList
Posts: 10
Joined: Mon Sep 25, 2017 6:02 am

Post by PrideList »

I wonder what he found out on this. Still following.

Post Reply