@@ -96,6 +96,7 @@ void PowerMonitorSelectorAuterion::try_eeprom_start()
9696 EepromBlockPm eeprom_block_pm = _eeprom_blocks_pm[ii];
9797
9898 uint16_t dev_type = eeprom_block_pm.dev_type ;
99+ set_max_current (dev_type, eeprom_block_pm.max_current );
99100 set_shunt_value (dev_type, eeprom_block_pm.shunt_value );
100101 int ret_val = start_pm (_buses[i].bus_number , dev_type, eeprom_block_pm.i2c_addr , _buses[i].id );
101102
@@ -368,6 +369,19 @@ bool PowerMonitorSelectorAuterion::is_user_configured(const uint16_t dev_type) c
368369 return sens_en != 0 ;
369370}
370371
372+ void PowerMonitorSelectorAuterion::set_max_current (const uint16_t dev_type, const float max_current) const
373+ {
374+ const char *ina_type = get_ina_type (dev_type);
375+
376+ if (ina_type == nullptr ) {
377+ return ;
378+ }
379+
380+ char param_name[PARAM_MAX_LEN];
381+ snprintf (param_name, sizeof (param_name), " INA%s_CURRENT" , ina_type);
382+ set_float_param (param_name, max_current);
383+ }
384+
371385void PowerMonitorSelectorAuterion::set_shunt_value (const uint16_t dev_type, const float shunt_value) const
372386{
373387 const char *ina_type = get_ina_type (dev_type);
@@ -378,12 +392,16 @@ void PowerMonitorSelectorAuterion::set_shunt_value(const uint16_t dev_type, cons
378392
379393 char param_name[PARAM_MAX_LEN];
380394 snprintf (param_name, sizeof (param_name), " INA%s_SHUNT" , ina_type);
395+ set_float_param (param_name, shunt_value);
396+ }
381397
382- float current_shunt_value = 0 ;
383- param_get (param_find (param_name), ¤t_shunt_value);
398+ void PowerMonitorSelectorAuterion::set_float_param (const char *param_name, const float param_val) const
399+ {
400+ float current_param_value = 0 ;
401+ param_get (param_find (param_name), ¤t_param_value);
384402
385- if (fabsf (current_shunt_value - shunt_value ) > FLT_EPSILON) {
386- param_set (param_find (param_name), &(shunt_value ));
403+ if (fabsf (current_param_value - param_val ) > FLT_EPSILON) {
404+ param_set (param_find (param_name), &(param_val ));
387405 }
388406}
389407
0 commit comments