-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Temperature Rewrite #150
base: master
Are you sure you want to change the base?
Temperature Rewrite #150
Conversation
Codecov Report
@@ Coverage Diff @@
## master #150 +/- ##
==========================================
+ Coverage 38.20% 38.27% +0.06%
==========================================
Files 69 69
Lines 3942 3977 +35
==========================================
+ Hits 1506 1522 +16
- Misses 2436 2455 +19
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couple of things to start with.
// convert to degrees C | ||
double temp = static_cast<double>(raw_value) / 4095; | ||
temp = (temp * 175) - 50; | ||
return static_cast<int8_t>(temp); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like a convoluted way of doing this. Is there a datasheet somewhere?
Why not the following?
return std::round(static_cast<double>(raw_value) / 23.4 - 50);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You may have to recast the result to make the compiler happy. Actually, we may want to assert that the result is in bounds, e.g. by checking std::numeric_limits<int8_t>::max()
or INT8_MAX
.
* @param raw_value input voltage | ||
* @return int representation of temperature | ||
*/ | ||
static int8_t scaleData(uint8_t raw_value); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const
data::TemperatureData temperature_data_; | ||
}; | ||
|
||
class BrakesAndSuspensionTemperature : public ITemperature { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this should go into a separate file.
|
||
void BrakesAndSuspensionTemperature::run() | ||
{ | ||
uint16_t raw_value = pin_.read(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const
} | ||
|
||
void Temperature::run() | ||
void AmbientTemperature::run() | ||
{ | ||
uint16_t raw_value = pin_.read(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const
@@ -8,7 +8,7 @@ | |||
namespace hyped::sensors { | |||
|
|||
using AmbientTemperaturePins = std::array<uint8_t, data::Sensors::kNumAmbientTemp>; | |||
using BrakeTemperaturePins = std::array<uint8_t, data::Sensors::kNumBrakeTemp>; | |||
using BrakeTemperaturePins = std::array<uint8_t, data::Sensors::kNumBrakeSuspensionTemp>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BrakeAndSuspension
static constexpr size_t kNumImus = 4; | ||
static constexpr size_t kNumEncoders = 4; | ||
static constexpr size_t kNumBrakePressure = 2; | ||
static constexpr size_t kNumBrakeSuspensionTemp = 4; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
kNumBrakeAndSuspensionTemperature
static constexpr size_t kNumEncoders = 4; | ||
static constexpr size_t kNumBrakePressure = 2; | ||
static constexpr size_t kNumBrakeSuspensionTemp = 4; | ||
static constexpr size_t kNumAmbientTemp = 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
kNumAmbientTemperature
#143 rewrite
Adds brakes and suspension temperatures