-
-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathLeptonFLiR.cpp
2349 lines (1919 loc) · 77.8 KB
/
LeptonFLiR.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* Arduino Library for the Lepton FLiR Thermal Camera Module.
Copyright (c) 2016 NachtRaveVL <[email protected]>
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
This permission notice shall be included in all copies or
substantial portions of the Software.
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
NONINFRINGEMENT. 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.
Lepton-FLiR-Arduino - Version 0.9.91
*/
#include "LeptonFLiR.h"
#if (defined(ARDUINO_ARCH_SAM) || defined(ARDUINO_ARCH_SAMD)) && !defined(LEPFLIR_DISABLE_SCHEDULER)
#include "Scheduler.h"
#define LEPFLIR_USE_SCHEDULER 1
#endif
#define LEPFLIR_GEN_CMD_TIMEOUT 5000 // Timeout for commands to be processed
#define LEPFLIR_SPI_MAX_SPEED 20000000 // Maximum SPI speed for FLiR module
#define LEPFLIR_SPI_MIN_SPEED 2200000 // Minimum SPI speed for FLiR module
#define LEPFLIR_SPI_FRAME_PACKET_SIZE 164 // 2B ID + 2B CRC + 160B for 80x1 14bpp/8bppAGC thermal image data or telemetry data
#define LEPFLIR_SPI_FRAME_PACKET_SIZE16 82
#ifndef LEPFLIR_DISABLE_ALIGNED_MALLOC
static inline int roundUpVal16(int val) { return ((val + 15) & -16); }
static inline byte *roundUpPtr16(byte *ptr) { return ptr ? (byte *)(((uintptr_t)ptr + 15) & -16) : NULL; }
static inline byte *roundUpMalloc16(int size) { return (byte *)malloc((size_t)(size + 15)); }
static inline byte *roundUpSpiFrame16(byte *spiFrame) { return spiFrame ? roundUpPtr16(spiFrame) + 16 - 4 : NULL; }
#else
static inline int roundUpVal16(int val) { return val; }
static inline byte *roundUpPtr16(byte *ptr) { return ptr; }
static inline byte *roundUpMalloc16(int size) { return (byte *)malloc((size_t)size); }
static inline byte *roundUpSpiFrame16(byte *spiFrame) { return spiFrame; }
#endif
#ifndef digitalWriteFast
static void csEnableFuncDef(byte pin) { digitalWrite(pin, LOW); }
static void csDisableFuncDef(byte pin) { digitalWrite(pin, HIGH); }
#else
static void csEnableFuncDef(byte pin) { digitalWriteFast(pin, LOW); }
static void csDisableFuncDef(byte pin) { digitalWriteFast(pin, HIGH); }
#endif
#ifndef LEPFLIR_USE_SOFTWARE_I2C
LeptonFLiR::LeptonFLiR(TwoWire& i2cWire, byte spiCSPin) {
_i2cWire = &i2cWire;
#else
LeptonFLiR::LeptonFLiR(byte spiCSPin) {
#endif
_spiCSPin = spiCSPin;
_spiSettings = SPISettings(LEPFLIR_SPI_MAX_SPEED, MSBFIRST, SPI_MODE3);
_storageMode = LeptonFLiR_ImageStorageMode_Count;
_csEnableFunc = csEnableFuncDef;
_csDisableFunc = csDisableFuncDef;
_imageData = _spiFrameData = _telemetryData = NULL;
_isReadingNextFrame = false;
_lastI2CError = _lastLepResult = 0;
}
LeptonFLiR::~LeptonFLiR() {
if (_imageData) free(_imageData);
if (_spiFrameData) free(_spiFrameData);
if (_telemetryData) free(_telemetryData);
}
void LeptonFLiR::init(LeptonFLiR_ImageStorageMode storageMode, LeptonFLiR_TemperatureMode tempMode) {
_storageMode = (LeptonFLiR_ImageStorageMode)constrain((int)storageMode, 0, (int)LeptonFLiR_ImageStorageMode_Count - 1);
_tempMode = (LeptonFLiR_TemperatureMode)constrain((int)tempMode, 0, (int)LeptonFLiR_TemperatureMode_Count - 1);
#ifdef LEPFLIR_ENABLE_DEBUG_OUTPUT
Serial.print("LeptonFLiR::init spiCSPin: ");
Serial.print(_spiCSPin);
Serial.print(", storageMode: ");
Serial.print(_storageMode);
Serial.print(", tempMode: ");
Serial.println(_tempMode);
#endif
pinMode(_spiCSPin, OUTPUT);
_csDisableFunc(_spiCSPin);
_imageData = roundUpMalloc16(getImageTotalBytes());
#ifdef LEPFLIR_ENABLE_DEBUG_OUTPUT
if (!_imageData)
Serial.println(" LeptonFLiR::init Failure allocating imageData.");
#endif
_spiFrameData = roundUpMalloc16(getSPIFrameTotalBytes());
#ifdef LEPFLIR_ENABLE_DEBUG_OUTPUT
if (!_spiFrameData)
Serial.println(" LeptonFLiR::init Failure allocating spiFrameData.");
#endif
#ifdef LEPFLIR_ENABLE_DEBUG_OUTPUT
int mallocOffset = 0;
#ifndef LEPFLIR_DISABLE_ALIGNED_MALLOC
mallocOffset = 15;
#endif
Serial.print(" LeptonFLiR::init imageData: ");
Serial.print(_imageData ? getImageTotalBytes() + mallocOffset : 0);
Serial.print("B, spiFrameData: ");
Serial.print(_spiFrameData ? getSPIFrameTotalBytes() + mallocOffset : 0);
Serial.print("B, total: ");
Serial.print((_imageData ? getImageTotalBytes() + mallocOffset : 0) + (_spiFrameData ? getSPIFrameTotalBytes() + mallocOffset : 0));
Serial.println("B");
Serial.print(" LeptonFLiR::init SPIPortSpeed: ");
for (int divisor = 2; divisor <= 128; divisor *= 2) {
if (F_CPU / (float)divisor <= LEPFLIR_SPI_MAX_SPEED + 0.00001f || divisor == 128) {
Serial.print(roundf((F_CPU / (float)divisor) / 1000.0f) / 1000.0f);
Serial.print("MHz (SPI_CLOCK_DIV");
Serial.print(divisor);
Serial.print(")");
break;
}
}
if (F_CPU / 2.0f < LEPFLIR_SPI_MIN_SPEED - 0.00001f)
Serial.println(" <speed too low>");
else if (F_CPU / 128.0f > LEPFLIR_SPI_MAX_SPEED + 0.00001f)
Serial.println(" <speed too high>");
else
Serial.println("");
#endif
}
byte LeptonFLiR::getChipSelectPin() {
return _spiCSPin;
}
LeptonFLiR_ImageStorageMode LeptonFLiR::getImageStorageMode() {
return _storageMode;
}
LeptonFLiR_TemperatureMode LeptonFLiR::getTemperatureMode() {
return _tempMode;
}
void LeptonFLiR::setFastCSFuncs(digitalWriteFunc csEnableFunc, digitalWriteFunc csDisableFunc) {
_csEnableFunc = csEnableFunc ? : csEnableFuncDef;
_csDisableFunc = csDisableFunc ? : csDisableFuncDef;
}
int LeptonFLiR::getImageWidth() {
switch (_storageMode) {
case LeptonFLiR_ImageStorageMode_80x60_16bpp:
case LeptonFLiR_ImageStorageMode_80x60_8bpp:
return 80;
case LeptonFLiR_ImageStorageMode_40x30_16bpp:
case LeptonFLiR_ImageStorageMode_40x30_8bpp:
return 40;
case LeptonFLiR_ImageStorageMode_20x15_16bpp:
case LeptonFLiR_ImageStorageMode_20x15_8bpp:
return 20;
default:
return 0;
}
}
int LeptonFLiR::getImageHeight() {
switch (_storageMode) {
case LeptonFLiR_ImageStorageMode_80x60_16bpp:
case LeptonFLiR_ImageStorageMode_80x60_8bpp:
return 60;
case LeptonFLiR_ImageStorageMode_40x30_16bpp:
case LeptonFLiR_ImageStorageMode_40x30_8bpp:
return 30;
case LeptonFLiR_ImageStorageMode_20x15_16bpp:
case LeptonFLiR_ImageStorageMode_20x15_8bpp:
return 15;
default:
return 0;
}
}
int LeptonFLiR::getImageBpp() {
switch (_storageMode) {
case LeptonFLiR_ImageStorageMode_80x60_16bpp:
case LeptonFLiR_ImageStorageMode_40x30_16bpp:
case LeptonFLiR_ImageStorageMode_20x15_16bpp:
return 2;
case LeptonFLiR_ImageStorageMode_80x60_8bpp:
case LeptonFLiR_ImageStorageMode_40x30_8bpp:
case LeptonFLiR_ImageStorageMode_20x15_8bpp:
return 1;
default:
return 0;
}
}
int LeptonFLiR::getImagePitch() {
switch (_storageMode) {
case LeptonFLiR_ImageStorageMode_80x60_16bpp:
return roundUpVal16(80 * 2);
case LeptonFLiR_ImageStorageMode_80x60_8bpp:
return roundUpVal16(80 * 1);
case LeptonFLiR_ImageStorageMode_40x30_16bpp:
return roundUpVal16(40 * 2);
case LeptonFLiR_ImageStorageMode_40x30_8bpp:
return roundUpVal16(40 * 1);
case LeptonFLiR_ImageStorageMode_20x15_16bpp:
return roundUpVal16(20 * 2);
case LeptonFLiR_ImageStorageMode_20x15_8bpp:
return roundUpVal16(20 * 1);
default:
return 0;
}
}
int LeptonFLiR::getImageTotalBytes() {
return ((getImageHeight() - 1) * getImagePitch()) + (getImageWidth() * getImageBpp());
}
byte *LeptonFLiR::getImageData() {
return !_isReadingNextFrame && _imageData ? roundUpPtr16(_imageData) : NULL;
}
byte *LeptonFLiR::getImageDataRow(int row) {
return !_isReadingNextFrame && _imageData ? (roundUpPtr16(_imageData) + (row * getImagePitch())) : NULL;
}
byte *LeptonFLiR::_getImageDataRow(int row) {
return _imageData ? roundUpPtr16(_imageData) + (getImagePitch() * row) : NULL;
}
uint16_t LeptonFLiR::getImageDataRowCol(int row, int col) {
if (_isReadingNextFrame || !_imageData) return 0;
byte *imageData = roundUpPtr16(_imageData) + (row * getImagePitch()) + (col * getImageBpp());
return getImageBpp() == 2 ? *((uint16_t *)imageData) : (uint16_t)(*imageData);
}
byte *LeptonFLiR::getTelemetryData() {
return !_isReadingNextFrame && _telemetryData && !(*((uint16_t *)_telemetryData) & 0x0F00 == 0x0F00) ? _telemetryData : NULL;
}
void LeptonFLiR::getTelemetryData(TelemetryData *telemetry) {
if (_isReadingNextFrame || !_telemetryData || !telemetry) return;
uint16_t *telemetryData = (uint16_t *)&_telemetryData[4];
telemetry->revisionMajor = lowByte(telemetryData[0]);
telemetry->revisionMinor = highByte(telemetryData[0]);
telemetry->cameraUptime = ((uint32_t)telemetryData[1] << 16) | (uint32_t)telemetryData[2];
telemetry->ffcDesired = telemetryData[4] & 0x0004;
uint_fast8_t ffcState = (telemetryData[4] & 0x0018) >> 3;
if (telemetry->revisionMajor >= 9 && ffcState >= 1)
ffcState -= 1;
telemetry->ffcState = (TelemetryData_FFCState)ffcState;
telemetry->agcEnabled = telemetryData[4] & 0x0800;
telemetry->shutdownImminent = telemetryData[3] & 0x0010;
wordsToHexString(&telemetryData[5], 8, telemetry->serialNumber, 24);
wordsToHexString(&telemetryData[13], 4, telemetry->softwareRevision, 12);
telemetry->frameCounter = ((uint32_t)telemetryData[20] << 16) | (uint32_t)telemetryData[21];
telemetry->frameMean = telemetryData[22];
telemetry->fpaTemperature = kelvin100ToTemperature(telemetryData[24]);
telemetry->housingTemperature = kelvin100ToTemperature(telemetryData[26]);
telemetry->lastFFCTime = ((uint32_t)telemetryData[30] << 16) | (uint32_t)telemetryData[31];
telemetry->fpaTempAtLastFFC = kelvin100ToTemperature(telemetryData[29]);
telemetry->housingTempAtLastFFC = kelvin100ToTemperature(telemetryData[32]);
telemetry->agcRegion.startRow = telemetryData[34];
telemetry->agcRegion.startCol = telemetryData[35];
telemetry->agcRegion.endCol = telemetryData[36];
telemetry->agcRegion.endRow = telemetryData[37];
telemetry->agcClipHigh = telemetryData[38];
telemetry->agcClipLow = telemetryData[39];
telemetry->log2FFCFrames = telemetryData[74];
}
uint32_t LeptonFLiR::getTelemetryFrameCounter() {
if (_isReadingNextFrame || !_telemetryData) return 0;
uint16_t *telemetryData = (uint16_t *)&_telemetryData[4];
return ((uint32_t)telemetryData[20] << 16) | (uint32_t)telemetryData[21];
}
bool LeptonFLiR::getShouldRunFFCNormalization() {
if (_isReadingNextFrame || !_telemetryData) return false;
uint16_t *telemetryData = (uint16_t *)&_telemetryData[4];
uint_fast8_t ffcState = (telemetryData[4] & 0x0018) >> 3;
if (lowByte(telemetryData[0]) >= 9 && ffcState >= 1)
ffcState -= 1;
return (telemetryData[4] & 0x0004) && ffcState != (uint_fast8_t)TelemetryData_FFCState_InProgress;
}
int LeptonFLiR::getSPIFrameLines() {
switch (_storageMode) {
case LeptonFLiR_ImageStorageMode_80x60_16bpp:
case LeptonFLiR_ImageStorageMode_80x60_8bpp:
return 1;
case LeptonFLiR_ImageStorageMode_40x30_16bpp:
case LeptonFLiR_ImageStorageMode_40x30_8bpp:
return 2;
case LeptonFLiR_ImageStorageMode_20x15_16bpp:
case LeptonFLiR_ImageStorageMode_20x15_8bpp:
return 4;
default:
return 0;
}
}
int LeptonFLiR::getSPIFrameTotalBytes() {
return getSPIFrameLines() * roundUpVal16(LEPFLIR_SPI_FRAME_PACKET_SIZE);
}
uint16_t *LeptonFLiR::getSPIFrameDataRow(int row) {
return (uint16_t *)(roundUpSpiFrame16(_spiFrameData) + (row * roundUpVal16(LEPFLIR_SPI_FRAME_PACKET_SIZE)));
}
#ifdef LEPFLIR_ENABLE_DEBUG_OUTPUT
static void printSPIFrame(uint16_t *spiFrame) {
Serial.print("ID: 0x");
Serial.print(spiFrame[0], HEX);
Serial.print(" CRC: 0x");
Serial.print(spiFrame[1], HEX);
Serial.print(" Data: ");
for (int i = 0; i < 5; ++i) {
Serial.print(i > 0 ? "-0x" : "0x");
Serial.print(spiFrame[i + 2], HEX);
}
Serial.print("...");
for (int i = 75; i < 80; ++i) {
Serial.print(i > 75 ? "-0x" : "0x");
Serial.print(spiFrame[i + 2], HEX);
}
Serial.println("");
}
#endif
static void delayTimeout(int timeout) {
unsigned long endTime = millis() + (unsigned long)timeout;
while (millis() < endTime) {
#ifdef LEPFLIR_USE_SCHEDULER
Scheduler.yield();
#else
delay(1);
#endif
}
}
static void SPI_transfer16(uint16_t *buffer, int count) {
while (count-- > 0)
*buffer++ = SPI.transfer16(0x0000);
}
static void SPI_ignore16(int count) {
while (count-- > 0)
SPI.transfer16(0x0000);
}
//#define LEPFLIR_ENABLE_FRAME_PACKET_DEBUG_OUTPUT 1
bool LeptonFLiR::readNextFrame() {
if (!_isReadingNextFrame) {
_isReadingNextFrame = true;
#ifdef LEPFLIR_ENABLE_DEBUG_OUTPUT
Serial.println("LeptonFLiR::readNextFrame");
#endif
bool agc8Enabled;
LEP_SYS_TELEMETRY_LOCATION telemetryLocation;
{ bool telemetryEnabled, cameraBooted, stateErrors = false;
uint32_t value = 0;
receiveCommand(cmdCode(LEP_CID_AGC_ENABLE_STATE, LEP_I2C_COMMAND_TYPE_GET), &value);
agc8Enabled = value;
stateErrors = stateErrors || _lastI2CError || _lastLepResult;
if (agc8Enabled) {
receiveCommand(cmdCode(LEP_CID_AGC_HEQ_SCALE_FACTOR, LEP_I2C_COMMAND_TYPE_GET), &value);
agc8Enabled = (value == (uint32_t)LEP_AGC_SCALE_TO_8_BITS);
stateErrors = stateErrors || _lastI2CError || _lastLepResult;
}
receiveCommand(cmdCode(LEP_CID_SYS_TELEMETRY_ENABLE_STATE, LEP_I2C_COMMAND_TYPE_GET), &value);
telemetryEnabled = value;
stateErrors = stateErrors || _lastI2CError || _lastLepResult;
if (telemetryEnabled) {
receiveCommand(cmdCode(LEP_CID_SYS_TELEMETRY_LOCATION, LEP_I2C_COMMAND_TYPE_GET), &value);
telemetryLocation = (LEP_SYS_TELEMETRY_LOCATION)value;
stateErrors = stateErrors || _lastI2CError || _lastLepResult;
}
uint16_t status; readRegister(LEP_I2C_STATUS_REG, &status);
#ifdef LEPFLIR_ENABLE_DEBUG_OUTPUT
checkForErrors();
#endif
cameraBooted = (status & LEP_I2C_STATUS_BOOT_MODE_BIT_MASK) && (status & LEP_I2C_STATUS_BOOT_STATUS_BIT_MASK);
stateErrors = stateErrors || _lastI2CError || _lastLepResult;
if (stateErrors) {
#ifdef LEPFLIR_ENABLE_DEBUG_OUTPUT
Serial.println(" LeptonFLiR::readNextFrame Errors reading state encountered. Aborting.");
#endif
_isReadingNextFrame = false;
return false;
}
if (!cameraBooted) {
#ifdef LEPFLIR_ENABLE_DEBUG_OUTPUT
Serial.println(" LeptonFLiR::readNextFrame Camera has not yet booted. Aborting.");
#endif
_isReadingNextFrame = false;
return false;
}
if (telemetryEnabled && !_telemetryData) {
_telemetryData = (byte *)malloc(LEPFLIR_SPI_FRAME_PACKET_SIZE);
if (_telemetryData)
_telemetryData[0] = _telemetryData[1] = 0xFF; // initialize as discard packet
#ifdef LEPFLIR_ENABLE_DEBUG_OUTPUT
if (!_telemetryData)
Serial.println(" LeptonFLiR::readNextFrame Failure allocating telemetryData.");
#endif
}
else if (!telemetryEnabled && _telemetryData) {
free(_telemetryData);
_telemetryData = NULL;
}
}
#ifdef LEPFLIR_ENABLE_DEBUG_OUTPUT
Serial.print(" LeptonFLiR::readNextFrame AGC-8bit: ");
Serial.print(agc8Enabled ? "enabled" : "disabled");
Serial.print(", Telemetry: ");
if (_telemetryData) {
Serial.print("enabled, Location: ");
Serial.println(telemetryLocation == LEP_TELEMETRY_LOCATION_HEADER ? "header" : "footer");
}
else
Serial.println("disabled");
#endif
uint16_t *spiFrame = NULL;
uint_fast8_t imgRows = getImageHeight();
uint_fast8_t currImgRow = 0;
uint_fast8_t spiRows = getSPIFrameLines();
uint_fast8_t currSpiRow = 0;
uint_fast8_t teleRows = (_telemetryData ? 4 : 0);
uint_fast8_t currTeleRow = 0;
uint_fast8_t currReadRow = 0;
uint_fast8_t framesSkipped = 0;
uint_fast8_t currRow = 0;
bool skipFrame = false;
bool spiPacketRead = false;
SPI.beginTransaction(_spiSettings);
_csEnableFunc(_spiCSPin);
_csDisableFunc(_spiCSPin);
delayTimeout(185);
_csEnableFunc(_spiCSPin);
while (currImgRow < imgRows || currTeleRow < teleRows) {
if (!spiPacketRead) {
spiFrame = getSPIFrameDataRow(currSpiRow);
SPI_transfer16(spiFrame, LEPFLIR_SPI_FRAME_PACKET_SIZE16);
skipFrame = ((spiFrame[0] & 0x0F00) == 0x0F00);
currRow = (spiFrame[0] & 0x00FF);
}
else
spiPacketRead = false;
if (!skipFrame && currRow == currReadRow && (
((!teleRows || telemetryLocation == LEP_TELEMETRY_LOCATION_FOOTER) && currRow < 60) ||
(telemetryLocation == LEP_TELEMETRY_LOCATION_HEADER && currReadRow >= teleRows))) { // Image packet
#if defined(LEPFLIR_ENABLE_DEBUG_OUTPUT) && defined(LEPFLIR_ENABLE_FRAME_PACKET_DEBUG_OUTPUT)
Serial.println(" LeptonFLiR::readNextFrame VoSPI Image Packet:");
Serial.print(" "); printSPIFrame(spiFrame);
#endif
++currReadRow; ++currSpiRow;
}
else if (!skipFrame && currRow == currReadRow && teleRows &&
((telemetryLocation == LEP_TELEMETRY_LOCATION_HEADER && currReadRow < teleRows) ||
(telemetryLocation == LEP_TELEMETRY_LOCATION_FOOTER && currReadRow >= 60))) { // Telemetry packet
if (currTeleRow == 0)
memcpy(_telemetryData, spiFrame, LEPFLIR_SPI_FRAME_PACKET_SIZE);
#if defined(LEPFLIR_ENABLE_DEBUG_OUTPUT) && defined(LEPFLIR_ENABLE_FRAME_PACKET_DEBUG_OUTPUT)
Serial.print(" LeptonFLiR::readNextFrame VoSPI Telemetry(");
Serial.print((char)('A' + currTeleRow));
Serial.println(") Packet:");
Serial.print(" "); printSPIFrame(spiFrame);
#endif
++currReadRow; ++currTeleRow;
}
else if (!skipFrame && currRow < currReadRow) { // Ignore packet
#if defined(LEPFLIR_ENABLE_DEBUG_OUTPUT) && defined(LEPFLIR_ENABLE_FRAME_PACKET_DEBUG_OUTPUT)
Serial.println(" LeptonFLiR::readNextFrame VoSPI Ignore Packet:");
Serial.print(" "); printSPIFrame(spiFrame);
#endif
}
else { // Discard packet
#if defined(LEPFLIR_ENABLE_DEBUG_OUTPUT) && defined(LEPFLIR_ENABLE_FRAME_PACKET_DEBUG_OUTPUT)
Serial.println(" LeptonFLiR::readNextFrame VoSPI Discard Packet:");
Serial.print(" "); printSPIFrame(spiFrame);
#endif
if (skipFrame && (currReadRow || framesSkipped)) {
_csDisableFunc(_spiCSPin);
delayTimeout(185);
_csEnableFunc(_spiCSPin);
}
uint_fast8_t triesLeft = 120;
spiPacketRead = true;
while (triesLeft > 0) {
SPI_transfer16(spiFrame, LEPFLIR_SPI_FRAME_PACKET_SIZE16);
skipFrame = ((spiFrame[0] & 0x0F00) == 0x0F00);
currRow = (spiFrame[0] & 0x00FF);
if (!skipFrame) {
if (currRow == currReadRow) { // Reestablished sync at position we're next expecting
break;
}
else if (currRow == 0) { // Reestablished sync at next frame position
if ((currReadRow || framesSkipped) && ++framesSkipped >= 5) {
#ifdef LEPFLIR_ENABLE_DEBUG_OUTPUT
Serial.println(" LeptonFLiR::readNextFrame Maximum frame skip reached. Aborting.");
#endif
_csDisableFunc(_spiCSPin);
SPI.endTransaction();
_isReadingNextFrame = false;
return false;
}
else {
currReadRow = currImgRow = currSpiRow = currTeleRow = 0;
uint16_t* prevSPIFrame = spiFrame;
spiFrame = getSPIFrameDataRow(currSpiRow);
if (spiFrame != prevSPIFrame)
memcpy(spiFrame, prevSPIFrame, LEPFLIR_SPI_FRAME_PACKET_SIZE);
break;
}
}
}
#if defined(LEPFLIR_ENABLE_DEBUG_OUTPUT) && defined(LEPFLIR_ENABLE_FRAME_PACKET_DEBUG_OUTPUT)
Serial.println(" LeptonFLiR::readNextFrame VoSPI Discard Retry Packet:");
Serial.print(" "); printSPIFrame(spiFrame);
#endif
--triesLeft;
}
if (triesLeft == 0) {
#ifdef LEPFLIR_ENABLE_DEBUG_OUTPUT
Serial.println(" LeptonFLiR::readNextFrame Maximum resync retries reached. Aborting.");
#endif
_csDisableFunc(_spiCSPin);
SPI.endTransaction();
_isReadingNextFrame = false;
return false;
}
}
// Write out to frame
if (currSpiRow == spiRows) {
if (_storageMode == LeptonFLiR_ImageStorageMode_80x60_16bpp) {
memcpy(_getImageDataRow(currImgRow), getSPIFrameDataRow(0) + 2, LEPFLIR_SPI_FRAME_PACKET_SIZE - 4);
}
else if (_storageMode == LeptonFLiR_ImageStorageMode_80x60_8bpp && agc8Enabled) {
byte *pxlData = _getImageDataRow(currImgRow);
spiFrame = getSPIFrameDataRow(0) + 2;
uint_fast8_t size = LEPFLIR_SPI_FRAME_PACKET_SIZE16 - 2;
while (size--)
*pxlData++ = (byte)constrain(*spiFrame++, 0, 0x00FF);
}
else {
spiFrame = getSPIFrameDataRow(0) + 2;
byte *pxlData = _getImageDataRow(currImgRow);
uint_fast8_t imgWidth = getImageWidth();
uint_fast8_t imgBpp = getImageBpp();
uint_fast8_t spiPitch16 = roundUpVal16(LEPFLIR_SPI_FRAME_PACKET_SIZE) / 2;
uint_fast32_t divisor = (spiRows * spiRows) * (!agc8Enabled && imgBpp == 1 ? 64 : 1);
uint_fast32_t clamp = (!agc8Enabled && imgBpp == 2 ? 0x3FFF : 0x00FF);
while (imgWidth-- > 0) {
uint_fast32_t total = 0;
uint_fast8_t y = spiRows;
uint16_t *spiYFrame = spiFrame;
while (y-- > 0) {
uint_fast8_t x = spiRows;
uint16_t *spiXFrame = spiYFrame;
while (x-- > 0)
total += *spiXFrame++;
spiYFrame += spiPitch16;
}
total /= divisor;
if (imgBpp == 2)
*((uint16_t *)pxlData) = (uint16_t)constrain(total, 0, clamp);
else
*((byte *)pxlData) = (byte)constrain(total, 0, clamp);
pxlData += imgBpp;
spiFrame += spiRows;
}
}
++currImgRow; currSpiRow = 0;
}
}
SPI.endTransaction();
_isReadingNextFrame = false;
}
return true;
}
void LeptonFLiR::agc_setAGCEnabled(bool enabled) {
#ifdef LEPFLIR_ENABLE_DEBUG_OUTPUT
Serial.println("LeptonFLiR::agc_setAGCEnabled");
#endif
sendCommand(cmdCode(LEP_CID_AGC_ENABLE_STATE, LEP_I2C_COMMAND_TYPE_SET), (uint32_t)enabled);
}
bool LeptonFLiR::agc_getAGCEnabled() {
#ifdef LEPFLIR_ENABLE_DEBUG_OUTPUT
Serial.println("LeptonFLiR::agc_getAGCEnabled");
#endif
uint32_t enabled;
receiveCommand(cmdCode(LEP_CID_AGC_ENABLE_STATE, LEP_I2C_COMMAND_TYPE_GET), &enabled);
return enabled;
}
void LeptonFLiR::agc_setAGCPolicy(LEP_AGC_POLICY policy) {
#ifdef LEPFLIR_ENABLE_DEBUG_OUTPUT
Serial.println("LeptonFLiR::agc_setAGCPolicy");
#endif
sendCommand(cmdCode(LEP_CID_AGC_POLICY, LEP_I2C_COMMAND_TYPE_SET), (uint32_t)policy);
}
LEP_AGC_POLICY LeptonFLiR::agc_getAGCPolicy() {
#ifdef LEPFLIR_ENABLE_DEBUG_OUTPUT
Serial.println("LeptonFLiR::agc_getAGCPolicy");
#endif
uint32_t policy;
receiveCommand(cmdCode(LEP_CID_AGC_POLICY, LEP_I2C_COMMAND_TYPE_GET), &policy);
return (LEP_AGC_POLICY)policy;
}
void LeptonFLiR::agc_setHEQScaleFactor(LEP_AGC_HEQ_SCALE_FACTOR factor) {
#ifdef LEPFLIR_ENABLE_DEBUG_OUTPUT
Serial.println("LeptonFLiR::agc_setHEQScaleFactor");
#endif
sendCommand(cmdCode(LEP_CID_AGC_HEQ_SCALE_FACTOR, LEP_I2C_COMMAND_TYPE_SET), (uint32_t)factor);
}
LEP_AGC_HEQ_SCALE_FACTOR LeptonFLiR::agc_getHEQScaleFactor() {
#ifdef LEPFLIR_ENABLE_DEBUG_OUTPUT
Serial.println("LeptonFLiR::agc_getHEQScaleFactor");
#endif
uint32_t factor;
receiveCommand(cmdCode(LEP_CID_AGC_HEQ_SCALE_FACTOR, LEP_I2C_COMMAND_TYPE_GET), &factor);
return (LEP_AGC_HEQ_SCALE_FACTOR)factor;
}
void LeptonFLiR::agc_setAGCCalcEnabled(bool enabled) {
#ifdef LEPFLIR_ENABLE_DEBUG_OUTPUT
Serial.println("LeptonFLiR::agc_setAGCCalcEnabled");
#endif
sendCommand(cmdCode(LEP_CID_AGC_CALC_ENABLE_STATE, LEP_I2C_COMMAND_TYPE_SET), (uint32_t)enabled);
}
bool LeptonFLiR::agc_getAGCCalcEnabled() {
#ifdef LEPFLIR_ENABLE_DEBUG_OUTPUT
Serial.println("LeptonFLiR::agc_getAGCCalcEnabled");
#endif
uint32_t enabled;
receiveCommand(cmdCode(LEP_CID_AGC_CALC_ENABLE_STATE, LEP_I2C_COMMAND_TYPE_GET), &enabled);
return enabled;
}
void LeptonFLiR::sys_getCameraStatus(LEP_SYS_CAM_STATUS *status) {
#ifdef LEPFLIR_ENABLE_DEBUG_OUTPUT
Serial.println("LeptonFLiR::sys_getCameraStatus");
#endif
receiveCommand(cmdCode(LEP_CID_SYS_CAM_STATUS, LEP_I2C_COMMAND_TYPE_GET), (uint16_t *)status, sizeof(LEP_SYS_CAM_STATUS) / 2);
}
LEP_SYS_CAM_STATUS_STATES LeptonFLiR::sys_getCameraStatus() {
LEP_SYS_CAM_STATUS camStatus;
sys_getCameraStatus(&camStatus);
return (LEP_SYS_CAM_STATUS_STATES)camStatus.camStatus;
}
void LeptonFLiR::sys_getFlirSerialNumber(char *buffer, int maxLength) {
if (!buffer || maxLength < 16) return;
#ifdef LEPFLIR_ENABLE_DEBUG_OUTPUT
Serial.println("LeptonFLiR::sys_getFlirSerialNumber");
#endif
uint16_t innerBuffer[4];
receiveCommand(cmdCode(LEP_CID_SYS_FLIR_SERIAL_NUMBER, LEP_I2C_COMMAND_TYPE_GET), innerBuffer, 4);
wordsToHexString(innerBuffer, 4, buffer, maxLength);
}
void LeptonFLiR::sys_getCustomerSerialNumber(char *buffer, int maxLength) {
if (!buffer || maxLength < 64) return;
#ifdef LEPFLIR_ENABLE_DEBUG_OUTPUT
Serial.println("LeptonFLiR::sys_getCustomerSerialNumber");
#endif
uint16_t innerBuffer[16];
receiveCommand(cmdCode(LEP_CID_SYS_CUST_SERIAL_NUMBER, LEP_I2C_COMMAND_TYPE_GET), innerBuffer, 16);
wordsToHexString(innerBuffer, 16, buffer, maxLength);
}
uint32_t LeptonFLiR::sys_getCameraUptime() {
#ifdef LEPFLIR_ENABLE_DEBUG_OUTPUT
Serial.println("LeptonFLiR::sys_getCameraUptime");
#endif
uint32_t uptime;
receiveCommand(cmdCode(LEP_CID_SYS_CAM_UPTIME, LEP_I2C_COMMAND_TYPE_GET), &uptime);
return uptime;
}
float LeptonFLiR::sys_getAuxTemperature() {
#ifdef LEPFLIR_ENABLE_DEBUG_OUTPUT
Serial.println("LeptonFLiR::sys_getAuxTemperature");
#endif
uint16_t kelvin100;
receiveCommand(cmdCode(LEP_CID_SYS_AUX_TEMPERATURE_KELVIN, LEP_I2C_COMMAND_TYPE_GET), &kelvin100);
return kelvin100ToTemperature(kelvin100);
}
float LeptonFLiR::sys_getFPATemperature() {
#ifdef LEPFLIR_ENABLE_DEBUG_OUTPUT
Serial.println("LeptonFLiR::sys_getFPATemperature");
#endif
uint16_t kelvin100;
receiveCommand(cmdCode(LEP_CID_SYS_FPA_TEMPERATURE_KELVIN, LEP_I2C_COMMAND_TYPE_GET), &kelvin100);
return kelvin100ToTemperature(kelvin100);
}
void LeptonFLiR::sys_setTelemetryEnabled(bool enabled) {
#ifdef LEPFLIR_ENABLE_DEBUG_OUTPUT
Serial.println("LeptonFLiR::sys_setTelemetryEnabled");
#endif
sendCommand(cmdCode(LEP_CID_SYS_TELEMETRY_ENABLE_STATE, LEP_I2C_COMMAND_TYPE_SET), (uint32_t)enabled);
if (!_lastI2CError && !_lastLepResult) {
if (enabled && !_telemetryData) {
_telemetryData = (byte *)malloc(LEPFLIR_SPI_FRAME_PACKET_SIZE);
if (_telemetryData)
_telemetryData[0] = _telemetryData[1] = 0xFF; // initialize as discard packet
#ifdef LEPFLIR_ENABLE_DEBUG_OUTPUT
if (!_telemetryData)
Serial.println(" LeptonFLiR::sys_setTelemetryEnabled Failure allocating telemetryData.");
#endif
}
else if (!enabled && _telemetryData) {
free(_telemetryData);
_telemetryData = NULL;
}
}
}
bool LeptonFLiR::sys_getTelemetryEnabled() {
#ifdef LEPFLIR_ENABLE_DEBUG_OUTPUT
Serial.println("LeptonFLiR::sys_getTelemetryEnabled");
#endif
uint32_t enabled;
receiveCommand(cmdCode(LEP_CID_SYS_TELEMETRY_ENABLE_STATE, LEP_I2C_COMMAND_TYPE_GET), &enabled);
if (!_lastI2CError && !_lastLepResult) {
if (enabled && !_telemetryData) {
_telemetryData = (byte *)malloc(LEPFLIR_SPI_FRAME_PACKET_SIZE);
if (_telemetryData)
_telemetryData[0] = _telemetryData[1] = 0xFF; // initialize as discard packet
#ifdef LEPFLIR_ENABLE_DEBUG_OUTPUT
if (!_telemetryData)
Serial.println(" LeptonFLiR::sys_getTelemetryEnabled Failure allocating telemetryData.");
#endif
}
else if (!enabled && _telemetryData) {
free(_telemetryData);
_telemetryData = NULL;
}
}
return enabled;
}
void LeptonFLiR::sys_runFFCNormalization() {
#ifdef LEPFLIR_ENABLE_DEBUG_OUTPUT
Serial.println("LeptonFLiR::sys_runFFCNormalization");
#endif
sendCommand(cmdCode(LEP_CID_SYS_RUN_FFC, LEP_I2C_COMMAND_TYPE_RUN));
}
void LeptonFLiR::vid_setPolarity(LEP_VID_POLARITY polarity) {
#ifdef LEPFLIR_ENABLE_DEBUG_OUTPUT
Serial.println("LeptonFLiR::vid_setPolarity");
#endif
sendCommand(cmdCode(LEP_CID_VID_POLARITY_SELECT, LEP_I2C_COMMAND_TYPE_SET), (uint32_t)polarity);
}
LEP_VID_POLARITY LeptonFLiR::vid_getPolarity() {
#ifdef LEPFLIR_ENABLE_DEBUG_OUTPUT
Serial.println("LeptonFLiR::vid_getPolarity");
#endif
uint32_t polarity;
receiveCommand(cmdCode(LEP_CID_VID_POLARITY_SELECT, LEP_I2C_COMMAND_TYPE_GET), &polarity);
return (LEP_VID_POLARITY)polarity;
}
void LeptonFLiR::vid_setPseudoColorLUT(LEP_VID_PCOLOR_LUT table) {
#ifdef LEPFLIR_ENABLE_DEBUG_OUTPUT
Serial.println("LeptonFLiR::vid_setPseudoColorLUT");
#endif
sendCommand(cmdCode(LEP_CID_VID_LUT_SELECT, LEP_I2C_COMMAND_TYPE_SET), (uint32_t)table);
}
LEP_VID_PCOLOR_LUT LeptonFLiR::vid_getPseudoColorLUT() {
#ifdef LEPFLIR_ENABLE_DEBUG_OUTPUT
Serial.println("LeptonFLiR::vid_getPseudoColorLUT");
#endif
uint32_t table;
receiveCommand(cmdCode(LEP_CID_VID_LUT_SELECT, LEP_I2C_COMMAND_TYPE_GET), &table);
return (LEP_VID_PCOLOR_LUT)table;
}
void LeptonFLiR::vid_setFocusCalcEnabled(bool enabled) {
#ifdef LEPFLIR_ENABLE_DEBUG_OUTPUT
Serial.println("LeptonFLiR::vid_setFocusCalcEnabled");
#endif
sendCommand(cmdCode(LEP_CID_VID_FOCUS_CALC_ENABLE, LEP_I2C_COMMAND_TYPE_SET), (uint32_t)enabled);
}
bool LeptonFLiR::vid_getFocusCalcEnabled() {
#ifdef LEPFLIR_ENABLE_DEBUG_OUTPUT
Serial.println("LeptonFLiR::vid_getFocusCalcEnabled");
#endif
uint32_t enabled;
receiveCommand(cmdCode(LEP_CID_VID_FOCUS_CALC_ENABLE, LEP_I2C_COMMAND_TYPE_GET), &enabled);
return enabled;
}
void LeptonFLiR::vid_setFreezeEnabled(bool enabled) {
#ifdef LEPFLIR_ENABLE_DEBUG_OUTPUT
Serial.println("LeptonFLiR::vid_setFreezeEnabled");
#endif
sendCommand(cmdCode(LEP_CID_VID_FREEZE_ENABLE, LEP_I2C_COMMAND_TYPE_SET), (uint32_t)enabled);
}
bool LeptonFLiR::vid_getFreezeEnabled() {
#ifdef LEPFLIR_ENABLE_DEBUG_OUTPUT
Serial.println("LeptonFLiR::vid_getFreezeEnabled");
#endif
uint32_t enabled;
receiveCommand(cmdCode(LEP_CID_VID_FREEZE_ENABLE, LEP_I2C_COMMAND_TYPE_GET), &enabled);
return enabled;
}
#ifndef LEPFLIR_EXCLUDE_EXT_I2C_FUNCS
void LeptonFLiR::agc_setHistogramRegion(LEP_AGC_HISTOGRAM_ROI *region) {
if (!region) return;
#ifdef LEPFLIR_ENABLE_DEBUG_OUTPUT
Serial.println("LeptonFLiR::agc_setHistogramRegion");
#endif
sendCommand(cmdCode(LEP_CID_AGC_ROI, LEP_I2C_COMMAND_TYPE_SET), (uint16_t *)region, sizeof(LEP_AGC_HISTOGRAM_ROI) / 2);
}
void LeptonFLiR::agc_getHistogramRegion(LEP_AGC_HISTOGRAM_ROI *region) {
if (!region) return;
#ifdef LEPFLIR_ENABLE_DEBUG_OUTPUT
Serial.println("LeptonFLiR::agc_getHistogramRegion");
#endif
receiveCommand(cmdCode(LEP_CID_AGC_ROI, LEP_I2C_COMMAND_TYPE_GET), (uint16_t *)region, sizeof(LEP_AGC_HISTOGRAM_ROI) / 2);
}
void LeptonFLiR::agc_getHistogramStatistics(LEP_AGC_HISTOGRAM_STATISTICS *statistics) {
if (!statistics) return;
#ifdef LEPFLIR_ENABLE_DEBUG_OUTPUT
Serial.println("LeptonFLiR::agc_getHistogramStatistics");
#endif
receiveCommand(cmdCode(LEP_CID_AGC_STATISTICS, LEP_I2C_COMMAND_TYPE_GET), (uint16_t *)statistics, sizeof(LEP_AGC_HISTOGRAM_STATISTICS) / 2);
}
void LeptonFLiR::agc_setHistogramClipPercent(uint16_t percent) {
#ifdef LEPFLIR_ENABLE_DEBUG_OUTPUT
Serial.println("LeptonFLiR::agc_setHistogramClipPercent");
#endif
sendCommand(cmdCode(LEP_CID_AGC_HISTOGRAM_CLIP_PERCENT, LEP_I2C_COMMAND_TYPE_SET), percent);
}
uint16_t LeptonFLiR::agc_getHistogramClipPercent() {
#ifdef LEPFLIR_ENABLE_DEBUG_OUTPUT
Serial.println("LeptonFLiR::agc_getHistogramClipPercent");
#endif
uint16_t percent;
receiveCommand(cmdCode(LEP_CID_AGC_HISTOGRAM_CLIP_PERCENT, LEP_I2C_COMMAND_TYPE_GET), &percent);
return percent;
}
void LeptonFLiR::agc_setHistogramTailSize(uint16_t size) {
#ifdef LEPFLIR_ENABLE_DEBUG_OUTPUT
Serial.println("LeptonFLiR::agc_setHistogramTailSize");
#endif
sendCommand(cmdCode(LEP_CID_AGC_HISTOGRAM_TAIL_SIZE, LEP_I2C_COMMAND_TYPE_SET), size);
}
uint16_t LeptonFLiR::agc_getHistogramTailSize() {
#ifdef LEPFLIR_ENABLE_DEBUG_OUTPUT
Serial.println("LeptonFLiR::agc_getHistogramTailSize");
#endif
uint16_t size;
receiveCommand(cmdCode(LEP_CID_AGC_HISTOGRAM_TAIL_SIZE, LEP_I2C_COMMAND_TYPE_GET), &size);
return size;
}
void LeptonFLiR::agc_setLinearMaxGain(uint16_t gain) {
#ifdef LEPFLIR_ENABLE_DEBUG_OUTPUT