Class: Denko::Sensor::VL53L0X

Inherits:
Object
  • Object
show all
Includes:
AnalogIO::InputHelper, Behaviors::Lifecycle, Behaviors::Poller, I2C::Peripheral
Defined in:
lib/denko/sensor/vl53l0x.rb

Constant Summary collapse

I2C_ADDRESS =
0x29
REFERENCE_REGISTER_START =
0xC0
REFERENCE_VALUES =
[0xEE, 0xAA, 0x10]
SYSRANGE_START =
0x00
POWER_MANAGEMENT_GO1_POWER_FORCE =
0x80
INTERNAL_TUNING_1 =
0x91
INTERNAL_TUNING_2 =
0xFF
RESULT_RANGE_STATUS =
0x14

Constants included from Behaviors::Lifecycle

Behaviors::Lifecycle::CALLBACK_METHODS

Constants included from Behaviors::Reader

Behaviors::Reader::READ_WAIT_TIME

Constants included from I2C::Peripheral

I2C::Peripheral::I2C_FREQUENCY, I2C::Peripheral::I2C_REPEATED_START

Instance Attribute Summary collapse

Attributes included from AnalogIO::InputHelper

#smoothing, #smoothing_size

Attributes included from Behaviors::Threaded

#interrupts_enabled, #thread

Attributes included from Behaviors::State

#state

Attributes included from I2C::Peripheral

#i2c_frequency, #i2c_repeated_start

Attributes included from Behaviors::Component

#board, #params

Instance Method Summary collapse

Methods included from AnalogIO::InputHelper

#on_change, #smooth_input, #smoothing_set

Methods included from Behaviors::Lifecycle

included

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::Callbacks

#add_callback, #callbacks, #remove_callback, #update

Methods included from Behaviors::State

#update_state

Methods included from I2C::Peripheral

#address, #i2c_default, #i2c_read, #i2c_read_raw, #i2c_write

Methods included from Behaviors::BusPeripheralAddressed

#address

Methods included from Behaviors::BusPeripheral

#atomically

Methods included from Behaviors::Component

#initialize, #micro_delay

Instance Attribute Details

#correction_offsetObject

Returns the value of attribute correction_offset.



21
22
23
# File 'lib/denko/sensor/vl53l0x.rb', line 21

def correction_offset
  @correction_offset
end

#stop_variableObject (readonly)

Returns the value of attribute stop_variable.



20
21
22
# File 'lib/denko/sensor/vl53l0x.rb', line 20

def stop_variable
  @stop_variable
end

Instance Method Details

#_readObject



45
46
47
# File 'lib/denko/sensor/vl53l0x.rb', line 45

def _read
  i2c_read(2, register: RESULT_RANGE_STATUS + 10)
end

#pre_callback_filter(bytes) ⇒ Object



49
50
51
52
53
54
55
# File 'lib/denko/sensor/vl53l0x.rb', line 49

def pre_callback_filter(bytes)
  # Distance is 2 bytes, big-endian.
  mm = (bytes[0] << 8) | bytes[1]
  mm = mm + correction_offset if correction_offset
  # super handles smoothing if enabled.
  return (mm > 0) ? super(mm) : nil
end