embeddedadventures / MOD-1016

Source and examples for talking to the MOD-1016 AS3935 lightning sensor module
http://www.embeddedadventures.com/as3935_lightning_sensor_module_mod-1016.html
13 stars 6 forks source link

No constant usage of well defined integers #3

Closed Rotzbua closed 7 years ago

Rotzbua commented 7 years ago

Hi,

this library do not always use well defined integers. For example the irq is a unsigned 8 bit integer uns8, but the function accepts int which could be any size. I think the library should be refactored and use always well defined integers like uns8.

Some bad functions:

void autoTuneCaps(int irq);
sgn32 getFrequency(int irq);
void freqPerTuneCaps(int fdiv, int irq);
void auto_calibrate(int irq);

class AS3935Class
{
private:
    uns8    _irq; // here well defined
public:
    void init(int IRQ_pin); // bad
    int  calculateDistance();
    int  getDivisionRatio();
    unsigned int  getIntensity();
};
dr4nc3s commented 7 years ago

Thanks for pointing that out! I'll get to work on it and update it after testing :)