pcfens / RaspberryPi-AS3935

A basic library for working with the AS3935 that's connected to the Raspberry Pi.
Other
52 stars 24 forks source link

calibration methods added #14

Closed merlinmb closed 9 years ago

merlinmb commented 9 years ago

Hi @pcfens - I have written two methods in python to put the module into calibration mode to find the frequency, tried committing, seems I have no rights. Perhaps you would consider including these methods into RPi_AS3935.py

def display_res_freq_irq(self):
    # Set register to get resonant frequency
    # Note: multiply frequency reading by 16 for actual resonating frequency (target:500khz)
    self.read_data()
    self.set_byte(0x08, (self.registers[0x08] | 0x80))  
    time.sleep(0.002)
    # Good to measure IRQ pin for freq..

def display_res_freq_irq_off(self): 
    # Reset IRQ for no freq output"   
    #01111111 = 0x7F     = off
    self.read_data()
    self.set_byte(0x08, (self.registers[0x08] & 0x7F))
    time.sleep(0.002)
pcfens commented 9 years ago

Hi @merlinmb - I really like the idea of making the library more complete.

To submit patches directly you'll want to fork the repository, then make changes in a new branch before submitting a pull request. I'll review the code (after some automated style checking) and if everything looks good the code is added.

Rather than using 2 functions I think it might make more sense to have one setter with a parameter like

def set_disp_lco(self, display):
    self.read_data()
    if display:
        self.set_byte(0x08, (self.registers[0x08] | 0x80))
    else:
        self.set_byte(0x08, (self.registers[0x08] & 0x7F))
    time.sleep(0.002)

It might even be paired with another function to get the status of the flag as well.

Thoughts?

merlinmb commented 9 years ago

Thanks for the assistance - new to python and Git, I'm receiving errors while trying to publish a new branch with my changes... will research more online on howto accomplish this with Git for Windows destop.

On Wed, Jan 7, 2015 at 9:30 PM, Phil Fenstermacher <notifications@github.com

wrote:

Hi @merlinmb https://github.com/merlinmb - I really like the idea of making the library more complete.

To submit patches directly you'll want to fork the repository, then make changes in a new branch before submitting a pull request https://help.github.com/articles/using-pull-requests/. I'll review the code (after some automated style checking) and if everything looks good the code is added.

Rather than using 2 functions I think it might make more sense to have one setter with a parameter like

def set_disp_lco(self, display): self.read_data() if display: self.set_byte(0x08, (self.registers[0x08] | 0x80)) else: self.set_byte(0x08, (self.registers[0x08] & 0x7F)) time.sleep(0.002)

It might even be paired with another function to get the status of the flag as well.

Thoughts?

— Reply to this email directly or view it on GitHub https://github.com/pcfens/RaspberryPi-AS3935/issues/14#issuecomment-69077140 .

pcfens commented 9 years ago

Relates to PR #16

pcfens commented 9 years ago

Closed/fixed as part of #16 and #18.