Skip to content

Commit 875a32e

Browse files
authored
make display of PID valid code (#9)
make display of PID valid code
1 parent 0405a74 commit 875a32e

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

Project.toml

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
name = "DiscretePIDs"
22
uuid = "c1363496-6848-4723-8758-079b737f6baf"
33
authors = ["Fredrik Bagge Carlson"]
4-
version = "0.1.3"
4+
version = "0.1.4"
5+
6+
[deps]
7+
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
58

69
[compat]
710
julia = "1.7"

src/DiscretePIDs.jl

+7-4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ module DiscretePIDs
22

33
export DiscretePID, calculate_control!, set_K!, set_Td!, set_Ti!
44

5+
using Printf
6+
57
"""
68
DiscretePID{T}
79
"""
@@ -78,8 +80,8 @@ function DiscretePID(;
7880
Tt = Ti > 0 && Td > 0 ? typeof(K)((Ti*Td)) : typeof(K)(10),
7981
N = typeof(K)(10),
8082
b = typeof(K)(1),
81-
umin = typemin(K),
82-
umax = typemax(K),
83+
umin = typemin(typeof(K)),
84+
umax = typemax(typeof(K)),
8385
Ts,
8486
I = zero(typeof(K)),
8587
D = zero(typeof(K)),
@@ -175,10 +177,11 @@ end
175177
(pid::DiscretePID)(args...) = calculate_control!(pid, args...)
176178

177179
function Base.show(io::IO, ::MIME"text/plain", pid::DiscretePID)
178-
println(io, "$(typeof(pid)) with parameters and state:")
180+
println(io, "$(typeof(pid))( # with parameters and state:")
179181
for name in fieldnames(DiscretePID)
180-
println(io, name, ":\t", getfield(pid, name))
182+
@printf(io, " %-14.7g,# %s\n", getfield(pid, name), name)
181183
end
184+
println(io, ")")
182185
end
183186

184187

0 commit comments

Comments
 (0)