Skip to content

Commit

Permalink
add missing u2i function (thanks @TheCedarPrince)
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander-Barth committed Dec 23, 2024
1 parent ea8de28 commit 8c2cbf1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/pi.jl
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ function tickDiff(t1, t2)
return tDiff
end

u2i(x::UInt32) = signed(x)

"""
Converts a 32 bit unsigned number to signed. If the number
Expand All @@ -81,6 +82,7 @@ function _u2i(x::UInt32)
end



struct InMsg
cmd::Cuint # a bits type
p1::Cuint # an array of bits types
Expand Down
9 changes: 9 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
using PiGPIO
using Test

using PiGPIO: u2i


@testset "utility functions" begin
# https://github.com/joan2937/pigpio/blob/c33738a320a3e28824af7807edafda440952c05d/pigpio.py#L989

@test u2i(UInt32(4294967272)) == -24
@test u2i(UInt32(37)) == 37
end

@testset "aqua checks" begin
include("test_aqua.jl")
Expand Down

0 comments on commit 8c2cbf1

Please sign in to comment.