groupgets / purethermal1-firmware

Reference firmware for PureThermal 1 FLIR Lepton Dev Kit
MIT License
126 stars 64 forks source link

FFC Control on Purethermal 2 #19

Closed Jens1503 closed 5 years ago

Jens1503 commented 5 years ago

Hey,

I use the PT2 with the lepton 3.5 on a Mac OS, and I would like to control the shutter. Does this repository hold the solution to my struggle?

cheers, jens

kekiefer commented 5 years ago

Have you seen this? https://github.com/groupgets/purethermal1-firmware/wiki/Lepton-CCI-through-UVC-extension-units

You could take a look at GetThermal, it sends some CCI commands using these extension units. There are also some python examples here https://github.com/groupgets/purethermal1-uvc-capture

Jens1503 commented 5 years ago

Thanks! I'll have a look at that :) cheers

Jens1503 commented 5 years ago

Ok, so I have tried to sort this out. I m totally new at this, so I hope you could give me some hints and helps :)

So, as I write in python I have tried to use the purethermal1-uvc-capture repository. In the uvctypes.py I added the following: screenshot 2018-11-27 at 12 56 53 Where # LEP_SYS_FFC_SHUTTER_MODE_MANUAL = LEP_CID_SYS_FFC_SHUTTER_MODE_OBJ + 0 = (LEP_SYS_MODULE_BASE + 0x003C ) = 512 + 60

When I add this function in the uvc-deviceinfo.py and run the code, I get the following message: Kernel died, restarting

Any Idea what I do wrong?

kekiefer commented 5 years ago

I think you're close.

You're providing libuvc.uvc_set_ctrl with the parameter unit asSYS_UNIT_ID, then you don't need to add that offset to ctrl, which isn't computed quite right, see the follow up comment. The next two parameters are data and len. data is the shutter position, here's the enum from the SDK:

typedef enum LEP_SYS_FFC_SHUTTER_MODE_E_TAG
{
   LEP_SYS_FFC_SHUTTER_MODE_MANUAL = 0,
   LEP_SYS_FFC_SHUTTER_MODE_AUTO,
   LEP_SYS_FFC_SHUTTER_MODE_EXTERNAL,

   LEP_SYS_FFC_SHUTTER_MODE_END

}LEP_SYS_FFC_SHUTTER_MODE_E, *LEP_SYS_FFC_SHUTTER_MODE_E_PTR;

So data should be 0 or 1, and len will be in bytes, confusingly enums are all 2 bytes.

Note that if you're running a command, data can be anything, but len will be 1 byte.

I'm going to close this issue because this isn't the right place to discuss this. If you need more help, I suggest posting to the FLIR lepton google group with what you know so far (you should get more help with a better researched question) and I'll try to keep an eye on that group. Once you have the solution, posting up there will be very helpful for others.

kekiefer commented 5 years ago

Edit from above, from the first the link I sent.

control_id = ((lepton_cci_reg & 0x00ff) >> 2) + 1

So lepton_cci_reg is LEP_CID_SYS_FFC_SHUTTER_MODE_OBJ (LEP_SYS_MODULE_BASE + 0x3c), then your control_id is (0x3c >> 2) + 1 = 0x10