Advertisement
Guest User

Untitled

a guest
Mar 18th, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.06 KB | None | 0 0
  1. setTickRate(30)
  2.  
  3. -- Set ShiftX3 configuration parameters with default parameters
  4. -- orientation: 0=normal, 1=inverted (display above LED bar)
  5. -- brightness: 0-100%, 0 = auto brightness
  6. -- can bus: 0=CAN1, 1=CAN2
  7. sxSetConfig(0,0,1)
  8.  
  9. --config shift light
  10. sxCfgLinearGraph(0,0,0,10000) --left to right graph, smooth style, 0 - 7000 RPM range
  11.  
  12. sxSetLinearThresh(0,0,0,0,255,0,0) --green
  13. sxSetLinearThresh(1,0,5000,255,255,0,0) --yellow
  14. sxSetLinearThresh(2,0,6000,255,0,0,0) --red
  15. sxSetLinearThresh(3,0,8000,255,255,255,10) --whiteflash
  16.  
  17.  
  18. --configure first alert (right LED)
  19. sxSetAlertThresh(1,0,205,255,255,0,0) --yellow warning at 205
  20. sxSetAlertThresh(1,1,225,255,0,0,10) -- red flash at 225
  21.  
  22. --configure second alert (left LED)
  23. sxSetAlertThresh(0,0,170,255,0,255,10) --purple at 170
  24. sxSetAlertThresh(0,1,280,255,255,0,5) -- yellow at 280
  25.  
  26. --Create simulated channels and state
  27. --Channel ID, currentValue, increment, min, max
  28. rpmState = {addChannel('SimRPM', 10, 0, 0, 10000), 0, 200, 0, 10000}
  29. etState = {addChannel('SimEngTmp', 10, 0, 0, 300), 0, 2, 0, 300}
  30. oilState = {addChannel('SimOilTmp', 10, 0, 0, 300), 0, 1, 0, 300}
  31. display = 1
  32.  
  33. function updateSimChannel(state, incDisplay)
  34. local id = state[1]
  35. local currentVal = state[2]
  36. local increment = state[3]
  37. local min = state[4]
  38. local max = state[5]
  39.  
  40. currentVal = currentVal + increment
  41.  
  42. -- check min/max and change direction if needed
  43. if currentVal >= max or currentVal <= min then
  44. increment = -increment
  45. if incDisplay == true and currentVal >= max then
  46. display = display + 1
  47. if display > 6 then display = 1 end
  48. sxSetDisplay(0,display)
  49. end
  50. end
  51.  
  52. --update the virtual channel
  53. setChannel(id, currentVal)
  54.  
  55. --store updated values in state
  56. state[2] = currentVal
  57. state[3] = increment
  58. end
  59.  
  60. function onTick()
  61. updateSimChannel(rpmState, true)
  62. updateSimChannel(etState)
  63. updateSimChannel(oilState)
  64.  
  65. --update RPM
  66. sxUpdateLinearGraph(getChannel("SimRPM"))
  67. --update engine temp alert
  68. sxUpdateAlert(1, getChannel("SimEngTmp"))
  69. --update oil pressure alert
  70. sxUpdateAlert(0, getChannel("SimOilTmp"))
  71. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement