Class: Denko::AnalogIO::ADS1115
- Inherits:
-
Object
- Object
- Denko::AnalogIO::ADS1115
- Includes:
- ADS111X, Behaviors::Lifecycle, I2C::Peripheral
- Defined in:
- lib/denko/analog_io/ads1115.rb
Constant Summary collapse
- I2C_ADDRESS =
0x48- I2C_FREQUENCY =
400_000- CONFIG_STARTUP =
Config register values on startup. MSB-first. Matches datasheet, except MSB bit 7 unset to avoid conversion start. Same as: [0x05, 0x83] or [5, 131]
[0b00000101, 0b10000011]
- BASE_MSB =
Base config bytes to mask settings into. Not same as startup config. MSB bits 0 and 7 set to enable single-shot mode. LSB bits 0 and 1 set to disable comparator.
0b10000001
- BASE_LSB =
0b00000011
- CONFIG_ADDRESS =
Register addresses.
0b01
- CONVERSION_ADDRESS =
0b00
Constants included from ADS111X
Denko::AnalogIO::ADS111X::MUX_SETTINGS, Denko::AnalogIO::ADS111X::PGA_RANGE, Denko::AnalogIO::ADS111X::PGA_SETTINGS, Denko::AnalogIO::ADS111X::SAMPLE_RATE_RANGE, Denko::AnalogIO::ADS111X::SAMPLE_TIMES, Denko::AnalogIO::ADS111X::WAIT_TIMES
Constants included from Behaviors::Reader
Behaviors::Reader::READ_WAIT_TIME
Constants included from Behaviors::Lifecycle
Behaviors::Lifecycle::CALLBACK_METHODS
Constants included from I2C::Peripheral
I2C::Peripheral::I2C_REPEATED_START
Instance Attribute Summary
Attributes included from ADS111X
#active_gain, #active_pin, #config_register
Attributes included from Behaviors::State
Attributes included from I2C::Peripheral
#i2c_frequency, #i2c_repeated_start
Attributes included from Behaviors::Component
Instance Method Summary collapse
Methods included from ADS111X
#analog_listen, #analog_read, #enable_proxy, #mutex, #pins_to_mux_bits, #pre_callback_filter, #stop_listener
Methods included from Behaviors::BoardProxy
#analog_read_high, #analog_write_high, #convert_pin, #high, #low, #set_pin_mode, #start_read
Methods included from Behaviors::Subcomponents
#add_component, #add_hw_i2c, #add_hw_spi, #add_single_pin, #components, #hw_i2c_comps, #hw_spi_comps, #remove_component, #remove_hw_i2c, #remove_hw_spi, #remove_single_pin, #single_pin_components
Methods included from Behaviors::Reader
#read, #read_busy?, #read_nb, #read_raw, #read_using, #update
Methods included from Behaviors::Callbacks
#add_callback, #callbacks, #pre_callback_filter, #remove_callback, #update
Methods included from Behaviors::State
Methods included from Behaviors::Lifecycle
Methods included from I2C::Peripheral
#address, #i2c_default, #i2c_read, #i2c_read_raw, #i2c_write
Methods included from Behaviors::BusPeripheralAddressed
Methods included from Behaviors::BusPeripheral
Methods included from Behaviors::Component
Instance Method Details
#_read(config) ⇒ Object
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/denko/analog_io/ads1115.rb', line 32 def _read(config) # Write config register to start reading. i2c_write [CONFIG_ADDRESS] + config # Sleep the right amount of time for conversion, based on sample rate bits. sleep WAIT_TIMES[config[1] >> 5] # Read the result, triggering callbacks. i2c_read(2, register: CONVERSION_ADDRESS) end |