├── .gitignore ├── LICENSE ├── README.md ├── docs └── lepton_interface_design_document.pdf ├── hardware ├── LeptonBreakout │ ├── LeptonAdaptor.step │ └── LeptonAdaptorSch.PDF └── LeptonMicroBreakout │ ├── PT Micro Breakout Board Dimensional Drawing.pdf │ ├── PT-Micro.kicad_mod │ ├── PT_micro_bob.kicad_sym │ ├── PureThermal Micro Breakout Board Datasheet Rev2 May 2023.pdf │ └── PureThermal_Micro_BoB.step └── software ├── STM32F3Discovery_ChibiOS ├── Makefile ├── README.md ├── chconf.h ├── flir_dump.c ├── halconf.h ├── main.c ├── make_all.bat ├── make_changes.bat ├── mcuconf.h ├── usbcfg.c └── usbcfg.h ├── ThermalView ├── Makefile ├── README.md ├── include │ ├── callbacks.h │ └── guicon.h ├── obj │ └── .gitignore ├── res │ ├── Application.ico │ ├── Application.manifest │ ├── main_dialog.rc │ └── resource.h └── src │ ├── guicon.c │ ├── serial_win32.c │ ├── serial_win32.h │ └── winmain.c ├── arduino_i2c └── Lepton.ino ├── beagleboneblack_video ├── LeptonThread.cpp ├── LeptonThread.h ├── Lepton_I2C.cpp ├── Lepton_I2C.h ├── MyLabel.cpp ├── MyLabel.h ├── Palettes.cpp ├── Palettes.h ├── README.md ├── SPI.cpp ├── SPI.h ├── bbb.pro ├── leptonSDKEmb32PUB │ ├── LEPTON_AGC.c │ ├── LEPTON_AGC.h │ ├── LEPTON_ErrorCodes.h │ ├── LEPTON_I2C_Protocol.c │ ├── LEPTON_I2C_Protocol.h │ ├── LEPTON_I2C_Reg.h │ ├── LEPTON_I2C_Service.c │ ├── LEPTON_I2C_Service.h │ ├── LEPTON_Macros.h │ ├── LEPTON_SDK.c │ ├── LEPTON_SDK.h │ ├── LEPTON_SDKConfig.h │ ├── LEPTON_SYS.c │ ├── LEPTON_SYS.h │ ├── LEPTON_Types.h │ ├── LEPTON_VID.c │ ├── LEPTON_VID.h │ ├── Makefile │ ├── bbb_I2C.c │ ├── bbb_I2C.h │ ├── crc16.h │ └── crc16fast.c └── main.cpp ├── edison_capture ├── README.md └── lepton_capture.c ├── flirpi ├── Makefile ├── README.md ├── fblept.c ├── greyenhance.sh ├── leptbmp.c ├── leptcam.c ├── leptgraypng.c ├── leptsci.c ├── leptsci.h └── picamoverlay.sh ├── raspberrypi_capture ├── Makefile ├── README.md └── raspberrypi_capture.c ├── raspberrypi_libs └── leptonSDKEmb32PUB │ ├── .gitignore │ ├── LEPTON_AGC.c │ ├── LEPTON_AGC.h │ ├── LEPTON_ErrorCodes.h │ ├── LEPTON_I2C_Protocol.c │ ├── LEPTON_I2C_Protocol.h │ ├── LEPTON_I2C_Reg.h │ ├── LEPTON_I2C_Service.c │ ├── LEPTON_I2C_Service.h │ ├── LEPTON_Macros.h │ ├── LEPTON_OEM.c │ ├── LEPTON_OEM.h │ ├── LEPTON_SDK.c │ ├── LEPTON_SDK.h │ ├── LEPTON_SDKConfig.h │ ├── LEPTON_SYS.c │ ├── LEPTON_SYS.h │ ├── LEPTON_Types.h │ ├── LEPTON_VID.c │ ├── LEPTON_VID.h │ ├── Makefile │ ├── crc16.h │ ├── crc16fast.c │ ├── raspi_I2C.c │ └── raspi_I2C.h ├── raspberrypi_qt ├── .gitignore ├── LeptonThread.cpp ├── LeptonThread.h ├── README.md ├── main.cpp ├── mainwindow.cpp ├── mainwindow.h └── raspberrypi_qt.pro ├── raspberrypi_video ├── .gitignore ├── LeptonThread.cpp ├── LeptonThread.h ├── Lepton_I2C.cpp ├── Lepton_I2C.h ├── MyLabel.cpp ├── MyLabel.h ├── Palettes.cpp ├── Palettes.h ├── README.md ├── SPI.cpp ├── SPI.h ├── main.cpp └── raspberrypi_video.pro ├── stm32nucleo_401re ├── README.md └── main.cpp └── v4l2lepton ├── Lepton_I2C.cpp ├── Lepton_I2C.h ├── Makefile ├── Palettes.cpp ├── Palettes.h ├── README.md ├── SPI.cpp ├── SPI.h ├── leptsci.c ├── leptsci.h └── v4l2lepton.cpp /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014, Pure Engineering LLC 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 17 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 18 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 20 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 21 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 22 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | 25 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Important Note 2 | ============ 3 | GroupGets does not provide coding, firmware, or software support of any kind and will not respond to related requests. All software and firmware provided by GroupGets are offered solely as examples or potential starting points. These repositories may be outdated and are not guaranteed to function as intended. 4 | 5 | We do not accept returns or offer replacements due to issues related to software, firmware, or code compatibility. 6 | 7 | The software is provided "AS IS", without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and non-infringement. In no event shall the authors or copyright holders be liable for any claim, damages, or other liability, whether in an action of contract, tort, or otherwise, arising from, out of, or in connection with the software or the use or other dealings in the software. 8 | 9 | LeptonModule 10 | ============ 11 | The FLIR Lepton™ is the most compact longwave infrared (LWIR) sensor available as an OEM product. The Lepton 2.x camera cores has a resolution of 80 × 60 pixels and the newer Lepton 3.x camera cores have a resolution of 160 x 120 pixels respectively. The Lepton 2.5 and 3.5 are both also radiometric which means they can output a factory-calibrated temperature value for all pixels in a frame irrespective of the camera temperature with an accuracy of +/-5˚C. Lepton contains a breakthrough lens fabricated in wafer form, along with a microbolometer focal plane array (FPA) and advanced thermal image processing. 12 | 13 | More Information 14 | https://groupgets.com/manufacturers/flir/products/lepton-3-5 15 | 16 | 17 | beagleboneblack_video 18 | -------------- 19 | This example is for the Beagle Bone Black board and runs a basic video feed. 20 | Requires the device's SPI0 tree to be exported to a slot before running. 21 | Steps are outlined within this directory. 22 | 23 | 24 | raspberrypi_capture 25 | -------------- 26 | This is for the Raspberry Pi, 27 | you have to enable the spi and i2c ports first for this code to work. 28 | 29 | 1. sudo vi /etc/modules 30 | 2. add # in front of spi-bcm2708 and ic2-dev 31 | 3. to compile the code just run "gcc raspberry_pi_capture.c" 32 | 4. to capture an image run "sudo ./a.out" 33 | 5. a file called image.pgm will be created, you can use GIMP to view the image 34 | 35 | See the wiki page for more information: https://github.com/groupgets/LeptonModule/wiki 36 | 37 | raspberrypi_video 38 | -------------- 39 | This is for the Raspberry Pi, see this page for more information https://github.com/groupgets/LeptonModule/tree/master/software/raspberrypi_video 40 | 41 | 42 | Software modules: 43 | 44 | arduino_i2c 45 | -------------- 46 | This example shows how to read the i2c ports using an Arduino. 47 | Note that most Arduino hardware does not have enough memory to buffer the thermal image. 80*60*2 = 9600 bytes. Some of the Arm based units will work. 48 | 49 | 50 | STM32F3Discovery_ChibiOS 51 | -------------- 52 | Download and install ChibiOS_2.6.5 into the same directory first. 53 | This example takes the SPI data stream from the Lepton module, buffers it and send it out the USB VCP device. 54 | On the PC the binary stream of data can be parsed easily by looking for the 0xdeadbeef header on each frame. 55 | 56 | 57 | stm32nucleo_401re 58 | -------------- 59 | This example shows how to read stream photos at the rate of about 1 every 2 seconds from the $10 STM32nucleo 401 RE development board. This example uses the mbed toolchain, an extremely simple to use web based IDE. 60 | 61 | ThermalView 62 | -------------- 63 | This super simple win32 example shows how draw the images onto the screen of a windows computer. This software is compiled using MinGW toolchain. 64 | 65 | edison_capture 66 | -------------- 67 | This example shows how to capture a still image from the lepton using Intel Edison. 68 | 69 | v4l2lepton 70 | ---------- 71 | This simple program will stream frames from the Lepton to a v4l2loopback device. Very useful for interacting with the Lepton in the same way you would a webcam. This was created mainly for use on Raspberry Pi with the original breakout board. 72 | 73 | Python 74 | -------------- 75 | If you'd like to use the breakout board with Python on Linux, check out the pylepton project: https://github.com/groupgets/pylepton 76 | -------------------------------------------------------------------------------- /docs/lepton_interface_design_document.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/groupgets/LeptonModule/907520ba463b3056b5b5224ef33fac5080c7f5ee/docs/lepton_interface_design_document.pdf -------------------------------------------------------------------------------- /hardware/LeptonBreakout/LeptonAdaptorSch.PDF: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/groupgets/LeptonModule/907520ba463b3056b5b5224ef33fac5080c7f5ee/hardware/LeptonBreakout/LeptonAdaptorSch.PDF -------------------------------------------------------------------------------- /hardware/LeptonMicroBreakout/PT Micro Breakout Board Dimensional Drawing.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/groupgets/LeptonModule/907520ba463b3056b5b5224ef33fac5080c7f5ee/hardware/LeptonMicroBreakout/PT Micro Breakout Board Dimensional Drawing.pdf -------------------------------------------------------------------------------- /hardware/LeptonMicroBreakout/PT-Micro.kicad_mod: -------------------------------------------------------------------------------- 1 | (footprint "PT-Micro" (version 20211014) (generator pcbnew) 2 | (layer "F.Cu") 3 | (tedit 63B518BB) 4 | (attr smd) 5 | (fp_text reference "A1" (at 6.93 -6.41 unlocked) (layer "F.SilkS") 6 | (effects (font (size 1 1) (thickness 0.15))) 7 | (tstamp e2fac877-439c-4da0-af2e-5fdc70f85d42) 8 | ) 9 | (fp_text value "PT-Micro" (at 7.07 -5.03 unlocked) (layer "F.Fab") 10 | (effects (font (size 1 1) (thickness 0.15))) 11 | (tstamp 4641c87c-bffa-41fe-ae77-be3a97a6f797) 12 | ) 13 | (fp_text user "Lepton socket (f.courtyard)" (at 0 2.6 unlocked) (layer "Cmts.User") hide 14 | (effects (font (size 1 1) (thickness 0.15)) (justify left)) 15 | (tstamp 1755646e-fc08-4e43-a301-d9b3ea704cf6) 16 | ) 17 | (fp_text user "PCB Edge (f.silk)" (at 0 1 unlocked) (layer "Cmts.User") hide 18 | (effects (font (size 1 1) (thickness 0.15)) (justify left)) 19 | (tstamp 8aff0f38-92a8-45ec-b106-b185e93ca3fd) 20 | ) 21 | (fp_text user "Rear components (b.courtyard)" (at 0 4.2 unlocked) (layer "Cmts.User") hide 22 | (effects (font (size 1 1) (thickness 0.15)) (justify left)) 23 | (tstamp ef4533db-6ea4-4b68-b436-8e9575be570d) 24 | ) 25 | (fp_line (start 0 -11.05) (end 0 -1.15) (layer "F.SilkS") (width 0.1) (tstamp 7233cb6b-d8fd-4fcd-9b4f-8b0ed19b1b12)) 26 | (fp_line (start 12.85 -12.2) (end 1.15 -12.2) (layer "F.SilkS") (width 0.1) (tstamp 761c8e29-382a-475c-a37a-7201cc9cd0f5)) 27 | (fp_line (start 1.15 0) (end 12.85 0) (layer "F.SilkS") (width 0.1) (tstamp a7fc0812-140f-4d96-9cd8-ead8c1c610b1)) 28 | (fp_line (start 14 -1.15) (end 14 -11.05) (layer "F.SilkS") (width 0.1) (tstamp f33ec0db-ef0f-4576-8054-2833161a8f30)) 29 | (fp_arc (start 14 -11.05) (mid 13.186827 -11.386827) (end 12.85 -12.2) (layer "F.SilkS") (width 0.1) (tstamp 29cbb0bc-f66b-4d11-80e7-5bb270e42496)) 30 | (fp_arc (start 1.15 -12.2) (mid 0.827636 -11.372364) (end 0 -11.05) (layer "F.SilkS") (width 0.1) (tstamp 355ced6c-c08a-4586-9a09-7a9c624536f6)) 31 | (fp_arc (start 12.85 0) (mid 13.186827 -0.813173) (end 14 -1.15) (layer "F.SilkS") (width 0.1) (tstamp 653a86ba-a1ae-4175-9d4c-c788087956d0)) 32 | (fp_arc (start 0 -1.15) (mid 0.813173 -0.813173) (end 1.15 0) (layer "F.SilkS") (width 0.1) (tstamp 6a0919c2-460c-4229-b872-14e318e1ba8b)) 33 | (fp_circle (center -1.8 -11.62) (end -1.5 -11.62) (layer "F.SilkS") (width 0.6) (fill none) (tstamp d8200a86-aa75-47a3-ad2a-7f4c9c999a6f)) 34 | (fp_line (start 1.85 -11.5) (end 12 -11.5) (layer "B.CrtYd") (width 0.1) (tstamp 0554bea0-89b2-4e25-9ea3-4c73921c94cb)) 35 | (fp_line (start 10.4 -0.25) (end 10.4 -2) (layer "B.CrtYd") (width 0.1) (tstamp 275b6416-db29-42cc-9307-bf426917c3b4)) 36 | (fp_line (start 2.7 -4.3) (end 2.7 -0.25) (layer "B.CrtYd") (width 0.1) (tstamp 8eb98c56-17e4-4de6-a3e3-06dcfa392040)) 37 | (fp_line (start 10.4 -2) (end 12 -2) (layer "B.CrtYd") (width 0.1) (tstamp af186015-d283-4209-aade-a247e5de01df)) 38 | (fp_line (start 12 -11.5) (end 12 -2) (layer "B.CrtYd") (width 0.1) (tstamp bb8162f0-99c8-4884-be5b-c0d0c7e81ff6)) 39 | (fp_line (start 1.85 -4.3) (end 2.7 -4.3) (layer "B.CrtYd") (width 0.1) (tstamp bd085057-7c0e-463a-982b-968a2dc1f0f8)) 40 | (fp_line (start 1.85 -11.5) (end 1.85 -4.3) (layer "B.CrtYd") (width 0.1) (tstamp cd1cff81-9d8a-4511-96d6-4ddb79484001)) 41 | (fp_line (start 2.7 -0.25) (end 10.4 -0.25) (layer "B.CrtYd") (width 0.1) (tstamp d1cd5391-31d2-459f-8adb-4ae3f304a833)) 42 | (fp_rect (start 1.15 -11.95) (end 12.85 -0.25) (layer "F.CrtYd") (width 0.05) (fill none) (tstamp 9da1ace0-4181-4f12-80f8-16786a9e5c07)) 43 | (pad "1" smd roundrect (at -0.5 -9.910003 90) (size 1 2.2) (layers "F.Cu" "F.Paste" "F.Mask") (roundrect_rratio 0.25) (tstamp d05faa1f-5f69-41bf-86d3-2cd224432e1b)) 44 | (pad "2" smd roundrect (at -0.5 -8.640003 90) (size 1 2.2) (layers "F.Cu" "F.Paste" "F.Mask") (roundrect_rratio 0.25) (tstamp 41485de5-6ed3-4c83-b69e-ef83ae18093c)) 45 | (pad "3" smd roundrect (at -0.5 -7.370003 90) (size 1 2.2) (layers "F.Cu" "F.Paste" "F.Mask") (roundrect_rratio 0.25) (tstamp bef2abc2-bf3e-4a72-ad03-f8da3cd893cb)) 46 | (pad "4" smd roundrect (at -0.5 -6.100003 90) (size 1 2.2) (layers "F.Cu" "F.Paste" "F.Mask") (roundrect_rratio 0.25) (tstamp dd1edfbb-5fb6-42cd-b740-fd54ab3ef1f1)) 47 | (pad "5" smd roundrect (at -0.5 -4.830003 90) (size 1 2.2) (layers "F.Cu" "F.Paste" "F.Mask") (roundrect_rratio 0.25) (tstamp 7bea05d4-1dec-4cd6-aa53-302dde803254)) 48 | (pad "6" smd roundrect (at -0.5 -3.560003 90) (size 1 2.2) (layers "F.Cu" "F.Paste" "F.Mask") (roundrect_rratio 0.25) (tstamp 1cc5480b-56b7-4379-98e2-ccafc88911a7)) 49 | (pad "7" smd roundrect (at -0.5 -2.290003 90) (size 1 2.2) (layers "F.Cu" "F.Paste" "F.Mask") (roundrect_rratio 0.25) (tstamp 851f3d61-ba3b-4e6e-abd4-cafa4d9b64cb)) 50 | (pad "8" smd roundrect (at 14.5 -2.290003 270) (size 1 2.2) (layers "F.Cu" "F.Paste" "F.Mask") (roundrect_rratio 0.25) (tstamp d18f2428-546f-4066-8ffb-7653303685db)) 51 | (pad "9" smd roundrect (at 14.5 -3.560003 270) (size 1 2.2) (layers "F.Cu" "F.Paste" "F.Mask") (roundrect_rratio 0.25) (tstamp 12fa3c3f-3d14-451a-a6a8-884fd1b32fa7)) 52 | (pad "10" smd roundrect (at 14.5 -4.830003 270) (size 1 2.2) (layers "F.Cu" "F.Paste" "F.Mask") (roundrect_rratio 0.25) (tstamp e76ec524-408a-4daa-89f6-0edfdbcfb621)) 53 | (pad "11" smd roundrect (at 14.5 -6.100003 270) (size 1 2.2) (layers "F.Cu" "F.Paste" "F.Mask") (roundrect_rratio 0.25) (tstamp 3993c707-5291-41b6-83c0-d1c09cb3833a)) 54 | (pad "12" smd roundrect (at 14.5 -7.370003 270) (size 1 2.2) (layers "F.Cu" "F.Paste" "F.Mask") (roundrect_rratio 0.25) (tstamp d13b0eae-4711-4325-a6bb-aa8e3646e86e)) 55 | (pad "13" smd roundrect (at 14.5 -8.640003 270) (size 1 2.2) (layers "F.Cu" "F.Paste" "F.Mask") (roundrect_rratio 0.25) (tstamp 89a3dae6-dcb5-435b-a383-656b6a19a316)) 56 | (pad "14" smd roundrect (at 14.5 -9.910003 270) (size 1 2.2) (layers "F.Cu" "F.Paste" "F.Mask") (roundrect_rratio 0.25) (tstamp 26bc8641-9bca-4204-9709-deedbe202a36)) 57 | (model "E:/GroupGets Products/PureThermals/PureThermal BoB Micro/PureThermal_BoB_Micro/3D models/PureThermal_BoB_Mini.step" 58 | (offset (xyz 0 0 0)) 59 | (scale (xyz 1 1 1)) 60 | (rotate (xyz 0 0 0)) 61 | ) 62 | ) 63 | -------------------------------------------------------------------------------- /hardware/LeptonMicroBreakout/PT_micro_bob.kicad_sym: -------------------------------------------------------------------------------- 1 | (kicad_symbol_lib (version 20211014) (generator kicad_symbol_editor) 2 | (symbol "PT_Micro" (in_bom yes) (on_board yes) 3 | (property "Reference" "A1" (id 0) (at 0 15.875 0) 4 | (effects (font (size 1.27 1.27))) 5 | ) 6 | (property "Value" "PT_M_BoB" (id 1) (at 0 13.335 0) 7 | (effects (font (size 1.27 1.27))) 8 | ) 9 | (property "Footprint" "" (id 2) (at 0 0 0) 10 | (effects (font (size 1.27 1.27)) hide) 11 | ) 12 | (property "Datasheet" "" (id 3) (at 0 0 0) 13 | (effects (font (size 1.27 1.27)) hide) 14 | ) 15 | (symbol "PT_Micro_0_1" 16 | (rectangle (start -10.16 10.16) (end 10.16 -10.16) 17 | (stroke (width 0) (type default) (color 0 0 0 0)) 18 | (fill (type none)) 19 | ) 20 | ) 21 | (symbol "PT_Micro_1_1" 22 | (pin power_in line (at -13.97 7.62 0) (length 3.81) 23 | (name "GND" (effects (font (size 1.27 1.27)))) 24 | (number "1" (effects (font (size 1.27 1.27)))) 25 | ) 26 | (pin input line (at 13.97 -2.54 180) (length 3.81) 27 | (name "SCL" (effects (font (size 1.27 1.27)))) 28 | (number "10" (effects (font (size 1.27 1.27)))) 29 | ) 30 | (pin bidirectional line (at 13.97 0 180) (length 3.81) 31 | (name "SDA" (effects (font (size 1.27 1.27)))) 32 | (number "11" (effects (font (size 1.27 1.27)))) 33 | ) 34 | (pin input line (at 13.97 2.54 180) (length 3.81) 35 | (name "CLK_STBY" (effects (font (size 1.27 1.27)))) 36 | (number "12" (effects (font (size 1.27 1.27)))) 37 | ) 38 | (pin input line (at 13.97 5.08 180) (length 3.81) 39 | (name "Lepton_PW_DWN_L" (effects (font (size 0.8 0.8)))) 40 | (number "13" (effects (font (size 1.27 1.27)))) 41 | ) 42 | (pin input line (at 13.97 7.62 180) (length 3.81) 43 | (name "Lepton_Reset_L" (effects (font (size 0.8 0.8)))) 44 | (number "14" (effects (font (size 1.27 1.27)))) 45 | ) 46 | (pin input line (at -13.97 5.08 0) (length 3.81) 47 | (name "SPI_CS" (effects (font (size 1.27 1.27)))) 48 | (number "2" (effects (font (size 1.27 1.27)))) 49 | ) 50 | (pin output line (at -13.97 2.54 0) (length 3.81) 51 | (name "SPI_CLK" (effects (font (size 1.27 1.27)))) 52 | (number "3" (effects (font (size 1.27 1.27)))) 53 | ) 54 | (pin output line (at -13.97 0 0) (length 3.81) 55 | (name "SPI_MISO" (effects (font (size 1.27 1.27)))) 56 | (number "4" (effects (font (size 1.27 1.27)))) 57 | ) 58 | (pin input line (at -13.97 -2.54 0) (length 3.81) 59 | (name "SPI_MOSI" (effects (font (size 1.27 1.27)))) 60 | (number "5" (effects (font (size 1.27 1.27)))) 61 | ) 62 | (pin power_in line (at -13.97 -5.08 0) (length 3.81) 63 | (name "VIN" (effects (font (size 1.27 1.27)))) 64 | (number "6" (effects (font (size 1.27 1.27)))) 65 | ) 66 | (pin output line (at -13.97 -7.62 0) (length 3.81) 67 | (name "Lepton_GPIO3_VSync" (effects (font (size 0.8 0.8)))) 68 | (number "7" (effects (font (size 1.27 1.27)))) 69 | ) 70 | (pin power_in line (at 13.97 -7.62 180) (length 3.81) 71 | (name "GND" (effects (font (size 1.27 1.27)))) 72 | (number "9" (effects (font (size 1.27 1.27)))) 73 | ) 74 | (pin input line (at 13.97 -5.08 180) (length 3.81) 75 | (name "Lepton_Enable" (effects (font (size 1.27 1.27)))) 76 | (number "9" (effects (font (size 1.27 1.27)))) 77 | ) 78 | ) 79 | ) 80 | ) 81 | -------------------------------------------------------------------------------- /hardware/LeptonMicroBreakout/PureThermal Micro Breakout Board Datasheet Rev2 May 2023.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/groupgets/LeptonModule/907520ba463b3056b5b5224ef33fac5080c7f5ee/hardware/LeptonMicroBreakout/PureThermal Micro Breakout Board Datasheet Rev2 May 2023.pdf -------------------------------------------------------------------------------- /software/STM32F3Discovery_ChibiOS/Makefile: -------------------------------------------------------------------------------- 1 | ############################################################################## 2 | # Build global options 3 | # NOTE: Can be overridden externally. 4 | # 5 | 6 | # Compiler options here. 7 | ifeq ($(USE_OPT),) 8 | USE_OPT = -O2 -ggdb -fomit-frame-pointer -falign-functions=16 9 | endif 10 | 11 | # C specific options here (added to USE_OPT). 12 | ifeq ($(USE_COPT),) 13 | USE_COPT = 14 | endif 15 | 16 | # C++ specific options here (added to USE_OPT). 17 | ifeq ($(USE_CPPOPT),) 18 | USE_CPPOPT = -fno-rtti 19 | endif 20 | 21 | # Enable this if you want the linker to remove unused code and data 22 | ifeq ($(USE_LINK_GC),) 23 | USE_LINK_GC = yes 24 | endif 25 | 26 | # If enabled, this option allows to compile the application in THUMB mode. 27 | ifeq ($(USE_THUMB),) 28 | USE_THUMB = yes 29 | endif 30 | 31 | # Enable this if you want to see the full log while compiling. 32 | ifeq ($(USE_VERBOSE_COMPILE),) 33 | USE_VERBOSE_COMPILE = no 34 | endif 35 | 36 | # 37 | # Build global options 38 | ############################################################################## 39 | 40 | ############################################################################## 41 | # Architecture or project specific options 42 | # 43 | 44 | # Enables the use of FPU on Cortex-M4. 45 | # Enable this if you really want to use the STM FWLib. 46 | ifeq ($(USE_FPU),) 47 | USE_FPU = no 48 | endif 49 | 50 | # Enable this if you really want to use the STM FWLib. 51 | ifeq ($(USE_FWLIB),) 52 | USE_FWLIB = no 53 | endif 54 | 55 | # 56 | # Architecture or project specific options 57 | ############################################################################## 58 | 59 | ############################################################################## 60 | # Project, sources and paths 61 | # 62 | 63 | # Define project name here 64 | PROJECT = stm32f3discovery-demo 65 | 66 | # Imported source files and paths 67 | CHIBIOS = ./ChibiOS_2.6.5 68 | include $(CHIBIOS)/boards/ST_STM32F3_DISCOVERY/board.mk 69 | include $(CHIBIOS)/os/hal/platforms/STM32F30x/platform.mk 70 | include $(CHIBIOS)/os/hal/hal.mk 71 | include $(CHIBIOS)/os/ports/GCC/ARMCMx/STM32F3xx/port.mk 72 | include $(CHIBIOS)/os/kernel/kernel.mk 73 | include $(CHIBIOS)/test/test.mk 74 | 75 | # Define linker script file here 76 | LDSCRIPT= $(PORTLD)/STM32F303xC.ld 77 | 78 | # C sources that can be compiled in ARM or THUMB mode depending on the global 79 | # setting. 80 | CSRC = $(PORTSRC) \ 81 | $(KERNSRC) \ 82 | $(TESTSRC) \ 83 | $(HALSRC) \ 84 | $(PLATFORMSRC) \ 85 | $(BOARDSRC) \ 86 | $(CHIBIOS)/os/various/chprintf.c \ 87 | usbcfg.c \ 88 | main.c 89 | 90 | # C++ sources that can be compiled in ARM or THUMB mode depending on the global 91 | # setting. 92 | CPPSRC = 93 | 94 | # C sources to be compiled in ARM mode regardless of the global setting. 95 | # NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler 96 | # option that results in lower performance and larger code size. 97 | ACSRC = 98 | 99 | # C++ sources to be compiled in ARM mode regardless of the global setting. 100 | # NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler 101 | # option that results in lower performance and larger code size. 102 | ACPPSRC = 103 | 104 | # C sources to be compiled in THUMB mode regardless of the global setting. 105 | # NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler 106 | # option that results in lower performance and larger code size. 107 | TCSRC = 108 | 109 | # C sources to be compiled in THUMB mode regardless of the global setting. 110 | # NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler 111 | # option that results in lower performance and larger code size. 112 | TCPPSRC = 113 | 114 | # List ASM source files here 115 | ASMSRC = $(PORTASM) 116 | 117 | INCDIR = $(PORTINC) $(KERNINC) $(TESTINC) \ 118 | $(HALINC) $(PLATFORMINC) $(BOARDINC) \ 119 | $(CHIBIOS)/os/various/devices_lib/accel \ 120 | $(CHIBIOS)/os/various \ 121 | 122 | # 123 | # Project, sources and paths 124 | ############################################################################## 125 | 126 | ############################################################################## 127 | # Compiler settings 128 | # 129 | 130 | MCU = cortex-m4 131 | 132 | #TRGT = arm-elf- 133 | TRGT = arm-none-eabi- 134 | CC = $(TRGT)gcc 135 | CPPC = $(TRGT)g++ 136 | # Enable loading with g++ only if you need C++ runtime support. 137 | # NOTE: You can use C++ even without C++ support if you are careful. C++ 138 | # runtime support makes code size explode. 139 | LD = $(TRGT)gcc 140 | #LD = $(TRGT)g++ 141 | CP = $(TRGT)objcopy 142 | AS = $(TRGT)gcc -x assembler-with-cpp 143 | OD = $(TRGT)objdump 144 | HEX = $(CP) -O ihex 145 | BIN = $(CP) -O binary 146 | 147 | # ARM-specific options here 148 | AOPT = 149 | 150 | # THUMB-specific options here 151 | TOPT = -mthumb -DTHUMB 152 | 153 | # Define C warning options here 154 | CWARN = -Wall -Wextra -Wstrict-prototypes 155 | 156 | # Define C++ warning options here 157 | CPPWARN = -Wall -Wextra 158 | 159 | # 160 | # Compiler settings 161 | ############################################################################## 162 | 163 | ############################################################################## 164 | # Start of default section 165 | # 166 | 167 | # List all default C defines here, like -D_DEBUG=1 168 | DDEFS = -DCHPRINTF_USE_FLOAT=TRUE 169 | 170 | # List all default ASM defines here, like -D_DEBUG=1 171 | DADEFS = 172 | 173 | # List all default directories to look for include files here 174 | DINCDIR = 175 | 176 | # List the default directory to look for the libraries here 177 | DLIBDIR = 178 | 179 | # List all default libraries here 180 | DLIBS = 181 | 182 | # 183 | # End of default section 184 | ############################################################################## 185 | 186 | ############################################################################## 187 | # Start of user section 188 | # 189 | 190 | # List all user C define here, like -D_DEBUG=1 191 | UDEFS = 192 | 193 | # Define ASM defines here 194 | UADEFS = 195 | 196 | # List all user directories here 197 | UINCDIR = 198 | 199 | # List the user directory to look for the libraries here 200 | ULIBDIR = 201 | 202 | # List all user libraries here 203 | ULIBS = 204 | 205 | # 206 | # End of user defines 207 | ############################################################################## 208 | 209 | ifeq ($(USE_FPU),yes) 210 | USE_OPT += -mfloat-abi=softfp -mfpu=fpv4-sp-d16 -fsingle-precision-constant 211 | DDEFS += -DCORTEX_USE_FPU=TRUE 212 | else 213 | DDEFS += -DCORTEX_USE_FPU=FALSE 214 | endif 215 | 216 | ifeq ($(USE_FWLIB),yes) 217 | include $(CHIBIOS)/ext/stm32lib/stm32lib.mk 218 | CSRC += $(STM32SRC) 219 | INCDIR += $(STM32INC) 220 | USE_OPT += -DUSE_STDPERIPH_DRIVER 221 | endif 222 | 223 | include $(CHIBIOS)/os/ports/GCC/ARMCMx/rules.mk 224 | -------------------------------------------------------------------------------- /software/STM32F3Discovery_ChibiOS/README.md: -------------------------------------------------------------------------------- 1 | STM32F3Discovery_ChibiOS 2 | ----------- 3 | Download and install ChibiOS_2.6.5 into the same directory first. 4 | This example takes the SPI data stream from the Lepton module, buffers it and send it out the USB VCP device. On the PC the binary stream of data can be parsed easily by looking for the 0xdeadbeef header on each frame. 5 | 6 | -------------------------------------------------------------------------------- /software/STM32F3Discovery_ChibiOS/flir_dump.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014, Pure Engineering LLC 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright notice, this 9 | list of conditions and the following disclaimer. 10 | 11 | * Redistributions in binary form must reproduce the above copyright notice, 12 | this list of conditions and the following disclaimer in the documentation 13 | and/or other materials provided with the distribution. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 19 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 21 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 22 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 23 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 24 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | 37 | #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) 38 | 39 | static void pabort(const char *s) 40 | { 41 | perror(s); 42 | abort(); 43 | } 44 | 45 | static const char *device = "/dev/spidev0.0"; 46 | static uint8_t mode; 47 | static uint8_t bits = 8; 48 | static uint32_t speed = 16000000; 49 | static uint16_t delay; 50 | 51 | #define VOSPI_FRAME_SIZE (164) 52 | uint8_t lepton_frame_packet[VOSPI_FRAME_SIZE]; 53 | static int lepton_image[80][80]; 54 | 55 | static void save_pgm_file(void) 56 | { 57 | int i; 58 | int j; 59 | 60 | FILE *f = fopen("image.pgm", "w"); 61 | if (f == NULL) 62 | { 63 | printf("Error opening file!\n"); 64 | exit(1); 65 | } 66 | 67 | fprintf(f,"P2\n80 60\n255\n"); 68 | for(i=0;i<60;i++) 69 | { 70 | for(j=0;j<80;j++) 71 | { 72 | fprintf(f,"%d ", lepton_image[i][j]); 73 | } 74 | printf("\n"); 75 | } 76 | printf("\n\n"); 77 | 78 | fclose(f); 79 | } 80 | 81 | static void print_image(void) 82 | { 83 | int i; 84 | int j; 85 | 86 | printf("P2\n80\n60\n255\n"); 87 | for(i=0;i<60;i++) 88 | { 89 | for(j=0;j<80;j++) 90 | { 91 | printf("%d ", lepton_image[i][j]); 92 | } 93 | printf("\n"); 94 | } 95 | printf("\n\n"); 96 | 97 | 98 | } 99 | 100 | static void transfer(int fd) 101 | { 102 | int ret; 103 | int i; 104 | int j; 105 | int frame_number; 106 | uint8_t tx[VOSPI_FRAME_SIZE] = {0, }; 107 | struct spi_ioc_transfer tr = { 108 | .tx_buf = (unsigned long)tx, 109 | .rx_buf = (unsigned long)lepton_frame_packet, 110 | .len = VOSPI_FRAME_SIZE, 111 | .delay_usecs = delay, 112 | .speed_hz = speed, 113 | .bits_per_word = bits, 114 | }; 115 | 116 | ret = ioctl(fd, SPI_IOC_MESSAGE(1), &tr); 117 | if (ret < 1) 118 | pabort("can't send spi message"); 119 | 120 | if(((lepton_frame_packet[0]&0xf) != 0x0f)) 121 | { 122 | frame_number = lepton_frame_packet[1]; 123 | 124 | if(frame_number < 60 ) 125 | { 126 | for(i=0;i<80;i++) 127 | { 128 | lepton_image[frame_number][i] = (lepton_frame_packet[2*i+4] << 8 | lepton_frame_packet[2*i+5]); 129 | } 130 | } 131 | } 132 | 133 | if(frame_number == 59) 134 | { 135 | print_image(); 136 | } 137 | } 138 | 139 | int main(int argc, char *argv[]) 140 | { 141 | int ret = 0; 142 | int fd; 143 | int i; 144 | 145 | 146 | fd = open(device, O_RDWR); 147 | if (fd < 0) 148 | { 149 | pabort("can't open device"); 150 | } 151 | 152 | ret = ioctl(fd, SPI_IOC_WR_MODE, &mode); 153 | if (ret == -1) 154 | { 155 | pabort("can't set spi mode"); 156 | } 157 | 158 | ret = ioctl(fd, SPI_IOC_RD_MODE, &mode); 159 | if (ret == -1) 160 | { 161 | pabort("can't get spi mode"); 162 | } 163 | 164 | ret = ioctl(fd, SPI_IOC_WR_BITS_PER_WORD, &bits); 165 | if (ret == -1) 166 | { 167 | pabort("can't set bits per word"); 168 | } 169 | 170 | ret = ioctl(fd, SPI_IOC_RD_BITS_PER_WORD, &bits); 171 | if (ret == -1) 172 | { 173 | pabort("can't get bits per word"); 174 | } 175 | 176 | ret = ioctl(fd, SPI_IOC_WR_MAX_SPEED_HZ, &speed); 177 | if (ret == -1) 178 | { 179 | pabort("can't set max speed hz"); 180 | } 181 | 182 | ret = ioctl(fd, SPI_IOC_RD_MAX_SPEED_HZ, &speed); 183 | if (ret == -1) 184 | { 185 | pabort("can't get max speed hz"); 186 | } 187 | 188 | printf("spi mode: %d\n", mode); 189 | printf("bits per word: %d\n", bits); 190 | printf("max speed: %d Hz (%d KHz)\n", speed, speed/1000); 191 | 192 | for(i=0;i<5000;i++) 193 | { 194 | transfer(fd); 195 | } 196 | 197 | close(fd); 198 | 199 | save_pgm_file(); 200 | 201 | return ret; 202 | } 203 | -------------------------------------------------------------------------------- /software/STM32F3Discovery_ChibiOS/make_all.bat: -------------------------------------------------------------------------------- 1 | make clean -r 2 | make all -r 3 | pause 4 | -------------------------------------------------------------------------------- /software/STM32F3Discovery_ChibiOS/make_changes.bat: -------------------------------------------------------------------------------- 1 | make -r 2 | pause 3 | -------------------------------------------------------------------------------- /software/STM32F3Discovery_ChibiOS/usbcfg.h: -------------------------------------------------------------------------------- 1 | #ifndef _USBCFG_H_ 2 | #define _USBCFG_H_ 3 | 4 | extern const USBConfig usbcfg; 5 | extern SerialUSBConfig serusbcfg; 6 | 7 | #endif /* _USBCFG_H_ */ 8 | -------------------------------------------------------------------------------- /software/ThermalView/Makefile: -------------------------------------------------------------------------------- 1 | 2 | TARGET = ThermalView.exe 3 | 4 | HEADERS = include/callbacks.h res/resource.h 5 | OBJS = obj/winmain.o obj/resource.o obj/guicon.o obj/serial_win32.o 6 | INCLUDE_DIRS = -I.\include -I.\res 7 | 8 | WARNS = -Wall 9 | 10 | CC = gcc 11 | CFLAGS = -funsigned-char -fsigned-bitfields -fpack-struct -fshort-enums -mwindows -mconsole -lsetupapi -O2 -std=c99 -D UNICODE -D _UNICODE -D _WIN32_IE=0x0500 -D WINVER=0x500 ${WARNS} 12 | LDFLAGS = -s -lsetupapi -lcomctl32 -mconsole -mwindows -Wl,--subsystem,windows # 13 | RC = windres 14 | 15 | all : $(TARGET) 16 | 17 | $(TARGET) : ${OBJS} 18 | ${CC} -o "$@" ${OBJS} ${LDFLAGS} 19 | 20 | clean : 21 | rm -f $(TARGET) $(OBJS) 22 | 23 | obj/%.o : src/%.c ${HEADERS} 24 | ${CC} ${CFLAGS} ${INCLUDE_DIRS} -c $< -o $@ 25 | 26 | obj/resource.o : res/main_dialog.rc res/Application.manifest res/Application.ico res/resource.h 27 | ${RC} -I.\include -I.\res -i $< -o $@ 28 | -------------------------------------------------------------------------------- /software/ThermalView/README.md: -------------------------------------------------------------------------------- 1 | ThermalVew is a program used to read seial data from the stm32nucleo_401re example code. 2 | 3 | The program uses the MingGW toolchain for compiling the code. You can obtain a suitable toolchain from http://www.mingw.org/ or http://tdm-gcc.tdragon.net/ - install the 32 bit version for this purpose. 4 | 5 | Install the toolchain and add the bin directory to your path, e.g., PATH=C:\MinGW\bin;%PATH% 6 | 7 | Run Make (mingw32-make.exe) to build the code. Use the "clean" target to clean before building. 8 | 9 | The program has a hardcoded serial (COM) port - you will need to update this accordingly before compiling. 10 | 11 | -------------------------------------------------------------------------------- /software/ThermalView/include/callbacks.h: -------------------------------------------------------------------------------- 1 | #ifndef CALLBACKS_H 2 | #define CALLBACKS_H 3 | 4 | #include 5 | 6 | // Window procedure for our main window. 7 | LRESULT CALLBACK MainWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); 8 | 9 | // Dialog procedure for our "about" dialog. 10 | INT_PTR CALLBACK AboutDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); 11 | INT_PTR CALLBACK PulseDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /software/ThermalView/include/guicon.h: -------------------------------------------------------------------------------- 1 | #ifndef __GUICON_H__ 2 | #define __GUICON_H__ 3 | void RedirectIOToConsole(); 4 | #endif 5 | 6 | -------------------------------------------------------------------------------- /software/ThermalView/obj/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/groupgets/LeptonModule/907520ba463b3056b5b5224ef33fac5080c7f5ee/software/ThermalView/obj/.gitignore -------------------------------------------------------------------------------- /software/ThermalView/res/Application.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/groupgets/LeptonModule/907520ba463b3056b5b5224ef33fac5080c7f5ee/software/ThermalView/res/Application.ico -------------------------------------------------------------------------------- /software/ThermalView/res/Application.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /software/ThermalView/res/main_dialog.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/groupgets/LeptonModule/907520ba463b3056b5b5224ef33fac5080c7f5ee/software/ThermalView/res/main_dialog.rc -------------------------------------------------------------------------------- /software/ThermalView/res/resource.h: -------------------------------------------------------------------------------- 1 | #ifndef IDC_STATIC 2 | #define IDC_STATIC (-1) 3 | #endif 4 | 5 | #define MAIN_DIALOG 103 6 | #define IDR_ACCELERATOR 108 7 | #define IDR_MAINMENU 110 8 | #define IDI_APPICON 114 9 | #define ID_HELP_ABOUT 40000 10 | #define ID_FILE_EXIT 40001 11 | #define IDM_DEBUG_CONSOLE 40003 12 | #define IDM_PULSE_MODE 40004 13 | -------------------------------------------------------------------------------- /software/ThermalView/src/guicon.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | 6 | void RedirectIOToConsole() 7 | { 8 | AllocConsole(); 9 | freopen("CONIN$","rb",stdin); // reopen stdin handle as console window input 10 | freopen("CONOUT$","wb",stdout); // reopen stout handle as console window output 11 | freopen("CONOUT$","wb",stderr); // reopen stderr handle as console window output 12 | } 13 | 14 | 15 | -------------------------------------------------------------------------------- /software/ThermalView/src/serial_win32.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include /* for isprint */ 5 | 6 | #include "serial_win32.h" 7 | 8 | 9 | #define W32SERBUFSIZE 1024 10 | 11 | struct baud_mapping { 12 | long baud; 13 | DWORD speed; 14 | }; 15 | 16 | struct baud_mapping baud_lookup_table [] = { 17 | { 1200, CBR_1200 }, 18 | { 2400, CBR_2400 }, 19 | { 4800, CBR_4800 }, 20 | { 9600, CBR_9600 }, 21 | { 19200, CBR_19200 }, 22 | { 38400, CBR_38400 }, 23 | { 57600, CBR_57600 }, 24 | { 115200, CBR_115200 }, 25 | { 256000, CBR_256000 }, 26 | { 0, 0 } /* Terminator. */ 27 | }; 28 | 29 | DWORD serial_baud_lookup(long baud) 30 | { 31 | struct baud_mapping *map = baud_lookup_table; 32 | 33 | while (map->baud) { 34 | if (map->baud == baud) 35 | return map->speed; 36 | map++; 37 | } 38 | 39 | printf("\n\rUsing non standard baud rate: %d\n\r",baud); 40 | return baud; 41 | } 42 | 43 | BOOL serial_w32SetTimeOut(HANDLE hComPort, DWORD timeout) // in ms 44 | { 45 | COMMTIMEOUTS ctmo; 46 | ZeroMemory (&ctmo, sizeof(COMMTIMEOUTS)); 47 | ctmo.ReadIntervalTimeout = timeout; 48 | ctmo.ReadTotalTimeoutMultiplier = timeout; 49 | ctmo.ReadTotalTimeoutConstant = timeout; 50 | 51 | return SetCommTimeouts(hComPort, &ctmo); 52 | } 53 | 54 | int ser_setspeed(union filedescriptor *fd, long baud) 55 | { 56 | DCB dcb; 57 | HANDLE hComPort = (HANDLE)fd->pfd; 58 | 59 | ZeroMemory (&dcb, sizeof(DCB)); 60 | dcb.DCBlength = sizeof(DCB); 61 | dcb.BaudRate = serial_baud_lookup (baud); 62 | 63 | dcb.fBinary = 1; 64 | dcb.fDtrControl = DTR_CONTROL_DISABLE; 65 | dcb.fRtsControl = RTS_CONTROL_DISABLE; 66 | dcb.ByteSize = 8; 67 | dcb.Parity = NOPARITY; 68 | dcb.StopBits = ONESTOPBIT; 69 | 70 | if (!SetCommState(hComPort, &dcb)) 71 | return -1; 72 | 73 | return 0; 74 | } 75 | 76 | ////////////////Freertos Versions, note not exactly the same, but good enough for testing////////////////////////////// 77 | 78 | void xSerialPortInitMinimal(char * port, long baud, union filedescriptor *fdp) 79 | { 80 | LPVOID lpMsgBuf; 81 | HANDLE hComPort=INVALID_HANDLE_VALUE; 82 | char fixedport[32]; 83 | 84 | /* 85 | * If the port is of the form "net::", then 86 | * handle it as a TCP connection to a terminal server. 87 | * 88 | * This is curently not implemented for Win32. 89 | */ 90 | if (strncmp(port, "net:", strlen("net:")) == 0) { 91 | // fprintf(stderr, 92 | // "%s: ser_open(): network connects are currently not" 93 | // "implemented for Win32 environments\n", 94 | // progname); 95 | exit(1); 96 | } 97 | 98 | /* if (hComPort!=INVALID_HANDLE_VALUE) 99 | fprintf(stderr, "%s: ser_open(): \"%s\" is already open\n", 100 | progname, port); 101 | */ 102 | 103 | sprintf(fixedport,"\\\\.\%s", port); 104 | //hComPort = CreateFile(fixedport, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL); 105 | hComPort = CreateFile(fixedport, GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, 0); 106 | 107 | if (hComPort == INVALID_HANDLE_VALUE) { 108 | FormatMessage( 109 | FORMAT_MESSAGE_ALLOCATE_BUFFER | 110 | FORMAT_MESSAGE_FROM_SYSTEM | 111 | FORMAT_MESSAGE_IGNORE_INSERTS, 112 | NULL, 113 | GetLastError(), 114 | MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language 115 | (LPTSTR) &lpMsgBuf, 116 | 0, 117 | NULL); 118 | fprintf(stderr, "ser_open(): can't open device \"%s\": %s\n",fixedport, (char*)lpMsgBuf); 119 | LocalFree( lpMsgBuf ); 120 | //exit(1); 121 | } 122 | 123 | if (!SetupComm(hComPort, W32SERBUFSIZE, W32SERBUFSIZE)) 124 | { 125 | CloseHandle(hComPort); 126 | fprintf(stderr, "ser_open(): can't set buffers for \"%s\"\n", fixedport); 127 | //exit(1); 128 | } 129 | 130 | fdp->pfd = (void *)hComPort; 131 | if (ser_setspeed(fdp, baud) != 0) 132 | { 133 | CloseHandle(hComPort); 134 | fprintf(stderr, "ser_open(): can't set com-state for \"%s\"\n",fixedport); 135 | //exit(1); 136 | } 137 | 138 | if (!serial_w32SetTimeOut(hComPort,0)) 139 | { 140 | CloseHandle(hComPort); 141 | fprintf(stderr, "ser_open(): can't set initial timeout for \"%s\"\n", fixedport); 142 | //exit(1); 143 | } 144 | } 145 | 146 | void xSerialPortClose(union filedescriptor *fd) 147 | { 148 | HANDLE hComPort=(HANDLE)fd->pfd; 149 | if (hComPort != INVALID_HANDLE_VALUE) 150 | CloseHandle (hComPort); 151 | 152 | hComPort = INVALID_HANDLE_VALUE; 153 | } 154 | 155 | int xSerialGetChar(union filedescriptor *fd, signed char *pcRxedChar, long xBlockTime) 156 | { 157 | unsigned char buf[1]; 158 | DWORD read; 159 | 160 | HANDLE hComPort=(HANDLE)fd->pfd; 161 | 162 | if (hComPort == INVALID_HANDLE_VALUE) { 163 | //exit(1); 164 | } 165 | 166 | serial_w32SetTimeOut(hComPort, xBlockTime); 167 | 168 | if (!ReadFile(hComPort, buf, 1, &read, NULL)) { 169 | LPVOID lpMsgBuf; 170 | FormatMessage( 171 | FORMAT_MESSAGE_ALLOCATE_BUFFER | 172 | FORMAT_MESSAGE_FROM_SYSTEM | 173 | FORMAT_MESSAGE_IGNORE_INSERTS, 174 | NULL, 175 | GetLastError(), 176 | MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language 177 | (LPTSTR) &lpMsgBuf, 178 | 0, 179 | NULL ); 180 | fprintf(stderr, "ser_recv(): read error: %s\n",(char*)lpMsgBuf); 181 | LocalFree( lpMsgBuf ); 182 | //exit(1); 183 | } 184 | 185 | *pcRxedChar = buf[0]; 186 | 187 | return read; 188 | } 189 | 190 | int xSerialPutChar( union filedescriptor *fd, signed char cOutChar, long xBlockTime ) 191 | { 192 | DWORD written; 193 | //unsigned char * b = buf; 194 | unsigned char buf[1]; 195 | 196 | buf[0] = cOutChar; 197 | 198 | HANDLE hComPort=(HANDLE)fd->pfd; 199 | 200 | if (hComPort == INVALID_HANDLE_VALUE) { 201 | fprintf(stderr, "ser_send(): port not open\n"); 202 | //exit(1); 203 | } 204 | 205 | serial_w32SetTimeOut(hComPort,xBlockTime); 206 | 207 | if (!WriteFile (hComPort, buf, 1, &written, NULL)) { 208 | fprintf(stderr, "ser_send(): write error: %s\n", "sorry no info avail"); // TODO 209 | //exit(1); 210 | } 211 | 212 | return written; 213 | } 214 | 215 | int vSerialPutString(union filedescriptor *fd, const char * pcString, int xBlockTime) 216 | { 217 | size_t len; 218 | unsigned char c='\0'; 219 | DWORD written; 220 | 221 | len = strlen(pcString); 222 | 223 | HANDLE hComPort=(HANDLE)fd->pfd; 224 | 225 | if (hComPort == INVALID_HANDLE_VALUE) { 226 | // fprintf(stderr, "%s: ser_send(): port not open\n", 227 | // progname); 228 | //exit(1); 229 | } 230 | 231 | if (!len) 232 | return 0; 233 | 234 | serial_w32SetTimeOut(hComPort,xBlockTime); 235 | 236 | if (!WriteFile (hComPort, pcString, len, &written, NULL)) { 237 | fprintf(stderr, "ser_send(): write error: %s\n", "sorry no info avail"); // TODO 238 | //exit(1); 239 | } 240 | 241 | return written; 242 | } 243 | 244 | -------------------------------------------------------------------------------- /software/ThermalView/src/serial_win32.h: -------------------------------------------------------------------------------- 1 | #ifndef serial_h 2 | #define serial_h 3 | 4 | union filedescriptor 5 | { 6 | int ifd; 7 | void *pfd; 8 | }; 9 | 10 | 11 | void xSerialPortInitMinimal(char * port, long baud, union filedescriptor *fdp); 12 | int xSerialGetChar(union filedescriptor *fd, signed char *pcRxedChar, long xBlockTime); 13 | int xSerialPutChar( union filedescriptor *fd, signed char cOutChar, long xBlockTime ); 14 | int vSerialPutString(union filedescriptor *fd, const char * pcString, int xBlockTime); 15 | 16 | void xSerialPortClose(union filedescriptor *fd); 17 | int ser_setspeed(union filedescriptor *fd, long baud); 18 | 19 | 20 | #endif /* serial_h */ 21 | 22 | -------------------------------------------------------------------------------- /software/beagleboneblack_video/LeptonThread.cpp: -------------------------------------------------------------------------------- 1 | #include "LeptonThread.h" 2 | 3 | #include "Palettes.h" 4 | #include "SPI.h" 5 | #include "Lepton_I2C.h" 6 | 7 | #define PACKET_SIZE 164 8 | #define PACKET_SIZE_UINT16 (PACKET_SIZE/2) 9 | #define PACKETS_PER_FRAME 60 10 | #define FRAME_SIZE_UINT16 (PACKET_SIZE_UINT16*PACKETS_PER_FRAME) 11 | #define FPS 27; 12 | 13 | LeptonThread::LeptonThread() : QThread() 14 | { 15 | } 16 | 17 | LeptonThread::~LeptonThread() { 18 | } 19 | 20 | void LeptonThread::run() 21 | { 22 | //create the initial image 23 | myImage = QImage(80, 60, QImage::Format_RGB888); 24 | 25 | //open spi port 26 | SpiOpenPort(0); 27 | 28 | while(true) { 29 | 30 | //read data packets from lepton over SPI 31 | int resets = 0; 32 | for(int j=0;j= 30) { 50 | qDebug() << "done reading, resets: " << resets; 51 | } 52 | 53 | frameBuffer = (uint16_t *)result; 54 | int row, column; 55 | uint16_t value; 56 | uint16_t minValue = 65535; 57 | uint16_t maxValue = 0; 58 | 59 | 60 | for(int i=0;i maxValue) { 73 | maxValue = value; 74 | } 75 | if(value < minValue) { 76 | minValue = value; 77 | } 78 | column = i % PACKET_SIZE_UINT16 - 2; 79 | row = i / PACKET_SIZE_UINT16 ; 80 | } 81 | 82 | float diff = maxValue - minValue; 83 | float scale = 255/diff; 84 | QRgb color; 85 | for(int i=0;i 5 | #include 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #define PACKET_SIZE 164 13 | #define PACKET_SIZE_UINT16 (PACKET_SIZE/2) 14 | #define PACKETS_PER_FRAME 60 15 | #define FRAME_SIZE_UINT16 (PACKET_SIZE_UINT16*PACKETS_PER_FRAME) 16 | 17 | class LeptonThread : public QThread 18 | { 19 | Q_OBJECT; 20 | 21 | public: 22 | LeptonThread(); 23 | ~LeptonThread(); 24 | 25 | void run(); 26 | 27 | public slots: 28 | void performFFC(); 29 | 30 | signals: 31 | void updateText(QString); 32 | void updateImage(QImage); 33 | 34 | private: 35 | 36 | QImage myImage; 37 | 38 | uint8_t result[PACKET_SIZE*PACKETS_PER_FRAME]; 39 | uint16_t *frameBuffer; 40 | 41 | }; 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /software/beagleboneblack_video/Lepton_I2C.cpp: -------------------------------------------------------------------------------- 1 | #include "Lepton_I2C.h" 2 | 3 | #include "leptonSDKEmb32PUB/LEPTON_SDK.h" 4 | #include "leptonSDKEmb32PUB/LEPTON_SYS.h" 5 | #include "leptonSDKEmb32PUB/LEPTON_Types.h" 6 | 7 | bool _connected; 8 | 9 | LEP_CAMERA_PORT_DESC_T _port; 10 | 11 | int lepton_connect() { 12 | LEP_OpenPort(1, LEP_CCI_TWI, 400, &_port); 13 | _connected = true; 14 | return 0; 15 | } 16 | 17 | void lepton_perform_ffc() { 18 | if(!_connected) { 19 | lepton_connect(); 20 | } 21 | LEP_RunSysFFCNormalization(&_port); 22 | } 23 | 24 | //presumably more commands could go here if desired 25 | -------------------------------------------------------------------------------- /software/beagleboneblack_video/Lepton_I2C.h: -------------------------------------------------------------------------------- 1 | #ifndef LEPTON_I2C 2 | #define LEPTON_I2C 3 | 4 | void lepton_perform_ffc(); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /software/beagleboneblack_video/MyLabel.cpp: -------------------------------------------------------------------------------- 1 | #include "MyLabel.h" 2 | 3 | MyLabel::MyLabel(QWidget *parent) : QLabel(parent) 4 | { 5 | } 6 | MyLabel::~MyLabel() 7 | { 8 | } 9 | 10 | //when the system calls setImage, we'll set the label's pixmap 11 | void MyLabel::setImage(QImage image) { 12 | QPixmap pixmap = QPixmap::fromImage(image); 13 | int w = this->width(); 14 | int h = this->height(); 15 | setPixmap(pixmap.scaled(w, h, Qt::KeepAspectRatio)); 16 | } 17 | -------------------------------------------------------------------------------- /software/beagleboneblack_video/MyLabel.h: -------------------------------------------------------------------------------- 1 | #ifndef MYLABEL_H 2 | #define MYLABEL_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | 9 | //we extend QLabel to give it an extra slot, setImage 10 | //this is because we can't pass a QPixmap from our thread 11 | //so we have to pass a QImage and turn the QImage into a QPixmap on our end 12 | 13 | class MyLabel : public QLabel { 14 | Q_OBJECT; 15 | 16 | public: 17 | MyLabel(QWidget *parent = 0); 18 | ~MyLabel(); 19 | 20 | public slots: 21 | void setImage(QImage); 22 | }; 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /software/beagleboneblack_video/Palettes.h: -------------------------------------------------------------------------------- 1 | #ifndef PALETTES_H 2 | #define PALETTES_H 3 | 4 | extern const int colormap_rainbow[]; 5 | extern const int colormap_grayscale[]; 6 | extern const int colormap_ironblack[]; 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /software/beagleboneblack_video/README.md: -------------------------------------------------------------------------------- 1 | This example is meant for BeagleBone Black. 2 | 3 | It has been tested on the OS Debian. 4 | 5 | BeagleBone Black Setup Steps 6 | -------------- 7 | **NOTE: Removing power by unplugging the power cable can damage the board. Use the power button or terminal interface to power down the board.** 8 | 9 | Steps to setup: 10 | 11 | 1. If you’re starting with a brand new BeagleBone Black: follow the steps on http://beagleboard.org/getting-started to get started. 12 | - **Note:** If you’re using a Mac, you can download and use Pi Filler from http://ivanx.com/raspberrypi/ instead of using 7-Zip 13 | 14 | 2. The Physical Setup. 15 | - Connect USB Hub to BeagleBone Black 16 | - Connect Mouse and Keyboard to Hub 17 | - Connect monitor to BeagleBone Black via micro HDMI cable 18 | - Do not connect to power yet 19 | 20 | 3. Setup breadboard and wiring to BeagleBone 21 | - Insert the Lepton into the breakout board with the black triangle on the faceplate being on bottom right corner. 22 | - Attach breakout board to the breadboard (you can skip this step if you wanted to directly wire the breakout board to the beaglebone). 23 | - Go to the following link to see the pinout of the BeagleBone that will be configured after the completion of step 7. 24 | - http://beagleboard.org/static/images/cape-headers.png 25 | - Wire the Lepton to the BeagleBone with the following connections: 26 | - CS to pin 17 (SPI0_CS0) 27 | - MISO to pin 21 (SPI_D0) 28 | - CLK to pin 22 (SPI0_CLK) 29 | - GND to pin 1 (DGND) 30 | - VIN to pin 3 (VDD_3V3) 31 | - SDA to pin 20 (I2C2_SDA) 32 | - SCL to pin 19 (I2C2_SCL) 33 | 34 | 35 | 4. Connect 5V Power Cable to BeagleBone. 36 | - **Note:** The board can be powered either by connecting the power cable or connecting to a computer via the USB cable. Connecting both can cause damage to the board. For this section of the setup, we are not connecting to a computer so only the power cable should be attached to the board and not the USB cable. 37 | 38 | 5. Update BeagleBone Black’s packages by running the following commands 39 | - apt-get upgrade 40 | - apt-get update 41 | - apt-get install qt4-dev-tools 42 | 43 | 6. Reboot BeagleBone Black 44 | 45 | 7. Configure BeagleBone Pins 46 | - Run the following command to check the board’s slots. There should be 5 47 | - cat /sys/devices/bone_capemgr.9/slots 48 | - Export SPI device tree overlay with the following command: 49 | - echo ADAFRUIT-SPI0 > /sys/devices/bone_capemgr.9/slots 50 | - When running the cat command from part a, you should now see a 6th slot being occupied 51 | 52 | 8. Clone BeagleBone Black Lepton repository 53 | - git clone this repo to your machine 54 | 55 | 9. Run the demo by entering the following commands exactly as they appear 56 | - cd LeptonModule 57 | - cd beagleboneblack_video 58 | - cd leptonSDKEmb32PUB 59 | - make 60 | - cd .. 61 | - qmake && make 62 | - ./bbb 63 | - Your demo should be running and a video feed should be appearing on your monitor! 64 | 65 | 10. Troubleshooting 66 | - If the demo won't run, disattach and reattach the Lepton. 67 | - **IMPORTANT NOTE:** Remember to remove power first and then ground to power off. Reattach ground first and then power to power on. 68 | 69 | Parts Needed: 70 | * USB Hub 71 | * USB Mouse 72 | * USB Keyboard 73 | * HDMI Monitor 74 | * Wires 75 | * BreadBoard 76 | * Micro SD Card (with SD card adapter) 77 | 78 | 79 | *The following are available at www.digikey.com:* 80 | 81 | **BeagleBone Black (comes with USB cable)** 82 | - Order from: http://www.digikey.com/product-detail/en/0/BB-BBLK-000-REVC-ND 83 | - Part#: BB-BBLK-000-REVC-ND 84 | 85 | **Micro HDMI Cable** 86 | - Order from: http://www.digikey.com/product-detail/en/0687860006/WM1285-ND/2330698 87 | - Part#: WM1285-ND 88 | 89 | **Power Supply** 90 | - Order from: http://www.digikey.com/product-detail/en/WSU050-2000/237-1385-ND/3094911 91 | - Part#: 237-1385-ND 92 | 93 | **Flir Lepton** 94 | - Order from: http://www.digikey.com/product-search/en/sensors-transducers/image-sensors-camera/1966754?k=lepton 95 | 96 | **Lepton Breakout Board** 97 | - Order from: http://www.digikey.com/product-search/en/prototyping-products/adapter-breakout-boards/2360393?k=lepton 98 | - Part#: 250-0587-00-ND -------------------------------------------------------------------------------- /software/beagleboneblack_video/SPI.cpp: -------------------------------------------------------------------------------- 1 | #include "SPI.h" 2 | 3 | int spi_cs0_fd = -1; 4 | int spi_cs1_fd = -1; 5 | 6 | unsigned char spi_mode = SPI_MODE_3; 7 | unsigned char spi_bitsPerWord = 8; 8 | unsigned int spi_speed = 10000000; 9 | 10 | int SpiOpenPort (int spi_device) 11 | { 12 | int status_value = -1; 13 | int *spi_cs_fd; 14 | 15 | 16 | //----- SET SPI MODE ----- 17 | //SPI_MODE_0 (0,0) CPOL=0 (Clock Idle low level), CPHA=0 (SDO transmit/change edge active to idle) 18 | //SPI_MODE_1 (0,1) CPOL=0 (Clock Idle low level), CPHA=1 (SDO transmit/change edge idle to active) 19 | //SPI_MODE_2 (1,0) CPOL=1 (Clock Idle high level), CPHA=0 (SDO transmit/change edge active to idle) 20 | //SPI_MODE_3 (1,1) CPOL=1 (Clock Idle high level), CPHA=1 (SDO transmit/change edge idle to active) 21 | spi_mode = SPI_MODE_3; 22 | 23 | //----- SET BITS PER WORD ----- 24 | spi_bitsPerWord = 8; 25 | 26 | //----- SET SPI BUS SPEED ----- 27 | spi_speed = 10000000; //1000000 = 1MHz (1uS per bit) 28 | 29 | 30 | if (spi_device) 31 | spi_cs_fd = &spi_cs1_fd; 32 | else 33 | spi_cs_fd = &spi_cs0_fd; 34 | 35 | 36 | if (spi_device) 37 | *spi_cs_fd = open(std::string("/dev/spidev1.0").c_str(), O_RDWR); 38 | else 39 | *spi_cs_fd = open(std::string("/dev/spidev1.0").c_str(), O_RDWR); 40 | 41 | if (*spi_cs_fd < 0) 42 | { 43 | perror("Error - Could not open SPI device"); 44 | exit(1); 45 | } 46 | 47 | status_value = ioctl(*spi_cs_fd, SPI_IOC_WR_MODE, &spi_mode); 48 | if(status_value < 0) 49 | { 50 | perror("Could not set SPIMode (WR)...ioctl fail"); 51 | exit(1); 52 | } 53 | 54 | status_value = ioctl(*spi_cs_fd, SPI_IOC_RD_MODE, &spi_mode); 55 | if(status_value < 0) 56 | { 57 | perror("Could not set SPIMode (RD)...ioctl fail"); 58 | exit(1); 59 | } 60 | 61 | status_value = ioctl(*spi_cs_fd, SPI_IOC_WR_BITS_PER_WORD, &spi_bitsPerWord); 62 | if(status_value < 0) 63 | { 64 | perror("Could not set SPI bitsPerWord (WR)...ioctl fail"); 65 | exit(1); 66 | } 67 | 68 | status_value = ioctl(*spi_cs_fd, SPI_IOC_RD_BITS_PER_WORD, &spi_bitsPerWord); 69 | if(status_value < 0) 70 | { 71 | perror("Could not set SPI bitsPerWord(RD)...ioctl fail"); 72 | exit(1); 73 | } 74 | 75 | status_value = ioctl(*spi_cs_fd, SPI_IOC_WR_MAX_SPEED_HZ, &spi_speed); 76 | if(status_value < 0) 77 | { 78 | perror("Could not set SPI speed (WR)...ioctl fail"); 79 | exit(1); 80 | } 81 | 82 | status_value = ioctl(*spi_cs_fd, SPI_IOC_RD_MAX_SPEED_HZ, &spi_speed); 83 | if(status_value < 0) 84 | { 85 | perror("Could not set SPI speed (RD)...ioctl fail"); 86 | exit(1); 87 | } 88 | return(status_value); 89 | } 90 | 91 | int SpiClosePort(int spi_device) 92 | { 93 | int status_value = -1; 94 | int *spi_cs_fd; 95 | 96 | if (spi_device) 97 | spi_cs_fd = &spi_cs1_fd; 98 | else 99 | spi_cs_fd = &spi_cs0_fd; 100 | 101 | 102 | status_value = close(*spi_cs_fd); 103 | if(status_value < 0) 104 | { 105 | perror("Error - Could not close SPI device"); 106 | exit(1); 107 | } 108 | return(status_value); 109 | } 110 | -------------------------------------------------------------------------------- /software/beagleboneblack_video/SPI.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPI testing utility (using spidev driver) 3 | * 4 | * Copyright (c) 2007 MontaVista Software, Inc. 5 | * Copyright (c) 2007 Anton Vorontsov 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License. 10 | * 11 | * Cross-compile with cross-gcc -I/path/to/cross-kernel/include 12 | */ 13 | 14 | #ifndef SPI_H 15 | #define SPI_H 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | extern int spi_cs0_fd; 29 | extern int spi_cs1_fd; 30 | extern unsigned char spi_mode; 31 | extern unsigned char spi_bitsPerWord; 32 | extern unsigned int spi_speed; 33 | 34 | int SpiOpenPort(int spi_device); 35 | int SpiClosePort(int spi_device); 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /software/beagleboneblack_video/bbb.pro: -------------------------------------------------------------------------------- 1 | ###################################################################### 2 | # Automatically generated by qmake (2.01a) Wed Sep 10 19:53:24 2014 3 | ###################################################################### 4 | 5 | TEMPLATE = app 6 | TARGET = 7 | DEPENDPATH += . 8 | INCLUDEPATH += . 9 | 10 | # Input 11 | HEADERS += Lepton_I2C.h LeptonThread.h MyLabel.h Palettes.h SPI.h 12 | SOURCES += Lepton_I2C.cpp \ 13 | LeptonThread.cpp \ 14 | main.cpp \ 15 | MyLabel.cpp \ 16 | Palettes.cpp \ 17 | SPI.cpp 18 | LIBS += -LleptonSDKEmb32PUB/Debug -lLEPTON_SDK 19 | -------------------------------------------------------------------------------- /software/beagleboneblack_video/leptonSDKEmb32PUB/LEPTON_I2C_Service.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * FILE: LEPTON_I2C_Service.h 4 | * 5 | * DESCRIPTION: Lepton I2C Device Driver Service Layer Interface 6 | * 7 | * AUTHOR: 8 | * 9 | * CREATED: 4/10/2012 10 | * 11 | * HISTORY: 4/10/2012 DWD Initial Draft 12 | * 13 | ** Copyright 2011,2012,2013,2014 FLIR Systems - Commercial 14 | ** Vision Systems. All rights reserved. 15 | ** 16 | ** Proprietary - PROPRIETARY - FLIR Systems Inc.. 17 | ** 18 | ** This document is controlled to FLIR Technology Level 2. 19 | ** The information contained in this document pertains to a 20 | ** dual use product Controlled for export by the Export 21 | ** Administration Regulations (EAR). Diversion contrary to 22 | ** US law is prohibited. US Department of Commerce 23 | ** authorization is not required prior to export or 24 | ** transfer to foreign persons or parties unless otherwise 25 | ** prohibited. 26 | ** 27 | ** Redistribution and use in source and binary forms, with 28 | ** or without modification, are permitted provided that the 29 | ** following conditions are met: 30 | ** 31 | ** Redistributions of source code must retain the above 32 | ** copyright notice, this list of conditions and the 33 | ** following disclaimer. 34 | ** 35 | ** Redistributions in binary form must reproduce the above 36 | ** copyright notice, this list of conditions and the 37 | ** following disclaimer in the documentation and/or other 38 | ** materials provided with the distribution. 39 | ** 40 | ** Neither the name of the FLIR Systems Corporation nor the 41 | ** names of its contributors may be used to endorse or 42 | ** promote products derived from this software without 43 | ** specific prior written permission. 44 | ** 45 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 46 | ** CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 47 | ** WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 48 | ** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 49 | ** PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 50 | ** COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY 51 | ** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 52 | ** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 53 | ** PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 54 | ** USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 55 | ** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 56 | ** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 57 | ** NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 58 | ** USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 59 | ** OF SUCH DAMAGE. 60 | ** 61 | *******************************************************************************/ 62 | #ifndef _LEPTON_I2C_SERVICE_H_ 63 | #define _LEPTON_I2C_SERVICE_H_ 64 | 65 | #ifdef __cplusplus 66 | extern "C" 67 | { 68 | #endif 69 | 70 | /******************************************************************************/ 71 | /** INCLUDE FILES **/ 72 | /******************************************************************************/ 73 | #include "LEPTON_Types.h" 74 | #include "LEPTON_ErrorCodes.h" 75 | 76 | 77 | /******************************************************************************/ 78 | /** EXPORTED DEFINES **/ 79 | /******************************************************************************/ 80 | 81 | /******************************************************************************/ 82 | /** EXPORTED TYPE DEFINITIONS **/ 83 | /******************************************************************************/ 84 | 85 | /******************************************************************************/ 86 | /** EXPORTED PUBLIC DATA **/ 87 | /******************************************************************************/ 88 | 89 | /******************************************************************************/ 90 | /** EXPORTED PUBLIC FUNCTIONS **/ 91 | /******************************************************************************/ 92 | 93 | extern LEP_RESULT LEP_I2C_MasterOpen(LEP_UINT16 portID, 94 | LEP_UINT16 *portBaudRate); 95 | 96 | extern LEP_RESULT LEP_I2C_MasterClose(LEP_CAMERA_PORT_DESC_T_PTR portDescPtr ); 97 | 98 | extern LEP_RESULT LEP_I2C_MasterReset(LEP_CAMERA_PORT_DESC_T_PTR portDescPtr ); 99 | 100 | extern LEP_RESULT LEP_I2C_MasterReadData(LEP_UINT16 portID, 101 | LEP_UINT8 deviceAddress, 102 | LEP_UINT16 subAddress, 103 | LEP_UINT16 *dataPtr, 104 | LEP_UINT16 dataLength); 105 | 106 | extern LEP_RESULT LEP_I2C_MasterWriteData(LEP_UINT16 portID, 107 | LEP_UINT8 deviceAddress, 108 | LEP_UINT16 subAddress, 109 | LEP_UINT16 *dataPtr, 110 | LEP_UINT16 dataLength); 111 | 112 | extern LEP_RESULT LEP_I2C_MasterReadRegister(LEP_UINT16 portID, 113 | LEP_UINT8 deviceAddress, 114 | LEP_UINT16 regAddress, 115 | LEP_UINT16 *regValue); 116 | 117 | 118 | extern LEP_RESULT LEP_I2C_MasterWriteRegister(LEP_UINT16 portID, 119 | LEP_UINT8 deviceAddress, 120 | LEP_UINT16 regAddress, 121 | LEP_UINT16 regValue); 122 | 123 | extern LEP_RESULT LEP_I2C_MasterStatus(LEP_UINT16 portID, 124 | LEP_UINT16 *portStatus ); 125 | 126 | /******************************************************************************/ 127 | #ifdef __cplusplus 128 | } 129 | #endif 130 | 131 | #endif /* _LEPTON_I2C_SERVICE_H_ */ 132 | -------------------------------------------------------------------------------- /software/beagleboneblack_video/leptonSDKEmb32PUB/LEPTON_Macros.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | ** 3 | ** File NAME: LEPTON_Macros.h 4 | ** 5 | ** AUTHOR: David Dart 6 | ** 7 | ** CREATED: 7/11/2012 8 | ** 9 | ** DESCRIPTION: 10 | ** 11 | ** HISTORY: 7/11/2012 DWD - Initial Draft 12 | ** 13 | ** Copyright 2011,2012,2013,2014 FLIR Systems - Commercial 14 | ** Vision Systems. All rights reserved. 15 | ** 16 | ** Proprietary - PROPRIETARY - FLIR Systems Inc.. 17 | ** 18 | ** This document is controlled to FLIR Technology Level 2. 19 | ** The information contained in this document pertains to a 20 | ** dual use product Controlled for export by the Export 21 | ** Administration Regulations (EAR). Diversion contrary to 22 | ** US law is prohibited. US Department of Commerce 23 | ** authorization is not required prior to export or 24 | ** transfer to foreign persons or parties unless otherwise 25 | ** prohibited. 26 | ** 27 | ** Redistribution and use in source and binary forms, with 28 | ** or without modification, are permitted provided that the 29 | ** following conditions are met: 30 | ** 31 | ** Redistributions of source code must retain the above 32 | ** copyright notice, this list of conditions and the 33 | ** following disclaimer. 34 | ** 35 | ** Redistributions in binary form must reproduce the above 36 | ** copyright notice, this list of conditions and the 37 | ** following disclaimer in the documentation and/or other 38 | ** materials provided with the distribution. 39 | ** 40 | ** Neither the name of the FLIR Systems Corporation nor the 41 | ** names of its contributors may be used to endorse or 42 | ** promote products derived from this software without 43 | ** specific prior written permission. 44 | ** 45 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 46 | ** CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 47 | ** WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 48 | ** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 49 | ** PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 50 | ** COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY 51 | ** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 52 | ** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 53 | ** PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 54 | ** USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 55 | ** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 56 | ** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 57 | ** NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 58 | ** USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 59 | ** OF SUCH DAMAGE. 60 | ** 61 | *******************************************************************************/ 62 | #ifndef _LEP_MACROS_H_ 63 | #define _LEP_MACROS_H_ 64 | 65 | #ifdef __cplusplus 66 | extern "C" 67 | { 68 | #endif 69 | 70 | /******************************************************************************/ 71 | /** INCLUDE FILES **/ 72 | /******************************************************************************/ 73 | 74 | /******************************************************************************/ 75 | /** EXPORTED DEFINES **/ 76 | /******************************************************************************/ 77 | 78 | /****************************************************************** 79 | *** USEFUL MACROS *** 80 | ******************************************************************/ 81 | 82 | #ifndef MIN 83 | #define MIN(a, b) ((a) < (b)? (a): (b)) 84 | #endif 85 | #ifndef MAX 86 | #define MAX(a, b) ((a) > (b)? (a): (b)) 87 | #endif 88 | 89 | #ifndef LOW_WORD 90 | #define LOW_WORD(longVariable) ((LEP_UINT16)longVariable) 91 | #endif 92 | #ifndef HIGH_WORD 93 | #define HIGH_WORD(longVariable) ((LEP_UINT16)(longVariable>>16)) 94 | #endif 95 | #ifndef LOW_BYTE 96 | #define LOW_BYTE(w) ((LEP_UINT8)(w)) 97 | #endif 98 | #ifndef HIGH_BYTE 99 | #define HIGH_BYTE(w) ((LEP_UINT8)(((w) >> 8) & 0xFF)) 100 | #endif 101 | 102 | #ifndef LOW_NIBBLE 103 | #define LOW_NIBBLE(w) ((LEP_UINT8)(w) & 0x0F) 104 | #endif 105 | #ifndef HIGH_NIBBLE 106 | #define HIGH_NIBBLE(w) ((LEP_UINT8)(((w) >> 4) & 0x0F)) 107 | #endif 108 | 109 | #define CLR_BIT(_port,_bit) ((_port) & ~(_bit)) 110 | 111 | 112 | #define REVERSE_ENDIENESS_UINT16(uint16Var) \ 113 | ( ( ((LEP_UINT16)LOW_BYTE(uint16Var))<<8) + (LEP_UINT16)HIGH_BYTE(uint16Var)) 114 | 115 | #define REVERSE_ENDIENESS_UINT32(uint32Var) \ 116 | ( ((LEP_UINT32)REVERSE_ENDIENESS_UINT16(LOW_WORD(uint32Var)) << 16) + \ 117 | (LEP_UINT32)REVERSE_ENDIENESS_UINT16(HIGH_WORD(uint32Var) ) ) 118 | 119 | #define REVERSE_NIBBLE_UINT8(uint8Var) \ 120 | ( ( ((LEP_UINT8)LOW_NIBBLE(uint8Var))<<4) + (LEP_UINT8)HIGH_NIBBLE(uint8Var)) 121 | 122 | #define REVERSE_BYTEORDER_UINT32(uint32Var) \ 123 | ( (((LEP_UINT32)LOW_BYTE(uint32Var))<<24) + (((LEP_UINT32)HIGH_BYTE(uint32Var))<<16) + \ 124 | (((LEP_UINT32)LOW_BYTE(HIGH_WORD(uint32Var)))<<8) + (LEP_UINT32)HIGH_BYTE(HIGH_WORD(uint32Var)) ) 125 | 126 | #define WORD_SWAP_16(uint32Var) \ 127 | ( ((LEP_UINT16)LOW_WORD(uint32Var) << 16) + ((LEP_UINT16)HIGH_WORD(uint32Var)) ) 128 | 129 | 130 | #ifndef NUM_ELEMENTS_IN_ARRAY 131 | #define NUM_ELEMENTS_IN_ARRAY(array) (sizeof (array) / sizeof ((array) [0])) 132 | #endif /* NUM_ELEMENTS_IN_ARRAY */ 133 | 134 | #ifndef NELEMENTS 135 | #define NELEMENTS(array) /* number of elements in an array */ \ 136 | (sizeof (array) / sizeof ((array) [0])) 137 | #endif /* NELEMENTS */ 138 | 139 | 140 | /******************************************************************************/ 141 | /** EXPORTED TYPE DEFINITIONS **/ 142 | /******************************************************************************/ 143 | 144 | /******************************************************************************/ 145 | /** EXPORTED PUBLIC DATA **/ 146 | /******************************************************************************/ 147 | 148 | /******************************************************************************/ 149 | /** EXPORTED PUBLIC FUNCTIONS **/ 150 | /******************************************************************************/ 151 | 152 | 153 | /******************************************************************************/ 154 | #ifdef __cplusplus 155 | } 156 | #endif 157 | 158 | #endif /* _LEP_MACROS_H_ */ 159 | 160 | -------------------------------------------------------------------------------- /software/beagleboneblack_video/leptonSDKEmb32PUB/LEPTON_SDKConfig.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | ** 3 | ** File NAME: _LEPTON_SDKCONFIG_H_.h 4 | ** 5 | ** AUTHOR: hthomson 6 | ** 7 | ** CREATED: 3/28/2014 8 | ** 9 | ** DESCRIPTION: typedefs for coding style/conventions 10 | ** 11 | ** HISTORY: 3/28/2014 HT - Initial Draft 12 | ** 13 | ** Copyright 2011,2012,2013,2014 FLIR Systems - Commercial 14 | ** Vision Systems. All rights reserved. 15 | ** 16 | ** Proprietary - PROPRIETARY - FLIR Systems Inc.. 17 | ** 18 | ** This document is controlled to FLIR Technology Level 2. 19 | ** The information contained in this document pertains to a 20 | ** dual use product Controlled for export by the Export 21 | ** Administration Regulations (EAR). Diversion contrary to 22 | ** US law is prohibited. US Department of Commerce 23 | ** authorization is not required prior to export or 24 | ** transfer to foreign persons or parties unless otherwise 25 | ** prohibited. 26 | ** 27 | ** Redistribution and use in source and binary forms, with 28 | ** or without modification, are permitted provided that the 29 | ** following conditions are met: 30 | ** 31 | ** Redistributions of source code must retain the above 32 | ** copyright notice, this list of conditions and the 33 | ** following disclaimer. 34 | ** 35 | ** Redistributions in binary form must reproduce the above 36 | ** copyright notice, this list of conditions and the 37 | ** following disclaimer in the documentation and/or other 38 | ** materials provided with the distribution. 39 | ** 40 | ** Neither the name of the FLIR Systems Corporation nor the 41 | ** names of its contributors may be used to endorse or 42 | ** promote products derived from this software without 43 | ** specific prior written permission. 44 | ** 45 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 46 | ** CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 47 | ** WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 48 | ** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 49 | ** PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 50 | ** COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY 51 | ** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 52 | ** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 53 | ** PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 54 | ** USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 55 | ** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 56 | ** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 57 | ** NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 58 | ** USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 59 | ** OF SUCH DAMAGE. 60 | ** 61 | *******************************************************************************/ 62 | #ifndef _LEPTON_SDKCONFIG_H_ 63 | #define _LEPTON_SDKCONFIG_H_ 64 | 65 | #ifdef __cplusplus 66 | extern "C" 67 | { 68 | #endif 69 | 70 | /******************************************************************************/ 71 | /** INCLUDE FILES **/ 72 | /******************************************************************************/ 73 | 74 | 75 | /******************************************************************************/ 76 | /** EXPORTED DEFINES **/ 77 | /******************************************************************************/ 78 | 79 | #define USE_DEPRECATED_SERIAL_NUMBER_INTERFACE 0 80 | #define USE_DEPRECATED_PART_NUMBER_INTERFACE 0 81 | #define USE_DEPRECATED_ASICID_INTERFACE 0 82 | #define USE_DEPRECATED_HOUSING_TCP_INTERFACE 0 83 | 84 | /******************************************************************************/ 85 | /** EXPORTED TYPE DEFINITIONS **/ 86 | /******************************************************************************/ 87 | 88 | 89 | /******************************************************************************/ 90 | /** EXPORTED PUBLIC DATA **/ 91 | /******************************************************************************/ 92 | 93 | /******************************************************************************/ 94 | /** EXPORTED PUBLIC FUNCTIONS **/ 95 | /******************************************************************************/ 96 | 97 | 98 | /******************************************************************************/ 99 | #ifdef __cplusplus 100 | } 101 | #endif 102 | #endif // _LEPTON_SDKCONFIG_H_ 103 | 104 | 105 | -------------------------------------------------------------------------------- /software/beagleboneblack_video/leptonSDKEmb32PUB/Makefile: -------------------------------------------------------------------------------- 1 | # SlickEdit generated file. Do not edit this file except in designated areas. 2 | 3 | # Make command to use for dependencies 4 | MAKE=make 5 | RM=rm 6 | MKDIR=mkdir 7 | CP=cp 8 | 9 | # -----Begin user-editable area----- 10 | 11 | # -----End user-editable area----- 12 | 13 | # If no configuration is specified, "Debug" will be used 14 | ifndef CFG 15 | CFG=Debug 16 | endif 17 | 18 | # 19 | # Configuration: Debug 20 | # 21 | ifeq "$(CFG)" "Debug" 22 | OUTDIR=Debug 23 | OUTFILE=$(OUTDIR)/libLEPTON_SDK.a 24 | CFG_INC=-I/cygdrive/c/WinAVR-20090313/avr/include 25 | CFG_LIB= 26 | CFG_OBJ= 27 | COMMON_OBJ=$(OUTDIR)/bbb_I2C.o $(OUTDIR)/crc16fast.o \ 28 | $(OUTDIR)/LEPTON_AGC.o $(OUTDIR)/LEPTON_VID.o \ 29 | $(OUTDIR)/LEPTON_I2C_Protocol.o $(OUTDIR)/LEPTON_I2C_Service.o \ 30 | $(OUTDIR)/LEPTON_SDK.o $(OUTDIR)/LEPTON_SYS.o 31 | OBJ=$(COMMON_OBJ) $(CFG_OBJ) 32 | ALL_OBJ=$(OUTDIR)/bbb_I2C.o $(OUTDIR)/crc16fast.o \ 33 | $(OUTDIR)/LEPTON_AGC.o $(OUTDIR)/LEPTON_VID.o \ 34 | $(OUTDIR)/LEPTON_I2C_Protocol.o $(OUTDIR)/LEPTON_I2C_Service.o \ 35 | $(OUTDIR)/LEPTON_SDK.o $(OUTDIR)/LEPTON_SYS.o 36 | 37 | COMPILE=gcc -fpermissive -Dlinux=1 -c -v -g -o "$(OUTDIR)/$(*F).o" $(CFG_INC) "$<" 38 | LINK=ar -rs "$(OUTFILE)" $(OBJ) 39 | 40 | # Pattern rules 41 | $(OUTDIR)/%.o : %.c 42 | $(COMPILE) 43 | 44 | # Build rules 45 | all: $(OUTFILE) 46 | 47 | $(OUTFILE): $(OUTDIR) $(OBJ) 48 | $(LINK) 49 | 50 | $(OUTDIR): 51 | $(MKDIR) -p "$(OUTDIR)" 52 | 53 | # Rebuild this project 54 | rebuild: cleanall all 55 | 56 | # Clean this project 57 | clean: 58 | $(RM) -f $(OUTFILE) 59 | $(RM) -f $(OBJ) 60 | 61 | # Clean this project and all dependencies 62 | cleanall: clean 63 | endif 64 | 65 | # 66 | # Configuration: Release 67 | # 68 | ifeq "$(CFG)" "Release" 69 | OUTDIR=Release 70 | OUTFILE=$(OUTDIR)/libLEPTON_SDK.a 71 | CFG_INC=-I/cygdrive/c/WinAVR-20090313/avr/include 72 | CFG_LIB= 73 | CFG_OBJ= 74 | COMMON_OBJ=$(OUTDIR)/bbb_I2C.o $(OUTDIR)/crc16fast.o \ 75 | $(OUTDIR)/LEPTON_AGC.o $(OUTDIR)/LEPTON_VID.o \ 76 | $(OUTDIR)/LEPTON_I2C_Protocol.o $(OUTDIR)/LEPTON_I2C_Service.o \ 77 | $(OUTDIR)/LEPTON_SDK.o $(OUTDIR)/LEPTON_SYS.o 78 | OBJ=$(COMMON_OBJ) $(CFG_OBJ) 79 | ALL_OBJ=$(OUTDIR)/bbb_I2C.o $(OUTDIR)/crc16fast.o \ 80 | $(OUTDIR)/LEPTON_AGC.o $(OUTDIR)/LEPTON_VID.o \ 81 | $(OUTDIR)/LEPTON_I2C_Protocol.o $(OUTDIR)/LEPTON_I2C_Service.o \ 82 | $(OUTDIR)/LEPTON_SDK.o $(OUTDIR)/LEPTON_SYS.o 83 | 84 | COMPILE=g++ -fpermissive -mno-cygwin -c -v -o "$(OUTDIR)/$(*F).o" $(CFG_INC) "$<" 85 | LINK=ar -rs "$(OUTFILE)" $(OBJ) 86 | 87 | # Pattern rules 88 | $(OUTDIR)/%.o : %.c 89 | $(COMPILE) 90 | 91 | # Build rules 92 | all: $(OUTFILE) 93 | 94 | $(OUTFILE): $(OUTDIR) $(OBJ) 95 | $(LINK) 96 | 97 | $(OUTDIR): 98 | $(MKDIR) -p "$(OUTDIR)" 99 | 100 | 101 | # Rebuild this project 102 | rebuild: cleanall all 103 | 104 | # Clean this project 105 | clean: 106 | $(RM) -f $(OUTFILE) 107 | $(RM) -f $(OBJ) 108 | 109 | # Clean this project and all dependencies 110 | cleanall: clean 111 | endif 112 | -------------------------------------------------------------------------------- /software/beagleboneblack_video/leptonSDKEmb32PUB/bbb_I2C.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | ** 3 | ** File NAME: jova_I2C.h 4 | ** 5 | ** AUTHOR: Hart Thomson 6 | ** 7 | ** CREATED: 9/25/2012 8 | ** 9 | ** DESCRIPTION: 10 | ** 11 | ** HISTORY: 9/25/2012 HT - Initial Draft 12 | ** 13 | ** Copyright 2011,2012,2013 FLIR Systems - Commercial Vision Systems 14 | ** All rights reserved. 15 | ** 16 | ** Proprietary - Company Only. 17 | ** 18 | ** This document is controlled to FLIR Technology Level 2. 19 | ** The information contained in this document pertains to a dual use product 20 | ** Controlled for export by the Export Administration Regulations (EAR). 21 | ** FLIR trade secrets contained herein are subject to disclosure restrictions 22 | ** as a matter of law. Diversion contrary to US law is prohibited. 23 | ** US Department of Commerce authorization is required prior to export or 24 | ** transfer to foreign persons or parties and for uses otherwise prohibited. 25 | ** 26 | *******************************************************************************/ 27 | #ifndef _JOVA_I2C_H_ 28 | #define _JOVA_I2C_H_ 29 | 30 | #ifdef __cplusplus 31 | extern "C" 32 | { 33 | #endif 34 | /******************************************************************************/ 35 | /** INCLUDE FILES **/ 36 | /******************************************************************************/ 37 | #include "LEPTON_Types.h" 38 | #include "LEPTON_ErrorCodes.h" 39 | 40 | /******************************************************************************/ 41 | /** EXPORTED DEFINES **/ 42 | /******************************************************************************/ 43 | 44 | /******************************************************************************/ 45 | /** EXPORTED TYPE DEFINITIONS **/ 46 | /******************************************************************************/ 47 | 48 | /******************************************************************************/ 49 | /** EXPORTED PUBLIC DATA **/ 50 | /******************************************************************************/ 51 | 52 | /******************************************************************************/ 53 | /** EXPORTED PUBLIC FUNCTIONS **/ 54 | /******************************************************************************/ 55 | 56 | extern LEP_RESULT DEV_I2C_MasterInit(LEP_UINT16 portID, 57 | LEP_UINT16 *BaudRate); 58 | 59 | extern LEP_RESULT DEV_I2C_MasterClose(); 60 | 61 | extern LEP_RESULT DEV_I2C_MasterReset(void ); 62 | 63 | extern LEP_RESULT DEV_I2C_MasterReadData(LEP_UINT16 portID, 64 | LEP_UINT8 deviceAddress, 65 | LEP_UINT16 regAddress, // Lepton Register Address 66 | LEP_UINT16 *readDataPtr, 67 | LEP_UINT16 wordsToRead, // Number of 16-bit words to Read 68 | LEP_UINT16 *numWordsRead, // Number of 16-bit words actually Read 69 | LEP_UINT16 *status 70 | ); 71 | 72 | extern LEP_RESULT DEV_I2C_MasterWriteData(LEP_UINT16 portID, 73 | LEP_UINT8 deviceAddress, 74 | LEP_UINT16 regAddress, // Lepton Register Address 75 | LEP_UINT16 *writeDataPtr, 76 | LEP_UINT16 wordsToWrite, // Number of 16-bit words to Write 77 | LEP_UINT16 *numWordsWritten, // Number of 16-bit words actually written 78 | LEP_UINT16 *status 79 | ); 80 | 81 | extern LEP_RESULT DEV_I2C_MasterReadRegister( LEP_UINT16 portID, 82 | LEP_UINT8 deviceAddress, 83 | LEP_UINT16 regAddress, 84 | LEP_UINT16 *regValue, // Number of 16-bit words actually written 85 | LEP_UINT16 *status 86 | ); 87 | 88 | extern LEP_RESULT DEV_I2C_MasterWriteRegister( LEP_UINT16 portID, 89 | LEP_UINT8 deviceAddress, 90 | LEP_UINT16 regAddress, 91 | LEP_UINT16 regValue, // Number of 16-bit words actually written 92 | LEP_UINT16 *status 93 | ); 94 | 95 | extern LEP_RESULT DEV_I2C_MasterStatus(void ); 96 | 97 | /******************************************************************************/ 98 | #ifdef __cplusplus 99 | } 100 | #endif 101 | 102 | #endif /* _JOVA_I2C_H_ */ 103 | 104 | -------------------------------------------------------------------------------- /software/beagleboneblack_video/leptonSDKEmb32PUB/crc16.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | 3 | Filename: crc16.h 4 | Description: Cyclic Redundancy Check 16 functions 5 | Created: 24-Feb-1999 6 | 7 | ** Copyright 2011,2012,2013,2014 FLIR Systems - Commercial 8 | ** Vision Systems. All rights reserved. 9 | ** 10 | ** Proprietary - PROPRIETARY - FLIR Systems Inc.. 11 | ** 12 | ** This document is controlled to FLIR Technology Level 2. 13 | ** The information contained in this document pertains to a 14 | ** dual use product Controlled for export by the Export 15 | ** Administration Regulations (EAR). Diversion contrary to 16 | ** US law is prohibited. US Department of Commerce 17 | ** authorization is not required prior to export or 18 | ** transfer to foreign persons or parties unless otherwise 19 | ** prohibited. 20 | ** 21 | ** Redistribution and use in source and binary forms, with 22 | ** or without modification, are permitted provided that the 23 | ** following conditions are met: 24 | ** 25 | ** Redistributions of source code must retain the above 26 | ** copyright notice, this list of conditions and the 27 | ** following disclaimer. 28 | ** 29 | ** Redistributions in binary form must reproduce the above 30 | ** copyright notice, this list of conditions and the 31 | ** following disclaimer in the documentation and/or other 32 | ** materials provided with the distribution. 33 | ** 34 | ** Neither the name of the FLIR Systems Corporation nor the 35 | ** names of its contributors may be used to endorse or 36 | ** promote products derived from this software without 37 | ** specific prior written permission. 38 | ** 39 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 40 | ** CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 41 | ** WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 42 | ** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 43 | ** PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 44 | ** COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY 45 | ** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 46 | ** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 47 | ** PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 48 | ** USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 49 | ** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 50 | ** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 51 | ** NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 52 | ** USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 53 | ** OF SUCH DAMAGE. 54 | 55 | ****************************************************************************/ 56 | 57 | #ifndef __CRC16_H__ 58 | #define __CRC16_H__ 59 | 60 | #ifdef __cplusplus 61 | extern "C" 62 | { 63 | #endif 64 | 65 | typedef unsigned short CRC16; 66 | 67 | int ByteCRC16(int value, int crcin); 68 | CRC16 CalcCRC16Words(unsigned int count, short *buffer); 69 | CRC16 CalcCRC16Bytes(unsigned int count, char *buffer); 70 | 71 | #ifdef __cplusplus 72 | } 73 | #endif 74 | 75 | #endif /* __CRC16_H__ */ 76 | -------------------------------------------------------------------------------- /software/beagleboneblack_video/leptonSDKEmb32PUB/crc16fast.c: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | 3 | Filename: crc16fast.c 4 | Description: Cyclic Redundancy Check 16 functions 5 | Created: 24-Feb-1999 6 | 7 | ** Copyright 2011,2012,2013,2014 FLIR Systems - Commercial 8 | ** Vision Systems. All rights reserved. 9 | ** 10 | ** Proprietary - PROPRIETARY - FLIR Systems Inc.. 11 | ** 12 | ** This document is controlled to FLIR Technology Level 2. 13 | ** The information contained in this document pertains to a 14 | ** dual use product Controlled for export by the Export 15 | ** Administration Regulations (EAR). Diversion contrary to 16 | ** US law is prohibited. US Department of Commerce 17 | ** authorization is not required prior to export or 18 | ** transfer to foreign persons or parties unless otherwise 19 | ** prohibited. 20 | ** 21 | ** Redistribution and use in source and binary forms, with 22 | ** or without modification, are permitted provided that the 23 | ** following conditions are met: 24 | ** 25 | ** Redistributions of source code must retain the above 26 | ** copyright notice, this list of conditions and the 27 | ** following disclaimer. 28 | ** 29 | ** Redistributions in binary form must reproduce the above 30 | ** copyright notice, this list of conditions and the 31 | ** following disclaimer in the documentation and/or other 32 | ** materials provided with the distribution. 33 | ** 34 | ** Neither the name of the FLIR Systems Corporation nor the 35 | ** names of its contributors may be used to endorse or 36 | ** promote products derived from this software without 37 | ** specific prior written permission. 38 | ** 39 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 40 | ** CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 41 | ** WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 42 | ** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 43 | ** PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 44 | ** COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY 45 | ** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 46 | ** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 47 | ** PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 48 | ** USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 49 | ** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 50 | ** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 51 | ** NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 52 | ** USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 53 | ** OF SUCH DAMAGE. 54 | ** 55 | ****************************************************************************/ 56 | 57 | #include "crc16.h" 58 | 59 | const CRC16 ccitt_16Table[] = { 60 | 0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50A5, 0x60C6, 0x70E7, 61 | 0x8108, 0x9129, 0xA14A, 0xB16B, 0xC18C, 0xD1AD, 0xE1CE, 0xF1EF, 62 | 0x1231, 0x0210, 0x3273, 0x2252, 0x52B5, 0x4294, 0x72F7, 0x62D6, 63 | 0x9339, 0x8318, 0xB37B, 0xA35A, 0xD3BD, 0xC39C, 0xF3FF, 0xE3DE, 64 | 0x2462, 0x3443, 0x0420, 0x1401, 0x64E6, 0x74C7, 0x44A4, 0x5485, 65 | 0xA56A, 0xB54B, 0x8528, 0x9509, 0xE5EE, 0xF5CF, 0xC5AC, 0xD58D, 66 | 0x3653, 0x2672, 0x1611, 0x0630, 0x76D7, 0x66F6, 0x5695, 0x46B4, 67 | 0xB75B, 0xA77A, 0x9719, 0x8738, 0xF7DF, 0xE7FE, 0xD79D, 0xC7BC, 68 | 0x48C4, 0x58E5, 0x6886, 0x78A7, 0x0840, 0x1861, 0x2802, 0x3823, 69 | 0xC9CC, 0xD9ED, 0xE98E, 0xF9AF, 0x8948, 0x9969, 0xA90A, 0xB92B, 70 | 0x5AF5, 0x4AD4, 0x7AB7, 0x6A96, 0x1A71, 0x0A50, 0x3A33, 0x2A12, 71 | 0xDBFD, 0xCBDC, 0xFBBF, 0xEB9E, 0x9B79, 0x8B58, 0xBB3B, 0xAB1A, 72 | 0x6CA6, 0x7C87, 0x4CE4, 0x5CC5, 0x2C22, 0x3C03, 0x0C60, 0x1C41, 73 | 0xEDAE, 0xFD8F, 0xCDEC, 0xDDCD, 0xAD2A, 0xBD0B, 0x8D68, 0x9D49, 74 | 0x7E97, 0x6EB6, 0x5ED5, 0x4EF4, 0x3E13, 0x2E32, 0x1E51, 0x0E70, 75 | 0xFF9F, 0xEFBE, 0xDFDD, 0xCFFC, 0xBF1B, 0xAF3A, 0x9F59, 0x8F78, 76 | 0x9188, 0x81A9, 0xB1CA, 0xA1EB, 0xD10C, 0xC12D, 0xF14E, 0xE16F, 77 | 0x1080, 0x00A1, 0x30C2, 0x20E3, 0x5004, 0x4025, 0x7046, 0x6067, 78 | 0x83B9, 0x9398, 0xA3FB, 0xB3DA, 0xC33D, 0xD31C, 0xE37F, 0xF35E, 79 | 0x02B1, 0x1290, 0x22F3, 0x32D2, 0x4235, 0x5214, 0x6277, 0x7256, 80 | 0xB5EA, 0xA5CB, 0x95A8, 0x8589, 0xF56E, 0xE54F, 0xD52C, 0xC50D, 81 | 0x34E2, 0x24C3, 0x14A0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405, 82 | 0xA7DB, 0xB7FA, 0x8799, 0x97B8, 0xE75F, 0xF77E, 0xC71D, 0xD73C, 83 | 0x26D3, 0x36F2, 0x0691, 0x16B0, 0x6657, 0x7676, 0x4615, 0x5634, 84 | 0xD94C, 0xC96D, 0xF90E, 0xE92F, 0x99C8, 0x89E9, 0xB98A, 0xA9AB, 85 | 0x5844, 0x4865, 0x7806, 0x6827, 0x18C0, 0x08E1, 0x3882, 0x28A3, 86 | 0xCB7D, 0xDB5C, 0xEB3F, 0xFB1E, 0x8BF9, 0x9BD8, 0xABBB, 0xBB9A, 87 | 0x4A75, 0x5A54, 0x6A37, 0x7A16, 0x0AF1, 0x1AD0, 0x2AB3, 0x3A92, 88 | 0xFD2E, 0xED0F, 0xDD6C, 0xCD4D, 0xBDAA, 0xAD8B, 0x9DE8, 0x8DC9, 89 | 0x7C26, 0x6C07, 0x5C64, 0x4C45, 0x3CA2, 0x2C83, 0x1CE0, 0x0CC1, 90 | 0xEF1F, 0xFF3E, 0xCF5D, 0xDF7C, 0xAF9B, 0xBFBA, 0x8FD9, 0x9FF8, 91 | 0x6E17, 0x7E36, 0x4E55, 0x5E74, 0x2E93, 0x3EB2, 0x0ED1, 0x1EF0 92 | }; 93 | 94 | /* 95 | * ===== ByteCRC16 ===== 96 | * Calculate (update) the CRC16 for a single 8-bit byte 97 | */ 98 | int ByteCRC16(int value, int crcin) 99 | { 100 | return (unsigned short)((crcin << 8) ^ ccitt_16Table[((crcin >> 8) ^ (value)) & 255]); 101 | } 102 | 103 | /* 104 | * ===== CalcCRC16Words ===== 105 | * Calculate the CRC for a buffer of 16-bit words. Supports both 106 | * Little and Big Endian formats using conditional compilation. 107 | * Note: minimum count is 1 (0 case not handled) 108 | */ 109 | CRC16 CalcCRC16Words(unsigned int count, short *buffer) { 110 | 111 | int crc = 0; 112 | 113 | do { 114 | 115 | int value = *buffer++; 116 | #ifdef _BIG_ENDIAN 117 | crc = ByteCRC16(value >> 8, crc); 118 | crc = ByteCRC16(value, crc); 119 | #else 120 | crc = ByteCRC16(value, crc); 121 | crc = ByteCRC16(value >> 8, crc); 122 | #endif 123 | } 124 | while (--count); 125 | return (CRC16) crc; 126 | } 127 | 128 | /* 129 | * ===== CalcCRC16Bytes ===== 130 | * Calculate the CRC for a buffer of 8-bit words. 131 | * Note: minimum count is 1 (0 case not handled) 132 | */ 133 | CRC16 CalcCRC16Bytes(unsigned int count, char *buffer) { 134 | 135 | int crc = 0; 136 | 137 | do { 138 | 139 | int value = *buffer++; 140 | crc = ByteCRC16(value, crc); 141 | } 142 | while (--count); 143 | return crc; 144 | } 145 | -------------------------------------------------------------------------------- /software/beagleboneblack_video/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #include "LeptonThread.h" 13 | #include "MyLabel.h" 14 | 15 | int main( int argc, char **argv ) 16 | { 17 | //create the app 18 | QApplication a( argc, argv ); 19 | 20 | QWidget *myWidget = new QWidget; 21 | myWidget->setGeometry(400, 300, 340, 290); 22 | 23 | //create an image placeholder for myLabel 24 | //fill the top left corner with red, just bcuz 25 | QImage myImage; 26 | myImage = QImage(320, 240, QImage::Format_RGB888); 27 | QRgb red = qRgb(255,0,0); 28 | for(int i=0;i<80;i++) { 29 | for(int j=0;j<60;j++) { 30 | myImage.setPixel(i, j, red); 31 | } 32 | } 33 | 34 | //create a label, and set it's image to the placeholder 35 | MyLabel myLabel(myWidget); 36 | myLabel.setGeometry(10, 10, 320, 240); 37 | myLabel.setPixmap(QPixmap::fromImage(myImage)); 38 | 39 | //create a FFC button 40 | QPushButton *button1 = new QPushButton("Perform FFC", myWidget); 41 | button1->setGeometry(320/2-50, 290-35, 100, 30); 42 | 43 | //create a thread to gather SPI data 44 | //when the thread emits updateImage, the label should update its image accordingly 45 | LeptonThread *thread = new LeptonThread(); 46 | QObject::connect(thread, SIGNAL(updateImage(QImage)), &myLabel, SLOT(setImage(QImage))); 47 | 48 | //connect ffc button to the thread's ffc action 49 | QObject::connect(button1, SIGNAL(clicked()), thread, SLOT(performFFC())); 50 | thread->start(); 51 | 52 | myWidget->show(); 53 | 54 | return a.exec(); 55 | } 56 | 57 | -------------------------------------------------------------------------------- /software/edison_capture/README.md: -------------------------------------------------------------------------------- 1 | edison_capture 2 | ----------- 3 | Captures a still image from the lepton on the Intel Edison, using pins 10 - 13 for CS, MOSI, MISO and CLK. The image is stored as a PGM file under image.pgm. 4 | Make sure, the MRAA library is up to date. 5 | 6 | Compile with: 7 | gcc -lmraa -o lepton_capture lepton_capture.c 8 | 9 | Run with: 10 | ./lepton_capture -------------------------------------------------------------------------------- /software/edison_capture/lepton_capture.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014, C. Gyger, S. Raible 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright notice, this 9 | list of conditions and the following disclaimer. 10 | 11 | * Redistributions in binary form must reproduce the above copyright notice, 12 | this list of conditions and the following disclaimer in the documentation 13 | and/or other materials provided with the distribution. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 19 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 21 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 22 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 23 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 24 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | void sig_handler(int signum); 33 | void save_pgm_file(); 34 | 35 | static sig_atomic_t volatile isrunning = 1; 36 | static unsigned int image[80*60]; 37 | 38 | main(int argc, char **argv) 39 | { 40 | signal(SIGINT, &sig_handler); 41 | 42 | // init 43 | mraa_init(); 44 | 45 | mraa_gpio_context cs = mraa_gpio_init(10); 46 | mraa_gpio_dir(cs, MRAA_GPIO_OUT); 47 | 48 | mraa_spi_context spi = mraa_spi_init(5); // bus 5 for edison 49 | mraa_spi_mode(spi, MRAA_SPI_MODE3); 50 | mraa_spi_frequency(spi, 6250000); 51 | mraa_spi_lsbmode(spi, 0); 52 | mraa_spi_bit_per_word(spi, 8); 53 | 54 | uint8_t payload[164]; 55 | uint8_t *recv = NULL; 56 | int packetNb; 57 | int i; 58 | uint8_t checkByte = 0x0f; 59 | 60 | printf("\nStarting Lepton Test\n"); 61 | 62 | //sync 63 | mraa_gpio_write(cs, 1); // high to de-select chip 64 | usleep(200000); 65 | mraa_gpio_write(cs, 0); // low to select chip 66 | 67 | // loop while discard packets 68 | while((checkByte & 0x0f) == 0x0f && isrunning){ 69 | if(recv) 70 | free(recv); 71 | recv = mraa_spi_write_buf(spi, payload, 164); 72 | checkByte = recv[0]; 73 | packetNb = recv[1]; 74 | } 75 | 76 | // sync done, first packet is ready, store packets 77 | while(packetNb < 60 && isrunning) 78 | { 79 | // ignore discard packets 80 | if((recv[0] & 0x0f) != 0x0f){ 81 | for(i=0;i<80;i++) 82 | { 83 | image[packetNb * 80 + i] = (recv[2*i+4] << 8 | recv[2*i+5]); 84 | } 85 | } 86 | 87 | // read next packet 88 | if(recv) 89 | free(recv); 90 | recv = mraa_spi_write_buf(spi, payload, 164); 91 | packetNb = recv[1]; 92 | } 93 | 94 | printf("\nFrame received, storing PGM file\n"); 95 | save_pgm_file(); 96 | 97 | // de-init 98 | fprintf(stdout, "\nEnding, set CS = 0\n"); 99 | mraa_gpio_write(cs, 0); 100 | mraa_gpio_close(cs); 101 | 102 | fprintf(stdout, "\nDone\n"); 103 | 104 | return MRAA_SUCCESS; 105 | } 106 | 107 | void save_pgm_file() 108 | { 109 | int i; 110 | int j; 111 | unsigned int maxval = 0; 112 | unsigned int minval = 100000; 113 | FILE *f = fopen("image.pgm", "w"); 114 | if (f == NULL) 115 | { 116 | printf("Error opening file!\n"); 117 | exit(1); 118 | } 119 | printf("\nCalculating min/max values for proper scaling...\n"); 120 | for(i=0;i<60;i++) 121 | { 122 | for(j=0;j<80;j++) 123 | { 124 | if (image[i * 80 + j] > maxval) { 125 | maxval = image[i * 80 + j]; 126 | } 127 | if (image[i * 80 + j] < minval) { 128 | minval = image[i * 80 + j]; 129 | } 130 | } 131 | } 132 | printf("maxval = %u\n",maxval); 133 | printf("minval = %u\n",minval); 134 | fprintf(f,"P2\n80 60\n%u\n",maxval-minval); 135 | for(i=0;i<60;i++) 136 | { 137 | for(j=0;j<80;j++) 138 | { 139 | fprintf(f,"%d ", image[i * 80 + j] - minval); 140 | } 141 | fprintf(f,"\n"); 142 | } 143 | fprintf(f,"\n\n"); 144 | fclose(f); 145 | } 146 | 147 | void sig_handler(int signum) 148 | { 149 | if(signum == SIGINT) 150 | isrunning = 0; 151 | } 152 | -------------------------------------------------------------------------------- /software/flirpi/Makefile: -------------------------------------------------------------------------------- 1 | CC = gcc 2 | CFLAGS = -Wall 3 | 4 | all: leptbmp fblept leptgraypng leptcam 5 | 6 | leptcam: leptcam.o 7 | $(CC) -o leptcam leptcam.c leptsci.o -lpthread $(CFLAGS) 8 | 9 | leptgraypng: leptgraypng.c leptsci.o 10 | $(CC) -o leptgraypng leptgraypng.c leptsci.o -lpng $(CFLAGS) 11 | 12 | leptbmp: leptbmp.c leptsci.o 13 | 14 | fblept: fblept.c leptsci.o 15 | 16 | leptsci.o: leptsci.c 17 | 18 | clean: 19 | rm -f leptsci.o fblept leptbmp leptgraypng 20 | -------------------------------------------------------------------------------- /software/flirpi/README.md: -------------------------------------------------------------------------------- 1 | Released under the GPLv3 2 | 3 | These are miscellaneous utilities that work with the lepton module on the raspberry pi. 4 | 5 | You normally need to use sudo (until I or someone else does V4L2 for the module). 6 | 7 | leptsci.c is the code to access the flir module over SCI and fill an image buffer. 8 | 9 | (Note: there seems to be an occasional hiccup with the SCI, maybe it is just my jumper cables or something, but it occasionally gets out of sync, so there is some experimental code to address this) 10 | 11 | leptcam is work in progress, but using the V4L2 loopback module which must be loaded - it may be in your distro or is avaialble as source at: 12 | git clone https://github.com/umlaeute/v4l2loopback 13 | This will create a new /dev/videoN device. 14 | it will eventually turn the Lepton into a video-for-linux-2 device. 15 | Right now, when run in the background, e.g. 16 | leptcam /dev/videoN & # replace N with the V4L2loopback device number 17 | it just displays colored squares with 18 | vlc v4l2:///dev/videoN # replace N with the V4L2loopback device number 19 | 20 | fblept will display a false color image to the framebuffer (command line normally), updating about 10x/sec. Add "-c" to see a "contour" version that should show more detail in high dynamic range (e.g. a stove and refrigerator). 21 | 22 | leptbmp will write out a BMP with HTTP header. Most desktop browsers understand bmp, so you can animate by just including it via CGI in an tag and with a meta-refresh or javascript it will continually update 23 | 24 | leptgraypng is so you can use ImageMagic, typically convert. It takes the raw data and writes it to a PNG file with 16 bit grayscale. If you view it, it will look flat, but "convert x.png -equalize y.png" will show something much more normal. You can enhance it further. See http://www.imagemagick.org 25 | 26 | I get good images with "./leptgraypng >x.png ; convert x.png -normalize -contrast -sharpen 5 y.png; fbi -a y.png" 27 | 28 | The lepton sensor has a lot of range, but if you simply threshold, you won't see much if there is both a hot and cold object in the view. convert has more optons that can do things like high-pass filtering, so a hot handprint on the wall can be visible at the same time, but it requires some tweaking. GIMP tends to flatten to 8 bits so can't do much. 29 | 30 | -------------------------------------------------------------------------------- /software/flirpi/fblept.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | static void pabort(const char *s) 15 | { 16 | perror(s); 17 | abort(); 18 | } 19 | 20 | static struct fb_var_screeninfo vinfo; 21 | static struct fb_fix_screeninfo finfo; 22 | static char *fbp = 0; 23 | 24 | #define WD 80 25 | #define HT 60 26 | 27 | static unsigned short img[HT][80]; 28 | static unsigned char mag = 0, xo, yo; 29 | static unsigned contour = 0; 30 | static void writefb(void) 31 | { 32 | int x, y, xb, yb; 33 | long int loc = 0; 34 | int stride = vinfo.bits_per_pixel >> 3; 35 | unsigned short minval = 0xffff, maxval = 0; 36 | for (y = 0; y < HT; y++) 37 | for (x = 0; x < 80; x++) { 38 | if (img[y][x] > maxval) 39 | maxval = img[y][x]; 40 | if (img[y][x] < minval) 41 | minval = img[y][x]; 42 | } 43 | maxval -= minval; // span 44 | // printf("%d + %d\n", minval, maxval); 45 | 46 | for (y = 0; y < HT; y++) 47 | for (x = 0; x < WD; x++) { 48 | 49 | int val; 50 | if (!contour) 51 | val = ((img[y][x] - minval) * 255) / (maxval); 52 | else 53 | val = img[y][x] << 2; // - minval; 54 | val &= 0xff; 55 | 56 | int b = val; 57 | int r = val; 58 | int g = val; 59 | #define COLOR 60 | #ifdef COLOR 61 | switch (val >> 6) { 62 | case 0: 63 | b = 255; 64 | g = 0; 65 | r = 255 - (val << 2); 66 | break; 67 | case 1: 68 | r = 0; 69 | b = 255 - (val << 2); 70 | g = (val << 2); 71 | break; 72 | case 2: 73 | b = 0; 74 | g = 255; 75 | r = (val << 2); 76 | break; 77 | case 3: 78 | b = 0; 79 | r = 255; 80 | g = 255 - (val << 2); 81 | break; 82 | default: 83 | break; 84 | } 85 | #endif 86 | unsigned short int t = ((r & 0xf8) << 8) | ((g & 0xfc) << 3) | ((b & 0xf8) >> 3); 87 | 88 | for (yb = 0; yb < mag; yb++) { 89 | loc = (x * mag + xo) * stride + (yb + y * mag + yo) * finfo.line_length; 90 | for (xb = 0; xb < mag; xb++) { 91 | if (vinfo.bits_per_pixel == 32) { 92 | *(fbp + loc++) = b; // Some blue 93 | *(fbp + loc++) = g; // A little green 94 | *(fbp + loc++) = r; // A lot of red 95 | *(fbp + loc++) = 0; // No transparency 96 | } 97 | else { //assume 16bpp 98 | *(fbp + loc++) = t; 99 | *(fbp + loc++) = t >> 8; 100 | } 101 | } 102 | } 103 | } 104 | } 105 | 106 | #include "leptsci.h" 107 | 108 | char *spidev = "/dev/spidev0.0"; 109 | 110 | void usage(char *exec) 111 | { 112 | printf("Usage: %s [options]\n" 113 | "Options:\n" 114 | " -c | --contour Set contour to 1\n" 115 | " -d | --device name spidev device name (%s by default)\n" 116 | " -h | --help Print this message\n" 117 | " -m | --magnify factor Force given factor as magnify factor " 118 | "instead of auto-calculated one\n" 119 | "", exec, spidev); 120 | } 121 | 122 | static const char short_options [] = "cd:hm:"; 123 | 124 | static const struct option long_options [] = { 125 | { "contour", no_argument, NULL, 'c' }, 126 | { "device", required_argument, NULL, 'd' }, 127 | { "help", no_argument, NULL, 'h' }, 128 | { "magnify", required_argument, NULL, 'm' }, 129 | { 0, 0, 0, 0 } 130 | }; 131 | 132 | int main(int argc, char *argv[]) 133 | { 134 | int fbfd = 0; 135 | long int screensize = 0; 136 | 137 | /* Processing command line parameters */ 138 | for (;;) { 139 | int index; 140 | int c; 141 | 142 | c = getopt_long(argc, argv, 143 | short_options, long_options, 144 | &index); 145 | 146 | if (-1 == c) 147 | break; 148 | 149 | switch (c) { 150 | case 0: /* getopt_long() flag */ 151 | break; 152 | 153 | case 'c': 154 | contour = 1; 155 | break; 156 | 157 | case 'd': 158 | spidev = optarg; 159 | break; 160 | 161 | case 'h': 162 | usage(argv[0]); 163 | exit(EXIT_SUCCESS); 164 | 165 | case 'm': 166 | mag = strtoul(optarg, 0, 10); 167 | break; 168 | 169 | default: 170 | usage(argv[0]); 171 | exit(EXIT_FAILURE); 172 | } 173 | } 174 | 175 | fbfd = open("/dev/fb0", O_RDWR); 176 | if (fbfd == -1) 177 | pabort("Error: cannot open framebuffer device"); 178 | if (ioctl(fbfd, FBIOGET_FSCREENINFO, &finfo) == -1) 179 | pabort("Error reading fixed information"); 180 | if (ioctl(fbfd, FBIOGET_VSCREENINFO, &vinfo) == -1) 181 | pabort("Error reading variable information"); 182 | screensize = vinfo.xres * vinfo.yres * vinfo.bits_per_pixel / 8; 183 | fbp = (char *) mmap(0, screensize, PROT_READ | PROT_WRITE, MAP_SHARED, fbfd, 0); 184 | if ((int) fbp == -1) 185 | pabort("Error: failed to map framebuffer device to memory"); 186 | //printf("The framebuffer device was mapped to memory successfully.\n"); 187 | memset( fbp, 0, vinfo.xres*vinfo.yres*(vinfo.bits_per_pixel/8)); 188 | if (!mag) { 189 | mag = vinfo.xres / 80; 190 | } 191 | if (vinfo.yres / HT < mag) 192 | mag = vinfo.yres / HT; 193 | printf("Using magnify factor of %dx\n", mag); 194 | 195 | xo = (vinfo.xres - WD * mag) / 2 + vinfo.xoffset; 196 | yo = (vinfo.yres - HT * mag) / 2 + vinfo.yoffset; 197 | printf( "%d,%d,%d,%d\n",xo,yo,80*mag,60*mag ); 198 | if (leptopen(spidev)) 199 | return -7; 200 | 201 | for (;;) { 202 | if (leptget((unsigned short *) img)) 203 | return -8; 204 | writefb(); 205 | //usleep(125000); 206 | } 207 | leptclose(); 208 | munmap(fbp, screensize); 209 | close(fbfd); 210 | return 0; 211 | } 212 | -------------------------------------------------------------------------------- /software/flirpi/greyenhance.sh: -------------------------------------------------------------------------------- 1 | ./leptgraypng >x.png ; convert x.png -normalize -contrast -sharpen 5 -resize 320x240 y.png; fbi -T 1 -a y.png 2 | -------------------------------------------------------------------------------- /software/flirpi/leptbmp.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | static unsigned short img[60][80]; 5 | 6 | static char hhead[] = "HTTP/1.1 200 OK\r\nContent-Type: image/x-bmp\r\n\r\n"; 7 | static unsigned char bmphead[] = { 8 | 0x42, 0x4D, 0xF6, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x04, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 9 | 0x00, 0x3C, 0x00, 0x00, 0x00, 0x01, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 10 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 11 | }; 12 | 13 | static void writebmp(void) 14 | { 15 | int x, y; 16 | unsigned short minval = 0xffff, maxval = 0; 17 | for (y = 0; y < 60; y++) 18 | for (x = 0; x < 80; x++) { 19 | if (img[y][x] > maxval) 20 | maxval = img[y][x]; 21 | if (img[y][x] < minval) 22 | minval = img[y][x]; 23 | } 24 | maxval -= minval; // span 25 | // printf("%d + %d\n", minval, maxval); 26 | 27 | write(1, hhead, sizeof(hhead) - 1); // no trailing null 28 | write(1, bmphead, sizeof(bmphead)); 29 | int b, r, g, a = 0, val; 30 | for (val = 0; val < 256; val++) { 31 | 32 | #define COLOR 33 | #ifdef COLOR 34 | switch (val >> 6) { 35 | case 0: 36 | b = 255; 37 | g = 0; 38 | r = 255 - (val << 2); 39 | break; 40 | case 1: 41 | r = 0; 42 | b = 255 - (val << 2); 43 | g = (val << 2); 44 | break; 45 | case 2: 46 | b = 0; 47 | g = 255; 48 | r = (val << 2); 49 | break; 50 | case 3: 51 | b = 0; 52 | r = 255; 53 | g = 255 - (val << 2); 54 | break; 55 | default: 56 | break; 57 | } 58 | #else 59 | b = r = g = val; 60 | #endif 61 | write(1, &b, 1); 62 | write(1, &g, 1); 63 | write(1, &r, 1); 64 | write(1, &a, 1); 65 | } 66 | 67 | for (y = 59; y >= 0; y--) 68 | for (x = 0; x < 80; x++) { 69 | val = ((img[y][x] - minval) * 255) / (maxval); 70 | val &= 0xff; 71 | write(1, &val, 1); 72 | } 73 | } 74 | 75 | #include "leptsci.h" 76 | 77 | int main(int argc, char *argv[]) 78 | { 79 | if (leptopen(NULL) || leptget((unsigned short *) img)) 80 | return -1; 81 | leptclose(); 82 | writebmp(); 83 | return 0; 84 | } 85 | -------------------------------------------------------------------------------- /software/flirpi/leptcam.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include /* low-level i/o */ 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | static char *v4l2dev = "/dev/video1"; 18 | static int v4l2sink = -1; 19 | static int width = 80; //640; // Default for Flash 20 | static int height = 60; //480; // Default for Flash 21 | static char *vidsendbuf = NULL; 22 | static int vidsendsiz = 0; 23 | 24 | static void init_device() { 25 | 26 | } 27 | 28 | static void grab_lepton() { 29 | 30 | struct timespec ts; 31 | clock_gettime(CLOCK_REALTIME, &ts); 32 | memset( vidsendbuf, 0, 3); 33 | switch( ts.tv_sec & 3 ) { 34 | case 0: 35 | vidsendbuf[0] = 255; 36 | break; 37 | case 1: 38 | vidsendbuf[0] = 255; 39 | vidsendbuf[1] = 255; 40 | break; 41 | case 2: 42 | vidsendbuf[1] = 255; 43 | break; 44 | case 3: 45 | vidsendbuf[2] = 255; 46 | break; 47 | } 48 | memcpy( vidsendbuf+3, vidsendbuf, vidsendsiz-3 ); 49 | } 50 | 51 | static void stop_device() { 52 | 53 | } 54 | 55 | static void open_vpipe() 56 | { 57 | v4l2sink = open(v4l2dev, O_WRONLY); 58 | if (v4l2sink < 0) { 59 | fprintf(stderr, "Failed to open v4l2sink device. (%s)\n", strerror(errno)); 60 | exit(-2); 61 | } 62 | // setup video for proper format 63 | struct v4l2_format v; 64 | int t; 65 | v.type = V4L2_BUF_TYPE_VIDEO_OUTPUT; 66 | t = ioctl(v4l2sink, VIDIOC_G_FMT, &v); 67 | if( t < 0 ) 68 | exit(t); 69 | v.fmt.pix.width = width; 70 | v.fmt.pix.height = height; 71 | v.fmt.pix.pixelformat = V4L2_PIX_FMT_RGB24; 72 | vidsendsiz = width * height * 3; 73 | v.fmt.pix.sizeimage = vidsendsiz; 74 | t = ioctl(v4l2sink, VIDIOC_S_FMT, &v); 75 | if( t < 0 ) 76 | exit(t); 77 | vidsendbuf = malloc( vidsendsiz ); 78 | } 79 | 80 | static pthread_t sender; 81 | static sem_t lock1,lock2; 82 | static void *sendvid(void *v) 83 | { 84 | for (;;) { 85 | sem_wait(&lock1); 86 | if (vidsendsiz != write(v4l2sink, vidsendbuf, vidsendsiz)) 87 | exit(-1); 88 | sem_post(&lock2); 89 | } 90 | } 91 | 92 | int main(int argc, char **argv) 93 | { 94 | struct timespec ts; 95 | 96 | if( argc == 2 ) 97 | v4l2dev = argv[1]; 98 | 99 | open_vpipe(); 100 | 101 | // open and lock response 102 | if (sem_init(&lock2, 0, 1) == -1) 103 | exit(-1); 104 | sem_wait(&lock2); 105 | 106 | if (sem_init(&lock1, 0, 1) == -1) 107 | exit(-1); 108 | pthread_create(&sender, NULL, sendvid, NULL); 109 | 110 | for (;;) { 111 | // wait until a frame can be written 112 | fprintf( stderr, "Waiting for sink\n" ); 113 | sem_wait(&lock2); 114 | // setup source 115 | init_device(); // open and setup SPI 116 | for (;;) { 117 | grab_lepton(); 118 | // push it out 119 | sem_post(&lock1); 120 | clock_gettime(CLOCK_REALTIME, &ts); 121 | ts.tv_sec += 2; 122 | // wait for it to get written (or is blocking) 123 | if (sem_timedwait(&lock2, &ts)) 124 | break; 125 | } 126 | stop_device(); // close SPI 127 | } 128 | close(v4l2sink); 129 | return 0; 130 | } 131 | -------------------------------------------------------------------------------- /software/flirpi/leptgraypng.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "leptsci.h" 4 | 5 | #define HT 60 6 | #define WD 80 7 | 8 | //static char hhead[] = "HTTP/1.1 200 OK\r\nContent-Type: image/x-png\r\n\r\n"; 9 | 10 | png_byte *rps[HT]; 11 | png_byte image[WD * HT * 2]; 12 | unsigned short *simage = (unsigned short *) image; 13 | 14 | int main(int argc, char *argv[]) 15 | { 16 | int y; 17 | 18 | for (y = 0; y < HT; y++) 19 | rps[y] = image + WD * 2 * y; 20 | if (leptopen(NULL) || leptget(simage)) 21 | return -1; 22 | leptclose(); 23 | 24 | png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); 25 | if (!png_ptr) 26 | return -2; 27 | png_infop info_ptr = png_create_info_struct(png_ptr); 28 | if (!info_ptr) { 29 | png_destroy_write_struct(&png_ptr, (png_infopp) NULL); 30 | return -3; 31 | } 32 | png_init_io(png_ptr, stdout); 33 | 34 | png_set_IHDR(png_ptr, info_ptr, WD, HT, 16, PNG_COLOR_TYPE_GRAY, PNG_INTERLACE_ADAM7 /*_NONE */ , 35 | PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); 36 | png_write_info(png_ptr, info_ptr); 37 | png_set_swap(png_ptr); 38 | png_write_image(png_ptr, rps); 39 | png_write_end(png_ptr, info_ptr); 40 | png_destroy_write_struct(&png_ptr, &info_ptr); 41 | return 0; 42 | } 43 | -------------------------------------------------------------------------------- /software/flirpi/leptsci.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | static uint8_t bits = 8; 10 | static uint32_t speed = 16000000; //16 11 | static uint16_t delay = 0; 12 | static int leptfd; 13 | 14 | int leptopen(char *device) 15 | { 16 | uint8_t mode = 0; 17 | char *spidev = "/dev/spidev0.0"; 18 | 19 | if (device) 20 | spidev = device; 21 | 22 | leptfd = open(spidev, O_RDWR); 23 | if (leptfd < 0) { 24 | perror("spidev device"); 25 | return -1; 26 | } 27 | if (-1 == ioctl(leptfd, SPI_IOC_WR_MODE, &mode)) 28 | return -2; 29 | if (-1 == ioctl(leptfd, SPI_IOC_RD_MODE, &mode)) 30 | return -3; 31 | if (-1 == ioctl(leptfd, SPI_IOC_WR_BITS_PER_WORD, &bits)) 32 | return -4; 33 | if (-1 == ioctl(leptfd, SPI_IOC_RD_BITS_PER_WORD, &bits)) 34 | return -5; 35 | if (-1 == ioctl(leptfd, SPI_IOC_WR_MAX_SPEED_HZ, &speed)) 36 | return -6; 37 | if (-1 == ioctl(leptfd, SPI_IOC_RD_MAX_SPEED_HZ, &speed)) 38 | return -7; 39 | return 0; 40 | } 41 | 42 | void leptclose() 43 | { 44 | close(leptfd); 45 | } 46 | 47 | int leptget(unsigned short *img) 48 | { 49 | #define VOSPI_FRAME_SIZE (164) 50 | int row = -1; 51 | int hiccup = 0; 52 | int notready = 0; 53 | do { 54 | 55 | uint8_t lepacket[VOSPI_FRAME_SIZE]; 56 | uint8_t tx[VOSPI_FRAME_SIZE] = { 0, }; 57 | struct spi_ioc_transfer tr = { 58 | .tx_buf = (unsigned long) tx, 59 | .rx_buf = (unsigned long) lepacket, 60 | .len = VOSPI_FRAME_SIZE, 61 | .delay_usecs = delay, 62 | .speed_hz = speed, 63 | .bits_per_word = bits, 64 | }; 65 | 66 | int i; 67 | i = ioctl(leptfd, SPI_IOC_MESSAGE(1), &tr); 68 | if (i < 1) { 69 | fprintf(stderr, "1"); 70 | continue; 71 | } 72 | //return -1; 73 | if (((lepacket[0] & 0xf) == 0x0f)) { 74 | //fprintf( stderr, "." ); 75 | if (!notready) 76 | usleep(25000); // wait for next frame 77 | else 78 | usleep(1000); 79 | notready++; 80 | continue; 81 | } 82 | //if( notready ) fprintf( stderr, "<%d>", notready ); 83 | notready = 0; 84 | //return -2; 85 | row = lepacket[1]; 86 | hiccup++; 87 | if (row >= 60) { 88 | if (hiccup > 8) { 89 | //leptclose(); 90 | usleep(125000); 91 | //leptopen(); 92 | fprintf(stderr, "!\n"); 93 | } 94 | fprintf(stderr, "[%d]", row); 95 | continue; 96 | } 97 | hiccup = 0; 98 | for (i = 0; i < 80; i++) 99 | img[row * 80 + i] 100 | = (lepacket[2 * i + 4] << 8) | lepacket[2 * i + 5]; 101 | //printf ("%d ",img[row*81]); 102 | } while (row != 59); 103 | return 0; 104 | } 105 | -------------------------------------------------------------------------------- /software/flirpi/leptsci.h: -------------------------------------------------------------------------------- 1 | int leptopen(char *dev); 2 | int leptget(unsigned short *); 3 | int leptclose(void); 4 | -------------------------------------------------------------------------------- /software/flirpi/picamoverlay.sh: -------------------------------------------------------------------------------- 1 | raspiyuv -rgb -o x.rgb -w 480 -h 360 -sa -100 -op 128 -t 0 -p 120,72,480,338 2 | -------------------------------------------------------------------------------- /software/raspberrypi_capture/Makefile: -------------------------------------------------------------------------------- 1 | 2 | TARGET = raspberrypi_capture 3 | LIBS = -lm 4 | CC = gcc 5 | CFLAGS = -g -Wall 6 | 7 | .PHONY: default all clean 8 | 9 | default: $(TARGET) 10 | all: default 11 | 12 | OBJECTS = $(patsubst %.c, %.o, $(wildcard *.c)) 13 | HEADERS = $(wildcard *.h) 14 | 15 | %.o: %.c $(HEADERS) 16 | $(CC) $(CFLAGS) -c $< -o $@ 17 | 18 | .PRECIOUS: $(TARGET) $(OBJECTS) 19 | 20 | $(TARGET): $(OBJECTS) 21 | $(CC) $(OBJECTS) -Wall $(LIBS) -o $@ 22 | 23 | clean: 24 | -rm -f *.o 25 | -rm -f $(TARGET) 26 | 27 | -------------------------------------------------------------------------------- /software/raspberrypi_capture/README.md: -------------------------------------------------------------------------------- 1 | Sample program that grabs a frame on the Pi and outputs it as a PGM file 2 | 3 | Defaults to SPI channel 0 - update the "/dev/spidev0.*" value accordingly 4 | 5 | Build with 'make' 6 | 7 | -------------------------------------------------------------------------------- /software/raspberrypi_capture/raspberrypi_capture.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014, Pure Engineering LLC 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright notice, this 9 | list of conditions and the following disclaimer. 10 | 11 | * Redistributions in binary form must reproduce the above copyright notice, 12 | this list of conditions and the following disclaimer in the documentation 13 | and/or other materials provided with the distribution. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 19 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 21 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 22 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 23 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 24 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | 38 | #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) 39 | 40 | static void pabort(const char *s) 41 | { 42 | perror(s); 43 | abort(); 44 | } 45 | 46 | static const char *device = "/dev/spidev0.1"; 47 | static uint8_t mode; 48 | static uint8_t bits = 8; 49 | static uint32_t speed = 16000000; 50 | static uint16_t delay; 51 | 52 | #define VOSPI_FRAME_SIZE (164) 53 | uint8_t lepton_frame_packet[VOSPI_FRAME_SIZE]; 54 | static unsigned int lepton_image[80][80]; 55 | 56 | static void save_pgm_file(void) 57 | { 58 | int i; 59 | int j; 60 | unsigned int maxval = 0; 61 | unsigned int minval = UINT_MAX; 62 | char image_name[32]; 63 | int image_index = 0; 64 | 65 | do { 66 | sprintf(image_name, "IMG_%.4d.pgm", image_index); 67 | image_index += 1; 68 | if (image_index > 9999) 69 | { 70 | image_index = 0; 71 | break; 72 | } 73 | 74 | } while (access(image_name, F_OK) == 0); 75 | 76 | FILE *f = fopen(image_name, "w"); 77 | if (f == NULL) 78 | { 79 | printf("Error opening file!\n"); 80 | exit(1); 81 | } 82 | 83 | printf("Calculating min/max values for proper scaling...\n"); 84 | for(i=0;i<60;i++) 85 | { 86 | for(j=0;j<80;j++) 87 | { 88 | if (lepton_image[i][j] > maxval) { 89 | maxval = lepton_image[i][j]; 90 | } 91 | if (lepton_image[i][j] < minval) { 92 | minval = lepton_image[i][j]; 93 | } 94 | } 95 | } 96 | printf("maxval = %u\n",maxval); 97 | printf("minval = %u\n",minval); 98 | 99 | fprintf(f,"P2\n80 60\n%u\n",maxval-minval); 100 | for(i=0;i<60;i++) 101 | { 102 | for(j=0;j<80;j++) 103 | { 104 | fprintf(f,"%d ", lepton_image[i][j] - minval); 105 | } 106 | fprintf(f,"\n"); 107 | } 108 | fprintf(f,"\n\n"); 109 | 110 | fclose(f); 111 | } 112 | 113 | int transfer(int fd) 114 | { 115 | int ret; 116 | int i; 117 | int frame_number; 118 | uint8_t tx[VOSPI_FRAME_SIZE] = {0, }; 119 | struct spi_ioc_transfer tr = { 120 | .tx_buf = (unsigned long)tx, 121 | .rx_buf = (unsigned long)lepton_frame_packet, 122 | .len = VOSPI_FRAME_SIZE, 123 | .delay_usecs = delay, 124 | .speed_hz = speed, 125 | .bits_per_word = bits, 126 | }; 127 | 128 | ret = ioctl(fd, SPI_IOC_MESSAGE(1), &tr); 129 | if (ret < 1) 130 | pabort("can't send spi message"); 131 | 132 | if(((lepton_frame_packet[0]&0xf) != 0x0f)) 133 | { 134 | frame_number = lepton_frame_packet[1]; 135 | 136 | if(frame_number < 60 ) 137 | { 138 | for(i=0;i<80;i++) 139 | { 140 | lepton_image[frame_number][i] = (lepton_frame_packet[2*i+4] << 8 | lepton_frame_packet[2*i+5]); 141 | } 142 | } 143 | } 144 | return frame_number; 145 | } 146 | 147 | int main(int argc, char *argv[]) 148 | { 149 | int ret = 0; 150 | int fd; 151 | 152 | 153 | fd = open(device, O_RDWR); 154 | if (fd < 0) 155 | { 156 | pabort("can't open device"); 157 | } 158 | 159 | ret = ioctl(fd, SPI_IOC_WR_MODE, &mode); 160 | if (ret == -1) 161 | { 162 | pabort("can't set spi mode"); 163 | } 164 | 165 | ret = ioctl(fd, SPI_IOC_RD_MODE, &mode); 166 | if (ret == -1) 167 | { 168 | pabort("can't get spi mode"); 169 | } 170 | 171 | ret = ioctl(fd, SPI_IOC_WR_BITS_PER_WORD, &bits); 172 | if (ret == -1) 173 | { 174 | pabort("can't set bits per word"); 175 | } 176 | 177 | ret = ioctl(fd, SPI_IOC_RD_BITS_PER_WORD, &bits); 178 | if (ret == -1) 179 | { 180 | pabort("can't get bits per word"); 181 | } 182 | 183 | ret = ioctl(fd, SPI_IOC_WR_MAX_SPEED_HZ, &speed); 184 | if (ret == -1) 185 | { 186 | pabort("can't set max speed hz"); 187 | } 188 | 189 | ret = ioctl(fd, SPI_IOC_RD_MAX_SPEED_HZ, &speed); 190 | if (ret == -1) 191 | { 192 | pabort("can't get max speed hz"); 193 | } 194 | 195 | printf("spi mode: %d\n", mode); 196 | printf("bits per word: %d\n", bits); 197 | printf("max speed: %d Hz (%d KHz)\n", speed, speed/1000); 198 | 199 | while(transfer(fd)!=59){} 200 | 201 | close(fd); 202 | 203 | save_pgm_file(); 204 | 205 | return ret; 206 | } 207 | -------------------------------------------------------------------------------- /software/raspberrypi_libs/leptonSDKEmb32PUB/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | Debug 3 | *.o 4 | 5 | -------------------------------------------------------------------------------- /software/raspberrypi_libs/leptonSDKEmb32PUB/LEPTON_ErrorCodes.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * FILE: LEPTON_ErrorCodes.h 4 | * 5 | * DESCRIPTION: Contains the Lepton SDK Error Codes 6 | * 7 | * AUTHOR: 8 | * 9 | * CREATED: 3/1/2012 10 | * 11 | * HISTORY: 3/1/2012 DWD Initial Draft 12 | * 13 | ** Copyright 2011,2012,2013,2014 FLIR Systems - Commercial 14 | ** Vision Systems. All rights reserved. 15 | ** 16 | ** Proprietary - PROPRIETARY - FLIR Systems Inc.. 17 | ** 18 | ** This document is controlled to FLIR Technology Level 2. 19 | ** The information contained in this document pertains to a 20 | ** dual use product Controlled for export by the Export 21 | ** Administration Regulations (EAR). Diversion contrary to 22 | ** US law is prohibited. US Department of Commerce 23 | ** authorization is not required prior to export or 24 | ** transfer to foreign persons or parties unless otherwise 25 | ** prohibited. 26 | ** 27 | ** Redistribution and use in source and binary forms, with 28 | ** or without modification, are permitted provided that the 29 | ** following conditions are met: 30 | ** 31 | ** Redistributions of source code must retain the above 32 | ** copyright notice, this list of conditions and the 33 | ** following disclaimer. 34 | ** 35 | ** Redistributions in binary form must reproduce the above 36 | ** copyright notice, this list of conditions and the 37 | ** following disclaimer in the documentation and/or other 38 | ** materials provided with the distribution. 39 | ** 40 | ** Neither the name of the FLIR Systems Corporation nor the 41 | ** names of its contributors may be used to endorse or 42 | ** promote products derived from this software without 43 | ** specific prior written permission. 44 | ** 45 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 46 | ** CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 47 | ** WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 48 | ** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 49 | ** PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 50 | ** COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY 51 | ** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 52 | ** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 53 | ** PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 54 | ** USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 55 | ** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 56 | ** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 57 | ** NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 58 | ** USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 59 | ** OF SUCH DAMAGE. 60 | ** 61 | *******************************************************************************/ 62 | #ifndef _LEPTON_ERROR_CODES_H_ 63 | #define _LEPTON_ERROR_CODES_H_ 64 | 65 | #ifdef __cplusplus 66 | extern "C" 67 | { 68 | #endif 69 | 70 | /******************************************************************************/ 71 | /** INCLUDE FILES **/ 72 | /******************************************************************************/ 73 | 74 | /******************************************************************************/ 75 | /** EXPORTED DEFINES **/ 76 | /******************************************************************************/ 77 | 78 | /******************************************************************************/ 79 | /** EXPORTED TYPE DEFINITIONS **/ 80 | /******************************************************************************/ 81 | 82 | /******************************************************************************/ 83 | /* 84 | * Represents the different result codes the camera can return. 85 | */ 86 | typedef enum Result 87 | { 88 | LEP_OK = 0, /* Camera ok */ 89 | LEP_COMM_OK = LEP_OK, /* Camera comm ok (same as LEP_OK) */ 90 | 91 | LEP_ERROR = -1, /* Camera general error */ 92 | LEP_NOT_READY = -2, /* Camera not ready error */ 93 | LEP_RANGE_ERROR = -3, /* Camera range error */ 94 | LEP_CHECKSUM_ERROR = -4, /* Camera checksum error */ 95 | LEP_BAD_ARG_POINTER_ERROR = -5, /* Camera Bad argument error */ 96 | LEP_DATA_SIZE_ERROR = -6, /* Camera byte count error */ 97 | LEP_UNDEFINED_FUNCTION_ERROR = -7, /* Camera undefined function error */ 98 | LEP_FUNCTION_NOT_SUPPORTED = -8, /* Camera function not yet supported error */ 99 | 100 | /* OTP access errors */ 101 | LEP_OTP_WRITE_ERROR = -15, /*!< Camera OTP write error */ 102 | LEP_OTP_READ_ERROR = -16, /* double bit error detected (uncorrectible) */ 103 | 104 | LEP_OTP_NOT_PROGRAMMED_ERROR = -18, /* Flag read as non-zero */ 105 | 106 | /* I2C Errors */ 107 | LEP_ERROR_I2C_BUS_NOT_READY = -20, /* I2C Bus Error - Bus Not Avaialble */ 108 | LEP_ERROR_I2C_BUFFER_OVERFLOW = -22, /* I2C Bus Error - Buffer Overflow */ 109 | LEP_ERROR_I2C_ARBITRATION_LOST = -23, /* I2C Bus Error - Bus Arbitration Lost */ 110 | LEP_ERROR_I2C_BUS_ERROR = -24, /* I2C Bus Error - General Bus Error */ 111 | LEP_ERROR_I2C_NACK_RECEIVED = -25, /* I2C Bus Error - NACK Received */ 112 | LEP_ERROR_I2C_FAIL = -26, /* I2C Bus Error - General Failure */ 113 | 114 | /* Processing Errors */ 115 | LEP_DIV_ZERO_ERROR = -80, /* Attempted div by zero */ 116 | 117 | /* Comm Errors */ 118 | LEP_COMM_PORT_NOT_OPEN = -101, /* Comm port not open */ 119 | LEP_COMM_INVALID_PORT_ERROR = -102, /* Comm port no such port error */ 120 | LEP_COMM_RANGE_ERROR = -103, /* Comm port range error */ 121 | LEP_ERROR_CREATING_COMM = -104, /* Error creating comm */ 122 | LEP_ERROR_STARTING_COMM = -105, /* Error starting comm */ 123 | LEP_ERROR_CLOSING_COMM = -106, /* Error closing comm */ 124 | LEP_COMM_CHECKSUM_ERROR = -107, /* Comm checksum error */ 125 | LEP_COMM_NO_DEV = -108, /* No comm device */ 126 | LEP_TIMEOUT_ERROR = -109, /* Comm timeout error */ 127 | LEP_COMM_ERROR_WRITING_COMM = -110, /* Error writing comm */ 128 | LEP_COMM_ERROR_READING_COMM = -111, /* Error reading comm */ 129 | LEP_COMM_COUNT_ERROR = -112, /* Comm byte count error */ 130 | 131 | /* Other Errors */ 132 | LEP_OPERATION_CANCELED = -126, /* Camera operation canceled */ 133 | LEP_UNDEFINED_ERROR_CODE = -127 /* Undefined error */ 134 | 135 | } LEP_RESULT; 136 | 137 | /** EXPORTED PUBLIC DATA **/ 138 | /******************************************************************************/ 139 | 140 | /******************************************************************************/ 141 | /** EXPORTED PUBLIC FUNCTIONS **/ 142 | /******************************************************************************/ 143 | 144 | 145 | #ifdef __cplusplus 146 | } 147 | #endif 148 | 149 | #endif /* _LEPTON_ERROR_CODES_H_ */ 150 | -------------------------------------------------------------------------------- /software/raspberrypi_libs/leptonSDKEmb32PUB/LEPTON_I2C_Service.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * 3 | * FILE: LEPTON_I2C_Service.h 4 | * 5 | * DESCRIPTION: Lepton I2C Device Driver Service Layer Interface 6 | * 7 | * AUTHOR: 8 | * 9 | * CREATED: 4/10/2012 10 | * 11 | * HISTORY: 4/10/2012 DWD Initial Draft 12 | * 13 | ** Copyright 2011,2012,2013,2014 FLIR Systems - Commercial 14 | ** Vision Systems. All rights reserved. 15 | ** 16 | ** Proprietary - PROPRIETARY - FLIR Systems Inc.. 17 | ** 18 | ** This document is controlled to FLIR Technology Level 2. 19 | ** The information contained in this document pertains to a 20 | ** dual use product Controlled for export by the Export 21 | ** Administration Regulations (EAR). Diversion contrary to 22 | ** US law is prohibited. US Department of Commerce 23 | ** authorization is not required prior to export or 24 | ** transfer to foreign persons or parties unless otherwise 25 | ** prohibited. 26 | ** 27 | ** Redistribution and use in source and binary forms, with 28 | ** or without modification, are permitted provided that the 29 | ** following conditions are met: 30 | ** 31 | ** Redistributions of source code must retain the above 32 | ** copyright notice, this list of conditions and the 33 | ** following disclaimer. 34 | ** 35 | ** Redistributions in binary form must reproduce the above 36 | ** copyright notice, this list of conditions and the 37 | ** following disclaimer in the documentation and/or other 38 | ** materials provided with the distribution. 39 | ** 40 | ** Neither the name of the FLIR Systems Corporation nor the 41 | ** names of its contributors may be used to endorse or 42 | ** promote products derived from this software without 43 | ** specific prior written permission. 44 | ** 45 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 46 | ** CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 47 | ** WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 48 | ** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 49 | ** PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 50 | ** COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY 51 | ** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 52 | ** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 53 | ** PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 54 | ** USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 55 | ** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 56 | ** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 57 | ** NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 58 | ** USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 59 | ** OF SUCH DAMAGE. 60 | ** 61 | *******************************************************************************/ 62 | #ifndef _LEPTON_I2C_SERVICE_H_ 63 | #define _LEPTON_I2C_SERVICE_H_ 64 | 65 | #ifdef __cplusplus 66 | extern "C" 67 | { 68 | #endif 69 | 70 | /******************************************************************************/ 71 | /** INCLUDE FILES **/ 72 | /******************************************************************************/ 73 | #include "LEPTON_Types.h" 74 | #include "LEPTON_ErrorCodes.h" 75 | 76 | 77 | /******************************************************************************/ 78 | /** EXPORTED DEFINES **/ 79 | /******************************************************************************/ 80 | 81 | /******************************************************************************/ 82 | /** EXPORTED TYPE DEFINITIONS **/ 83 | /******************************************************************************/ 84 | 85 | /******************************************************************************/ 86 | /** EXPORTED PUBLIC DATA **/ 87 | /******************************************************************************/ 88 | 89 | /******************************************************************************/ 90 | /** EXPORTED PUBLIC FUNCTIONS **/ 91 | /******************************************************************************/ 92 | 93 | extern LEP_RESULT LEP_I2C_MasterOpen(LEP_UINT16 portID, 94 | LEP_UINT16 *portBaudRate); 95 | 96 | extern LEP_RESULT LEP_I2C_MasterClose(LEP_CAMERA_PORT_DESC_T_PTR portDescPtr ); 97 | 98 | extern LEP_RESULT LEP_I2C_MasterReset(LEP_CAMERA_PORT_DESC_T_PTR portDescPtr ); 99 | 100 | extern LEP_RESULT LEP_I2C_MasterReadData(LEP_UINT16 portID, 101 | LEP_UINT8 deviceAddress, 102 | LEP_UINT16 subAddress, 103 | LEP_UINT16 *dataPtr, 104 | LEP_UINT16 dataLength); 105 | 106 | extern LEP_RESULT LEP_I2C_MasterWriteData(LEP_UINT16 portID, 107 | LEP_UINT8 deviceAddress, 108 | LEP_UINT16 subAddress, 109 | LEP_UINT16 *dataPtr, 110 | LEP_UINT16 dataLength); 111 | 112 | extern LEP_RESULT LEP_I2C_MasterReadRegister(LEP_UINT16 portID, 113 | LEP_UINT8 deviceAddress, 114 | LEP_UINT16 regAddress, 115 | LEP_UINT16 *regValue); 116 | 117 | 118 | extern LEP_RESULT LEP_I2C_MasterWriteRegister(LEP_UINT16 portID, 119 | LEP_UINT8 deviceAddress, 120 | LEP_UINT16 regAddress, 121 | LEP_UINT16 regValue); 122 | 123 | extern LEP_RESULT LEP_I2C_MasterStatus(LEP_UINT16 portID, 124 | LEP_UINT16 *portStatus ); 125 | 126 | /******************************************************************************/ 127 | #ifdef __cplusplus 128 | } 129 | #endif 130 | 131 | #endif /* _LEPTON_I2C_SERVICE_H_ */ 132 | -------------------------------------------------------------------------------- /software/raspberrypi_libs/leptonSDKEmb32PUB/LEPTON_Macros.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | ** 3 | ** File NAME: LEPTON_Macros.h 4 | ** 5 | ** AUTHOR: David Dart 6 | ** 7 | ** CREATED: 7/11/2012 8 | ** 9 | ** DESCRIPTION: 10 | ** 11 | ** HISTORY: 7/11/2012 DWD - Initial Draft 12 | ** 13 | ** Copyright 2011,2012,2013,2014 FLIR Systems - Commercial 14 | ** Vision Systems. All rights reserved. 15 | ** 16 | ** Proprietary - PROPRIETARY - FLIR Systems Inc.. 17 | ** 18 | ** This document is controlled to FLIR Technology Level 2. 19 | ** The information contained in this document pertains to a 20 | ** dual use product Controlled for export by the Export 21 | ** Administration Regulations (EAR). Diversion contrary to 22 | ** US law is prohibited. US Department of Commerce 23 | ** authorization is not required prior to export or 24 | ** transfer to foreign persons or parties unless otherwise 25 | ** prohibited. 26 | ** 27 | ** Redistribution and use in source and binary forms, with 28 | ** or without modification, are permitted provided that the 29 | ** following conditions are met: 30 | ** 31 | ** Redistributions of source code must retain the above 32 | ** copyright notice, this list of conditions and the 33 | ** following disclaimer. 34 | ** 35 | ** Redistributions in binary form must reproduce the above 36 | ** copyright notice, this list of conditions and the 37 | ** following disclaimer in the documentation and/or other 38 | ** materials provided with the distribution. 39 | ** 40 | ** Neither the name of the FLIR Systems Corporation nor the 41 | ** names of its contributors may be used to endorse or 42 | ** promote products derived from this software without 43 | ** specific prior written permission. 44 | ** 45 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 46 | ** CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 47 | ** WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 48 | ** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 49 | ** PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 50 | ** COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY 51 | ** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 52 | ** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 53 | ** PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 54 | ** USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 55 | ** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 56 | ** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 57 | ** NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 58 | ** USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 59 | ** OF SUCH DAMAGE. 60 | ** 61 | *******************************************************************************/ 62 | #ifndef _LEP_MACROS_H_ 63 | #define _LEP_MACROS_H_ 64 | 65 | #ifdef __cplusplus 66 | extern "C" 67 | { 68 | #endif 69 | 70 | /******************************************************************************/ 71 | /** INCLUDE FILES **/ 72 | /******************************************************************************/ 73 | 74 | /******************************************************************************/ 75 | /** EXPORTED DEFINES **/ 76 | /******************************************************************************/ 77 | 78 | /****************************************************************** 79 | *** USEFUL MACROS *** 80 | ******************************************************************/ 81 | 82 | #ifndef MIN 83 | #define MIN(a, b) ((a) < (b)? (a): (b)) 84 | #endif 85 | #ifndef MAX 86 | #define MAX(a, b) ((a) > (b)? (a): (b)) 87 | #endif 88 | 89 | #ifndef LOW_WORD 90 | #define LOW_WORD(longVariable) ((LEP_UINT16)longVariable) 91 | #endif 92 | #ifndef HIGH_WORD 93 | #define HIGH_WORD(longVariable) ((LEP_UINT16)(longVariable>>16)) 94 | #endif 95 | #ifndef LOW_BYTE 96 | #define LOW_BYTE(w) ((LEP_UINT8)(w)) 97 | #endif 98 | #ifndef HIGH_BYTE 99 | #define HIGH_BYTE(w) ((LEP_UINT8)(((w) >> 8) & 0xFF)) 100 | #endif 101 | 102 | #ifndef LOW_NIBBLE 103 | #define LOW_NIBBLE(w) ((LEP_UINT8)(w) & 0x0F) 104 | #endif 105 | #ifndef HIGH_NIBBLE 106 | #define HIGH_NIBBLE(w) ((LEP_UINT8)(((w) >> 4) & 0x0F)) 107 | #endif 108 | 109 | #define CLR_BIT(_port,_bit) ((_port) & ~(_bit)) 110 | 111 | 112 | #define REVERSE_ENDIENESS_UINT16(uint16Var) \ 113 | ( ( ((LEP_UINT16)LOW_BYTE(uint16Var))<<8) + (LEP_UINT16)HIGH_BYTE(uint16Var)) 114 | 115 | #define REVERSE_ENDIENESS_UINT32(uint32Var) \ 116 | ( ((LEP_UINT32)REVERSE_ENDIENESS_UINT16(LOW_WORD(uint32Var)) << 16) + \ 117 | (LEP_UINT32)REVERSE_ENDIENESS_UINT16(HIGH_WORD(uint32Var) ) ) 118 | 119 | #define REVERSE_NIBBLE_UINT8(uint8Var) \ 120 | ( ( ((LEP_UINT8)LOW_NIBBLE(uint8Var))<<4) + (LEP_UINT8)HIGH_NIBBLE(uint8Var)) 121 | 122 | #define REVERSE_BYTEORDER_UINT32(uint32Var) \ 123 | ( (((LEP_UINT32)LOW_BYTE(uint32Var))<<24) + (((LEP_UINT32)HIGH_BYTE(uint32Var))<<16) + \ 124 | (((LEP_UINT32)LOW_BYTE(HIGH_WORD(uint32Var)))<<8) + (LEP_UINT32)HIGH_BYTE(HIGH_WORD(uint32Var)) ) 125 | 126 | #define WORD_SWAP_16(uint32Var) \ 127 | ( ((LEP_UINT16)LOW_WORD(uint32Var) << 16) + ((LEP_UINT16)HIGH_WORD(uint32Var)) ) 128 | 129 | 130 | #ifndef NUM_ELEMENTS_IN_ARRAY 131 | #define NUM_ELEMENTS_IN_ARRAY(array) (sizeof (array) / sizeof ((array) [0])) 132 | #endif /* NUM_ELEMENTS_IN_ARRAY */ 133 | 134 | #ifndef NELEMENTS 135 | #define NELEMENTS(array) /* number of elements in an array */ \ 136 | (sizeof (array) / sizeof ((array) [0])) 137 | #endif /* NELEMENTS */ 138 | 139 | 140 | /******************************************************************************/ 141 | /** EXPORTED TYPE DEFINITIONS **/ 142 | /******************************************************************************/ 143 | 144 | /******************************************************************************/ 145 | /** EXPORTED PUBLIC DATA **/ 146 | /******************************************************************************/ 147 | 148 | /******************************************************************************/ 149 | /** EXPORTED PUBLIC FUNCTIONS **/ 150 | /******************************************************************************/ 151 | 152 | 153 | /******************************************************************************/ 154 | #ifdef __cplusplus 155 | } 156 | #endif 157 | 158 | #endif /* _LEP_MACROS_H_ */ 159 | 160 | -------------------------------------------------------------------------------- /software/raspberrypi_libs/leptonSDKEmb32PUB/LEPTON_SDKConfig.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | ** 3 | ** File NAME: _LEPTON_SDKCONFIG_H_.h 4 | ** 5 | ** AUTHOR: hthomson 6 | ** 7 | ** CREATED: 3/28/2014 8 | ** 9 | ** DESCRIPTION: typedefs for coding style/conventions 10 | ** 11 | ** HISTORY: 3/28/2014 HT - Initial Draft 12 | ** 13 | ** Copyright 2011,2012,2013,2014 FLIR Systems - Commercial 14 | ** Vision Systems. All rights reserved. 15 | ** 16 | ** Proprietary - PROPRIETARY - FLIR Systems Inc.. 17 | ** 18 | ** This document is controlled to FLIR Technology Level 2. 19 | ** The information contained in this document pertains to a 20 | ** dual use product Controlled for export by the Export 21 | ** Administration Regulations (EAR). Diversion contrary to 22 | ** US law is prohibited. US Department of Commerce 23 | ** authorization is not required prior to export or 24 | ** transfer to foreign persons or parties unless otherwise 25 | ** prohibited. 26 | ** 27 | ** Redistribution and use in source and binary forms, with 28 | ** or without modification, are permitted provided that the 29 | ** following conditions are met: 30 | ** 31 | ** Redistributions of source code must retain the above 32 | ** copyright notice, this list of conditions and the 33 | ** following disclaimer. 34 | ** 35 | ** Redistributions in binary form must reproduce the above 36 | ** copyright notice, this list of conditions and the 37 | ** following disclaimer in the documentation and/or other 38 | ** materials provided with the distribution. 39 | ** 40 | ** Neither the name of the FLIR Systems Corporation nor the 41 | ** names of its contributors may be used to endorse or 42 | ** promote products derived from this software without 43 | ** specific prior written permission. 44 | ** 45 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 46 | ** CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 47 | ** WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 48 | ** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 49 | ** PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 50 | ** COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY 51 | ** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 52 | ** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 53 | ** PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 54 | ** USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 55 | ** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 56 | ** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 57 | ** NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 58 | ** USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 59 | ** OF SUCH DAMAGE. 60 | ** 61 | *******************************************************************************/ 62 | #ifndef _LEPTON_SDKCONFIG_H_ 63 | #define _LEPTON_SDKCONFIG_H_ 64 | 65 | #ifdef __cplusplus 66 | extern "C" 67 | { 68 | #endif 69 | 70 | /******************************************************************************/ 71 | /** INCLUDE FILES **/ 72 | /******************************************************************************/ 73 | 74 | 75 | /******************************************************************************/ 76 | /** EXPORTED DEFINES **/ 77 | /******************************************************************************/ 78 | 79 | #define USE_DEPRECATED_SERIAL_NUMBER_INTERFACE 0 80 | #define USE_DEPRECATED_PART_NUMBER_INTERFACE 0 81 | #define USE_DEPRECATED_ASICID_INTERFACE 0 82 | #define USE_DEPRECATED_HOUSING_TCP_INTERFACE 0 83 | 84 | /******************************************************************************/ 85 | /** EXPORTED TYPE DEFINITIONS **/ 86 | /******************************************************************************/ 87 | 88 | 89 | /******************************************************************************/ 90 | /** EXPORTED PUBLIC DATA **/ 91 | /******************************************************************************/ 92 | 93 | /******************************************************************************/ 94 | /** EXPORTED PUBLIC FUNCTIONS **/ 95 | /******************************************************************************/ 96 | 97 | 98 | /******************************************************************************/ 99 | #ifdef __cplusplus 100 | } 101 | #endif 102 | #endif // _LEPTON_SDKCONFIG_H_ 103 | 104 | 105 | -------------------------------------------------------------------------------- /software/raspberrypi_libs/leptonSDKEmb32PUB/Makefile: -------------------------------------------------------------------------------- 1 | # SlickEdit generated file. Do not edit this file except in designated areas. 2 | 3 | # Make command to use for dependencies 4 | MAKE=make 5 | RM=rm 6 | MKDIR=mkdir 7 | CP=cp 8 | 9 | # -----Begin user-editable area----- 10 | 11 | # -----End user-editable area----- 12 | 13 | # If no configuration is specified, "Debug" will be used 14 | ifndef CFG 15 | CFG=Debug 16 | endif 17 | 18 | # 19 | # Configuration: Debug 20 | # 21 | ifeq "$(CFG)" "Debug" 22 | OUTDIR=Debug 23 | OUTFILE=$(OUTDIR)/libLEPTON_SDK.a 24 | CFG_INC=-I/cygdrive/c/WinAVR-20090313/avr/include 25 | CFG_LIB= 26 | CFG_OBJ= 27 | COMMON_OBJ=$(OUTDIR)/raspi_I2C.o $(OUTDIR)/crc16fast.o \ 28 | $(OUTDIR)/LEPTON_AGC.o $(OUTDIR)/LEPTON_VID.o \ 29 | $(OUTDIR)/LEPTON_I2C_Protocol.o $(OUTDIR)/LEPTON_I2C_Service.o \ 30 | $(OUTDIR)/LEPTON_SDK.o $(OUTDIR)/LEPTON_SYS.o $(OUTDIR)/LEPTON_OEM.o 31 | OBJ=$(COMMON_OBJ) $(CFG_OBJ) 32 | ALL_OBJ=$(OUTDIR)/raspi_I2C.o $(OUTDIR)/crc16fast.o \ 33 | $(OUTDIR)/LEPTON_AGC.o $(OUTDIR)/LEPTON_VID.o \ 34 | $(OUTDIR)/LEPTON_I2C_Protocol.o $(OUTDIR)/LEPTON_I2C_Service.o \ 35 | $(OUTDIR)/LEPTON_SDK.o $(OUTDIR)/LEPTON_SYS.o $(OUTDIR)/LEPTON_OEM.o 36 | 37 | COMPILE=gcc -fpermissive -Dlinux=1 -c -v -g -o "$(OUTDIR)/$(*F).o" $(CFG_INC) "$<" 38 | LINK=ar -rs "$(OUTFILE)" $(OBJ) 39 | 40 | # Pattern rules 41 | $(OUTDIR)/%.o : %.c 42 | $(COMPILE) 43 | 44 | # Build rules 45 | all: $(OUTFILE) 46 | 47 | $(OUTFILE): $(OUTDIR) $(OBJ) 48 | $(LINK) 49 | 50 | $(OUTDIR): 51 | $(MKDIR) -p "$(OUTDIR)" 52 | 53 | # Rebuild this project 54 | rebuild: cleanall all 55 | 56 | # Clean this project 57 | clean: 58 | $(RM) -f $(OUTFILE) 59 | $(RM) -f $(OBJ) 60 | 61 | # Clean this project and all dependencies 62 | cleanall: clean 63 | endif 64 | 65 | # 66 | # Configuration: Release 67 | # 68 | ifeq "$(CFG)" "Release" 69 | OUTDIR=Release 70 | OUTFILE=$(OUTDIR)/libLEPTON_SDK.a 71 | CFG_INC=-I/cygdrive/c/WinAVR-20090313/avr/include 72 | CFG_LIB= 73 | CFG_OBJ= 74 | COMMON_OBJ=$(OUTDIR)/raspi_I2C.o $(OUTDIR)/crc16fast.o \ 75 | $(OUTDIR)/LEPTON_AGC.o $(OUTDIR)/LEPTON_VID.o \ 76 | $(OUTDIR)/LEPTON_I2C_Protocol.o $(OUTDIR)/LEPTON_I2C_Service.o \ 77 | $(OUTDIR)/LEPTON_SDK.o $(OUTDIR)/LEPTON_SYS.o $(OUTDIR)/LEPTON_OEM.o 78 | OBJ=$(COMMON_OBJ) $(CFG_OBJ) 79 | ALL_OBJ=$(OUTDIR)/raspi_I2C.o $(OUTDIR)/crc16fast.o \ 80 | $(OUTDIR)/LEPTON_AGC.o $(OUTDIR)/LEPTON_VID.o \ 81 | $(OUTDIR)/LEPTON_I2C_Protocol.o $(OUTDIR)/LEPTON_I2C_Service.o \ 82 | $(OUTDIR)/LEPTON_SDK.o $(OUTDIR)/LEPTON_SYS.o $(OUTDIR)/LEPTON_OEM.o 83 | 84 | COMPILE=g++ -fpermissive -mno-cygwin -c -v -o "$(OUTDIR)/$(*F).o" $(CFG_INC) "$<" 85 | LINK=ar -rs "$(OUTFILE)" $(OBJ) 86 | 87 | # Pattern rules 88 | $(OUTDIR)/%.o : %.c 89 | $(COMPILE) 90 | 91 | # Build rules 92 | all: $(OUTFILE) 93 | 94 | $(OUTFILE): $(OUTDIR) $(OBJ) 95 | $(LINK) 96 | 97 | $(OUTDIR): 98 | $(MKDIR) -p "$(OUTDIR)" 99 | 100 | 101 | # Rebuild this project 102 | rebuild: cleanall all 103 | 104 | # Clean this project 105 | clean: 106 | $(RM) -f $(OUTFILE) 107 | $(RM) -f $(OBJ) 108 | 109 | # Clean this project and all dependencies 110 | cleanall: clean 111 | endif 112 | -------------------------------------------------------------------------------- /software/raspberrypi_libs/leptonSDKEmb32PUB/crc16.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | 3 | Filename: crc16.h 4 | Description: Cyclic Redundancy Check 16 functions 5 | Created: 24-Feb-1999 6 | 7 | ** Copyright 2011,2012,2013,2014 FLIR Systems - Commercial 8 | ** Vision Systems. All rights reserved. 9 | ** 10 | ** Proprietary - PROPRIETARY - FLIR Systems Inc.. 11 | ** 12 | ** This document is controlled to FLIR Technology Level 2. 13 | ** The information contained in this document pertains to a 14 | ** dual use product Controlled for export by the Export 15 | ** Administration Regulations (EAR). Diversion contrary to 16 | ** US law is prohibited. US Department of Commerce 17 | ** authorization is not required prior to export or 18 | ** transfer to foreign persons or parties unless otherwise 19 | ** prohibited. 20 | ** 21 | ** Redistribution and use in source and binary forms, with 22 | ** or without modification, are permitted provided that the 23 | ** following conditions are met: 24 | ** 25 | ** Redistributions of source code must retain the above 26 | ** copyright notice, this list of conditions and the 27 | ** following disclaimer. 28 | ** 29 | ** Redistributions in binary form must reproduce the above 30 | ** copyright notice, this list of conditions and the 31 | ** following disclaimer in the documentation and/or other 32 | ** materials provided with the distribution. 33 | ** 34 | ** Neither the name of the FLIR Systems Corporation nor the 35 | ** names of its contributors may be used to endorse or 36 | ** promote products derived from this software without 37 | ** specific prior written permission. 38 | ** 39 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 40 | ** CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 41 | ** WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 42 | ** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 43 | ** PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 44 | ** COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY 45 | ** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 46 | ** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 47 | ** PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 48 | ** USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 49 | ** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 50 | ** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 51 | ** NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 52 | ** USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 53 | ** OF SUCH DAMAGE. 54 | 55 | ****************************************************************************/ 56 | 57 | #ifndef __CRC16_H__ 58 | #define __CRC16_H__ 59 | 60 | #ifdef __cplusplus 61 | extern "C" 62 | { 63 | #endif 64 | 65 | typedef unsigned short CRC16; 66 | 67 | int ByteCRC16(int value, int crcin); 68 | CRC16 CalcCRC16Words(unsigned int count, short *buffer); 69 | CRC16 CalcCRC16Bytes(unsigned int count, char *buffer); 70 | 71 | #ifdef __cplusplus 72 | } 73 | #endif 74 | 75 | #endif /* __CRC16_H__ */ 76 | -------------------------------------------------------------------------------- /software/raspberrypi_libs/leptonSDKEmb32PUB/crc16fast.c: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | 3 | Filename: crc16fast.c 4 | Description: Cyclic Redundancy Check 16 functions 5 | Created: 24-Feb-1999 6 | 7 | ** Copyright 2011,2012,2013,2014 FLIR Systems - Commercial 8 | ** Vision Systems. All rights reserved. 9 | ** 10 | ** Proprietary - PROPRIETARY - FLIR Systems Inc.. 11 | ** 12 | ** This document is controlled to FLIR Technology Level 2. 13 | ** The information contained in this document pertains to a 14 | ** dual use product Controlled for export by the Export 15 | ** Administration Regulations (EAR). Diversion contrary to 16 | ** US law is prohibited. US Department of Commerce 17 | ** authorization is not required prior to export or 18 | ** transfer to foreign persons or parties unless otherwise 19 | ** prohibited. 20 | ** 21 | ** Redistribution and use in source and binary forms, with 22 | ** or without modification, are permitted provided that the 23 | ** following conditions are met: 24 | ** 25 | ** Redistributions of source code must retain the above 26 | ** copyright notice, this list of conditions and the 27 | ** following disclaimer. 28 | ** 29 | ** Redistributions in binary form must reproduce the above 30 | ** copyright notice, this list of conditions and the 31 | ** following disclaimer in the documentation and/or other 32 | ** materials provided with the distribution. 33 | ** 34 | ** Neither the name of the FLIR Systems Corporation nor the 35 | ** names of its contributors may be used to endorse or 36 | ** promote products derived from this software without 37 | ** specific prior written permission. 38 | ** 39 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 40 | ** CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 41 | ** WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 42 | ** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 43 | ** PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 44 | ** COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY 45 | ** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 46 | ** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 47 | ** PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 48 | ** USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 49 | ** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 50 | ** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 51 | ** NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 52 | ** USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 53 | ** OF SUCH DAMAGE. 54 | ** 55 | ****************************************************************************/ 56 | 57 | #include "crc16.h" 58 | 59 | const CRC16 ccitt_16Table[] = { 60 | 0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50A5, 0x60C6, 0x70E7, 61 | 0x8108, 0x9129, 0xA14A, 0xB16B, 0xC18C, 0xD1AD, 0xE1CE, 0xF1EF, 62 | 0x1231, 0x0210, 0x3273, 0x2252, 0x52B5, 0x4294, 0x72F7, 0x62D6, 63 | 0x9339, 0x8318, 0xB37B, 0xA35A, 0xD3BD, 0xC39C, 0xF3FF, 0xE3DE, 64 | 0x2462, 0x3443, 0x0420, 0x1401, 0x64E6, 0x74C7, 0x44A4, 0x5485, 65 | 0xA56A, 0xB54B, 0x8528, 0x9509, 0xE5EE, 0xF5CF, 0xC5AC, 0xD58D, 66 | 0x3653, 0x2672, 0x1611, 0x0630, 0x76D7, 0x66F6, 0x5695, 0x46B4, 67 | 0xB75B, 0xA77A, 0x9719, 0x8738, 0xF7DF, 0xE7FE, 0xD79D, 0xC7BC, 68 | 0x48C4, 0x58E5, 0x6886, 0x78A7, 0x0840, 0x1861, 0x2802, 0x3823, 69 | 0xC9CC, 0xD9ED, 0xE98E, 0xF9AF, 0x8948, 0x9969, 0xA90A, 0xB92B, 70 | 0x5AF5, 0x4AD4, 0x7AB7, 0x6A96, 0x1A71, 0x0A50, 0x3A33, 0x2A12, 71 | 0xDBFD, 0xCBDC, 0xFBBF, 0xEB9E, 0x9B79, 0x8B58, 0xBB3B, 0xAB1A, 72 | 0x6CA6, 0x7C87, 0x4CE4, 0x5CC5, 0x2C22, 0x3C03, 0x0C60, 0x1C41, 73 | 0xEDAE, 0xFD8F, 0xCDEC, 0xDDCD, 0xAD2A, 0xBD0B, 0x8D68, 0x9D49, 74 | 0x7E97, 0x6EB6, 0x5ED5, 0x4EF4, 0x3E13, 0x2E32, 0x1E51, 0x0E70, 75 | 0xFF9F, 0xEFBE, 0xDFDD, 0xCFFC, 0xBF1B, 0xAF3A, 0x9F59, 0x8F78, 76 | 0x9188, 0x81A9, 0xB1CA, 0xA1EB, 0xD10C, 0xC12D, 0xF14E, 0xE16F, 77 | 0x1080, 0x00A1, 0x30C2, 0x20E3, 0x5004, 0x4025, 0x7046, 0x6067, 78 | 0x83B9, 0x9398, 0xA3FB, 0xB3DA, 0xC33D, 0xD31C, 0xE37F, 0xF35E, 79 | 0x02B1, 0x1290, 0x22F3, 0x32D2, 0x4235, 0x5214, 0x6277, 0x7256, 80 | 0xB5EA, 0xA5CB, 0x95A8, 0x8589, 0xF56E, 0xE54F, 0xD52C, 0xC50D, 81 | 0x34E2, 0x24C3, 0x14A0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405, 82 | 0xA7DB, 0xB7FA, 0x8799, 0x97B8, 0xE75F, 0xF77E, 0xC71D, 0xD73C, 83 | 0x26D3, 0x36F2, 0x0691, 0x16B0, 0x6657, 0x7676, 0x4615, 0x5634, 84 | 0xD94C, 0xC96D, 0xF90E, 0xE92F, 0x99C8, 0x89E9, 0xB98A, 0xA9AB, 85 | 0x5844, 0x4865, 0x7806, 0x6827, 0x18C0, 0x08E1, 0x3882, 0x28A3, 86 | 0xCB7D, 0xDB5C, 0xEB3F, 0xFB1E, 0x8BF9, 0x9BD8, 0xABBB, 0xBB9A, 87 | 0x4A75, 0x5A54, 0x6A37, 0x7A16, 0x0AF1, 0x1AD0, 0x2AB3, 0x3A92, 88 | 0xFD2E, 0xED0F, 0xDD6C, 0xCD4D, 0xBDAA, 0xAD8B, 0x9DE8, 0x8DC9, 89 | 0x7C26, 0x6C07, 0x5C64, 0x4C45, 0x3CA2, 0x2C83, 0x1CE0, 0x0CC1, 90 | 0xEF1F, 0xFF3E, 0xCF5D, 0xDF7C, 0xAF9B, 0xBFBA, 0x8FD9, 0x9FF8, 91 | 0x6E17, 0x7E36, 0x4E55, 0x5E74, 0x2E93, 0x3EB2, 0x0ED1, 0x1EF0 92 | }; 93 | 94 | /* 95 | * ===== ByteCRC16 ===== 96 | * Calculate (update) the CRC16 for a single 8-bit byte 97 | */ 98 | int ByteCRC16(int value, int crcin) 99 | { 100 | return (unsigned short)((crcin << 8) ^ ccitt_16Table[((crcin >> 8) ^ (value)) & 255]); 101 | } 102 | 103 | /* 104 | * ===== CalcCRC16Words ===== 105 | * Calculate the CRC for a buffer of 16-bit words. Supports both 106 | * Little and Big Endian formats using conditional compilation. 107 | * Note: minimum count is 1 (0 case not handled) 108 | */ 109 | CRC16 CalcCRC16Words(unsigned int count, short *buffer) { 110 | 111 | int crc = 0; 112 | 113 | do { 114 | 115 | int value = *buffer++; 116 | #ifdef _BIG_ENDIAN 117 | crc = ByteCRC16(value >> 8, crc); 118 | crc = ByteCRC16(value, crc); 119 | #else 120 | crc = ByteCRC16(value, crc); 121 | crc = ByteCRC16(value >> 8, crc); 122 | #endif 123 | } 124 | while (--count); 125 | return (CRC16) crc; 126 | } 127 | 128 | /* 129 | * ===== CalcCRC16Bytes ===== 130 | * Calculate the CRC for a buffer of 8-bit words. 131 | * Note: minimum count is 1 (0 case not handled) 132 | */ 133 | CRC16 CalcCRC16Bytes(unsigned int count, char *buffer) { 134 | 135 | int crc = 0; 136 | 137 | do { 138 | 139 | int value = *buffer++; 140 | crc = ByteCRC16(value, crc); 141 | } 142 | while (--count); 143 | return crc; 144 | } 145 | -------------------------------------------------------------------------------- /software/raspberrypi_libs/leptonSDKEmb32PUB/raspi_I2C.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | ** 3 | ** File NAME: raspi_I2C.h 4 | ** 5 | ** AUTHOR: Joseph Colicchio 6 | ** 7 | ** CREATED: 9/25/2012 8 | ** 9 | ** DESCRIPTION: 10 | ** 11 | ** HISTORY: 9/25/2012 HT - Initial Draft 12 | ** 13 | ** Copyright 2011,2012,2013,2014,2015 FLIR Systems - Commercial Vision Systems 14 | ** All rights reserved. 15 | ** 16 | ** Proprietary - Company Only. 17 | ** 18 | ** This document is controlled to FLIR Technology Level 2. 19 | ** The information contained in this document pertains to a dual use product 20 | ** Controlled for export by the Export Administration Regulations (EAR). 21 | ** FLIR trade secrets contained herein are subject to disclosure restrictions 22 | ** as a matter of law. Diversion contrary to US law is prohibited. 23 | ** US Department of Commerce authorization is required prior to export or 24 | ** transfer to foreign persons or parties and for uses otherwise prohibited. 25 | ** 26 | *******************************************************************************/ 27 | #ifndef _RASPI_I2C_H_ 28 | #define _RASPI_I2C_H_ 29 | 30 | #ifdef __cplusplus 31 | extern "C" 32 | { 33 | #endif 34 | /******************************************************************************/ 35 | /** INCLUDE FILES **/ 36 | /******************************************************************************/ 37 | #include "LEPTON_Types.h" 38 | #include "LEPTON_ErrorCodes.h" 39 | 40 | /******************************************************************************/ 41 | /** EXPORTED DEFINES **/ 42 | /******************************************************************************/ 43 | 44 | /******************************************************************************/ 45 | /** EXPORTED TYPE DEFINITIONS **/ 46 | /******************************************************************************/ 47 | 48 | /******************************************************************************/ 49 | /** EXPORTED PUBLIC DATA **/ 50 | /******************************************************************************/ 51 | 52 | /******************************************************************************/ 53 | /** EXPORTED PUBLIC FUNCTIONS **/ 54 | /******************************************************************************/ 55 | 56 | extern LEP_RESULT DEV_I2C_MasterInit(LEP_UINT16 portID, 57 | LEP_UINT16 *BaudRate); 58 | 59 | extern LEP_RESULT DEV_I2C_MasterClose(); 60 | 61 | extern LEP_RESULT DEV_I2C_MasterReset(void ); 62 | 63 | extern LEP_RESULT DEV_I2C_MasterReadData(LEP_UINT16 portID, 64 | LEP_UINT8 deviceAddress, 65 | LEP_UINT16 regAddress, // Lepton Register Address 66 | LEP_UINT16 *readDataPtr, 67 | LEP_UINT16 wordsToRead, // Number of 16-bit words to Read 68 | LEP_UINT16 *numWordsRead, // Number of 16-bit words actually Read 69 | LEP_UINT16 *status 70 | ); 71 | 72 | extern LEP_RESULT DEV_I2C_MasterWriteData(LEP_UINT16 portID, 73 | LEP_UINT8 deviceAddress, 74 | LEP_UINT16 regAddress, // Lepton Register Address 75 | LEP_UINT16 *writeDataPtr, 76 | LEP_UINT16 wordsToWrite, // Number of 16-bit words to Write 77 | LEP_UINT16 *numWordsWritten, // Number of 16-bit words actually written 78 | LEP_UINT16 *status 79 | ); 80 | 81 | extern LEP_RESULT DEV_I2C_MasterReadRegister( LEP_UINT16 portID, 82 | LEP_UINT8 deviceAddress, 83 | LEP_UINT16 regAddress, 84 | LEP_UINT16 *regValue, // Number of 16-bit words actually written 85 | LEP_UINT16 *status 86 | ); 87 | 88 | extern LEP_RESULT DEV_I2C_MasterWriteRegister( LEP_UINT16 portID, 89 | LEP_UINT8 deviceAddress, 90 | LEP_UINT16 regAddress, 91 | LEP_UINT16 regValue, // Number of 16-bit words actually written 92 | LEP_UINT16 *status 93 | ); 94 | 95 | extern LEP_RESULT DEV_I2C_MasterStatus(void ); 96 | 97 | /******************************************************************************/ 98 | #ifdef __cplusplus 99 | } 100 | #endif 101 | 102 | #endif /* _RASPI_I2C_H_ */ 103 | 104 | -------------------------------------------------------------------------------- /software/raspberrypi_qt/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | Makefile 3 | gen_objs 4 | gen_mocs 5 | *.o 6 | raspberrypi_qt 7 | 8 | -------------------------------------------------------------------------------- /software/raspberrypi_qt/LeptonThread.cpp: -------------------------------------------------------------------------------- 1 | #include "LeptonThread.h" 2 | 3 | #include 4 | #include 5 | 6 | LeptonThread::LeptonThread() 7 | : QThread() 8 | , result(RowPacketBytes*FrameHeight) 9 | , rawData(FrameWords) { } 10 | 11 | LeptonThread::~LeptonThread() { } 12 | 13 | #if HAVE_LEPTON 14 | const char *LeptonThread::device = "/dev/spidev0.1"; // Change to 0.0 if necessary! 15 | unsigned char LeptonThread::mode = 0, LeptonThread::bits = 8; 16 | unsigned int LeptonThread::speed = 16000000; 17 | unsigned short LeptonThread::delay = 0; 18 | QVector LeptonThread::tx(LeptonThread::RowPacketBytes, 0); 19 | 20 | bool LeptonThread::initLepton() { 21 | fd = open(device, O_RDWR); 22 | if (fd < 0) 23 | qDebug() << "Can't open device"; 24 | else if (-1 == ioctl(fd, SPI_IOC_WR_MODE, &mode)) 25 | qDebug() << "Can't set SPI mode"; 26 | else if (-1 == ioctl(fd, SPI_IOC_RD_MODE, &mode)) 27 | qDebug() << "Can't get SPI mode"; 28 | else if (-1 == ioctl(fd, SPI_IOC_WR_BITS_PER_WORD, &bits)) 29 | qDebug() << "Can't set bits per word"; 30 | else if (-1 == ioctl(fd, SPI_IOC_RD_BITS_PER_WORD, &bits)) 31 | qDebug() << "Can't get bits per word"; 32 | else if (-1 == ioctl(fd, SPI_IOC_WR_MAX_SPEED_HZ, &speed)) 33 | qDebug() << "Can't set max speed"; 34 | else if (-1 == ioctl(fd, SPI_IOC_RD_MAX_SPEED_HZ, &speed)) 35 | qDebug() << "Can't get max speed"; 36 | else 37 | return true; 38 | return false; 39 | } 40 | #else 41 | static int counter = 0; 42 | #endif 43 | 44 | int LeptonThread::getPacket(int iRow, unsigned char *packetData) { 45 | #if HAVE_LEPTON 46 | _tr.rx_buf = (unsigned long) packetData; 47 | return ioctl(fd, SPI_IOC_MESSAGE(1), &_tr); 48 | #else 49 | packetData[0] = 0; 50 | packetData[1] = iRow; 51 | for (int i = 4; i < RowPacketBytes; i += 2) 52 | *(short *)(packetData+i) = ((iRow+counter) % 20) + ((i/2-2) % 26); 53 | return 1; 54 | #endif 55 | } 56 | 57 | void LeptonThread::run() { 58 | #if HAVE_LEPTON 59 | if (!initLepton()) return; 60 | 61 | usleep(250000); 62 | 63 | _tr.tx_buf = (unsigned long) &tx[0]; 64 | _tr.len = RowPacketBytes; 65 | _tr.delay_usecs = delay; 66 | _tr.speed_hz = speed; 67 | _tr.bits_per_word = bits; 68 | #endif 69 | 70 | int resets = 0; // Number of times we've reset the 0...59 loop for packets 71 | int errors = 0; // Number of error-packets received 72 | while (true) { 73 | int iRow; 74 | for (iRow = 0; iRow < FrameHeight; ) { 75 | unsigned char *packet = &result[iRow*RowPacketBytes]; 76 | 77 | if (getPacket(iRow, packet) < 1) { 78 | qDebug() << "Error transferring SPI packet"; 79 | return; 80 | } 81 | 82 | int packetNumber; 83 | if ((packet[0] & 0xf)==0xf) 84 | packetNumber = -1; 85 | else 86 | packetNumber = packet[1]; 87 | 88 | #if DEBUG_LEPTON 89 | if (sequence.empty() || sequence.back().first!=packetNumber) 90 | sequence.push_back(std::make_pair(packetNumber, 1)); 91 | else 92 | ++sequence.back().second; 93 | #endif 94 | 95 | if (packetNumber==-1) { 96 | usleep(1000); 97 | if (++errors > 300) break; 98 | continue; 99 | } 100 | 101 | if (packetNumber != iRow) { 102 | usleep(1000); 103 | break; 104 | } 105 | 106 | ++iRow; 107 | } 108 | 109 | if (iRow < FrameHeight) { 110 | if (++resets >= 750) { 111 | qDebug() << "Packet reset counter hit 750"; 112 | resets = 0; 113 | usleep(750000); 114 | } 115 | continue; 116 | } 117 | 118 | #if DEBUG_LEPTON 119 | QString msg; 120 | QTextStream os(&msg); 121 | bool chain = false, first = true; int chain0, chain1; 122 | for (std::list< std::pair >::iterator iSeq = sequence.begin(); iSeq != sequence.end(); ++iSeq) { 123 | if (chain && iSeq->first==chain1+1) { ++chain1; continue; } 124 | if (chain && chain1!=chain0) os << "-" << chain1; 125 | if (iSeq->first >= 0 && !chain) { chain = true; chain0 = chain1 = iSeq->first; } 126 | if (first) first = false; else os << " "; 127 | if (iSeq->first==-1) os << "*"; else os << iSeq->first; 128 | if (iSeq->second!=1) { os << "^" << iSeq->second; chain = false; } 129 | } 130 | if (chain && chain1!=chain0) os << "-" << chain1; 131 | qDebug() << msg; 132 | sequence.clear(); 133 | // qDebug() << resets << "resets," << errors << "errors"; 134 | #endif 135 | 136 | resets = 0; errors = 0; 137 | 138 | uint16_t minValue = 65535; 139 | uint16_t maxValue = 0; 140 | unsigned char *in = &result[0]; 141 | unsigned short *out = &rawData[0]; 142 | for (int iRow = 0; iRow < FrameHeight; ++iRow) { 143 | in += 4; 144 | for (int iCol = 0; iCol < FrameWidth; ++iCol) { 145 | unsigned short value = in[0]; 146 | value <<= 8; 147 | value |= in[1]; 148 | in += 2; 149 | if (value > maxValue) maxValue = value; 150 | if (value < minValue) minValue = value; 151 | *(out++) = value; 152 | } 153 | } 154 | 155 | emit updateImage(&rawData[0], minValue, maxValue); 156 | 157 | #if !HAVE_LEPTON 158 | usleep(50000); // Need to slow things down if no ioctl call! 159 | counter = (counter + 1)%520; 160 | #endif 161 | } 162 | } 163 | -------------------------------------------------------------------------------- /software/raspberrypi_qt/LeptonThread.h: -------------------------------------------------------------------------------- 1 | #ifndef LEPTONTHREAD 2 | #define LEPTONTHREAD 3 | 4 | #define HAVE_LEPTON true 5 | #define DEBUG_LEPTON false 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | #if HAVE_LEPTON 15 | #include 16 | #include 17 | #include 18 | #endif 19 | 20 | #if DEBUG_LEPTON 21 | #include 22 | #include 23 | #endif 24 | 25 | #include 26 | #include 27 | #include 28 | 29 | 30 | class LeptonThread : public QThread { 31 | Q_OBJECT 32 | 33 | QVector result; 34 | QVector rawData; 35 | 36 | #if HAVE_LEPTON 37 | static const char *device; 38 | static unsigned char mode, bits; 39 | static unsigned int speed; 40 | static unsigned short delay; 41 | static QVector tx; 42 | 43 | int fd; 44 | struct spi_ioc_transfer _tr; 45 | #endif 46 | 47 | #if DEBUG_LEPTON 48 | std::list< std::pair > sequence; // ...of packet #'s received from Lepton, for troubleshooting 49 | #endif 50 | 51 | bool initLepton(); 52 | int getPacket(int iRow, unsigned char *packetData); 53 | 54 | public: 55 | enum { 56 | FrameWidth = 80, 57 | FrameHeight = 60, 58 | RowPacketWords = FrameWidth + 2, 59 | RowPacketBytes = 2*RowPacketWords, 60 | FrameWords = FrameWidth*FrameHeight 61 | }; 62 | 63 | LeptonThread(); 64 | ~LeptonThread(); 65 | 66 | void run(); 67 | 68 | signals: 69 | void updateImage(unsigned short *, int, int); 70 | }; 71 | 72 | #endif 73 | -------------------------------------------------------------------------------- /software/raspberrypi_qt/README.md: -------------------------------------------------------------------------------- 1 | This example is meant for Raspberry Pi and Pi2 and has been tested with Raspbian. 2 | 3 | Enable the SPI and I2C interfaces on the Pi. 4 | 5 | Install the 'qt4-dev-tools' package, which allows compiling of QT applications. 6 | 7 | To build (will build any SDK dependencies as well): 8 | qmake && make 9 | 10 | To clean: 11 | make sdkclean && make distclean 12 | 13 | If you wish to run this application without using sudo, you should add the user "pi" to the usergroup "i2c". 14 | 15 | ---- 16 | 17 | This is a fairly minimal (but functional) live view/snapshot application for the Raspberry PI + FLIR Lepton module. We had issues with some examples given that used the SDK, so we touched up the video program and did all of the SPI stuff without the SDK. No extra scripts, no extra resistors, etc. (all of these we tried first, but they didn't help)! 18 | 19 | The program runs a thread to pull data from the Lepton and signals when a fullimage is ready; the main window updates the image and stores both the RGB and raw (16-bit thermal) image, which can be saved to disk by clicking the Snapshot button at any time. The files created are numbered sequentially per run: 20 | 21 | * rgb?.jpg contains a 80x60 rgb image, and 22 | * raw?.bin contains the raw data; 23 | it consists of 9604 bytes (4802 unsigned shorts), as follows: 24 | - Word 0: minimum value from the scene 25 | - Word 1: maximum value from the scene 26 | - The rest are 80x60 unsigned shorts, listed by row then column. 27 | 28 | The project is set so that it can be worked with on a laptop (without Lepton) for 29 | development, controlled by the #define's at the top of LeptonThread.h: 30 | 31 | * HAVE_LEPTON: when true, uses ioctl to pull data packets from the Lepton; 32 | when false, a moving pattern is simulated instead. 33 | * DEBUG_LEPTON: when true, with each full frame is reported [via qDebug()] 34 | the full sequence of packets that were read while pulling the image; 35 | when everything is working properly, this typically consists of 36 | some small number of *'s (bad packets) followed by 0-59. 37 | 38 | Note that the SPI device is hardcoded as 0.0---change this to 0.1 if necessary! 39 | 40 | Enjoy! 41 | 42 | Frank Swenton, Middlebury College 43 | fswenton@middlebury.edu 44 | 45 | -------------------------------------------------------------------------------- /software/raspberrypi_qt/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "mainwindow.h" 4 | 5 | int main( int argc, char **argv ) 6 | { 7 | QApplication a(argc, argv); 8 | 9 | MainWindow *mainWindow = new MainWindow(); 10 | mainWindow->show(); 11 | 12 | return a.exec(); 13 | } 14 | 15 | -------------------------------------------------------------------------------- /software/raspberrypi_qt/mainwindow.h: -------------------------------------------------------------------------------- 1 | #ifndef MAINWINDOW_H 2 | #define MAINWINDOW_H 3 | 4 | #include 5 | #include 6 | 7 | class QLabel; 8 | class LeptonThread; 9 | class QGridLayout; 10 | 11 | class MainWindow : public QMainWindow { 12 | Q_OBJECT 13 | 14 | enum { ImageWidth = 320, ImageHeight = 240 }; 15 | 16 | static int snapshotCount; 17 | 18 | QLabel *imageLabel; 19 | LeptonThread *thread; 20 | QGridLayout *layout; 21 | 22 | unsigned short rawMin, rawMax; 23 | QVector rawData; 24 | QImage rgbImage; 25 | 26 | public: 27 | explicit MainWindow(QWidget *parent = 0); 28 | 29 | public slots: 30 | void saveSnapshot(); 31 | void updateImage(unsigned short *, int, int); 32 | }; 33 | 34 | #endif // MAINWINDOW_H 35 | -------------------------------------------------------------------------------- /software/raspberrypi_qt/raspberrypi_qt.pro: -------------------------------------------------------------------------------- 1 | 2 | TEMPLATE = app 3 | QT += core gui 4 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets 5 | 6 | TARGET = 7 | 8 | RPI_LIBS = ../raspberrypi_libs 9 | LEPTONSDK = leptonSDKEmb32PUB 10 | 11 | PRE_TARGETDEPS += sdk 12 | QMAKE_EXTRA_TARGETS += sdk sdkclean 13 | sdk.commands = make -C $${RPI_LIBS}/$${LEPTONSDK} 14 | sdkclean.commands = make -C $${RPI_LIBS}/$${LEPTONSDK} clean 15 | 16 | DEPENDPATH += . 17 | INCLUDEPATH += . $${RPI_LIBS} 18 | 19 | DESTDIR=. 20 | OBJECTS_DIR=gen_objs 21 | MOC_DIR=gen_mocs 22 | 23 | HEADERS += *.h 24 | 25 | SOURCES += *.cpp 26 | 27 | unix:LIBS += -L$${RPI_LIBS}/$${LEPTONSDK}/Debug -lLEPTON_SDK 28 | 29 | unix:QMAKE_CLEAN += -r $(OBJECTS_DIR) $${MOC_DIR} 30 | 31 | -------------------------------------------------------------------------------- /software/raspberrypi_video/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | Makefile 3 | gen_objs 4 | gen_mocs 5 | *.o 6 | raspberrypi_video 7 | 8 | -------------------------------------------------------------------------------- /software/raspberrypi_video/LeptonThread.h: -------------------------------------------------------------------------------- 1 | #ifndef TEXTTHREAD 2 | #define TEXTTHREAD 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #define PACKET_SIZE 164 13 | #define PACKET_SIZE_UINT16 (PACKET_SIZE/2) 14 | #define PACKETS_PER_FRAME 60 15 | #define FRAME_SIZE_UINT16 (PACKET_SIZE_UINT16*PACKETS_PER_FRAME) 16 | 17 | class LeptonThread : public QThread 18 | { 19 | Q_OBJECT; 20 | 21 | public: 22 | LeptonThread(); 23 | ~LeptonThread(); 24 | 25 | void setLogLevel(uint16_t); 26 | void useColormap(int); 27 | void useLepton(int); 28 | void useSpiSpeedMhz(unsigned int); 29 | void setAutomaticScalingRange(); 30 | void useRangeMinValue(uint16_t); 31 | void useRangeMaxValue(uint16_t); 32 | void run(); 33 | 34 | public slots: 35 | void performFFC(); 36 | 37 | signals: 38 | void updateText(QString); 39 | void updateImage(QImage); 40 | 41 | private: 42 | 43 | void log_message(uint16_t, std::string); 44 | uint16_t loglevel; 45 | int typeColormap; 46 | const int *selectedColormap; 47 | int selectedColormapSize; 48 | int typeLepton; 49 | unsigned int spiSpeed; 50 | bool autoRangeMin; 51 | bool autoRangeMax; 52 | uint16_t rangeMin; 53 | uint16_t rangeMax; 54 | int myImageWidth; 55 | int myImageHeight; 56 | QImage myImage; 57 | 58 | uint8_t result[PACKET_SIZE*PACKETS_PER_FRAME]; 59 | uint8_t shelf[4][PACKET_SIZE*PACKETS_PER_FRAME]; 60 | uint16_t *frameBuffer; 61 | 62 | }; 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /software/raspberrypi_video/Lepton_I2C.cpp: -------------------------------------------------------------------------------- 1 | #include "Lepton_I2C.h" 2 | 3 | #include "leptonSDKEmb32PUB/LEPTON_SDK.h" 4 | #include "leptonSDKEmb32PUB/LEPTON_SYS.h" 5 | #include "leptonSDKEmb32PUB/LEPTON_OEM.h" 6 | #include "leptonSDKEmb32PUB/LEPTON_Types.h" 7 | 8 | bool _connected; 9 | 10 | LEP_CAMERA_PORT_DESC_T _port; 11 | 12 | int lepton_connect() { 13 | LEP_OpenPort(1, LEP_CCI_TWI, 400, &_port); 14 | _connected = true; 15 | return 0; 16 | } 17 | 18 | void lepton_perform_ffc() { 19 | if(!_connected) { 20 | lepton_connect(); 21 | } 22 | LEP_RunSysFFCNormalization(&_port); 23 | } 24 | 25 | //presumably more commands could go here if desired 26 | 27 | void lepton_reboot() { 28 | if(!_connected) { 29 | lepton_connect(); 30 | } 31 | LEP_RunOemReboot(&_port); 32 | } 33 | -------------------------------------------------------------------------------- /software/raspberrypi_video/Lepton_I2C.h: -------------------------------------------------------------------------------- 1 | #ifndef LEPTON_I2C 2 | #define LEPTON_I2C 3 | 4 | void lepton_perform_ffc(); 5 | void lepton_reboot(); 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /software/raspberrypi_video/MyLabel.cpp: -------------------------------------------------------------------------------- 1 | #include "MyLabel.h" 2 | 3 | MyLabel::MyLabel(QWidget *parent) : QLabel(parent) 4 | { 5 | } 6 | MyLabel::~MyLabel() 7 | { 8 | } 9 | 10 | //when the system calls setImage, we'll set the label's pixmap 11 | void MyLabel::setImage(QImage image) { 12 | QPixmap pixmap = QPixmap::fromImage(image); 13 | int w = this->width(); 14 | int h = this->height(); 15 | setPixmap(pixmap.scaled(w, h, Qt::KeepAspectRatio)); 16 | } 17 | -------------------------------------------------------------------------------- /software/raspberrypi_video/MyLabel.h: -------------------------------------------------------------------------------- 1 | #ifndef MYLABEL_H 2 | #define MYLABEL_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | 9 | //we extend QLabel to give it an extra slot, setImage 10 | //this is because we can't pass a QPixmap from our thread 11 | //so we have to pass a QImage and turn the QImage into a QPixmap on our end 12 | 13 | class MyLabel : public QLabel { 14 | Q_OBJECT; 15 | 16 | public: 17 | MyLabel(QWidget *parent = 0); 18 | ~MyLabel(); 19 | 20 | public slots: 21 | void setImage(QImage); 22 | }; 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /software/raspberrypi_video/Palettes.h: -------------------------------------------------------------------------------- 1 | #ifndef PALETTES_H 2 | #define PALETTES_H 3 | 4 | extern const int colormap_rainbow[]; 5 | extern const int colormap_grayscale[]; 6 | extern const int colormap_ironblack[]; 7 | extern int get_size_colormap_rainbow(); 8 | extern int get_size_colormap_grayscale(); 9 | extern int get_size_colormap_ironblack(); 10 | 11 | #endif 12 | -------------------------------------------------------------------------------- /software/raspberrypi_video/README.md: -------------------------------------------------------------------------------- 1 | This example is meant for Raspberry Pi, Pi2, Pi3, PiZero, & Pi4 and has been tested with Raspbian. 2 | 3 | First enable the SPI and I2C interfaces on the Pi. 4 | ``` 5 | sudo raspi-config 6 | ``` 7 | 8 | Install the 'qt4-dev-tools' package, which allows compiling of QT applications. 9 | ``` 10 | sudo apt-get install qt4-dev-tools 11 | ``` 12 | 13 | To build (will build any SDK dependencies as well, cd to the *LeptonModule/sofware/raspberrypi_video* folder, then run: 14 | ``` 15 | qmake && make 16 | ``` 17 | 18 | To clean: 19 | ``` 20 | make sdkclean && make distclean 21 | ``` 22 | 23 | ## Raspberry Pi 1,2,3, & Zero 24 | 25 | ### Lepton 2.x 26 | To run the program while still in the raspberrypi_video directory, using a FLIR Lepton 2.x camera core use the following code: 27 | ``` 28 | ./raspberrypi_video 29 | ``` 30 | 31 | ### Lepton 3.x 32 | To run the program while still in the raspberrypi_video directory, using a FLIR Lepton 3.x camera core use the following code: 33 | ``` 34 | ./raspberrypi_video -tl 3 35 | ``` 36 | 37 | ## Raspberry Pi 4 38 | 39 | ### Lepton 2.x 40 | To run the program while still in the raspberrypi_video directory, using a FLIR Lepton 2.x camera core first use the following code: 41 | ``` 42 | sudo sh -c "echo performance > /sys/devices/system/cpu/cpufreq/policy0/scaling_governor" 43 | ``` 44 | Then run this to start the program: 45 | ``` 46 | ./raspberrypi_video 47 | ``` 48 | 49 | ### Lepton 3.x 50 | To run the program while still in the raspberrypi_video directory, using a FLIR Lepton 3.x camera core first use the following code: 51 | ``` 52 | sudo sh -c "echo performance > /sys/devices/system/cpu/cpufreq/policy0/scaling_governor" 53 | ``` 54 | Then run this to start the program: 55 | ``` 56 | ./raspberrypi_video -tl 3 57 | ``` 58 | 59 | ---- 60 | 61 | In order for the application to run properly, a Lepton camera must be attached in a specific way to the SPI, power, and ground pins of the Raspi's GPIO interface, as well as the I2C SDA/SCL pins: 62 | 63 | Lepton's GND pin should be connected to RasPi's ground. 64 | Lepton's CS pin should be connected to RasPi's CE1 pin. 65 | Lepton's MISO pin should be connected to RasPI's MISO pin. 66 | Lepton's CLK pin should be connected to RasPI's SCLK pin. 67 | Lepton's VIN pin should be connected to RasPI's 3v3 pin. 68 | Lepton's SDA pin should be connected to RasPI's SDA pin. 69 | Lepton's SCL pin should be connected to RasPI's SCL pin. 70 | -------------------------------------------------------------------------------- /software/raspberrypi_video/SPI.cpp: -------------------------------------------------------------------------------- 1 | #include "SPI.h" 2 | 3 | int spi_cs0_fd = -1; 4 | int spi_cs1_fd = -1; 5 | 6 | unsigned char spi_mode = SPI_MODE_3; 7 | unsigned char spi_bitsPerWord = 8; 8 | unsigned int spi_speed = 10000000; 9 | 10 | int SpiOpenPort (int spi_device, unsigned int useSpiSpeed) 11 | { 12 | int status_value = -1; 13 | int *spi_cs_fd; 14 | 15 | 16 | //----- SET SPI MODE ----- 17 | //SPI_MODE_0 (0,0) CPOL=0 (Clock Idle low level), CPHA=0 (SDO transmit/change edge active to idle) 18 | //SPI_MODE_1 (0,1) CPOL=0 (Clock Idle low level), CPHA=1 (SDO transmit/change edge idle to active) 19 | //SPI_MODE_2 (1,0) CPOL=1 (Clock Idle high level), CPHA=0 (SDO transmit/change edge active to idle) 20 | //SPI_MODE_3 (1,1) CPOL=1 (Clock Idle high level), CPHA=1 (SDO transmit/change edge idle to active) 21 | spi_mode = SPI_MODE_3; 22 | 23 | //----- SET BITS PER WORD ----- 24 | spi_bitsPerWord = 8; 25 | 26 | //----- SET SPI BUS SPEED ----- 27 | spi_speed = useSpiSpeed; //1000000 = 1MHz (1uS per bit) 28 | 29 | 30 | if (spi_device) 31 | spi_cs_fd = &spi_cs1_fd; 32 | else 33 | spi_cs_fd = &spi_cs0_fd; 34 | 35 | 36 | if (spi_device) 37 | *spi_cs_fd = open(std::string("/dev/spidev0.1").c_str(), O_RDWR); 38 | else 39 | *spi_cs_fd = open(std::string("/dev/spidev0.0").c_str(), O_RDWR); 40 | 41 | if (*spi_cs_fd < 0) 42 | { 43 | perror("Error - Could not open SPI device"); 44 | exit(1); 45 | } 46 | 47 | status_value = ioctl(*spi_cs_fd, SPI_IOC_WR_MODE, &spi_mode); 48 | if(status_value < 0) 49 | { 50 | perror("Could not set SPIMode (WR)...ioctl fail"); 51 | exit(1); 52 | } 53 | 54 | status_value = ioctl(*spi_cs_fd, SPI_IOC_RD_MODE, &spi_mode); 55 | if(status_value < 0) 56 | { 57 | perror("Could not set SPIMode (RD)...ioctl fail"); 58 | exit(1); 59 | } 60 | 61 | status_value = ioctl(*spi_cs_fd, SPI_IOC_WR_BITS_PER_WORD, &spi_bitsPerWord); 62 | if(status_value < 0) 63 | { 64 | perror("Could not set SPI bitsPerWord (WR)...ioctl fail"); 65 | exit(1); 66 | } 67 | 68 | status_value = ioctl(*spi_cs_fd, SPI_IOC_RD_BITS_PER_WORD, &spi_bitsPerWord); 69 | if(status_value < 0) 70 | { 71 | perror("Could not set SPI bitsPerWord(RD)...ioctl fail"); 72 | exit(1); 73 | } 74 | 75 | status_value = ioctl(*spi_cs_fd, SPI_IOC_WR_MAX_SPEED_HZ, &spi_speed); 76 | if(status_value < 0) 77 | { 78 | perror("Could not set SPI speed (WR)...ioctl fail"); 79 | exit(1); 80 | } 81 | 82 | status_value = ioctl(*spi_cs_fd, SPI_IOC_RD_MAX_SPEED_HZ, &spi_speed); 83 | if(status_value < 0) 84 | { 85 | perror("Could not set SPI speed (RD)...ioctl fail"); 86 | exit(1); 87 | } 88 | return(status_value); 89 | } 90 | 91 | int SpiClosePort(int spi_device) 92 | { 93 | int status_value = -1; 94 | int *spi_cs_fd; 95 | 96 | if (spi_device) 97 | spi_cs_fd = &spi_cs1_fd; 98 | else 99 | spi_cs_fd = &spi_cs0_fd; 100 | 101 | 102 | status_value = close(*spi_cs_fd); 103 | if(status_value < 0) 104 | { 105 | perror("Error - Could not close SPI device"); 106 | exit(1); 107 | } 108 | return(status_value); 109 | } 110 | -------------------------------------------------------------------------------- /software/raspberrypi_video/SPI.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPI testing utility (using spidev driver) 3 | * 4 | * Copyright (c) 2007 MontaVista Software, Inc. 5 | * Copyright (c) 2007 Anton Vorontsov 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License. 10 | * 11 | * Cross-compile with cross-gcc -I/path/to/cross-kernel/include 12 | */ 13 | 14 | #ifndef SPI_H 15 | #define SPI_H 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | extern int spi_cs0_fd; 29 | extern int spi_cs1_fd; 30 | extern unsigned char spi_mode; 31 | extern unsigned char spi_bitsPerWord; 32 | extern unsigned int spi_speed; 33 | 34 | int SpiOpenPort(int spi_device, unsigned int spi_speed); 35 | int SpiClosePort(int spi_device); 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /software/raspberrypi_video/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #include "LeptonThread.h" 13 | #include "MyLabel.h" 14 | 15 | void printUsage(char *cmd) { 16 | char *cmdname = basename(cmd); 17 | printf("Usage: %s [OPTION]...\n" 18 | " -h display this help and exit\n" 19 | " -cm x select colormap\n" 20 | " 1 : rainbow\n" 21 | " 2 : grayscale\n" 22 | " 3 : ironblack [default]\n" 23 | " -tl x select type of Lepton\n" 24 | " 2 : Lepton 2.x [default]\n" 25 | " 3 : Lepton 3.x\n" 26 | " [for your reference] Please use nice command\n" 27 | " e.g. sudo nice -n 0 ./%s -tl 3\n" 28 | " -ss x SPI bus speed [MHz] (10 - 30)\n" 29 | " 20 : 20MHz [default]\n" 30 | " -min x override minimum value for scaling (0 - 65535)\n" 31 | " [default] automatic scaling range adjustment\n" 32 | " e.g. -min 30000\n" 33 | " -max x override maximum value for scaling (0 - 65535)\n" 34 | " [default] automatic scaling range adjustment\n" 35 | " e.g. -max 32000\n" 36 | " -d x log level (0-255)\n" 37 | "", cmdname, cmdname); 38 | return; 39 | } 40 | 41 | int main( int argc, char **argv ) 42 | { 43 | int typeColormap = 3; // colormap_ironblack 44 | int typeLepton = 2; // Lepton 2.x 45 | int spiSpeed = 20; // SPI bus speed 20MHz 46 | int rangeMin = -1; // 47 | int rangeMax = -1; // 48 | int loglevel = 0; 49 | for(int i=1; i < argc; i++) { 50 | if (strcmp(argv[i], "-h") == 0) { 51 | printUsage(argv[0]); 52 | exit(0); 53 | } 54 | else if (strcmp(argv[i], "-d") == 0) { 55 | int val = 3; 56 | if ((i + 1 != argc) && (strncmp(argv[i + 1], "-", 1) != 0)) { 57 | val = std::atoi(argv[i + 1]); 58 | i++; 59 | } 60 | if (0 <= val) { 61 | loglevel = val & 0xFF; 62 | } 63 | } 64 | else if ((strcmp(argv[i], "-cm") == 0) && (i + 1 != argc)) { 65 | int val = std::atoi(argv[i + 1]); 66 | if ((val == 1) || (val == 2)) { 67 | typeColormap = val; 68 | i++; 69 | } 70 | } 71 | else if ((strcmp(argv[i], "-tl") == 0) && (i + 1 != argc)) { 72 | int val = std::atoi(argv[i + 1]); 73 | if (val == 3) { 74 | typeLepton = val; 75 | i++; 76 | } 77 | } 78 | else if ((strcmp(argv[i], "-ss") == 0) && (i + 1 != argc)) { 79 | int val = std::atoi(argv[i + 1]); 80 | if ((10 <= val) && (val <= 30)) { 81 | spiSpeed = val; 82 | i++; 83 | } 84 | } 85 | else if ((strcmp(argv[i], "-min") == 0) && (i + 1 != argc)) { 86 | int val = std::atoi(argv[i + 1]); 87 | if ((0 <= val) && (val <= 65535)) { 88 | rangeMin = val; 89 | i++; 90 | } 91 | } 92 | else if ((strcmp(argv[i], "-max") == 0) && (i + 1 != argc)) { 93 | int val = std::atoi(argv[i + 1]); 94 | if ((0 <= val) && (val <= 65535)) { 95 | rangeMax = val; 96 | i++; 97 | } 98 | } 99 | } 100 | 101 | //create the app 102 | QApplication a( argc, argv ); 103 | 104 | QWidget *myWidget = new QWidget; 105 | myWidget->setGeometry(400, 300, 340, 290); 106 | 107 | //create an image placeholder for myLabel 108 | //fill the top left corner with red, just bcuz 109 | QImage myImage; 110 | myImage = QImage(320, 240, QImage::Format_RGB888); 111 | QRgb red = qRgb(255,0,0); 112 | for(int i=0;i<80;i++) { 113 | for(int j=0;j<60;j++) { 114 | myImage.setPixel(i, j, red); 115 | } 116 | } 117 | 118 | //create a label, and set it's image to the placeholder 119 | MyLabel myLabel(myWidget); 120 | myLabel.setGeometry(10, 10, 320, 240); 121 | myLabel.setPixmap(QPixmap::fromImage(myImage)); 122 | 123 | //create a FFC button 124 | QPushButton *button1 = new QPushButton("Perform FFC", myWidget); 125 | button1->setGeometry(320/2-50, 290-35, 100, 30); 126 | 127 | //create a thread to gather SPI data 128 | //when the thread emits updateImage, the label should update its image accordingly 129 | LeptonThread *thread = new LeptonThread(); 130 | thread->setLogLevel(loglevel); 131 | thread->useColormap(typeColormap); 132 | thread->useLepton(typeLepton); 133 | thread->useSpiSpeedMhz(spiSpeed); 134 | thread->setAutomaticScalingRange(); 135 | if (0 <= rangeMin) thread->useRangeMinValue(rangeMin); 136 | if (0 <= rangeMax) thread->useRangeMaxValue(rangeMax); 137 | QObject::connect(thread, SIGNAL(updateImage(QImage)), &myLabel, SLOT(setImage(QImage))); 138 | 139 | //connect ffc button to the thread's ffc action 140 | QObject::connect(button1, SIGNAL(clicked()), thread, SLOT(performFFC())); 141 | thread->start(); 142 | 143 | myWidget->show(); 144 | 145 | return a.exec(); 146 | } 147 | 148 | -------------------------------------------------------------------------------- /software/raspberrypi_video/raspberrypi_video.pro: -------------------------------------------------------------------------------- 1 | 2 | TEMPLATE = app 3 | QT += core gui 4 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets 5 | 6 | TARGET = raspberrypi_video 7 | 8 | RPI_LIBS = ../raspberrypi_libs 9 | LEPTONSDK = leptonSDKEmb32PUB 10 | 11 | PRE_TARGETDEPS += sdk 12 | QMAKE_EXTRA_TARGETS += sdk sdkclean 13 | sdk.commands = make -C $${RPI_LIBS}/$${LEPTONSDK} 14 | sdkclean.commands = make -C $${RPI_LIBS}/$${LEPTONSDK} clean 15 | 16 | DEPENDPATH += . 17 | INCLUDEPATH += . $${RPI_LIBS} 18 | 19 | DESTDIR=. 20 | OBJECTS_DIR=gen_objs 21 | MOC_DIR=gen_mocs 22 | 23 | HEADERS += *.h 24 | 25 | SOURCES += *.cpp 26 | 27 | unix:LIBS += -L$${RPI_LIBS}/$${LEPTONSDK}/Debug -lLEPTON_SDK 28 | 29 | unix:QMAKE_CLEAN += -r $(OBJECTS_DIR) $${MOC_DIR} 30 | 31 | -------------------------------------------------------------------------------- /software/stm32nucleo_401re/README.md: -------------------------------------------------------------------------------- 1 | Links 2 | 3 | Compiler 4 | https://developer.mbed.org/ 5 | 6 | 7 | ST-LINK used for downloading firmware file to board. 8 | http://www.st.com/web/en/catalog/tools/PF258168 9 | 10 | driver 11 | http://www.st.com/web/catalog/tools/FM147/SC1887/PF260219 12 | 13 | How to use ST-Link 14 | http://www.st.com/st-web-ui/static/active/en/resource/technical/document/user_manual/CD00262073.pdf 15 | 16 | 17 | workflow: 18 | create an mbed account, start a nucleo_401 project then copy and paste the main.cpp code into it. 19 | compile the code, it will will be a downloaded file. The 401 code can be used on the 411 board as well. 20 | Use ST-link to flash the code to the nucleo board 21 | 22 | The Data comes out the serial port, you can use the device manager to find the correct serial port. 23 | The lepton and breakout board can be pluged directly into the nucleo board. 24 | any serial program can be used to view the raw data to verify that it is working. 25 | An example program to convert the raw data stream is called ThermalView. This is a window only program. 26 | -------------------------------------------------------------------------------- /software/stm32nucleo_401re/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2014, Pure Engineering LLC 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright notice, this 9 | list of conditions and the following disclaimer. 10 | 11 | * Redistributions in binary form must reproduce the above copyright notice, 12 | this list of conditions and the following disclaimer in the documentation 13 | and/or other materials provided with the distribution. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 19 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 21 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 22 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 23 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 24 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | 28 | #include "mbed.h" 29 | 30 | Serial pc(SERIAL_TX, SERIAL_RX); 31 | SPI lepton_spi(SPI_MOSI, SPI_MISO, SPI_SCK); 32 | DigitalOut spi_cs(SPI_CS); 33 | 34 | #define VOSPI_FRAME_SIZE (164) 35 | uint8_t lepton_frame_packet[VOSPI_FRAME_SIZE]; 36 | int lepton_image[80][80]; 37 | 38 | 39 | int print_image_binary_state =-1; 40 | int print_image_binary_i; 41 | int print_image_binary_j; 42 | 43 | static void print_image_binary_background(void) 44 | { 45 | if( print_image_binary_state == -1) 46 | { 47 | return; 48 | } 49 | else if( print_image_binary_state == 0) 50 | { 51 | pc.putc(0xDE); 52 | print_image_binary_state++; 53 | } 54 | else if( print_image_binary_state == 1) 55 | { 56 | pc.putc(0xAD); 57 | print_image_binary_state++; 58 | } 59 | else if( print_image_binary_state == 2) 60 | { 61 | pc.putc(0xBE); 62 | print_image_binary_state++; 63 | } 64 | else if( print_image_binary_state == 3) 65 | { 66 | pc.putc(0xEF); 67 | print_image_binary_state++; 68 | print_image_binary_i = 0; 69 | print_image_binary_j = 0; 70 | } 71 | else if( print_image_binary_state == 4) 72 | { 73 | while(pc.writeable() == 0); 74 | pc.putc((lepton_image[print_image_binary_i][print_image_binary_j]>>8)&0xff); 75 | while(pc.writeable() == 0); 76 | pc.putc(lepton_image[print_image_binary_i][print_image_binary_j]&0xff); 77 | 78 | print_image_binary_j++; 79 | if(print_image_binary_j>=80) 80 | { 81 | print_image_binary_j=0; 82 | print_image_binary_i++; 83 | if(print_image_binary_i>=60) 84 | { 85 | print_image_binary_state = -1; 86 | } 87 | } 88 | } 89 | 90 | } 91 | 92 | 93 | 94 | int lost_frame_counter = 0; 95 | int last_frame_number; 96 | int frame_complete = 0; 97 | int start_image = 0; 98 | int need_resync = 0; 99 | int last_crc; 100 | int new_frame = 0; 101 | int frame_counter = 0; 102 | 103 | void transfer(void) 104 | { 105 | int i; 106 | int frame_number; 107 | 108 | 109 | spi_cs = 0; 110 | for(i=0;i100) 159 | { 160 | need_resync = 1; 161 | lost_frame_counter = 0; 162 | 163 | } 164 | 165 | if(need_resync) 166 | { 167 | wait_ms(185); 168 | need_resync = 0; 169 | } 170 | 171 | 172 | if(frame_complete) 173 | { 174 | if(new_frame) 175 | { 176 | frame_counter++; 177 | { 178 | if(frame_counter%18 ==0) 179 | { 180 | print_image_binary_state = 0; 181 | } 182 | } 183 | new_frame = 0; 184 | } 185 | frame_complete = 0; 186 | } 187 | } 188 | 189 | 190 | int main() 191 | { 192 | pc.baud(115200); 193 | lepton_spi.format(8,3); 194 | lepton_spi.frequency(20000000); 195 | spi_cs = 1; 196 | spi_cs = 0; 197 | spi_cs = 1; 198 | 199 | wait_ms(185); 200 | 201 | while(1) 202 | { 203 | transfer(); 204 | print_image_binary_background(); 205 | } 206 | } 207 | 208 | -------------------------------------------------------------------------------- /software/v4l2lepton/Lepton_I2C.cpp: -------------------------------------------------------------------------------- 1 | #include "Lepton_I2C.h" 2 | 3 | #include "leptonSDKEmb32PUB/LEPTON_SDK.h" 4 | #include "leptonSDKEmb32PUB/LEPTON_SYS.h" 5 | #include "leptonSDKEmb32PUB/LEPTON_Types.h" 6 | 7 | bool _connected; 8 | 9 | LEP_CAMERA_PORT_DESC_T _port; 10 | 11 | int lepton_connect() { 12 | LEP_OpenPort(1, LEP_CCI_TWI, 400, &_port); 13 | _connected = true; 14 | return 0; 15 | } 16 | 17 | void lepton_perform_ffc() { 18 | if(!_connected) { 19 | lepton_connect(); 20 | } 21 | LEP_RunSysFFCNormalization(&_port); 22 | } 23 | 24 | //presumably more commands could go here if desired 25 | -------------------------------------------------------------------------------- /software/v4l2lepton/Lepton_I2C.h: -------------------------------------------------------------------------------- 1 | #ifndef LEPTON_I2C 2 | #define LEPTON_I2C 3 | 4 | void lepton_perform_ffc(); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /software/v4l2lepton/Makefile: -------------------------------------------------------------------------------- 1 | 2 | CC = gcc 3 | CXX = g++ 4 | CFLAGS = -pipe -O2 -Wall -W -D_REENTRANT -lpthread -lLEPTON_SDK -L/usr/lib/arm-linux-gnueabihf -L../raspberrypi_libs/leptonSDKEmb32PUB/Debug 5 | CXXFLAGS = -pipe -O2 -Wall -W -D_REENTRANT -lpthread -lLEPTON_SDK -L/usr/lib/arm-linux-gnueabihf -L../raspberrypi_libs/leptonSDKEmb32PUB/Debug 6 | INCPATH = -I. -I../raspberrypi_libs 7 | 8 | all: sdk leptsci.o SPI.o Lepton_I2C.o Palettes.o v4l2lepton 9 | 10 | sdk: 11 | make -C ../raspberrypi_libs/leptonSDKEmb32PUB 12 | 13 | sdkclean: 14 | make -C ../raspberrypi_libs/leptonSDKEmb32PUB clean 15 | 16 | Palettes.o: Palettes.cpp Palettes.h 17 | ${CXX} -c ${CXXFLAGS} ${INCPATH} -o Palettes.o Palettes.cpp 18 | 19 | SPI.o: SPI.cpp SPI.h 20 | ${CXX} -c ${CXXFLAGS} ${INCPATH} -o SPI.o SPI.cpp 21 | 22 | Lepton_I2C.o: 23 | ${CXX} -c ${CXXFLAGS} ${INCPATH} -o Lepton_I2C.o Lepton_I2C.cpp 24 | 25 | v4l2lepton: v4l2lepton.o leptsci.o Palettes.o SPI.o 26 | ${CXX} -o v4l2lepton leptsci.o Palettes.o SPI.o v4l2lepton.cpp ${CXXFLAGS} 27 | 28 | leptsci.o: leptsci.c 29 | 30 | clean: 31 | rm -f SPI.o Lepton_I2C.o Palettes.o leptsci.o v4l2lepton.o v4l2lepton 32 | -------------------------------------------------------------------------------- /software/v4l2lepton/Palettes.h: -------------------------------------------------------------------------------- 1 | #ifndef PALETTES_H 2 | #define PALETTES_H 3 | 4 | extern const int colormap_rainbow[]; 5 | extern const int colormap_grayscale[]; 6 | extern const int colormap_ironblack[]; 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /software/v4l2lepton/README.md: -------------------------------------------------------------------------------- 1 | Released under GPLv3 2 | 3 | This is a simple program initially designed for Raspberry Pi that reads frames from the FLIR Lepton and streams them to a v4l2loopback device. This program would be very useful if you want to stream the Lepton like any other webcam. Maybe you want to process the Lepton frames using a library that can read standard v4l2 devices, like OpenCV. Anything you can do with a webcam, this program will allow you to do it with the Lepton + basic breakout board. 4 | 5 | Code is borrowed from raspberrypi_video as well as the ondemandcam example provided with v4l2loopback. 6 | 7 | Install v4l2loopback kernel module to a Raspberry Pi: 8 | 9 | 1. Install kernel headers with [rpi-source](https://github.com/notro/rpi-source) utility. 10 | 2. Compile [v4l2loopback](https://github.com/umlaeute/v4l2loopback) 11 | 3. If step 2 is successful, you should have v4l2loopback.ko in the source directory 12 | 4. Copy v4l2loopback.ko to /lib/modules (I believe just /lib/modules directory works, but if that doesn't work, put it in /lib/modules/$(uname -r) OR just put it in both places...). 13 | 5. Run `sudo depmod -a` 14 | 15 | At this point, you should be able to modprobe v4l2loopback. This will create a new /dev/video device. It will be /dev/video0 if you have no other cameras attached. If you have other cameras, it will likely be the highest numbered /dev/video. To be sure, you can pass options to modprobe that will set it to a specific number (see v4l2loopback docs). You could also identify the proper video device with `v4l2-ctl`. 16 | 17 | Below, I refer to the new v4l2loopback device as `/dev/videoX` but you should replace X with the number on your system. 18 | 19 | To Compile v4l2lepton: 20 | 21 | make 22 | 23 | 24 | To Run v4l2lepton: 25 | 26 | ./v4l2lepton -v /dev/videoX -d /dev/spidevY.Z 27 | 28 | If spidev device is not given /dev/spidev0.1 will be used by default. 29 | You can confirm that the stream is working by using something like VLC Media Player and opening /dev/videoX as a capture device. Anything that can interface with v4l2 devices can use it though. 30 | -------------------------------------------------------------------------------- /software/v4l2lepton/SPI.cpp: -------------------------------------------------------------------------------- 1 | #include "SPI.h" 2 | 3 | int spi_cs_fd = -1; 4 | 5 | unsigned char spi_mode = SPI_MODE_3; 6 | unsigned char spi_bitsPerWord = 8; 7 | unsigned int spi_speed = 10000000; 8 | 9 | int SpiOpenPort (char* spi_device) 10 | { 11 | int status_value = -1; 12 | 13 | //----- SET SPI MODE ----- 14 | //SPI_MODE_0 (0,0) CPOL=0 (Clock Idle low level), CPHA=0 (SDO transmit/change edge active to idle) 15 | //SPI_MODE_1 (0,1) CPOL=0 (Clock Idle low level), CPHA=1 (SDO transmit/change edge idle to active) 16 | //SPI_MODE_2 (1,0) CPOL=1 (Clock Idle high level), CPHA=0 (SDO transmit/change edge active to idle) 17 | //SPI_MODE_3 (1,1) CPOL=1 (Clock Idle high level), CPHA=1 (SDO transmit/change edge idle to active) 18 | spi_mode = SPI_MODE_3; 19 | 20 | //----- SET BITS PER WORD ----- 21 | spi_bitsPerWord = 8; 22 | 23 | //----- SET SPI BUS SPEED ----- 24 | spi_speed = 10000000; //1000000 = 1MHz (1uS per bit) 25 | 26 | if (spi_device) 27 | spi_cs_fd = open(std::string(spi_device).c_str(), O_RDWR); 28 | else 29 | spi_cs_fd = open(std::string("/dev/spidev0.1").c_str(), O_RDWR); 30 | 31 | if (spi_cs_fd < 0) 32 | { 33 | perror("Error - Could not open SPI device"); 34 | exit(1); 35 | } 36 | 37 | status_value = ioctl(spi_cs_fd, SPI_IOC_WR_MODE, &spi_mode); 38 | if(status_value < 0) 39 | { 40 | perror("Could not set SPIMode (WR)...ioctl fail"); 41 | exit(1); 42 | } 43 | 44 | status_value = ioctl(spi_cs_fd, SPI_IOC_RD_MODE, &spi_mode); 45 | if(status_value < 0) 46 | { 47 | perror("Could not set SPIMode (RD)...ioctl fail"); 48 | exit(1); 49 | } 50 | 51 | status_value = ioctl(spi_cs_fd, SPI_IOC_WR_BITS_PER_WORD, &spi_bitsPerWord); 52 | if(status_value < 0) 53 | { 54 | perror("Could not set SPI bitsPerWord (WR)...ioctl fail"); 55 | exit(1); 56 | } 57 | 58 | status_value = ioctl(spi_cs_fd, SPI_IOC_RD_BITS_PER_WORD, &spi_bitsPerWord); 59 | if(status_value < 0) 60 | { 61 | perror("Could not set SPI bitsPerWord(RD)...ioctl fail"); 62 | exit(1); 63 | } 64 | 65 | status_value = ioctl(spi_cs_fd, SPI_IOC_WR_MAX_SPEED_HZ, &spi_speed); 66 | if(status_value < 0) 67 | { 68 | perror("Could not set SPI speed (WR)...ioctl fail"); 69 | exit(1); 70 | } 71 | 72 | status_value = ioctl(spi_cs_fd, SPI_IOC_RD_MAX_SPEED_HZ, &spi_speed); 73 | if(status_value < 0) 74 | { 75 | perror("Could not set SPI speed (RD)...ioctl fail"); 76 | exit(1); 77 | } 78 | return(status_value); 79 | } 80 | 81 | int SpiClosePort(void) 82 | { 83 | int status_value = -1; 84 | 85 | status_value = close(spi_cs_fd); 86 | if(status_value < 0) 87 | { 88 | perror("Error - Could not close SPI device"); 89 | exit(1); 90 | } 91 | return(status_value); 92 | } 93 | -------------------------------------------------------------------------------- /software/v4l2lepton/SPI.h: -------------------------------------------------------------------------------- 1 | /* 2 | * SPI testing utility (using spidev driver) 3 | * 4 | * Copyright (c) 2007 MontaVista Software, Inc. 5 | * Copyright (c) 2007 Anton Vorontsov 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License. 10 | * 11 | * Cross-compile with cross-gcc -I/path/to/cross-kernel/include 12 | */ 13 | 14 | #ifndef SPI_H 15 | #define SPI_H 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | extern int spi_cs_fd; 29 | extern unsigned char spi_mode; 30 | extern unsigned char spi_bitsPerWord; 31 | extern unsigned int spi_speed; 32 | 33 | int SpiOpenPort(char *device); 34 | int SpiClosePort(void); 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /software/v4l2lepton/leptsci.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | static uint8_t bits = 8; 10 | static uint32_t speed = 16000000; //16 11 | static uint16_t delay = 0; 12 | static int leptfd; 13 | 14 | int leptopen() 15 | { 16 | uint8_t mode = 0; 17 | const char device[] = "/dev/spidev0.0"; 18 | leptfd = open(device, O_RDWR); 19 | if (leptfd < 0) 20 | return -1; 21 | if (-1 == ioctl(leptfd, SPI_IOC_WR_MODE, &mode)) 22 | return -2; 23 | if (-1 == ioctl(leptfd, SPI_IOC_RD_MODE, &mode)) 24 | return -3; 25 | if (-1 == ioctl(leptfd, SPI_IOC_WR_BITS_PER_WORD, &bits)) 26 | return -4; 27 | if (-1 == ioctl(leptfd, SPI_IOC_RD_BITS_PER_WORD, &bits)) 28 | return -5; 29 | if (-1 == ioctl(leptfd, SPI_IOC_WR_MAX_SPEED_HZ, &speed)) 30 | return -6; 31 | if (-1 == ioctl(leptfd, SPI_IOC_RD_MAX_SPEED_HZ, &speed)) 32 | return -7; 33 | return 0; 34 | } 35 | 36 | void leptclose() 37 | { 38 | close(leptfd); 39 | } 40 | 41 | int leptget(unsigned short *img) 42 | { 43 | #define VOSPI_FRAME_SIZE (164) 44 | int row = -1; 45 | int hiccup = 0; 46 | int notready = 0; 47 | do { 48 | 49 | uint8_t lepacket[VOSPI_FRAME_SIZE]; 50 | uint8_t tx[VOSPI_FRAME_SIZE] = { 0, }; 51 | struct spi_ioc_transfer tr = { 52 | .tx_buf = (unsigned long) tx, 53 | .rx_buf = (unsigned long) lepacket, 54 | .len = VOSPI_FRAME_SIZE, 55 | .delay_usecs = delay, 56 | .speed_hz = speed, 57 | .bits_per_word = bits, 58 | }; 59 | 60 | int i; 61 | i = ioctl(leptfd, SPI_IOC_MESSAGE(1), &tr); 62 | if (i < 1) { 63 | fprintf(stderr, "1"); 64 | continue; 65 | } 66 | //return -1; 67 | if (((lepacket[0] & 0xf) == 0x0f)) { 68 | //fprintf( stderr, "." ); 69 | if (!notready) 70 | usleep(25000); // wait for next frame 71 | else 72 | usleep(1000); 73 | notready++; 74 | continue; 75 | } 76 | //if( notready ) fprintf( stderr, "<%d>", notready ); 77 | notready = 0; 78 | //return -2; 79 | row = lepacket[1]; 80 | hiccup++; 81 | if (row >= 60) { 82 | if (hiccup > 8) { 83 | //leptclose(); 84 | usleep(125000); 85 | //leptopen(); 86 | fprintf(stderr, "!\n"); 87 | } 88 | fprintf(stderr, "[%d]", row); 89 | continue; 90 | } 91 | hiccup = 0; 92 | for (i = 0; i < 80; i++) 93 | img[row * 80 + i] 94 | = (lepacket[2 * i + 4] << 8) | lepacket[2 * i + 5]; 95 | //printf ("%d ",img[row*81]); 96 | } while (row != 59); 97 | return 0; 98 | } 99 | -------------------------------------------------------------------------------- /software/v4l2lepton/leptsci.h: -------------------------------------------------------------------------------- 1 | int leptopen(void); 2 | int leptget(unsigned short *); 3 | int leptclose(void); 4 | --------------------------------------------------------------------------------