-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpid_group.rb
35 lines (29 loc) · 964 Bytes
/
pid_group.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
require_relative 'config'
class PIDGroup < FXGroupBox
def initialize(parent, window, type, name)
@name = name
@window = window
@type = type
super(parent, @name.to_s.capitalize, FRAME_RIDGE | LAYOUT_SIDE_LEFT)
self.setFont(FXFont.new(getApp(), "Helvetica", 14, FONTWEIGHT_BOLD))
# [kp, ki, kd, kw]
@control = []
4.times do
@control << FXDataTarget.new(0.0)
end
pid_matrix = FXMatrix.new(self, 2, MATRIX_BY_COLUMNS)
[:p, :i, :d, :w].each.with_index do |k, i|
FXLabel.new(pid_matrix, "k#{k}: ")
FXRealSpinner.new(pid_matrix, 7, @control[i],
FXDataTarget::ID_VALUE, FRAME_NORMAL
).setIncrement(Config::TUNING_STEP)
@control[i].connect(SEL_COMMAND) { |sender, sel, data| update_value(k, data) }
end
end
#######
private
#######
def update_value(k, data)
@window.writeout("%s%s%s" % [@type[0], @name[0], k], data)
end
end