diff --git a/firmware/config/engines/nissan_vq.cpp b/firmware/config/engines/nissan_vq.cpp index 6f5b0a23c8..a57e581b8c 100644 --- a/firmware/config/engines/nissan_vq.cpp +++ b/firmware/config/engines/nissan_vq.cpp @@ -36,6 +36,9 @@ void setHellen121nissanVQ() { strncpy(config->luaScript, R"( canRxAdd(0x35d) +OUT_1F9 = 0x1F9 +OUT_23D = 0x23D + setTickRate(100) t = Timer.new() t : reset() @@ -43,7 +46,8 @@ t : reset() globalAcOut = 0 function onTick() - local RPMread = math.floor(getSensor("RPM") + 0.5) / 3.15 + local rpmValue = math.floor(getSensor("RPM") + 0.5) + local RPMread = rpmValue / 3.15 local RPMhi = RPMread / 256 local RPMlo = RPMread cltValue = getSensor("CLT") @@ -51,7 +55,7 @@ function onTick() local CLTread = math.floor(cltValue + 0.5) --print('ac out = ' ..globalAcOut) - if globalAcOut == 1 and RPMread >80 then + if globalAcOut == 1 and rpmValue > 250 then fanPayloadOff = { 0x88, 0x00 } fanPayloadLo = { 0x88, 0x00 } fanPayloadHi = { 0x88, 0x00 } @@ -63,15 +67,11 @@ function onTick() end cltGauge = 0x00 - -- acOut = {0x32, 0x80, 0x00, 0x10, 0x00, 0x00} - -- txCan(1, 0x625, 0,acOut) -- clt gauge stuff if CLTread < 115 then - -- txCan(1, 0x608, 0, canCLTpayloadNo) - cltGauge = math.floor(CLTread * 1.5 + 0.5) + cltGauge = math.floor(cltValue * 1.5 + 0.5) elseif CLTread >= 115 then - -- txCan(1, 0x608, 0, canCLTpayloadHi) cltGauge = 0xF0 end -- print('clt gauge = '..cltGauge) @@ -82,20 +82,20 @@ function onTick() CLTandRPM = { 0x00, 0x18, 0x0c, RPMlo, RPMhi, 0x87, 0xFF, cltGauge } end - txCan(1, 0x23D, 0, CLTandRPM) -- transmit CLT and RPM + txCan(1, OUT_23D, 0, CLTandRPM) -- transmit CLT and RPM - if RPMread > 80 then + if rpmValue > 250 then if CLTread <= 80 then - txCan(1, 0x1F9, 0, fanPayloadOff) + txCan(1, OUT_1F9, 0, fanPayloadOff) elseif CLTread >= 85 and CLTread < 90 then - txCan(1, 0x1F9, 0, fanPayloadLo) + txCan(1, OUT_1F9, 0, fanPayloadLo) elseif CLTread >= 90 then - txCan(1, 0x1F9, 0, fanPayloadHi) + txCan(1, OUT_1F9, 0, fanPayloadHi) end else - txCan(1, 0x1F9, 0, fanPayloadOff) + txCan(1, OUT_1F9, 0, fanPayloadOff) end -- print('CLT temp' ..CLTread) end diff --git a/firmware/controllers/can/can_dash.cpp b/firmware/controllers/can/can_dash.cpp index c2cf6b6979..4403c62222 100644 --- a/firmware/controllers/can/can_dash.cpp +++ b/firmware/controllers/can/can_dash.cpp @@ -64,7 +64,9 @@ static time_msecs_t mph_ctr; // 505 #define NISSAN_RPM_1F9 0x1F9 -#define NISSAN_UNKNOWN_1 0x231 +// 561 +#define NISSAN_ENGINE_2 0x231 +// 563 #define NISSAN_UNKNOWN_2 0x233 // Nissan z33 350Z and else // 0x23d = 573 @@ -72,6 +74,7 @@ static time_msecs_t mph_ctr; // 574 #define NISSAN_UNKNOWN_3 0x23E +// 640 #define NISSAN_VEHICLE_SPEED_280 0x280 // wheel speed see "102 CAN Communication decoded" // 19500 value would be 100 kph