pub struct AS3935<I2C, D> { /* private fields */ }Expand description
the AS3935 device
Implementations§
Source§impl<I2C, D, E> AS3935<I2C, D>
impl<I2C, D, E> AS3935<I2C, D>
Sourcepub fn new(i2c: I2C, address: u8, delayer: D) -> Self
pub fn new(i2c: I2C, address: u8, delayer: D) -> Self
create new AS3935 driver with address and delay given
the datasheet states the max speed is 400 kHz with just AS3935 on the bus and external 10 k pull ups
otherwise use 4k7 pulls up and max speed is 100 kHz.
Best to use 100 kHz.
use constant::DeviceAddress::default() with AD1 and AD0 pins high
Source§impl<I2C, D, E> AS3935<I2C, D>
impl<I2C, D, E> AS3935<I2C, D>
Sourcepub fn calibrate_osc(&mut self) -> Result<(), Error<E>>
pub fn calibrate_osc(&mut self) -> Result<(), Error<E>>
calibrate both internal oscillators, first tune your antenna
Sourcepub fn reset_settings(&mut self) -> Result<(), Error<E>>
pub fn reset_settings(&mut self) -> Result<(), Error<E>>
reset all settings to defaults
Sourcepub fn get_lightning_energy(&mut self) -> Result<u32, Error<E>>
pub fn get_lightning_energy(&mut self) -> Result<u32, Error<E>>
read lightning energy (unit-less as per datasheet)
Sourcepub fn display_oscillator(
&mut self,
state: bool,
osc: Oscillator,
) -> Result<(), Error<E>>
pub fn display_oscillator( &mut self, state: bool, osc: Oscillator, ) -> Result<(), Error<E>>
display oscillator on IRQ pin state = true to turn on, false to turn off use a logic analyzer or oscilloscope to see the clock signal.
Sourcepub fn get_distance_to_storm(&mut self) -> Result<StormFrontDistance, Error<E>>
pub fn get_distance_to_storm(&mut self) -> Result<StormFrontDistance, Error<E>>
get distance to storm front in km. > 40 km == OutOfRange
Sourcepub fn power_down(&mut self) -> Result<(), Error<E>>
pub fn power_down(&mut self) -> Result<(), Error<E>>
power_down note: the TRCO oscillator must then be recalibrated after power_down() call which is built into wakeup()
Sourcepub fn set_indoor_outdoor(&mut self, location: Location) -> Result<(), Error<E>>
pub fn set_indoor_outdoor(&mut self, location: Location) -> Result<(), Error<E>>
set indoor-outdoor location of sensor
Sourcepub fn get_indoor_outdoor(&mut self) -> Result<Location, Error<E>>
pub fn get_indoor_outdoor(&mut self) -> Result<Location, Error<E>>
get indoor-outdoor location from sensor
Sourcepub fn get_interrupt_register(&mut self) -> Result<INTType, Error<E>>
pub fn get_interrupt_register(&mut self) -> Result<INTType, Error<E>>
get interrupt register: useful to see what the AS3935 detected
Sourcepub fn set_watchdog_threshold(&mut self, threshold: u8) -> Result<(), Error<E>>
pub fn set_watchdog_threshold(&mut self, threshold: u8) -> Result<(), Error<E>>
set watchdog threshold, threshold < 11
Sourcepub fn get_watchdog_threshold(&mut self) -> Result<u8, Error<E>>
pub fn get_watchdog_threshold(&mut self) -> Result<u8, Error<E>>
get watchdog threshold
Sourcepub fn set_noise_level(&mut self, level: u8) -> Result<(), Error<E>>
pub fn set_noise_level(&mut self, level: u8) -> Result<(), Error<E>>
set noise floor level, level < 8
Sourcepub fn get_noise_level(&mut self) -> Result<u8, Error<E>>
pub fn get_noise_level(&mut self) -> Result<u8, Error<E>>
get noise floor level
Sourcepub fn set_lightning_threshold(
&mut self,
threshold: MinStrikes,
) -> Result<(), Error<E>>
pub fn set_lightning_threshold( &mut self, threshold: MinStrikes, ) -> Result<(), Error<E>>
set lightning threshold (minimum number of lightning strikes)
Sourcepub fn get_lightning_threshold(&mut self) -> Result<MinStrikes, Error<E>>
pub fn get_lightning_threshold(&mut self) -> Result<MinStrikes, Error<E>>
get lightning threshold (minimum number of lightning strikes)
Sourcepub fn clear_statistics(&mut self) -> Result<(), Error<E>>
pub fn clear_statistics(&mut self) -> Result<(), Error<E>>
clear statistics : clears the number of lightning strikes detected in last 15 minutes
Sourcepub fn set_mask_disturber(&mut self, enable: bool) -> Result<(), Error<E>>
pub fn set_mask_disturber(&mut self, enable: bool) -> Result<(), Error<E>>
set mask disturber: defines if “disturbers” trigger interrupts, default is false == not masked
Sourcepub fn get_mask_disturber(&mut self) -> Result<bool, Error<E>>
pub fn get_mask_disturber(&mut self) -> Result<bool, Error<E>>
get mask disturber: whether disturbers triggers interrupts
Sourcepub fn set_spike_rejection(&mut self, sensitivity: u8) -> Result<(), Error<E>>
pub fn set_spike_rejection(&mut self, sensitivity: u8) -> Result<(), Error<E>>
set spike rejection sensitivity < 16
Sourcepub fn get_spike_rejection(&mut self) -> Result<u8, Error<E>>
pub fn get_spike_rejection(&mut self) -> Result<u8, Error<E>>
get spike rejection sensitivity
Sourcepub fn set_antenna_div_ratio(&mut self, ratio: u8) -> Result<(), Error<E>>
pub fn set_antenna_div_ratio(&mut self, ratio: u8) -> Result<(), Error<E>>
set antenna frequency division ratio for antenna tuning ratios are: 16, 32, 64 or 128
Sourcepub fn get_antenna_div_ratio(&mut self) -> Result<u8, Error<E>>
pub fn get_antenna_div_ratio(&mut self) -> Result<u8, Error<E>>
get antenna frequency division ratio for antenna tuning
Sourcepub fn set_tuning_cap(&mut self, p_farads: u8) -> Result<(), Error<E>>
pub fn set_tuning_cap(&mut self, p_farads: u8) -> Result<(), Error<E>>
set tuning cap for antenna farads must be <= 128 and modulo 8, specifically from 0 to 120 pF in steps of 8 pF (modulo 8)
Sourcepub fn get_tuning_cap(&mut self) -> Result<u8, Error<E>>
pub fn get_tuning_cap(&mut self) -> Result<u8, Error<E>>
get tuning cap (internal) for antenna in pF, manufacturer default is 0 pF if not changed