Class: Denko::Motor::A3967

Inherits:
Object
  • Object
show all
Includes:
Behaviors::Lifecycle, Behaviors::MultiPin
Defined in:
lib/denko/motor/a3967.rb

Constant Summary

Constants included from Behaviors::Lifecycle

Behaviors::Lifecycle::CALLBACK_METHODS

Instance Attribute Summary collapse

Attributes included from Behaviors::MultiPin

#pin, #pins, #proxies

Attributes included from Behaviors::Component

#board, #params

Attributes included from Behaviors::State

#state

Instance Method Summary collapse

Methods included from Behaviors::Lifecycle

included

Methods included from Behaviors::MultiPin

#convert_pins, #proxy_pin, #proxy_states, #require_pin, #require_pins

Methods included from Behaviors::Component

#initialize, #micro_delay

Methods included from Behaviors::State

#update_state

Instance Attribute Details

#microstepsObject

Returns the value of attribute microsteps.



17
18
19
# File 'lib/denko/motor/a3967.rb', line 17

def microsteps
  @microsteps
end

Instance Method Details

#initialize_pins(options = {}) ⇒ Object



7
8
9
10
11
12
13
14
15
# File 'lib/denko/motor/a3967.rb', line 7

def initialize_pins(options={})
  proxy_pin :step,      DigitalIO::Output
  proxy_pin :direction, DigitalIO::Output

  proxy_pin :ms1,    DigitalIO::Output, optional: true
  proxy_pin :ms2,    DigitalIO::Output, optional: true
  proxy_pin :enable, DigitalIO::Output, optional: true
  proxy_pin :slp,    DigitalIO::Output, optional: true
end

#offObject



33
34
35
# File 'lib/denko/motor/a3967.rb', line 33

def off
  enable.high if enable
end

#onObject



37
38
39
# File 'lib/denko/motor/a3967.rb', line 37

def on
  enable.low if enable
end

#sleepObject



25
26
27
# File 'lib/denko/motor/a3967.rb', line 25

def sleep
  slp.low if slp
end

#step_ccwObject



55
56
57
58
59
# File 'lib/denko/motor/a3967.rb', line 55

def step_ccw
  direction.high unless direction.high?
  step.high
  step.low
end

#step_cwObject



61
62
63
64
65
# File 'lib/denko/motor/a3967.rb', line 61

def step_cw
  direction.low unless direction.low?
  step.high
  step.low
end

#wakeObject



29
30
31
# File 'lib/denko/motor/a3967.rb', line 29

def wake
  slp.high if slp
end