Skip to content

Commit 3be5cba

Browse files
author
maxritter
committed
Updated firmware to version 3.0.1
1 parent c3c3481 commit 3be5cba

File tree

6 files changed

+29
-89
lines changed

6 files changed

+29
-89
lines changed

Firmware_V3/include/globaldefines.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,7 @@ extern "C" {
156156
#define diag_touch 1
157157
#define diag_sd 2
158158
#define diag_bat 3
159-
#define diag_lep_conf 4
160-
#define diag_lep_data 5
159+
#define diag_lepton 4
161160
#define diag_ok 255
162161

163162
//Color scheme numbers

Firmware_V3/include/lepton.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,12 @@
1616
#ifndef LEPTON_H
1717
#define LEPTON_H
1818

19-
//Lepton frame error return
20-
enum LeptonReadError
21-
{
22-
NONE,
23-
DISCARD,
24-
SEGMENT_ERROR,
25-
ROW_ERROR,
26-
SEGMENT_INVALID
27-
};
28-
2919
/*########################## PUBLIC PROCEDURES ################################*/
3020

3121
void lepton_begin();
3222
void lepton_end();
3323
bool lepton_ffc(bool message = false, bool switch_gain = false);
3424
void lepton_ffcMode(bool automatic);
35-
LeptonReadError lepton_getPacketSync(uint8_t line, uint8_t seg);
3625
bool lepton_getPacketAsync(uint8_t *line, uint8_t *seg);
3726
void lepton_getFrame();
3827
void lepton_getFrameAsync();

Firmware_V3/src/general/globalvariables.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
/*############################# PUBLIC VARIABLES ##############################*/
2727

2828
//Current firmware version
29-
char versionString[] = "Firmware 3.00 from 01.05.2021";
30-
uint16_t fwVersion = 300;
29+
char versionString[] = "Firmware 3.01 from 08.05.2021";
30+
uint16_t fwVersion = 301;
3131

3232
//320x240 buffer
3333
unsigned short* bigBuffer;

Firmware_V3/src/gui/gui.cpp

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,10 @@ void showDiagnostic()
148148
display_setColor(VGA_BLACK);
149149

150150
//Display hardware module names
151-
display_print((char *)"Display SPI", 50, 50);
152-
display_print((char *)"Touch SPI", 50, 78);
153-
display_print((char *)"Battery Gauge", 50, 106);
154-
display_print((char *)"Lepton I2C", 50, 134);
155-
display_print((char *)"Lepton SPI", 50, 162);
151+
display_print((char *)"Display", 50, 50);
152+
display_print((char *)"Touch", 50, 85);
153+
display_print((char *)"Battery Gauge", 50, 120);
154+
display_print((char *)"FLIR Lepton", 50, 155);
156155
display_print((char *)"SD card", 50, 190);
157156

158157
//Check display SPI
@@ -163,39 +162,34 @@ void showDiagnostic()
163162

164163
//Check touch SPI
165164
if (checkDiagnostic(diag_touch))
166-
display_print((char *)"OK ", 220, 78);
165+
display_print((char *)"OK ", 220, 85);
167166
else
168-
display_print((char *)"Failed", 220, 78);
167+
display_print((char *)"Failed", 220, 85);
169168

170169
//Check battery gauge
171170
if (checkDiagnostic(diag_bat))
172-
display_print((char *)"OK ", 220, 106);
171+
display_print((char *)"OK ", 220, 120);
173172
else
174-
display_print((char *)"Failed", 220, 106);
173+
display_print((char *)"Failed", 220, 120);
175174

176-
//Check lepton I2C
177-
if (checkDiagnostic(diag_lep_conf))
178-
display_print((char *)"OK ", 220, 134);
175+
//Check FLIR Lepton
176+
if (checkDiagnostic(diag_lepton))
177+
display_print((char *)"OK ", 220, 155);
179178
else
180-
display_print((char *)"Failed", 220, 134);
181-
182-
//Check lepton SPI
183-
if (checkDiagnostic(diag_lep_data))
184-
display_print((char *)"OK ", 220, 162);
185-
else
186-
display_print((char *)"Failed", 220, 162);
179+
display_print((char *)"Failed", 220, 155);
187180

188181
//Check sd card
189182
if (checkDiagnostic(diag_sd))
190183
display_print((char *)"OK ", 220, 190);
191184
else
192185
display_print((char *)"Failed", 220, 190);
193186

194-
//Wait until touch
195-
while (!touch_touched())
187+
//Show hint
188+
display_print((char *)"Touch to continue", CENTER, 220);
196189

197-
//Show hint
198-
display_print((char *)"Touch to continue (may freeze)", CENTER, 220);
190+
//Wait until touch
191+
while (!touch_touched());
192+
showFullMessage((char*) "Trying to continue boot, may freeze..");
199193
}
200194

201195
/* Draw the Boot screen */

Firmware_V3/src/hardware/connection.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,11 +1021,8 @@ void serialOutput()
10211021
break;
10221022

10231023
//Get the temps
1024-
if (checkDiagnostic(diag_lep_data))
1025-
{
1026-
lepton_startFrame();
1027-
lepton_getFrame();
1028-
}
1024+
lepton_startFrame();
1025+
lepton_getFrame();
10291026

10301027
//Get the spot temperature
10311028
getSpotTemp();

Firmware_V3/src/hardware/lepton.cpp

Lines changed: 7 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ void lepton_endFrame()
7171
/* Start Lepton SPI Transmission */
7272
void lepton_begin()
7373
{
74-
SPI1.beginTransaction(SPISettings(25000000, MSBFIRST, SPI_MODE1));
74+
SPI1.beginTransaction(SPISettings(30000000, MSBFIRST, SPI_MODE1));
7575
digitalWriteFast(pin_lepton_cs, LOW);
7676
}
7777

@@ -208,34 +208,6 @@ void lepton_getFrame()
208208
}
209209
}
210210

211-
/* Get one line package from the Lepton */
212-
LeptonReadError lepton_getPacketSync(uint8_t line, uint8_t seg)
213-
{
214-
//Receive one frame over SPI
215-
SPI1.transfer(lepton_packet, 164);
216-
217-
//Repeat as long as the frame is not valid, equals sync
218-
if ((lepton_packet[0] & 0x0F) == 0x0F)
219-
return DISCARD;
220-
221-
//Check if the line number matches the expected line
222-
if (lepton_packet[1] != line)
223-
return ROW_ERROR;
224-
225-
//For the Lepton3.5, check if the segment number matches
226-
if ((line == 20) && (leptonVersion == leptonVersion_3_5_shutter))
227-
{
228-
byte segment = (lepton_packet[0] >> 4);
229-
if (segment == 0)
230-
return SEGMENT_INVALID;
231-
if (segment != seg)
232-
return SEGMENT_ERROR;
233-
}
234-
235-
//Everything worked
236-
return NONE;
237-
}
238-
239211
/* Get one line package from the Lepton */
240212
bool lepton_getPacketAsync(uint8_t *line, uint8_t *seg)
241213
{
@@ -460,8 +432,11 @@ byte lepton_i2cWriteDataRegister(byte *data, int length)
460432
byte lepton_i2c_execute_command(byte cmdbyte0, byte cmdbyte1)
461433
{
462434
// Wait for execution of the command
463-
while (lepton_readReg(0x2) & 0x01)
435+
long timer = millis();
436+
while ((lepton_readReg(0x2) & 0x01) && ((millis() - timer) < 1000))
464437
;
438+
if ((millis() - timer) >= 1000)
439+
return 1;
465440

466441
Wire.beginTransmission(0x2A);
467442
Wire.write(0x00);
@@ -524,10 +499,7 @@ float lepton_spotTemp()
524499

525500
//Lepton I2C error, set diagnostic
526501
if (error != 0)
527-
{
528-
setDiagnostic(diag_lep_conf);
529502
return 0;
530-
}
531503

532504
//Transfer the new package
533505
Wire.beginTransmission(0x2A);
@@ -606,12 +578,9 @@ bool lepton_version()
606578
// 0x0800 (SDK Module ID) + 0x1C (SDK Command ID) + 0x0 (GET operation) + 0x4000 (Protection Bit) = 0x481C
607579
byte error = lepton_i2c_execute_command(0x48, 0x1C);
608580

609-
//Lepton I2C error, set diagnostic
581+
//Lepton I2C error
610582
if (error != 0)
611-
{
612-
setDiagnostic(diag_lep_conf);
613583
return false;
614-
}
615584

616585
char leptonhw[33];
617586
lepton_i2cReadDataRegister((byte *)leptonhw, 32);
@@ -836,18 +805,10 @@ bool lepton_spiCheck()
836805
/* Init the FLIR Lepton LWIR sensor */
837806
void lepton_init()
838807
{
839-
//Check if SPI connection to Lepton works
840-
if (!lepton_spiCheck())
841-
{
842-
setDiagnostic(diag_lep_data);
843-
setDiagnostic(diag_lep_conf);
844-
return;
845-
}
846-
847808
//Check the Lepton version
848809
if (!lepton_version())
849810
{
850-
setDiagnostic(diag_lep_conf);
811+
setDiagnostic(diag_lepton);
851812
return;
852813
}
853814

0 commit comments

Comments
 (0)