AMS, Franklin Lightning Sensor "AS3935" Library
Embed:
(wiki syntax)
Show/hide line numbers
AS3935.h
00001 /* 00002 * AMS, Franklin Lightning Sensor "AS3935" Library 00003 * Copyright (c) 2015 Hiroshi Suga 00004 * Released under the MIT License: http://mbed.org/license/mit 00005 */ 00006 // http://ams.com/eng/Products/Lightning-Sensor/Franklin-Lightning-Sensor/AS3935 00007 00008 #ifndef _AS3935_h_ 00009 #define _AS3935_h_ 00010 00011 #include "mbed.h" 00012 00013 class AS3935 { 00014 public: 00015 /** 00016 * @param i2c I2C class 00017 * @param irq IRQ pin 00018 */ 00019 AS3935 (I2C &i2c, PinName irq); 00020 /** 00021 * @param sda I2C SDA pin 00022 * @param scl I2C SCL pin 00023 * @param irq IRQ pin 00024 */ 00025 AS3935 (PinName sda, PinName scl, PinName irq); 00026 00027 /** Initialize AS3935 00028 */ 00029 void init (); 00030 00031 /** Read lightning signal validation 00032 * @param energy (return) Energy of the Single Lightning 00033 * @param distance (return) Distance estimation 00034 */ 00035 void read (int &energy, int &distance); 00036 00037 /** Attach a function, lightning interrupt 00038 * @param fptr pointer to a void function, or 0 to set as none 00039 */ 00040 void attach(void (*fptr)(void)) { 00041 _func.attach(fptr); 00042 } 00043 /** Attach a member function, lightning interrupt 00044 * @param tptr pointer to the object to call the member function on 00045 * @param mptr pointer to the member function to be called 00046 */ 00047 template<typename T> 00048 void attach(T *tptr, void (T::*mptr)(void)) { 00049 _func.attach(tptr, mptr); 00050 } 00051 00052 private: 00053 I2C _i2c; 00054 InterruptIn _irq; 00055 int _freq; 00056 int _mode; 00057 int _type; 00058 00059 FunctionPointer _func; 00060 00061 void calib_lco (); 00062 void isr_freq (); 00063 void isr_lightning (); 00064 }; 00065 00066 #endif
Generated on Fri Jul 22 2022 07:09:25 by 1.7.2