pull/2/head
ouki-wang 6 years ago
parent fde3d7941e
commit d71321f763
  1. 64
      DFRobot_AS3935_I2C.cpp
  2. 48
      DFRobot_AS3935_I2C.h
  3. 18
      examples/DFRobot_AS3935_lightning_sensor/DFRobot_AS3935_lightning_sensor.ino
  4. 48
      keywords.txt
  5. 39
      readme.md

@ -10,7 +10,7 @@ DFRobot_AS3935_I2C::DFRobot_AS3935_I2C(uint8_t irqx, uint8_t devAddx)
} }
void DFRobot_AS3935_I2C::AS3935SetI2CAddress(uint8_t devAddx) void DFRobot_AS3935_I2C::setI2CAddress(uint8_t devAddx)
{ {
if (devAddx == AS3935_ADD1) if (devAddx == AS3935_ADD1)
{ {
@ -52,7 +52,7 @@ void DFRobot_AS3935_I2C::singRegWrite(uint8_t regAdd, uint8_t dataMask, uint8_t
Serial.println(singRegRead(regAdd),HEX); Serial.println(singRegRead(regAdd),HEX);
} }
void DFRobot_AS3935_I2C::AS3935DefInit() void DFRobot_AS3935_I2C::defInit()
{ {
AS3935Reset(); // reset registers to default AS3935Reset(); // reset registers to default
} }
@ -71,7 +71,7 @@ void DFRobot_AS3935_I2C::calRCO()
delay(2); // wait 2ms to complete delay(2); // wait 2ms to complete
} }
void DFRobot_AS3935_I2C::AS3935PowerUp(void) void DFRobot_AS3935_I2C::powerUp(void)
{ {
// power-up sequence based on datasheet, pg 23/27 // power-up sequence based on datasheet, pg 23/27
// register 0x00, PWD bit: 0 (clears PWD) // register 0x00, PWD bit: 0 (clears PWD)
@ -82,27 +82,27 @@ void DFRobot_AS3935_I2C::AS3935PowerUp(void)
singRegWrite(0x08, 0x20, 0x00); // set DISP_SRCO to 0 singRegWrite(0x08, 0x20, 0x00); // set DISP_SRCO to 0
} }
void DFRobot_AS3935_I2C::AS3935PowerDown(void) void DFRobot_AS3935_I2C::powerDown(void)
{ {
// register 0x00, PWD bit: 0 (sets PWD) // register 0x00, PWD bit: 0 (sets PWD)
singRegWrite(0x00, 0x01, 0x01); singRegWrite(0x00, 0x01, 0x01);
Serial.println("AS3935 powered down"); Serial.println("AS3935 powered down");
} }
void DFRobot_AS3935_I2C::AS3935DisturberEn(void) void DFRobot_AS3935_I2C::disturberEn(void)
{ {
// register 0x03, PWD bit: 5 (sets MASK_DIST) // register 0x03, PWD bit: 5 (sets MASK_DIST)
singRegWrite(0x03, 0x20, 0x00); singRegWrite(0x03, 0x20, 0x00);
Serial.println("disturber detection enabled"); Serial.println("disturber detection enabled");
} }
void DFRobot_AS3935_I2C::AS3935DisturberDis(void) void DFRobot_AS3935_I2C::disturberDis(void)
{ {
// register 0x03, PWD bit: 5 (sets MASK_DIST) // register 0x03, PWD bit: 5 (sets MASK_DIST)
singRegWrite(0x03, 0x20, 0x20); singRegWrite(0x03, 0x20, 0x20);
} }
void DFRobot_AS3935_I2C::AS3935SetIRQOutputSource(uint8_t irqSelect) void DFRobot_AS3935_I2C::setIRQOutputSource(uint8_t irqSelect)
{ {
// set interrupt source - what to display on IRQ pin // set interrupt source - what to display on IRQ pin
// reg 0x08, bits 5 (TRCO), 6 (SRCO), 7 (LCO) // reg 0x08, bits 5 (TRCO), 6 (SRCO), 7 (LCO)
@ -128,7 +128,7 @@ void DFRobot_AS3935_I2C::AS3935SetIRQOutputSource(uint8_t irqSelect)
} }
void DFRobot_AS3935_I2C::AS3935SetTuningCaps(uint8_t capVal) void DFRobot_AS3935_I2C::setTuningCaps(uint8_t capVal)
{ {
// Assume only numbers divisible by 8 (because that's all the chip supports) // Assume only numbers divisible by 8 (because that's all the chip supports)
if(120 < capVal) // cap_value out of range, assume highest capacitance if(120 < capVal) // cap_value out of range, assume highest capacitance
@ -143,7 +143,7 @@ void DFRobot_AS3935_I2C::AS3935SetTuningCaps(uint8_t capVal)
Serial.println((singRegRead(0x08) & 0x0F)); Serial.println((singRegRead(0x08) & 0x0F));
} }
uint8_t DFRobot_AS3935_I2C::AS3935GetInterruptSrc(void) uint8_t DFRobot_AS3935_I2C::getInterruptSrc(void)
{ {
// definition of interrupt data on table 18 of datasheet // definition of interrupt data on table 18 of datasheet
// for this function: // for this function:
@ -166,13 +166,13 @@ uint8_t DFRobot_AS3935_I2C::AS3935GetInterruptSrc(void)
} }
uint8_t DFRobot_AS3935_I2C::AS3935GetLightningDistKm(void) uint8_t DFRobot_AS3935_I2C::getLightningDistKm(void)
{ {
uint8_t strikeDist = (singRegRead(0x07) & 0x3F); // read register, get rid of non-distance data uint8_t strikeDist = (singRegRead(0x07) & 0x3F); // read register, get rid of non-distance data
return strikeDist; return strikeDist;
} }
uint32_t DFRobot_AS3935_I2C::AS3935GetStrikeEnergyRaw(void) uint32_t DFRobot_AS3935_I2C::getStrikeEnergyRaw(void)
{ {
uint32_t nrgyRaw = ((singRegRead(0x06) & 0x1F) << 8); // MMSB, shift 8 bits left, make room for MSB uint32_t nrgyRaw = ((singRegRead(0x06) & 0x1F) << 8); // MMSB, shift 8 bits left, make room for MSB
nrgyRaw |= singRegRead(0x05); // read MSB nrgyRaw |= singRegRead(0x05); // read MSB
@ -182,7 +182,7 @@ uint32_t DFRobot_AS3935_I2C::AS3935GetStrikeEnergyRaw(void)
return nrgyRaw/16777; return nrgyRaw/16777;
} }
uint8_t DFRobot_AS3935_I2C::AS3935SetMinStrikes(uint8_t minStrk) uint8_t DFRobot_AS3935_I2C::setMinStrikes(uint8_t minStrk)
{ {
// This function sets min strikes to the closest available number, rounding to the floor, // This function sets min strikes to the closest available number, rounding to the floor,
// where necessary, then returns the physical value that was set. Options are 1, 5, 9 or 16 strikes. // where necessary, then returns the physical value that was set. Options are 1, 5, 9 or 16 strikes.
@ -209,7 +209,7 @@ uint8_t DFRobot_AS3935_I2C::AS3935SetMinStrikes(uint8_t minStrk)
} }
} }
void DFRobot_AS3935_I2C::AS3935SetIndoors(void) void DFRobot_AS3935_I2C::setIndoors(void)
{ {
// AFE settings addres 0x00, bits 5:1 (10010, based on datasheet, pg 19, table 15) // AFE settings addres 0x00, bits 5:1 (10010, based on datasheet, pg 19, table 15)
// this is the default setting at power-up (AS3935 datasheet, table 9) // this is the default setting at power-up (AS3935 datasheet, table 9)
@ -217,14 +217,14 @@ void DFRobot_AS3935_I2C::AS3935SetIndoors(void)
Serial.println("set up for indoor operation"); Serial.println("set up for indoor operation");
} }
void DFRobot_AS3935_I2C::AS3935SetOutdoors(void) void DFRobot_AS3935_I2C::setOutdoors(void)
{ {
// AFE settings addres 0x00, bits 5:1 (01110, based on datasheet, pg 19, table 15) // AFE settings addres 0x00, bits 5:1 (01110, based on datasheet, pg 19, table 15)
singRegWrite(0x00, 0x3E, 0x1C); singRegWrite(0x00, 0x3E, 0x1C);
Serial.println("set up for outdoor operation"); Serial.println("set up for outdoor operation");
} }
void DFRobot_AS3935_I2C::AS3935ClearStatistics(void) void DFRobot_AS3935_I2C::clearStatistics(void)
{ {
// clear is accomplished by toggling CL_STAT bit 'high-low-high' (then set low to move on) // clear is accomplished by toggling CL_STAT bit 'high-low-high' (then set low to move on)
singRegWrite(0x02, 0x40, 0x40); // high singRegWrite(0x02, 0x40, 0x40); // high
@ -232,7 +232,7 @@ void DFRobot_AS3935_I2C::AS3935ClearStatistics(void)
singRegWrite(0x02, 0x40, 0x40); // high singRegWrite(0x02, 0x40, 0x40); // high
} }
uint8_t DFRobot_AS3935_I2C::AS3935GetNoiseFloorLvl(void) uint8_t DFRobot_AS3935_I2C::getNoiseFloorLvl(void)
{ {
// NF settings addres 0x01, bits 6:4 // NF settings addres 0x01, bits 6:4
// default setting of 010 at startup (datasheet, table 9) // default setting of 010 at startup (datasheet, table 9)
@ -240,7 +240,7 @@ uint8_t DFRobot_AS3935_I2C::AS3935GetNoiseFloorLvl(void)
return ((regRaw & 0x70) >> 4); // should return value from 0-7, see table 16 for info return ((regRaw & 0x70) >> 4); // should return value from 0-7, see table 16 for info
} }
void DFRobot_AS3935_I2C::AS3935SetNoiseFloorLvl(uint8_t nfSel) void DFRobot_AS3935_I2C::setNoiseFloorLvl(uint8_t nfSel)
{ {
// NF settings addres 0x01, bits 6:4 // NF settings addres 0x01, bits 6:4
// default setting of 010 at startup (datasheet, table 9) // default setting of 010 at startup (datasheet, table 9)
@ -254,7 +254,7 @@ void DFRobot_AS3935_I2C::AS3935SetNoiseFloorLvl(uint8_t nfSel)
} }
} }
uint8_t DFRobot_AS3935_I2C::AS3935GetWatchdogThreshold(void) uint8_t DFRobot_AS3935_I2C::getWatchdogThreshold(void)
{ {
// This function is used to read WDTH. It is used to increase robustness to disturbers, // This function is used to read WDTH. It is used to increase robustness to disturbers,
// though will make detection less efficient (see page 19, Fig 20 of datasheet) // though will make detection less efficient (see page 19, Fig 20 of datasheet)
@ -265,7 +265,7 @@ uint8_t DFRobot_AS3935_I2C::AS3935GetWatchdogThreshold(void)
return (regRaw & 0x0F); return (regRaw & 0x0F);
} }
void DFRobot_AS3935_I2C::AS3935SetWatchdogThreshold(uint8_t wdth) void DFRobot_AS3935_I2C::setWatchdogThreshold(uint8_t wdth)
{ {
// This function is used to modify WDTH. It is used to increase robustness to disturbers, // This function is used to modify WDTH. It is used to increase robustness to disturbers,
// though will make detection less efficient (see page 19, Fig 20 of datasheet) // though will make detection less efficient (see page 19, Fig 20 of datasheet)
@ -275,7 +275,7 @@ void DFRobot_AS3935_I2C::AS3935SetWatchdogThreshold(uint8_t wdth)
singRegWrite(0x01, 0x0F, (wdth & 0x0F)); singRegWrite(0x01, 0x0F, (wdth & 0x0F));
} }
uint8_t DFRobot_AS3935_I2C::AS3935GetSpikeRejection(void) uint8_t DFRobot_AS3935_I2C::getSpikeRejection(void)
{ {
// This function is used to read SREJ (spike rejection). Similar to the Watchdog threshold, // This function is used to read SREJ (spike rejection). Similar to the Watchdog threshold,
// it is used to make the system more robust to disturbers, though will make general detection // it is used to make the system more robust to disturbers, though will make general detection
@ -287,7 +287,7 @@ uint8_t DFRobot_AS3935_I2C::AS3935GetSpikeRejection(void)
return (regRaw & 0x0F); return (regRaw & 0x0F);
} }
void DFRobot_AS3935_I2C::AS3935SetSpikeRejection(uint8_t srej) void DFRobot_AS3935_I2C::setSpikeRejection(uint8_t srej)
{ {
// This function is used to modify SREJ (spike rejection). Similar to the Watchdog threshold, // This function is used to modify SREJ (spike rejection). Similar to the Watchdog threshold,
// it is used to make the system more robust to disturbers, though will make general detection // it is used to make the system more robust to disturbers, though will make general detection
@ -298,7 +298,7 @@ void DFRobot_AS3935_I2C::AS3935SetSpikeRejection(uint8_t srej)
singRegWrite(0x02, 0x0F, (srej & 0x0F)); singRegWrite(0x02, 0x0F, (srej & 0x0F));
} }
void DFRobot_AS3935_I2C::AS3935SetLcoFdiv(uint8_t fdiv) void DFRobot_AS3935_I2C::setLcoFdiv(uint8_t fdiv)
{ {
// This function sets LCO_FDIV register. This is useful in the tuning of the antenna // This function sets LCO_FDIV register. This is useful in the tuning of the antenna
// LCO_FDIV register: add 0x03, bits 7:6 // LCO_FDIV register: add 0x03, bits 7:6
@ -308,7 +308,7 @@ void DFRobot_AS3935_I2C::AS3935SetLcoFdiv(uint8_t fdiv)
singRegWrite(0x03, 0xC0, ((fdiv & 0x03) << 6)); singRegWrite(0x03, 0xC0, ((fdiv & 0x03) << 6));
} }
void DFRobot_AS3935_I2C::AS3935PrintAllRegs(void) void DFRobot_AS3935_I2C::printAllRegs(void)
{ {
Serial.print("Reg 0x00: "); Serial.print("Reg 0x00: ");
Serial.println(singRegRead(0x00)); Serial.println(singRegRead(0x00));
@ -328,40 +328,40 @@ void DFRobot_AS3935_I2C::AS3935PrintAllRegs(void)
Serial.println(singRegRead(0x07)); Serial.println(singRegRead(0x07));
Serial.print("Reg 0x08: "); Serial.print("Reg 0x08: ");
Serial.println(singRegRead(0x08)); Serial.println(singRegRead(0x08));
uint32_t nrgyVal = AS3935GetStrikeEnergyRaw(); uint32_t nrgyVal = getStrikeEnergyRaw();
Serial.println(nrgyVal); Serial.println(nrgyVal);
} }
void DFRobot_AS3935_I2C::AS3935ManualCal(uint8_t capacitance, uint8_t location, uint8_t disturber) void DFRobot_AS3935_I2C::manualCal(uint8_t capacitance, uint8_t location, uint8_t disturber)
{ {
// start by powering up // start by powering up
AS3935PowerUp(); powerUp();
// indoors/outdoors next... // indoors/outdoors next...
if(1 == location) // set outdoors if 1 if(1 == location) // set outdoors if 1
{ {
AS3935SetOutdoors(); setOutdoors();
} }
else // set indoors if anything but 1 else // set indoors if anything but 1
{ {
AS3935SetIndoors(); setIndoors();
} }
// disturber cal // disturber cal
if(0 == disturber) // disabled if 0 if(0 == disturber) // disabled if 0
{ {
AS3935DisturberDis(); disturberDis();
} }
else // enabled if anything but 0 else // enabled if anything but 0
{ {
AS3935DisturberEn(); disturberEn();
} }
AS3935SetIRQOutputSource(0); setIRQOutputSource(0);
delay(500); delay(500);
// capacitance first... directly write value here // capacitance first... directly write value here
AS3935SetTuningCaps(capacitance); setTuningCaps(capacitance);
Serial.println("AS3935 manual cal complete"); Serial.println("AS3935 manual cal complete");
} }

@ -17,36 +17,36 @@ class DFRobot_AS3935_I2C
public: public:
DFRobot_AS3935_I2C(uint8_t irqx, uint8_t devAddx); DFRobot_AS3935_I2C(uint8_t irqx, uint8_t devAddx);
/*! Set i2c address */ /*! Set i2c address */
void AS3935SetI2CAddress(uint8_t devAddx); void setI2CAddress(uint8_t devAddx);
/*! Manual calibration */ /*! Manual calibration */
void AS3935ManualCal(uint8_t capacitance, uint8_t location, uint8_t disturber); void manualCal(uint8_t capacitance, uint8_t location, uint8_t disturber);
/*! reset registers to default */ /*! reset registers to default */
void AS3935DefInit(void); void defInit(void);
void AS3935PowerUp(void); void powerUp(void);
void AS3935PowerDown(void); void powerDown(void);
void AS3935DisturberEn(void); void disturberEn(void);
void AS3935DisturberDis(void); void disturberDis(void);
void AS3935SetIRQOutputSource(uint8_t irqSelect); void setIRQOutputSource(uint8_t irqSelect);
void AS3935SetTuningCaps(uint8_t capVal); void setTuningCaps(uint8_t capVal);
/*! 0 = unknown src, 1 = lightning detected, 2 = disturber, 3 = Noise level too high */ /*! 0 = unknown src, 1 = lightning detected, 2 = disturber, 3 = Noise level too high */
uint8_t AS3935GetInterruptSrc(void); uint8_t getInterruptSrc(void);
/*! Get rid of non-distance data */ /*! Get rid of non-distance data */
uint8_t AS3935GetLightningDistKm(void); uint8_t getLightningDistKm(void);
/*! Get lightning energy intensity */ /*! Get lightning energy intensity */
uint32_t AS3935GetStrikeEnergyRaw(void); uint32_t getStrikeEnergyRaw(void);
uint8_t AS3935SetMinStrikes(uint8_t minStrk); uint8_t setMinStrikes(uint8_t minStrk);
void AS3935ClearStatistics(void); void clearStatistics(void);
void AS3935SetIndoors(void); void setIndoors(void);
void AS3935SetOutdoors(void); void setOutdoors(void);
uint8_t AS3935GetNoiseFloorLvl(void); uint8_t getNoiseFloorLvl(void);
void AS3935SetNoiseFloorLvl(uint8_t nfSel); void setNoiseFloorLvl(uint8_t nfSel);
uint8_t AS3935GetWatchdogThreshold(void); uint8_t getWatchdogThreshold(void);
void AS3935SetWatchdogThreshold(uint8_t wdth); void setWatchdogThreshold(uint8_t wdth);
uint8_t AS3935GetSpikeRejection(void); uint8_t getSpikeRejection(void);
void AS3935SetSpikeRejection(uint8_t srej); void setSpikeRejection(uint8_t srej);
void AS3935SetLcoFdiv(uint8_t fdiv); void setLcoFdiv(uint8_t fdiv);
/*! View register data */ /*! View register data */
void AS3935PrintAllRegs(void); void printAllRegs(void);
private: private:
uint8_t irq, devAdd; uint8_t irq, devAdd;

@ -12,8 +12,8 @@
Copyright [DFRobot](http://www.dfrobot.com), 2018 Copyright [DFRobot](http://www.dfrobot.com), 2018
Copyright GNU Lesser General Public License Copyright GNU Lesser General Public License
version V0.3 version V0.4
date 2018-11-13 date 2018-11-15
*/ */
#include "Lib_I2C.h" #include "Lib_I2C.h"
@ -56,17 +56,17 @@ void setup()
delay(2); delay(2);
// Set registers to default // Set registers to default
lightning0.AS3935DefInit(); lightning0.defInit();
// Configure sensor // Configure sensor
lightning0.AS3935ManualCal(AS3935_CAPACITANCE, AS3935_MODE, AS3935_DIST); lightning0.manualCal(AS3935_CAPACITANCE, AS3935_MODE, AS3935_DIST);
// Enable interrupt (connect IRQ pin IRQ_PIN: 2, default) // Enable interrupt (connect IRQ pin IRQ_PIN: 2, default)
// Connect the IRQ and GND pin to the oscilloscope. // Connect the IRQ and GND pin to the oscilloscope.
// uncomment the following sentences to fine tune the antenna for better performance. // uncomment the following sentences to fine tune the antenna for better performance.
// This will dispaly the antenna's resonance frequency/16 on IRQ pin (The resonance frequency will be divided by 16 on this pin) // This will dispaly the antenna's resonance frequency/16 on IRQ pin (The resonance frequency will be divided by 16 on this pin)
// Tuning AS3935_CAPACITANCE to make the frequency within 500/16 kHz ± 3.5% // Tuning AS3935_CAPACITANCE to make the frequency within 500/16 kHz ± 3.5%
// lightning0.AS3935_SetLCO_FDIV(0); // lightning0.setLcoFdiv(0);
// lightning0.AS3935SetIRQOutputSource(3); // lightning0.setIRQOutputSource(3);
attachInterrupt(0, AS3935_ISR, RISING); attachInterrupt(0, AS3935_ISR, RISING);
@ -82,18 +82,18 @@ void loop()
AS3935IsrTrig = 0; AS3935IsrTrig = 0;
// Get interrupt source // Get interrupt source
uint8_t intSrc = lightning0.AS3935GetInterruptSrc(); uint8_t intSrc = lightning0.getInterruptSrc();
if (intSrc == 1) if (intSrc == 1)
{ {
// Get rid of non-distance data // Get rid of non-distance data
uint8_t lightningDistKm = lightning0.AS3935GetLightningDistKm(); uint8_t lightningDistKm = lightning0.getLightningDistKm();
Serial.println("Lightning occurs!"); Serial.println("Lightning occurs!");
Serial.print("Distance: "); Serial.print("Distance: ");
Serial.print(lightningDistKm); Serial.print(lightningDistKm);
Serial.println(" km"); Serial.println(" km");
// Get lightning energy intensity // Get lightning energy intensity
uint32_t lightningEnergyVal = lightning0.AS3935GetStrikeEnergyRaw(); uint32_t lightningEnergyVal = lightning0.getStrikeEnergyRaw();
Serial.print("Intensity: "); Serial.print("Intensity: ");
Serial.print(lightningEnergyVal); Serial.print(lightningEnergyVal);
Serial.println(""); Serial.println("");

@ -24,30 +24,30 @@ read KEYWORD2
available KEYWORD2 available KEYWORD2
receive KEYWORD2 receive KEYWORD2
AS3935SetI2CAddress KEYWORD2 setI2CAddress KEYWORD2
AS3935ManualCal KEYWORD2 manualCal KEYWORD2
AS3935DefInit KEYWORD2 defInit KEYWORD2
AS3935PowerUp KEYWORD2 powerUp KEYWORD2
AS3935PowerDown KEYWORD2 powerDown KEYWORD2
AS3935DisturberEn KEYWORD2 disturberEn KEYWORD2
AS3935DisturberDis KEYWORD2 disturberDis KEYWORD2
AS3935SetIRQOutputSource KEYWORD2 setIRQOutputSource KEYWORD2
AS3935SetTuningCaps KEYWORD2 setTuningCaps KEYWORD2
AS3935GetInterruptSrc KEYWORD2 getInterruptSrc KEYWORD2
AS3935GetLightningDistKm KEYWORD2 getLightningDistKm KEYWORD2
AS3935GetStrikeEnergyRaw KEYWORD2 getStrikeEnergyRaw KEYWORD2
AS3935SetMinStrikes KEYWORD2 setMinStrikes KEYWORD2
AS3935ClearStatistics KEYWORD2 clearStatistics KEYWORD2
AS3935SetIndoors KEYWORD2 setIndoors KEYWORD2
AS3935SetOutdoors KEYWORD2 setOutdoors KEYWORD2
AS3935GetNoiseFloorLvl KEYWORD2 getNoiseFloorLvl KEYWORD2
AS3935SetNoiseFloorLvl KEYWORD2 setNoiseFloorLvl KEYWORD2
AS3935GetWatchdogThreshold KEYWORD2 getWatchdogThreshold KEYWORD2
AS3935SetWatchdogThreshold KEYWORD2 setWatchdogThreshold KEYWORD2
AS3935GetSpikeRejection KEYWORD2 getSpikeRejection KEYWORD2
AS3935SetSpikeRejection KEYWORD2 setSpikeRejection KEYWORD2
AS3935SetLcoFdiv KEYWORD2 setLcoFdiv KEYWORD2
AS3935PrintAllRegs KEYWORD2 printAllRegs KEYWORD2
####################################### #######################################
# Constants (LITERAL1) # Constants (LITERAL1)

@ -53,14 +53,14 @@ DFRobot_AS3935_I2C(uint8_t irqx, uint8_t devAddx);
/* /*
* @brief reset registers to default * @brief reset registers to default
*/ */
void AS3935DefInit(void); void defInit(void);
/* /*
* @brief set i2c address * @brief set i2c address
* *
* @param devAddx i2c address * @param devAddx i2c address
*/ */
void AS3935SetI2CAddress(uint8_t devAddx); void setI2CAddress(uint8_t devAddx);
/* /*
* @brief manual calibration * @brief manual calibration
@ -69,12 +69,12 @@ void AS3935SetI2CAddress(uint8_t devAddx);
* location location * location location
* disturber disturber * disturber disturber
*/ */
void AS3935ManualCal(uint8_t capacitance, uint8_t location, uint8_t disturber); void manualCal(uint8_t capacitance, uint8_t location, uint8_t disturber);
/* /*
* @brief view register data * @brief view register data
*/ */
void AS3935PrintAllRegs(void); void printAllRegs(void);
/* /*
* @brief get interrupt source * @brief get interrupt source
@ -84,46 +84,55 @@ void AS3935PrintAllRegs(void);
* 2 disturber detected * 2 disturber detected
* 3 Noise level too high * 3 Noise level too high
*/ */
uint8_t AS3935GetInterruptSrc(void); uint8_t getInterruptSrc(void);
/* /*
* @brief get lightning distance * @brief get lightning distance
* *
* @return unit kilometer * @return unit kilometer
*/ */
uint8_t AS3935GetLightningDistKm(void); uint8_t getLightningDistKm(void);
/* /*
* @brief get lightning energy intensity * @brief get lightning energy intensity
* *
* @return lightning energy intensity(0-1000) * @return lightning energy intensity(0-1000)
*/ */
uint32_t AS3935GetStrikeEnergyRaw(void); uint32_t getStrikeEnergyRaw(void);
/* /*
* @brief Set to the outdoor model * @brief Set to the outdoor model
*/ */
void AS3935SetOutdoors(void); void setOutdoors(void);
/* /*
* @brief Set to the indoor model * @brief Set to the indoor model
*/ */
void AS3935SetIndoors(void); void setIndoors(void);
/* /*
* @brief Print all register values * @brief Disturber detection enabled
*/ */
void AS3935PrintAllRegs(void); void disturberEn(void);
/* /*
* @brief Disturber detection enabled * @brief Disturber detection disenabled
*/ */
void DFRobot_AS3935_I2C::AS3935DisturberEn(void); void disturberDis(void);
/* /*
* @brief Disturber detection disenabled * @brief Sets LCO_FDIV register
*
* @param fdiv Set 0, 1, 2 or 3 for ratios of 16, 32, 64 and 128, respectively
*/
void setLcoFdiv(uint8_t fdiv);
/*
* @brief Set interrupt source
*
* @param irqSelect 0 = NONE, 1 = TRCO, 2 = SRCO, 3 = LCO
*/ */
void DFRobot_AS3935_I2C::AS3935DisturberDis(void); void setIRQOutputSource(uint8_t irqSelect);
``` ```

Loading…
Cancel
Save