Class: Raudi::AVR::Timer

Inherits:
Object
  • Object
show all
Defined in:
lib/raudi/avr/timer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, params) ⇒ Timer

Returns a new instance of Timer.



19
20
21
22
23
# File 'lib/raudi/avr/timer.rb', line 19

def initialize(name, params)
  self.name = name
  self.length = params['length']
  self.normal!
end

Instance Attribute Details

#activeObject

Returns the value of attribute active.



7
8
9
# File 'lib/raudi/avr/timer.rb', line 7

def active
  @active
end

#counterObject

Returns the value of attribute counter.



7
8
9
# File 'lib/raudi/avr/timer.rb', line 7

def counter
  @counter
end

#interruptObject

Returns the value of attribute interrupt.



7
8
9
# File 'lib/raudi/avr/timer.rb', line 7

def interrupt
  @interrupt
end

#lengthObject

Returns the value of attribute length.



7
8
9
# File 'lib/raudi/avr/timer.rb', line 7

def length
  @length
end

#modeObject

Returns the value of attribute mode.



7
8
9
# File 'lib/raudi/avr/timer.rb', line 7

def mode
  @mode
end

#mode_paramsObject

Returns the value of attribute mode_params.



7
8
9
# File 'lib/raudi/avr/timer.rb', line 7

def mode_params
  @mode_params
end

#nameObject

Returns the value of attribute name.



7
8
9
# File 'lib/raudi/avr/timer.rb', line 7

def name
  @name
end

#prescaleObject

Returns the value of attribute prescale.



7
8
9
# File 'lib/raudi/avr/timer.rb', line 7

def prescale
  @prescale
end

Instance Method Details

#max_numberObject



33
34
35
# File 'lib/raudi/avr/timer.rb', line 33

def max_number
  2**length
end

#numberObject



25
26
27
# File 'lib/raudi/avr/timer.rb', line 25

def number
  name[/\d+/].to_i
end

#rangeObject



29
30
31
# File 'lib/raudi/avr/timer.rb', line 29

def range
  0...max_number
end