Class: Denko::AnalogIO::Input
- Inherits:
-
Object
- Object
- Denko::AnalogIO::Input
- Includes:
- InputHelper, Behaviors::InputPin, Behaviors::Lifecycle, Behaviors::Listener, Behaviors::Poller
- Defined in:
- lib/denko/analog_io/input.rb
Direct Known Subclasses
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
-
#divider ⇒ Object
Default 16ms listener for analog inputs connected to a Board.
-
#gain ⇒ Object
PGA gain for ADCs that support it.
-
#negative_pin ⇒ Object
Negative input on ADCs that support it.
-
#sample_rate ⇒ Object
Sample rates for ADCs that support it.
-
#volts_per_bit ⇒ Object
Allow ADCs to set this, so exact voltages can be calculated.
Attributes included from InputHelper
Attributes included from Behaviors::State
Attributes included from Behaviors::Threaded
Attributes included from Behaviors::SinglePin
Attributes included from Behaviors::Component
Instance Method Summary collapse
Methods included from Behaviors::Lifecycle
Methods included from InputHelper
#on_change, #pre_callback_filter, #smooth_input, #smoothing_set
Methods included from Behaviors::Listener
Methods included from Behaviors::Callbacks
#add_callback, #callbacks, #pre_callback_filter, #remove_callback, #update
Methods included from Behaviors::State
Methods included from Behaviors::Poller
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
Instance Attribute Details
#divider ⇒ Object
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 |
#gain ⇒ Object
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_pin ⇒ Object
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_rate ⇒ Object
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_bit ⇒ Object
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 |
#_read ⇒ Object
43 44 45 |
# File 'lib/denko/analog_io/input.rb', line 43 def _read board.analog_read(pin, negative_pin, gain, sample_rate) end |