Class: DeviceControl::Smoother
- Inherits:
-
Object
- Object
- DeviceControl::Smoother
- Includes:
- Updateable
- Defined in:
- lib/device_control.rb
Instance Method Summary collapse
-
#initialize(max_step:) ⇒ Smoother
constructor
A new instance of Smoother.
- #input=(val) ⇒ Object
- #output ⇒ Object
Methods included from Updateable
Constructor Details
#initialize(max_step:) ⇒ Smoother
Returns a new instance of Smoother.
273 274 275 276 |
# File 'lib/device_control.rb', line 273 def initialize(max_step:) @max_step = max_step @val = 0.0 end |
Instance Method Details
#input=(val) ⇒ Object
278 279 280 281 |
# File 'lib/device_control.rb', line 278 def input=(val) diff = val - @val @val += diff.clamp(-1 * @max_step, @max_step) end |
#output ⇒ Object
283 284 285 |
# File 'lib/device_control.rb', line 283 def output @val end |