@@ -12,16 +12,19 @@ namespace INA260 {
1212 constexpr uint_fast16_t u_TO_m = 1000 ;
1313 constexpr uint_fast32_t u_TO_BASE = m_TO_BASE * u_TO_m;
1414 static constexpr int_fast8_t MIN_VOLTAGE_V = -32 ;
15- static constexpr int_fast16_t MIN_VOLTAGE_mV = MIN_VOLTAGE_V * m_TO_BASE;
15+ static constexpr int_fast16_t MIN_VOLTAGE_mV =
16+ MIN_VOLTAGE_V * static_cast <int_fast16_t >(m_TO_BASE);
1617 static constexpr int_fast8_t MAX_VOLTAGE_V = 32 ;
1718 static constexpr int_fast16_t MAX_VOLTAGE_mV = MAX_VOLTAGE_V * m_TO_BASE;
1819 static constexpr int_fast8_t MIN_CURRENT_A = -15 ;
19- static constexpr int_fast16_t MIN_CURRENT_mA = MIN_CURRENT_A * m_TO_BASE;
20+ static constexpr int_fast16_t MIN_CURRENT_mA =
21+ MIN_CURRENT_A * static_cast <int_fast16_t >(m_TO_BASE);
2022 static constexpr int_fast8_t MAX_CURRENT_A = 15 ;
2123 static constexpr int_fast16_t MAX_CURRENT_mA = MAX_CURRENT_A * m_TO_BASE;
2224 static constexpr int_fast16_t MIN_POWER_W =
2325 MIN_VOLTAGE_V * MIN_CURRENT_A * -1 ;
24- static constexpr int_fast16_t MIN_POWER_mW = MIN_POWER_W * m_TO_BASE;
26+ static constexpr int_fast16_t MIN_POWER_mW =
27+ MIN_POWER_W * static_cast <int_fast16_t >(m_TO_BASE);
2528 static constexpr int_fast16_t MAX_POWER_W = MAX_VOLTAGE_V * MAX_CURRENT_A ;
2629 static constexpr int_fast16_t MAX_POWER_mW = MAX_POWER_W * m_TO_BASE;
2730
@@ -65,18 +68,18 @@ namespace INA260 {
6568 unsigned long currentTime_us = micros ();
6669 unsigned long dTime_us = currentTime_us - detail::lastUpdateTime_us;
6770
68- auto vTemp_mV = ( uint_fast32_t ) powerSensor.readBusVoltage ();
71+ auto vTemp_mV = static_cast < int_fast32_t >( powerSensor.readBusVoltage () );
6972 if ((vTemp_mV > MAX_VOLTAGE_mV) ||
7073 (vTemp_mV < PSENSOR ::MIN_VOLTAGE_mV)) {
7174 ESP_LOGE (" TAG" , " V reading out of bounds: %u mV" , vTemp_mV);
72- result & = false ;
75+ result = false ;
7376 } // Else: Valid reading
7477 prevVoltage_mV = voltage_mV;
7578 voltage_mV = vTemp_mV;
7679 int_fast16_t dVoltage_mV = voltage_mV - prevVoltage_mV;
7780 dVoltage_mVPS = dVoltage_mV * u_TO_BASE / dTime_us;
7881
79- auto iTemp = ( uint_fast32_t ) powerSensor.readCurrent ();
82+ auto iTemp = static_cast < int_fast32_t >( powerSensor.readCurrent () );
8083 if ((iTemp > MAX_CURRENT_mA) || (iTemp < MIN_CURRENT_mA)) {
8184 ESP_LOGE (" TAG" , " C reading out of bounds: %d mA" , iTemp);
8285 result &= false ;
@@ -86,7 +89,7 @@ namespace INA260 {
8689 int_fast16_t dCurrent_mA = current_mA - prevCurrent_mA;
8790 dCurrent_mAPS = dCurrent_mA * u_TO_BASE / dTime_us;
8891
89- auto pTemp = ( uint_fast32_t ) powerSensor.readPower ();
92+ auto pTemp = static_cast < int_fast32_t >( powerSensor.readPower () );
9093 if ((pTemp > (MAX_VOLTAGE_mV * MAX_CURRENT_A )) ||
9194 (pTemp < (PSENSOR ::MIN_VOLTAGE_mV * MIN_CURRENT_A ))) {
9295 ESP_LOGE (" TAG" , " P out of bounds: %d mW" , pTemp);
@@ -109,31 +112,31 @@ namespace INA260 {
109112 */
110113 etl::string<LOG_STRING_SIZE > getLogString () {
111114 etl::string<LOG_STRING_SIZE > logString (TAG ); // 3 chars
112- logString.append (" : mV: " ); // 6 chars
115+ ( void ) logString.append (" : mV: " ); // 6 chars
113116
114117 etl::format_spec decFormatA;
115- decFormatA.width (5 ).fill (' 0' ); // [5 chars]
118+ ( void ) decFormatA.width (5 ).fill (' 0' ); // [5 chars]
116119 /* *
117120 * @details I don't think we need strong guarantees on logging data
118121 * @see
119122 * https://stackoverflow.com/questions/12346487/what-do-each-memory-order-mean
120123 * @see https://en.cppreference.com/cpp/atomic/memory_order
121124 */
122125 etl::to_string (voltage_mV.load (), logString, decFormatA,
123- true ); // 5 chars
124- logString.append (" , mA: " ); // 6 chars
126+ true ); // 5 chars
127+ ( void ) logString.append (" , mA: " ); // 6 chars
125128 etl::to_string (current_mA.load (), logString, decFormatA,
126- true ); // 5 chars
127- logString.append (" , mW: " ); // 6 chars
129+ true ); // 5 chars
130+ ( void ) logString.append (" , mW: " ); // 6 chars
128131 etl::to_string (power_mW.load () / m_TO_BASE, logString, decFormatA,
129- true ); // 5 chars
130- logString.append (" , mV/s: " ); // 8 chars
132+ true ); // 5 chars
133+ ( void ) logString.append (" , mV/s: " ); // 8 chars
131134 etl::to_string (dVoltage_mVPS.load (), logString, decFormatA,
132- true ); // 5 chars
133- logString.append (" , mA/s: " ); // 8 chars
135+ true ); // 5 chars
136+ ( void ) logString.append (" , mA/s: " ); // 8 chars
134137 etl::to_string (dCurrent_mAPS.load (), logString, decFormatA,
135- true ); // 5 chars
136- logString.append (" , mW/s: " ); // 8 chars
138+ true ); // 5 chars
139+ ( void ) logString.append (" , mW/s: " ); // 8 chars
137140 etl::to_string (dPower_mWPS.load (), logString, decFormatA,
138141 true ); // 5 chars
139142
0 commit comments