Read tire temps from CAN
This commit is contained in:
parent
197b805f35
commit
c8e94175d1
|
@ -67,16 +67,26 @@ String get_value(Value val) {
|
|||
case VAL_RPM:
|
||||
return String(Vehicle_data.revol / 2);
|
||||
case VAL_TT_FL:
|
||||
return "00";
|
||||
return String(Vehicle_data.t_tfl * 0.423529 + 8, 0);
|
||||
case VAL_TT_FR:
|
||||
return "01";
|
||||
return String(Vehicle_data.t_tfr * 0.423529 + 0, 0);
|
||||
case VAL_TT_RL:
|
||||
return "10";
|
||||
return String(Vehicle_data.t_trl * 0.423529 + 11, 0);
|
||||
case VAL_TT_RR:
|
||||
return "11";
|
||||
case VAL_LAPTIME:
|
||||
return String(
|
||||
Vehicle_data.lap_time_sec + Vehicle_data.lap_time_msec / 1000.0, 2);
|
||||
return String(Vehicle_data.t_trr * 0.423529 + 4, 0);
|
||||
case VAL_LAPTIME: {
|
||||
double time =
|
||||
Vehicle_data.lap_time_sec + Vehicle_data.lap_time_msec / 1000.0;
|
||||
if (time < 100) {
|
||||
return String(time, 2);
|
||||
} else if (time < 1000) {
|
||||
return String(time, 1);
|
||||
} else if (time < 10000) {
|
||||
return String(time, 0);
|
||||
} else {
|
||||
return "2SLOW";
|
||||
}
|
||||
}
|
||||
case VAL_UBATT:
|
||||
return String(0.0706949 * Vehicle_data.u_batt, 2);
|
||||
case VAL_TMOT:
|
||||
|
@ -347,10 +357,10 @@ void update_view_driver() {
|
|||
gear_box.update_value(get_value(VAL_GEAR));
|
||||
left_box.update_value(get_value(left_box_value));
|
||||
right_box.update_value(get_value(VAL_RPM));
|
||||
fl_box.update_value(2);
|
||||
fr_box.update_value(55);
|
||||
rl_box.update_value(65);
|
||||
rr_box.update_value(90);
|
||||
fl_box.update_value(get_value(VAL_TT_FL).toInt());
|
||||
fr_box.update_value(get_value(VAL_TT_FR).toInt());
|
||||
rl_box.update_value(get_value(VAL_TT_RL).toInt());
|
||||
rr_box.update_value(get_value(VAL_TT_RR).toInt());
|
||||
}
|
||||
|
||||
void redraw_view_testing() {
|
||||
|
|
|
@ -60,8 +60,8 @@ typedef struct {
|
|||
// uint8_t i; //Index
|
||||
// linker Drehschalter
|
||||
uint8_t buttonStateEnc1; // button
|
||||
// uint8_t br; //test mode :
|
||||
// mittlere Drehschalter position
|
||||
// uint8_t br; //test
|
||||
// mode : mittlere Drehschalter position
|
||||
uint8_t buttonStateEnc2; // button
|
||||
uint8_t displayindex; // index für Displayanzeige
|
||||
uint8_t error_type; // Extrainfos über Error-LED
|
||||
|
@ -82,6 +82,10 @@ typedef struct {
|
|||
uint8_t t_oil; // Öl-Motor-Temperatur
|
||||
uint8_t t_mot; // Wasser-Motor-Temperatur
|
||||
uint8_t t_air; // LLK-Temperatur
|
||||
uint8_t t_tfl; // Tire temp front left
|
||||
uint8_t t_tfr; // Tire temp front right
|
||||
uint8_t t_trl; // Tire temp rear left
|
||||
uint8_t t_trr; // Tire temp rear right
|
||||
uint8_t u_batt; // Batteriespannung
|
||||
uint8_t rev_lim; // Drehzahllimit Bit
|
||||
uint8_t p_wat;
|
||||
|
@ -93,7 +97,7 @@ typedef struct {
|
|||
uint8_t speed_fr;
|
||||
uint8_t speed;
|
||||
uint8_t lap_time_sec;
|
||||
uint8_t lap_time_msec;
|
||||
uint16_t lap_time_msec;
|
||||
} vehicle_data_type;
|
||||
|
||||
extern volatile stw_data_type Stw_data;
|
||||
|
|
|
@ -19,11 +19,13 @@ void Init_Can_0() {
|
|||
Can0.setNumTXBoxes(1); // reserves mailbox 0 for tx only 8 mailboxes are
|
||||
// available (the other 7 mailboxes are for rx)
|
||||
|
||||
// We only have 7 mailboxes, but want to receive 8 messages. This trick should
|
||||
// allow us to receive BCU_APS_BRAKE and BCU_ETC in the same mailbox.
|
||||
Can0.watchFor(CAN_ID_BCU_APS_BRAKE & CAN_ID_BCU_ETC,
|
||||
~(CAN_ID_BCU_APS_BRAKE ^ CAN_ID_BCU_ETC));
|
||||
Can0.watchFor(CAN_ID_BCU_SHIFT_CTRL);
|
||||
// We only have 7 mailboxes, but want to receive 9 messages. This trick should
|
||||
// allow us to receive BCU_APS_BRAKE, BCU_ETC and BCU_SHIFT_CTRL in the same
|
||||
// mailbox. It will also let through 0x506, but that shouldn't be much of an
|
||||
// issue.
|
||||
Can0.watchFor(CAN_ID_BCU_APS_BRAKE & CAN_ID_BCU_ETC & CAN_ID_BCU_SHIFT_CTRL,
|
||||
0x7FC);
|
||||
Can0.watchFor(CAN_ID_BCU_TIRES);
|
||||
Can0.watchFor(CAN_ID_BCU_LAP_TIME);
|
||||
Can0.watchFor(CAN_ID_MS4_IGN_REV_ATH);
|
||||
Can0.watchFor(CAN_ID_MS4_SPEED);
|
||||
|
@ -92,9 +94,18 @@ void Receive_Can_0(CAN_FRAME *temp_message) {
|
|||
Vehicle_data.gear = (temp_message->data.byte[1]) >> 5;
|
||||
break;
|
||||
}
|
||||
case CAN_ID_BCU_TIRES: { // Tire temps
|
||||
Vehicle_data.t_trl = temp_message->data.byte[1];
|
||||
Vehicle_data.t_trr = temp_message->data.byte[4];
|
||||
Vehicle_data.t_tfl = temp_message->data.byte[5];
|
||||
Vehicle_data.t_tfr = temp_message->data.byte[6];
|
||||
break;
|
||||
}
|
||||
case CAN_ID_BCU_LAP_TIME: { // lap time
|
||||
Vehicle_data.lap_time_sec = temp_message->data.byte[1];
|
||||
Vehicle_data.lap_time_msec = temp_message->data.byte[1];
|
||||
Vehicle_data.lap_time_msec =
|
||||
temp_message->data.byte[2] | ((temp_message->data.byte[3] & 0b11) << 8);
|
||||
break;
|
||||
}
|
||||
case CAN_ID_MS4_IGN_REV_ATH: { // rpm
|
||||
Vehicle_data.revol =
|
||||
|
|
|
@ -11,6 +11,7 @@ FT_2018_STW_CAN.h
|
|||
#define CAN_ID_BCU_APS_BRAKE 0x500
|
||||
#define CAN_ID_BCU_ETC 0x502
|
||||
#define CAN_ID_BCU_SHIFT_CTRL 0x504
|
||||
#define CAN_ID_BCU_TIRES 0x562
|
||||
#define CAN_ID_BCU_LAP_TIME 0x570
|
||||
#define CAN_ID_MS4_IGN_REV_ATH 0x773
|
||||
#define CAN_ID_MS4_SPEED 0x775
|
||||
|
|
Loading…
Reference in New Issue