From 79637f1e9797240e0d5f51735bbd542986bf4d4a Mon Sep 17 00:00:00 2001 From: Ben Hall Date: Sat, 14 Sep 2024 00:26:11 -0400 Subject: [PATCH] one line does one thing and handling const correctly --- lib/interfaces/include/ThermistorInterface.h | 2 +- lib/interfaces/src/ThermistorInterface.cpp | 21 +++++++++++--------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/lib/interfaces/include/ThermistorInterface.h b/lib/interfaces/include/ThermistorInterface.h index 4c49f3ec6..4af4c5973 100644 --- a/lib/interfaces/include/ThermistorInterface.h +++ b/lib/interfaces/include/ThermistorInterface.h @@ -16,7 +16,7 @@ const int MCU15_THERM_FR_CHANNEL = 1; class ThermistorInterface { private: - Thermistors front_thermistors; + Thermistors _front_thermistors; float therm_fl; float therm_fr; diff --git a/lib/interfaces/src/ThermistorInterface.cpp b/lib/interfaces/src/ThermistorInterface.cpp index 642f01046..29ac6d267 100644 --- a/lib/interfaces/src/ThermistorInterface.cpp +++ b/lib/interfaces/src/ThermistorInterface.cpp @@ -3,22 +3,21 @@ -ThermistorInterface::ThermistorInterface(CANBufferType *msg_output_queue) : front_thermistors() +ThermistorInterface::ThermistorInterface(CANBufferType *msg_output_queue) { _msg_queue = msg_output_queue; } - void ThermistorInterface::update_front_thermistor_readings() { - // FRONT_THERMISTORS_t front_thermistors_; - // //scale by 500 for easy packing - // front_thermistors_.thermistor_motor_fl = HYTECH_thermistor_motor_fl_toS(therm_fl); - // front_thermistors_.thermistor_motor_fr = HYTECH_thermistor_motor_fr_toS(therm_fr); + FRONT_THERMISTORS_t front_thermistors; + //scale by 500 for easy packing + front_thermistors.thermistor_motor_fl_ro = HYTECH_thermistor_motor_fl_ro_toS(therm_fl); + front_thermistors.thermistor_motor_fr_ro = HYTECH_thermistor_motor_fr_ro_toS(therm_fr); - // enqueue_CAN_front_thermistors(&front_thermistors_, &Pack_FRONT_THERMISTORS_hytech); + enqueue_CAN_front_thermistors(&front_thermistors, &Pack_FRONT_THERMISTORS_hytech); } template @@ -32,9 +31,13 @@ void ThermistorInterface::enqueue_CAN_front_thermistors(U* structure, uint32_t ( } void ThermistorInterface::tick(const AnalogConversion_s &raw_therm_fl, const AnalogConversion_s &raw_therm_fr) + { - therm_fl = front_thermistors.get(MCU15_THERM_FL_CHANNEL).convert(raw_therm_fl.raw); - therm_fr = front_thermistors.get(MCU15_THERM_FR_CHANNEL).convert(raw_therm_fr.raw); + auto fl_channel = _front_thermistors.get(MCU15_THERM_FL_CHANNEL); + auto fr_channel = _front_thermistors.get(MCU15_THERM_FR_CHANNEL); + + therm_fl = fl_channel.convert((uint16_t)raw_therm_fl.raw); + therm_fr = fr_channel.convert((uint16_t)raw_therm_fr.raw); update_front_thermistor_readings(); } \ No newline at end of file