diff --git a/firmware/controllers/algo/rusefi_enums.h b/firmware/controllers/algo/rusefi_enums.h index 61de7a1f4b..f16f638059 100644 --- a/firmware/controllers/algo/rusefi_enums.h +++ b/firmware/controllers/algo/rusefi_enums.h @@ -459,6 +459,7 @@ typedef enum __attribute__ ((__packed__)) { CAN_BUS_GENESIS_COUPE = 10, CAN_BUS_HONDA_K = 11, CAN_AIM_DASH = 12, + CAN_BUS_MINI_R52 = 13, } can_nbc_e; diff --git a/firmware/controllers/can/can_dash.cpp b/firmware/controllers/can/can_dash.cpp index 7a1c68c271..d0feb924d0 100644 --- a/firmware/controllers/can/can_dash.cpp +++ b/firmware/controllers/can/can_dash.cpp @@ -14,6 +14,7 @@ #include "can_msg_tx.h" #include "can_bmw.h" #include "can_vag.h" +#include "can_mini.h" #include "rusefi_types.h" #include "rtc_helper.h" @@ -27,15 +28,15 @@ #define CAN_MAZDA_RX_STATUS_2 0x420 //w202 DASH -#define W202_STAT_1 0x308 /* _20ms cycle */ +#define W202_STAT_1 0x308 /* _20ms cycle */ #define W202_STAT_2 0x608 /* _100ms cycle */ -#define W202_ALIVE 0x210 /* _200ms cycle */ +#define W202_ALIVE 0x210 /* _200ms cycle */ #define W202_STAT_3 0x310 /* _200ms cycle */ //BMW E90 DASH #define E90_ABS_COUNTER 0x0C0 #define E90_SEATBELT_COUNTER 0x0D7 -#define E90_T15 0x130 +#define E90_T15 0x130 #define E90_RPM 0x175 #define E90_BRAKE_COUNTER 0x19E #define E90_SPEED 0x1A6 @@ -129,6 +130,7 @@ void canDashboardNissanVQ(CanCycle cycle); void canDashboardGenesisCoupe(CanCycle cycle); void canDashboardAim(CanCycle cycle); void canDashboardHaltech(CanCycle cycle); +void canDashboardMini(CanCycle cycle); void updateDash(CanCycle cycle) { @@ -169,6 +171,9 @@ void updateDash(CanCycle cycle) { case CAN_AIM_DASH: canDashboardAim(cycle); break; + case CAN_BUS_MINI_R52: + canDashboardMini(cycle); + break; default: firmwareError(ObdCode::OBD_PCM_Processor_Fault, "Nothing for canNbcType %s", getCan_nbc_e(engineConfiguration->canNbcType)); break; @@ -1316,4 +1321,44 @@ void canDashboardAim(CanCycle cycle) { // transmitStruct(0x5fd, false); } +void canDashboardMini(CanCycle cycle) { + if (cycle.isInterval(CI::_50ms)) { + int rpm = Sensor::getOrZero(SensorType::Rpm); + + { // block scope to invoke CanTxMessage deconstructor (send) + CanTxMessage msg1(CAN_MINI_DME1_ID, 8); + uint16_t scaledRpm = rpm * 6.4f; + msg1[3] = scaledRpm >> 8; + msg1[4] = scaledRpm && 0xff; + } + + { // block scope to invoke CanTxMessage deconstructor (send) + CanTxMessage msg2(CAN_MINI_IC_4_ID, 8); + // 25% LCD brightness + msg2[1] = 0x3f; + // enable LCD backlight, needle, lights (byte 2, bit 4) + msg2.setBit(2, 1); + // enable orange 6k LED bar + msg2.setBit(4, 4); + + if (rpm >= 5500) { + // enable red "5.5-6k" LED bars + msg2.setBit(4, 2); + + if (rpm >= 6000) { + // enable red "6k" LED + msg2.setBit(4, 3); + // enable red "6-7k" LED bars + msg2.setBit(4, 5); + } + + if (rpm >= 7000) { + // enable red "7-8k" LED bars + msg2.setBit(4, 6); + } + } + } + } +} + #endif // EFI_CAN_SUPPORT diff --git a/firmware/controllers/can/can_mini.h b/firmware/controllers/can/can_mini.h new file mode 100644 index 0000000000..693cb6f495 --- /dev/null +++ b/firmware/controllers/can/can_mini.h @@ -0,0 +1,35 @@ +/** + * BMC Mini R52 (e.g.) CAN dash implementation. + * + * @date 2024-05-16 + * @author Nathan Schulte, (c) 2024 + */ + +#pragma once + +// CAN frame IDs; BMW terms +//#define CAN_MINI_ASC1_ID 0x153 +#define CAN_MINI_DME1_ID 0x316 +//#define CAN_MINI_DME2_ID 0x329 +// DME4: CEL, cruise light, EML, fuel consumption, oil temp+overheat +//#define CAN_MINI_DME4_ID 0x545 +// Instrument Cluster,_1: A/C status +//#define CAN_MINI_IC_1_ID 0x615 +// Instrument Cluster, 2: odometer, fuel level, clock (since battery) +//#define CAN_MINI_IC_2_ID 0x613 +// Instrument Cluster, 3: trip, temp, speed, consumption, range +#define CAN_MINI_IC_3_ID 0x61a +// Instrument Cluster, 4: lights: RPM, high beams, cruise, service engine soon, brake, ABS, turn signals +#define CAN_MINI_IC_4_ID 0x61f + +// R52 tach has sent back frames like: +// can0 630 [8] 02 00 00 00 00 00 00 00 +// can0 630 [8] 02 50 00 00 00 00 00 00 +// can0 630 [8] 02 54 00 00 00 00 00 00 +// can0 630 [8] 02 70 00 00 00 00 00 00 +// can0 630 [8] 02 74 00 00 00 00 00 00 +// can0 630 [8] 02 7C 00 00 00 00 00 00 + +// 0x316 -- needs at least every 500ms +// 0x61a -- needs at least every 1000ms? +// 0x61f -- needs at least every 1000ms? diff --git a/firmware/integration/rusefi_config.txt b/firmware/integration/rusefi_config.txt index 4334953788..0c330cf12c 100644 --- a/firmware/integration/rusefi_config.txt +++ b/firmware/integration/rusefi_config.txt @@ -388,7 +388,7 @@ uint16_t engineSnifferRpmThreshold;Engine sniffer would be disabled above this r custom ignition_mode_e 1 bits, U08, @OFFSET@, [0:1], "Single Coil", "Individual Coils", "Wasted Spark", "Two Distributors" ignition_mode_e ignitionMode;Single coil = distributor\nIndividual coils = one coil per cylinder (COP, coil-near-plug), requires sequential mode\nWasted spark = Fires pairs of cylinders together, either one coil per pair of cylinders or one coil per cylinder\nTwo distributors = A pair of distributors, found on some BMW, Toyota and other engines -custom can_nbc_e 1 bits, U08, @OFFSET@, [0:4], "None", "FIAT", "VAG", "MAZDA RX8", "BMW", "W202", "BMW E90", "Haltech", "VAG MQB", "Nissan VQ35", "Genesis Coupe", "Honda K", "AiM", "type 13", "type 14" +custom can_nbc_e 1 bits, U08, @OFFSET@, [0:4], "None", "FIAT", "VAG", "MAZDA RX8", "BMW", "W202", "BMW E90", "Haltech", "VAG MQB", "Nissan VQ35", "Genesis Coupe", "Honda K", "AiM", "MINI R52", "type 14" can_nbc_e canNbcType struct injector_s