diff --git a/docs/reference.md b/docs/reference.md index b4792a6..a90afb7 100644 --- a/docs/reference.md +++ b/docs/reference.md @@ -67,7 +67,9 @@ Zero if the switch is current turned off, non-zero otherwise. Mode: Read/write Power will be maintained for this long after the switch has been -turned off. +turned off. The maximum value is 3276.7s, all register scalings +report in units of 100ms (thus int8 will not be able to command or +monitor the full possible scale). ### 0x004 - Boot time ### diff --git a/fw/power_dist.cc b/fw/power_dist.cc index 12f608e..9d9a96a 100644 --- a/fw/power_dist.cc +++ b/fw/power_dist.cc @@ -101,9 +101,9 @@ Value ScaleVoltage(float value, size_t type) { return ScaleMapping(value, 0.5f, 0.1f, 0.001f, type); } -int8_t ReadIntMapping(Value value) { +int16_t ReadInt16Mapping(Value value) { return std::visit([](auto a) { - return static_cast(a); + return static_cast(a); }, value); } @@ -514,7 +514,7 @@ class PowerDist : public mjlib::multiplex::MicroServer::Server { return 2; } case Register::kLockTime: { - status_.lock_time_100ms = ReadIntMapping(value); + status_.lock_time_100ms = ReadInt16Mapping(value); return 0; } case Register::kFaultCode: @@ -547,10 +547,10 @@ class PowerDist : public mjlib::multiplex::MicroServer::Server { return IntMapping(static_cast(status_.switch_status), type); } case Register::kLockTime: { - return IntMapping(static_cast(status_.lock_time_100ms), type); + return IntMapping(static_cast(status_.lock_time_100ms), type); } case Register::kBootTime: { - return IntMapping(static_cast(0), type); + return IntMapping(static_cast(0), type); } case Register::kOutputVoltage: { return ScaleVoltage(status_.output_voltage_V, type);