Class: LGPIO::PositionalServo

Inherits:
HardwarePWM show all
Defined in:
lib/lgpio/positional_servo.rb

Constant Summary collapse

FREQUENCY =
50

Constants inherited from HardwarePWM

HardwarePWM::NS_PER_S, HardwarePWM::NS_PER_US, HardwarePWM::SYS_FS_PWM_PATH

Instance Attribute Summary collapse

Attributes inherited from HardwarePWM

#duty, #enabled, #period, #polarity

Instance Method Summary collapse

Methods inherited from HardwarePWM

#disable, #duty_path, #duty_percent, #duty_percent=, #duty_us=, #enable, #enable_path, #frequency, #frequency=, #path, #period_path, #polarity_path, #tx_wave_ook

Constructor Details

#initialize(chip, channel, min_us, max_us, min_angle, max_angle) ⇒ PositionalServo

Returns a new instance of PositionalServo.



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/lgpio/positional_servo.rb', line 7

def initialize(chip, channel, min_us, max_us, min_angle, max_angle)
  super(chip, channel, frequency: FREQUENCY)

  raise "min_us: #{min_us} cannot be lower than max_us: #{max_us}" if max_us < min_us
  @min_us = min_us
  @max_us = max_us
  @us_range = @max_us - @min_us

  @min_angle = min_angle
  @max_angle = max_angle
end

Instance Attribute Details

#angleObject

Returns the value of attribute angle.



5
6
7
# File 'lib/lgpio/positional_servo.rb', line 5

def angle
  @angle
end