Skip to content

Commit

Permalink
Reduce the chance that input objects sometimes could report an off by…
Browse files Browse the repository at this point in the history
… 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.
  • Loading branch information
ad3154 committed Jan 18, 2024
1 parent 5fe0f1e commit 6465e2b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/DataMaskRenderAreaComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<isobus::NumberVariable>(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
Expand Down Expand Up @@ -484,7 +484,8 @@ void DataMaskRenderAreaComponent::InputNumberListener::sliderValueChanged(Slider
{
if ((nullptr != slider) && (nullptr != targetObject) && (0 != targetObject->get_scale()))
{
lastValue = static_cast<std::uint32_t>((slider->getValue() / targetObject->get_scale()) - targetObject->get_offset());
float scaledValue = (slider->getValue() / targetObject->get_scale()) - targetObject->get_offset();
lastValue = static_cast<std::uint32_t>(scaledValue);
}
}

Expand Down

0 comments on commit 6465e2b

Please sign in to comment.