Class: Denko::AnalogIO::Input

Inherits:
Object
  • Object
show all
Includes:
InputHelper, Behaviors::InputPin, Behaviors::Lifecycle, Behaviors::Listener, Behaviors::Poller
Defined in:
lib/denko/analog_io/input.rb

Direct Known Subclasses

Potentiometer

Constant Summary

Constants included from Behaviors::Lifecycle

Behaviors::Lifecycle::CALLBACK_METHODS

Constants included from Behaviors::Reader

Behaviors::Reader::READ_WAIT_TIME

Constants included from Behaviors::InputPin

Behaviors::InputPin::INPUT_MODES

Instance Attribute Summary collapse

Attributes included from InputHelper

#smoothing, #smoothing_size

Attributes included from Behaviors::State

#state

Attributes included from Behaviors::Threaded

#interrupts_enabled, #thread

Attributes included from Behaviors::SinglePin

#mode, #pin

Attributes included from Behaviors::Component

#board, #params

Instance Method Summary collapse

Methods included from Behaviors::Lifecycle

included

Methods included from InputHelper

#on_change, #pre_callback_filter, #smooth_input, #smoothing_set

Methods included from Behaviors::Listener

#listen, #stop

Methods included from Behaviors::Callbacks

#add_callback, #callbacks, #pre_callback_filter, #remove_callback, #update

Methods included from Behaviors::State

#update_state

Methods included from Behaviors::Poller

#poll, #poll_using, #stop

Methods included from Behaviors::Threaded

#enable_interrupts, included, #mruby_thread_check, #stop, #stop_thread, #threaded, #threaded_loop

Methods included from Behaviors::Reader

#read, #read_busy?, #read_nb, #read_raw, #read_using, #update

Methods included from Behaviors::InputPin

#_stop_listener, #debounce_time=

Methods included from Behaviors::SinglePin

#convert_pins, #initialize_pins

Methods included from Behaviors::Component

#initialize, #micro_delay

Instance Attribute Details

#dividerObject

Default 16ms listener for analog inputs connected to a Board.



19
20
21
# File 'lib/denko/analog_io/input.rb', line 19

def divider
  @divider ||= params[:divider] || 16
end

#gainObject

PGA gain for ADCs that support it



29
30
31
# File 'lib/denko/analog_io/input.rb', line 29

def gain
  @gain ||= params[:gain]
end

#negative_pinObject

Negative input on ADCs that support it.



24
25
26
# File 'lib/denko/analog_io/input.rb', line 24

def negative_pin
  @negative_pin ||= params[:negative_pin]
end

#sample_rateObject

Sample rates for ADCs that support it.



34
35
36
# File 'lib/denko/analog_io/input.rb', line 34

def sample_rate
  @sample_rate ||= params[:sample_rate]
end

#volts_per_bitObject

Allow ADCs to set this, so exact voltages can be calculated.



41
42
43
# File 'lib/denko/analog_io/input.rb', line 41

def volts_per_bit
  @volts_per_bit
end

Instance Method Details

#_listen(div = nil) ⇒ Object



47
48
49
50
# File 'lib/denko/analog_io/input.rb', line 47

def _listen(div=nil)
  self.divider = div if div
  board.analog_listen(pin, divider)
end

#_readObject



43
44
45
# File 'lib/denko/analog_io/input.rb', line 43

def _read
  board.analog_read(pin, negative_pin, gain, sample_rate)
end