Class: Dino::Components::Stepper

Inherits:
BaseComponent show all
Defined in:
lib/dino/components/stepper.rb

Instance Attribute Summary

Attributes inherited from BaseComponent

#board, #pin, #pullup

Instance Method Summary collapse

Methods inherited from BaseComponent

#initialize

Constructor Details

This class inherits a constructor from Dino::Components::BaseComponent

Instance Method Details

#after_initialize(options = {}) ⇒ Object



5
6
7
8
9
10
11
12
# File 'lib/dino/components/stepper.rb', line 5

def after_initialize(options={})
  raise 'missing pins[:step] pin' unless self.pins[:step]
  raise 'missing pins[:direction] pin' unless self.pins[:direction]

  set_pin_mode(pins[:step], :out)
  set_pin_mode(pins[:direction], :out)
  digital_write(pins[:step], Board::LOW)
end

#step_ccObject



14
15
16
17
18
# File 'lib/dino/components/stepper.rb', line 14

def step_cc
  digital_write(self.pins[:direction], Board::HIGH)
  digital_write(self.pins[:step],      Board::HIGH)
  digital_write(self.pins[:step],      Board::LOW)
end

#step_cwObject



20
21
22
23
24
# File 'lib/dino/components/stepper.rb', line 20

def step_cw
  digital_write(self.pins[:direction], Board::LOW)
  digital_write(self.pins[:step],      Board::HIGH)
  digital_write(self.pins[:step],      Board::LOW)
end