Skip to content

Commit

Permalink
Updated firmware to version 3.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
maxritter committed May 8, 2021
1 parent c3c3481 commit 3be5cba
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 89 deletions.
3 changes: 1 addition & 2 deletions Firmware_V3/include/globaldefines.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 0 additions & 11 deletions Firmware_V3/include/lepton.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions Firmware_V3/src/general/globalvariables.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
40 changes: 17 additions & 23 deletions Firmware_V3/src/gui/gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -163,39 +162,34 @@ 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))
display_print((char *)"OK ", 220, 190);
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 */
Expand Down
7 changes: 2 additions & 5 deletions Firmware_V3/src/hardware/connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
53 changes: 7 additions & 46 deletions Firmware_V3/src/hardware/lepton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 3be5cba

Please sign in to comment.