Skip to content

Conversation

klutvott123
Copy link
Member

Currently we're treating all incoming values as unsigned.
This PR adds detection of signed values by checking the fields min limit

@klutvott123 klutvott123 mentioned this pull request Nov 13, 2022
haslinghuis
haslinghuis previously approved these changes Nov 13, 2022
end
local bits = #f.vals * 8
if f.min < 0 and bit32.btest(f.value, bit32.lshift(1, bits - 1)) then
f.value = f.value - math.pow(2, bits)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
f.value = f.value - math.pow(2, bits)
f.value = f.value - (2 ^ bits)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done. thanks 👍

@haslinghuis haslinghuis merged commit 700c8c3 into betaflight:master Nov 13, 2022
@haslinghuis haslinghuis added this to the 1.7 milestone Nov 13, 2022
@klutvott123 klutvott123 deleted the handle-signed-values branch November 17, 2022 12:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

2 participants