58#if HW_PROTEUS && EFI_PROD_CODE
74 setPPSInputs(PROTEUS_IN_ANALOG_VOLT_4, PROTEUS_IN_ANALOG_VOLT_5);
79--startPwm(outputIndex, 100, 0)
81rpmLimitSetting = findSetting("compReleaseRpm", 300)
82compReleaseDulationLimit = findSetting("compReleaseDur", 6000)
84every200msTimer = Timer.new();
85everySecondTimer = Timer.new();
86every50msTimer = Timer.new();
89packet542 = {0x20, 0x82, 0x81, 0xd9, 0x00, 0x00, 0x00, 0x00}
90packet543 = {0x13, 0x57, 0x13, 0x45, 0x00, 0xe8, 0x00, 0x00}
91packet541 = {0x00, 0x00, 0x00, 0x00, 0x00, 0x45, 0x00, 0xFF}
94packet540 = {0x00, 0x00, 0x5a, 0x4c, 0xff, 0x00, 0x00, 0x00}
98packet546 = {0x35, 0x48, 0x44, 0x31, 0x46, 0x48}
99packet547 = {0x50, 0x41, 0x31, 0x4b, 0x42, 0x36}
100packet548 = {0x33, 0x34, 0x38, 0x32, 0x32, 0x00}
108function onCanRx(bus, id, dlc, data)
109 --print('got CAN id=' .. id .. ' dlc=' .. dlc)
111 if id == 0x500 then --Check can state of BCM
113 if canState == 01 then
120 if curState == 06 then -- Cranking TODO: MUST ONLY DO THIS ON RPM TILL STARt
123 if curState == 04 then -- Kill off
126 if curState == 01 then -- Kill
136 if packet502[1] == 01 then
138 counter543 = (counter543 + 1) % 64
139 packet543[7] = 64 + counter543
140 packet543[8] = crc8_j1850(packet543, 7)
141 APP = getSensor("AcceleratorPedal")
145 packet543[5] = APP *2
148 txCan(1, 0x543, 0, packet543)
149 txCan(1, 0x541, 0, packet541)
151 if every200msTimer:getElapsedSeconds() > 0.2 then
152 every200msTimer:reset();
153 txCan(1, 0x540, 0, packet540)
156 if every50msTimer:getElapsedSeconds() > 0.05 then
157 every50msTimer:reset();
158 txCan(1, 0x542, 0, packet542)
161 if everySecondTimer:getElapsedSeconds() > 1 then
162 everySecondTimer:reset();
163 txCan(1, 0x502, 0, packet502)
164 txCan(1, 0x546, 0, packet546)
165 txCan(1, 0x547, 0, packet547)
166 txCan(1, 0x548, 0, packet548)
170 rpm = getSensor("RPM")
171-- handle nil RPM, todo: change firmware to avoid nil RPM
172 rpm = (rpm == nil and 0 or rpm)
173 --print('Rpm ' .. rpm)
174 --print('getTimeSinceTriggerEventMs ' .. getTimeSinceTriggerEventMs())
175 enableCompressionReleaseSolenoid = getTimeSinceTriggerEventMs() < compReleaseDulationLimit and rpm < rpmLimitSetting
176 duty = enableCompressionReleaseSolenoid and 1 or 0
177-- print("Compression release solenoid " .. duty)
178-- setPwmDuty(outputIndex, duty)
180 if offCounter == 0 then --goodbye sweet love
181 txCan(1, 0x502, 0, packet502) --goodbye
182 offCounter = 1 --One shot
void setCustomMap(float lowValue, float mapLowValueVoltage, float highValue, float mapHighValueVoltage)
void setPPSInputs(adc_channel_e pps1, adc_channel_e pps2)
void setTPS1Inputs(adc_channel_e tps1, adc_channel_e tps2)
static constexpr persistent_config_s * config
static constexpr engine_configuration_s * engineConfiguration
static void harleyEngine()
vehicle_info_t engineMake
angle_t timing_offset_cylinder[MAX_CYLINDER_COUNT]
gppwm_note_t scriptSettingName[SCRIPT_SETTING_COUNT]
ignition_mode_e ignitionMode
int8_t gapTrackingLengthOverride
output_pin_e mainRelayPin
vvt_mode_e vvtMode[CAMS_PER_BANK]
output_pin_e injectionPins[MAX_CYLINDER_COUNT]
int8_t maximumIgnitionTiming
int8_t minimumIgnitionTiming
brain_input_pin_e triggerInputPins[TRIGGER_INPUT_PIN_COUNT]
script_setting_t scriptSetting[SCRIPT_SETTING_COUNT]
firing_order_e firingOrder
float triggerGapOverrideFrom[GAP_TRACKING_LENGTH]
injection_mode_e injectionMode
brain_input_pin_e camInputs[CAM_INPUTS_COUNT]
float mapCamDetectionAnglePosition
output_pin_e ignitionPins[MAX_CYLINDER_COUNT]
output_pin_e luaOutputPins[LUA_PWM_COUNT]
float triggerGapOverrideTo[GAP_TRACKING_LENGTH]