From 6465e2bb02afa845e9ccf2ce627f1b50e7f911bb Mon Sep 17 00:00:00 2001 From: Adrian Del Grosso <10929341+ad3154@users.noreply.github.com> Date: Wed, 3 Jan 2024 18:57:51 -0700 Subject: [PATCH] Reduce the chance that input objects sometimes could report an off by 1 value Fixed a situation where a 0.1 scale input number could cause the VT change numeric value command to be off by 1 due to an implicit cast. Fixed a situation where the VT change numeric value command could send the wrong value for a number variable underlying an input number. --- src/DataMaskRenderAreaComponent.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/DataMaskRenderAreaComponent.cpp b/src/DataMaskRenderAreaComponent.cpp index ff54b7b..fb0469c 100644 --- a/src/DataMaskRenderAreaComponent.cpp +++ b/src/DataMaskRenderAreaComponent.cpp @@ -322,7 +322,7 @@ void DataMaskRenderAreaComponent::mouseUp(const MouseEvent &event) { if (0xFFFF != varNumID) { - ownerServer.send_change_numeric_value_message(varNumID, clickedNumber->get_value(), ownerServer.get_client_control_function_for_working_set(parentWorkingSet)); + ownerServer.send_change_numeric_value_message(varNumID, std::static_pointer_cast(clickedNumber->get_object_by_id(clickedNumber->get_variable_reference(), parentWorkingSet->get_object_tree()))->get_value(), ownerServer.get_client_control_function_for_working_set(parentWorkingSet)); ownerServer.process_macro(clickedNumber->get_object_by_id(clickedNumber->get_variable_reference(), parentWorkingSet->get_object_tree()), isobus::EventID::OnChangeValue, isobus::VirtualTerminalObjectType::NumberVariable, parentWorkingSet); } else @@ -484,7 +484,8 @@ void DataMaskRenderAreaComponent::InputNumberListener::sliderValueChanged(Slider { if ((nullptr != slider) && (nullptr != targetObject) && (0 != targetObject->get_scale())) { - lastValue = static_cast((slider->getValue() / targetObject->get_scale()) - targetObject->get_offset()); + float scaledValue = (slider->getValue() / targetObject->get_scale()) - targetObject->get_offset(); + lastValue = static_cast(scaledValue); } }