cosmac / LePi

LePi is a lightweight library for FLIR Lepton (2, 2.5 and 3) and Raspberry pi.
MIT License
27 stars 10 forks source link

Support for Lepton 3.5 #6

Open brycheiniog opened 5 years ago

brycheiniog commented 5 years ago

Hi,

Has this been tried with a Lepton 3.5 sensor? I have the library working nicely on a Pi 3 Model B with a Lepton 2.5 sensor, but with the 3.5 sensor I just get repeated connect/disconnect messages. The sensor works fine in a PureThermal2 board. This is the quick test code I threw together to illustrate the problem:

        LeptonCamera cam;
    cam.start();
    printf("Dimensions: %dx%d  Type: %d\r\n",cam.width(),cam.height(),cam.LeptonVersion());

    while(1){
        if (cam.hasFrame())
            printf("Got frame!!!\r\n");
        usleep(1000);
    }

This is the output from the Lepton 3.5:

Open SPI port: 0, with address 3
Dimensions: 160x120  Type: 1
Close SPI port: 0, with address 3
Open SPI port: 0, with address 3
Close SPI port: 0, with address 3
Open SPI port: 0, with address 3
Close SPI port: 0, with address 3
Open SPI port: 0, with address 3
Reboot lepton sensor...
Close SPI port: 0, with address 3
Close I2C port: 1, with address 42
Open I2C port: 1, with address 42
Open SPI port: 0, with address 3
Close SPI port: 0, with address 3
Open SPI port: 0, with address 3
Close SPI port: 0, with address 3
Open SPI port: 0, with address 3
Close SPI port: 0, with address 3
Open SPI port: 0, with address 3
Reboot lepton sensor...
Close SPI port: 0, with address 3
Close I2C port: 1, with address 42

Any suggestions?

brycheiniog commented 5 years ago

Just to follow up. Everything worked fine when running the Lepton3-dev branch of pylepton so I dug into that code base and found they were running the SPI clock at 18MHz rather than the 32MHz specified in LeptonCommon.h.

Reducing the SPI Clock to the same 18MHz setting seems to have resolved all my problems. It might be worth suggesting this in the readme if you experience lots of resync attempts.

gar-syn commented 5 years ago

To add to this, I tested the program on the Raspberry Pi 3B+with a Lepton 3.5 and the clock setting of 32MHz works fine, 18MHz doesn't working well at all.