Class: DeviceControl::Smoother

Inherits:
Object
  • Object
show all
Includes:
Updateable
Defined in:
lib/device_control.rb

Instance Method Summary collapse

Methods included from Updateable

#update

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

#outputObject



283
284
285
# File 'lib/device_control.rb', line 283

def output
  @val
end