From 3be5cba278e3f2052dc74def633991f7605efb38 Mon Sep 17 00:00:00 2001 From: maxritter Date: Sat, 8 May 2021 17:22:16 +0200 Subject: [PATCH] Updated firmware to version 3.0.1 --- Firmware_V3/include/globaldefines.h | 3 +- Firmware_V3/include/lepton.h | 11 ----- Firmware_V3/src/general/globalvariables.cpp | 4 +- Firmware_V3/src/gui/gui.cpp | 40 +++++++--------- Firmware_V3/src/hardware/connection.cpp | 7 +-- Firmware_V3/src/hardware/lepton.cpp | 53 +++------------------ 6 files changed, 29 insertions(+), 89 deletions(-) diff --git a/Firmware_V3/include/globaldefines.h b/Firmware_V3/include/globaldefines.h index f2ee78f..1899201 100644 --- a/Firmware_V3/include/globaldefines.h +++ b/Firmware_V3/include/globaldefines.h @@ -156,8 +156,7 @@ extern "C" { #define diag_touch 1 #define diag_sd 2 #define diag_bat 3 -#define diag_lep_conf 4 -#define diag_lep_data 5 +#define diag_lepton 4 #define diag_ok 255 //Color scheme numbers diff --git a/Firmware_V3/include/lepton.h b/Firmware_V3/include/lepton.h index cc1ca83..e111dc2 100644 --- a/Firmware_V3/include/lepton.h +++ b/Firmware_V3/include/lepton.h @@ -16,23 +16,12 @@ #ifndef LEPTON_H #define LEPTON_H -//Lepton frame error return -enum LeptonReadError -{ - NONE, - DISCARD, - SEGMENT_ERROR, - ROW_ERROR, - SEGMENT_INVALID -}; - /*########################## PUBLIC PROCEDURES ################################*/ void lepton_begin(); void lepton_end(); bool lepton_ffc(bool message = false, bool switch_gain = false); void lepton_ffcMode(bool automatic); -LeptonReadError lepton_getPacketSync(uint8_t line, uint8_t seg); bool lepton_getPacketAsync(uint8_t *line, uint8_t *seg); void lepton_getFrame(); void lepton_getFrameAsync(); diff --git a/Firmware_V3/src/general/globalvariables.cpp b/Firmware_V3/src/general/globalvariables.cpp index bc01987..cd90981 100644 --- a/Firmware_V3/src/general/globalvariables.cpp +++ b/Firmware_V3/src/general/globalvariables.cpp @@ -26,8 +26,8 @@ /*############################# PUBLIC VARIABLES ##############################*/ //Current firmware version -char versionString[] = "Firmware 3.00 from 01.05.2021"; -uint16_t fwVersion = 300; +char versionString[] = "Firmware 3.01 from 08.05.2021"; +uint16_t fwVersion = 301; //320x240 buffer unsigned short* bigBuffer; diff --git a/Firmware_V3/src/gui/gui.cpp b/Firmware_V3/src/gui/gui.cpp index 6bb241a..ed128cf 100644 --- a/Firmware_V3/src/gui/gui.cpp +++ b/Firmware_V3/src/gui/gui.cpp @@ -148,11 +148,10 @@ void showDiagnostic() display_setColor(VGA_BLACK); //Display hardware module names - display_print((char *)"Display SPI", 50, 50); - display_print((char *)"Touch SPI", 50, 78); - display_print((char *)"Battery Gauge", 50, 106); - display_print((char *)"Lepton I2C", 50, 134); - display_print((char *)"Lepton SPI", 50, 162); + display_print((char *)"Display", 50, 50); + display_print((char *)"Touch", 50, 85); + display_print((char *)"Battery Gauge", 50, 120); + display_print((char *)"FLIR Lepton", 50, 155); display_print((char *)"SD card", 50, 190); //Check display SPI @@ -163,27 +162,21 @@ void showDiagnostic() //Check touch SPI if (checkDiagnostic(diag_touch)) - display_print((char *)"OK ", 220, 78); + display_print((char *)"OK ", 220, 85); else - display_print((char *)"Failed", 220, 78); + display_print((char *)"Failed", 220, 85); //Check battery gauge if (checkDiagnostic(diag_bat)) - display_print((char *)"OK ", 220, 106); + display_print((char *)"OK ", 220, 120); else - display_print((char *)"Failed", 220, 106); + display_print((char *)"Failed", 220, 120); - //Check lepton I2C - if (checkDiagnostic(diag_lep_conf)) - display_print((char *)"OK ", 220, 134); + //Check FLIR Lepton + if (checkDiagnostic(diag_lepton)) + display_print((char *)"OK ", 220, 155); else - display_print((char *)"Failed", 220, 134); - - //Check lepton SPI - if (checkDiagnostic(diag_lep_data)) - display_print((char *)"OK ", 220, 162); - else - display_print((char *)"Failed", 220, 162); + display_print((char *)"Failed", 220, 155); //Check sd card if (checkDiagnostic(diag_sd)) @@ -191,11 +184,12 @@ void showDiagnostic() else display_print((char *)"Failed", 220, 190); - //Wait until touch - while (!touch_touched()) + //Show hint + display_print((char *)"Touch to continue", CENTER, 220); - //Show hint - display_print((char *)"Touch to continue (may freeze)", CENTER, 220); + //Wait until touch + while (!touch_touched()); + showFullMessage((char*) "Trying to continue boot, may freeze.."); } /* Draw the Boot screen */ diff --git a/Firmware_V3/src/hardware/connection.cpp b/Firmware_V3/src/hardware/connection.cpp index 824e358..43a5999 100644 --- a/Firmware_V3/src/hardware/connection.cpp +++ b/Firmware_V3/src/hardware/connection.cpp @@ -1021,11 +1021,8 @@ void serialOutput() break; //Get the temps - if (checkDiagnostic(diag_lep_data)) - { - lepton_startFrame(); - lepton_getFrame(); - } + lepton_startFrame(); + lepton_getFrame(); //Get the spot temperature getSpotTemp(); diff --git a/Firmware_V3/src/hardware/lepton.cpp b/Firmware_V3/src/hardware/lepton.cpp index 5db46c2..5784db9 100644 --- a/Firmware_V3/src/hardware/lepton.cpp +++ b/Firmware_V3/src/hardware/lepton.cpp @@ -71,7 +71,7 @@ void lepton_endFrame() /* Start Lepton SPI Transmission */ void lepton_begin() { - SPI1.beginTransaction(SPISettings(25000000, MSBFIRST, SPI_MODE1)); + SPI1.beginTransaction(SPISettings(30000000, MSBFIRST, SPI_MODE1)); digitalWriteFast(pin_lepton_cs, LOW); } @@ -208,34 +208,6 @@ void lepton_getFrame() } } -/* Get one line package from the Lepton */ -LeptonReadError lepton_getPacketSync(uint8_t line, uint8_t seg) -{ - //Receive one frame over SPI - SPI1.transfer(lepton_packet, 164); - - //Repeat as long as the frame is not valid, equals sync - if ((lepton_packet[0] & 0x0F) == 0x0F) - return DISCARD; - - //Check if the line number matches the expected line - if (lepton_packet[1] != line) - return ROW_ERROR; - - //For the Lepton3.5, check if the segment number matches - if ((line == 20) && (leptonVersion == leptonVersion_3_5_shutter)) - { - byte segment = (lepton_packet[0] >> 4); - if (segment == 0) - return SEGMENT_INVALID; - if (segment != seg) - return SEGMENT_ERROR; - } - - //Everything worked - return NONE; -} - /* Get one line package from the Lepton */ bool lepton_getPacketAsync(uint8_t *line, uint8_t *seg) { @@ -460,8 +432,11 @@ byte lepton_i2cWriteDataRegister(byte *data, int length) byte lepton_i2c_execute_command(byte cmdbyte0, byte cmdbyte1) { // Wait for execution of the command - while (lepton_readReg(0x2) & 0x01) + long timer = millis(); + while ((lepton_readReg(0x2) & 0x01) && ((millis() - timer) < 1000)) ; + if ((millis() - timer) >= 1000) + return 1; Wire.beginTransmission(0x2A); Wire.write(0x00); @@ -524,10 +499,7 @@ float lepton_spotTemp() //Lepton I2C error, set diagnostic if (error != 0) - { - setDiagnostic(diag_lep_conf); return 0; - } //Transfer the new package Wire.beginTransmission(0x2A); @@ -606,12 +578,9 @@ bool lepton_version() // 0x0800 (SDK Module ID) + 0x1C (SDK Command ID) + 0x0 (GET operation) + 0x4000 (Protection Bit) = 0x481C byte error = lepton_i2c_execute_command(0x48, 0x1C); - //Lepton I2C error, set diagnostic + //Lepton I2C error if (error != 0) - { - setDiagnostic(diag_lep_conf); return false; - } char leptonhw[33]; lepton_i2cReadDataRegister((byte *)leptonhw, 32); @@ -836,18 +805,10 @@ bool lepton_spiCheck() /* Init the FLIR Lepton LWIR sensor */ void lepton_init() { - //Check if SPI connection to Lepton works - if (!lepton_spiCheck()) - { - setDiagnostic(diag_lep_data); - setDiagnostic(diag_lep_conf); - return; - } - //Check the Lepton version if (!lepton_version()) { - setDiagnostic(diag_lep_conf); + setDiagnostic(diag_lepton); return; }