Permalink
Browse files

Add files via upload

  • Loading branch information...
maxritter committed Sep 12, 2017
1 parent 6ab3409 commit 0c1953d155e9e92c583e7c1b85d8b7cac41f5193
@@ -14,8 +14,8 @@
*/
/* Current firmware version */
#define Version "Firmware 2.42 from 14.07.2017"
#define fwVersion 242
#define Version "Firmware 2.43 from 12.09.2017"
#define fwVersion 243
/* External Libraries */

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -160,43 +160,6 @@ void calibrationScreen(bool firstStart) {
}
}
/* Calibration Chooser */
bool calibrationChooser() {
//Title & Background
mainMenuBackground();
mainMenuTitle((char*)"Calibration");
//Draw the buttons
buttons_deleteAllButtons();
buttons_setTextFont(bigFont);
buttons_addButton(15, 47, 140, 120, (char*) "New");
buttons_addButton(165, 47, 140, 120, (char*) "Delete");
buttons_addButton(15, 188, 140, 40, (char*) "Back");
buttons_drawButtons();
//Touch handler
while (true) {
//If touch pressed
if (touch_touched() == true) {
int pressedButton = buttons_checkButtons(true);
//NEW
if (pressedButton == 0) {
calibrationProcess();
return true;
}
//DELETE
if (pressedButton == 1) {
calSlope = cal_stdSlope;
calOffset = ambTemp - (calSlope * 8192) + calComp;
calStatus = cal_standard;
storeCalibration();
return true;
}
//BACK
if (pressedButton == 2)
return false;
}
}
}
/* Menu to add or remove temperature points to the thermal image */
bool tempPointsMenu() {
//Still in warmup, do not add points
@@ -578,7 +541,6 @@ bool tempLimitsPresetSaveMenu() {
int pressedButton = buttons_checkButtons(true);
//SELECT
if (pressedButton == 3) {
int16_t min, max;
uint8_t farray[4];
switch (menuPos) {
//Temporary
@@ -587,12 +549,10 @@ bool tempLimitsPresetSaveMenu() {
break;
//Preset 1
case 1:
min = (int16_t)round(calFunction(minValue));
max = (int16_t)round(calFunction(maxValue));
EEPROM.write(eeprom_minValue1High, (min & 0xFF00) >> 8);
EEPROM.write(eeprom_minValue1Low, min & 0x00FF);
EEPROM.write(eeprom_maxValue1High, (max & 0xFF00) >> 8);
EEPROM.write(eeprom_maxValue1Low, max & 0x00FF);
EEPROM.write(eeprom_minValue1High, (minValue & 0xFF00) >> 8);
EEPROM.write(eeprom_minValue1Low, minValue & 0x00FF);
EEPROM.write(eeprom_maxValue1High, (maxValue & 0xFF00) >> 8);
EEPROM.write(eeprom_maxValue1Low, maxValue & 0x00FF);
floatToBytes(farray, (float)calComp);
for (int i = 0; i < 4; i++)
EEPROM.write(eeprom_minMax1Comp + i, (farray[i]));
@@ -601,12 +561,10 @@ bool tempLimitsPresetSaveMenu() {
break;
//Preset 2
case 2:
min = (int16_t)round(calFunction(minValue));
max = (int16_t)round(calFunction(maxValue));
EEPROM.write(eeprom_minValue2High, (min & 0xFF00) >> 8);
EEPROM.write(eeprom_minValue2Low, min & 0x00FF);
EEPROM.write(eeprom_maxValue2High, (max & 0xFF00) >> 8);
EEPROM.write(eeprom_maxValue2Low, max & 0x00FF);
EEPROM.write(eeprom_minValue2High, (minValue & 0xFF00) >> 8);
EEPROM.write(eeprom_minValue2Low, minValue & 0x00FF);
EEPROM.write(eeprom_maxValue2High, (maxValue & 0xFF00) >> 8);
EEPROM.write(eeprom_maxValue2Low, maxValue & 0x00FF);
floatToBytes(farray, (float)calComp);
for (int i = 0; i < 4; i++)
EEPROM.write(eeprom_minMax2Comp + i, (farray[i]));
@@ -615,12 +573,10 @@ bool tempLimitsPresetSaveMenu() {
break;
//Preset 3
case 3:
min = (int16_t)round(calFunction(minValue));
max = (int16_t)round(calFunction(maxValue));
EEPROM.write(eeprom_minValue3High, (min & 0xFF00) >> 8);
EEPROM.write(eeprom_minValue3Low, min & 0x00FF);
EEPROM.write(eeprom_maxValue3High, (max & 0xFF00) >> 8);
EEPROM.write(eeprom_maxValue3Low, max & 0x00FF);
EEPROM.write(eeprom_minValue3High, (minValue & 0xFF00) >> 8);
EEPROM.write(eeprom_minValue3Low, minValue & 0x00FF);
EEPROM.write(eeprom_maxValue3High, (maxValue & 0xFF00) >> 8);
EEPROM.write(eeprom_maxValue3Low, maxValue & 0x00FF);
floatToBytes(farray, (float)calComp);
for (int i = 0; i < 4; i++)
EEPROM.write(eeprom_minMax3Comp + i, (farray[i]));
@@ -219,7 +219,6 @@
//Calibration
#define cal_warmup 0
#define cal_standard 1
#define cal_manual 2
#define cal_stdSlope 0.0300f //Standard slope value
//Image save marker
@@ -168,8 +168,8 @@ void checkFWUpgrade() {
EEPROM.write(eeprom_adjComb3Set, 0);
}
//Clear temperature presets when coming from a FW smaller than 2.42
if(eepromVersion < 242)
//Clear temperature presets when coming from a FW smaller than 2.43
if(eepromVersion < 243)
{
EEPROM.write(eeprom_minMax1Set, 0);
EEPROM.write(eeprom_minMax2Set, 0);
@@ -371,8 +371,6 @@ void storeCalibration() {
for (int i = 0; i < 4; i++)
EEPROM.write(eeprom_calSlopeBase + i, (farray[i]));
EEPROM.write(eeprom_calSlopeSet, eeprom_setValue);
//Set calibration to manual
calStatus = cal_manual;
}
/* A method to check if the touch screen is pressed */
@@ -508,46 +506,55 @@ void setDisplayRotation() {
/* Reads the temperature limits from EEPROM */
void readTempLimits() {
int16_t min, max;
uint8_t farray[4];
//Some variables to get started
byte minValueHigh, minValueLow, maxValueHigh, maxValueLow, minMaxComp;
bool found = false;
//Min / max selection
byte minMaxPreset;
byte read = EEPROM.read(eeprom_minMaxPreset);
if ((read >= minMax_preset1) && (read <= minMax_preset3))
minMaxPreset = read;
else
minMaxPreset = minMax_temporary;
//Min / max preset 1
if ((minMaxPreset == minMax_preset1) && (EEPROM.read(eeprom_minMax1Set) == eeprom_setValue)) {
min = ((EEPROM.read(eeprom_minValue1High) << 8) + EEPROM.read(eeprom_minValue1Low));
max = ((EEPROM.read(eeprom_maxValue1High) << 8) + EEPROM.read(eeprom_maxValue1Low));
for (int i = 0; i < 4; i++)
farray[i] = EEPROM.read(eeprom_minMax1Comp + i);
calComp = bytesToFloat(farray);
minValue = tempToRaw(min);
maxValue = tempToRaw(max);
autoMode = false;
minValueHigh = eeprom_minValue1High;
minValueLow = eeprom_minValue1Low;
maxValueHigh = eeprom_maxValue1High;
maxValueLow = eeprom_maxValue1Low;
minMaxComp = eeprom_minMax1Comp;
found = true;
}
//Min / max preset 2
else if ((minMaxPreset == minMax_preset2) && (EEPROM.read(eeprom_minMax2Set) == eeprom_setValue)) {
min = ((EEPROM.read(eeprom_minValue2High) << 8) + EEPROM.read(eeprom_minValue2Low));
max = ((EEPROM.read(eeprom_maxValue2High) << 8) + EEPROM.read(eeprom_maxValue2Low));
for (int i = 0; i < 4; i++)
farray[i] = EEPROM.read(eeprom_minMax2Comp + i);
calComp = bytesToFloat(farray);
minValue = tempToRaw(min);
maxValue = tempToRaw(max);
autoMode = false;
minValueHigh = eeprom_minValue2High;
minValueLow = eeprom_minValue2Low;
maxValueHigh = eeprom_maxValue2High;
maxValueLow = eeprom_maxValue2Low;
minMaxComp = eeprom_minMax2Comp;
found = true;
}
//Min / max preset 3
else if ((minMaxPreset == minMax_preset3) && (EEPROM.read(eeprom_minMax3Set) == eeprom_setValue)) {
min = ((EEPROM.read(eeprom_minValue3High) << 8) + EEPROM.read(eeprom_minValue3Low));
max = ((EEPROM.read(eeprom_maxValue3High) << 8) + EEPROM.read(eeprom_maxValue3Low));
minValueHigh = eeprom_minValue3High;
minValueLow = eeprom_minValue3Low;
maxValueHigh = eeprom_maxValue3High;
maxValueLow = eeprom_maxValue3Low;
minMaxComp = eeprom_minMax3Comp;
found = true;
}
//Apply settings
if (found) {
minValue = ((EEPROM.read(minValueHigh) << 8) + EEPROM.read(minValueLow));
maxValue = ((EEPROM.read(maxValueHigh) << 8) + EEPROM.read(maxValueLow));
uint8_t farray[4];
for (int i = 0; i < 4; i++)
farray[i] = EEPROM.read(eeprom_minMax3Comp + i);
farray[i] = EEPROM.read(minMaxComp + i);
calComp = bytesToFloat(farray);
minValue = tempToRaw(min);
maxValue = tempToRaw(max);
autoMode = false;
}
}
@@ -459,10 +459,11 @@ void lepton_init() {
calTimer = millis();
//Set calibration status to warmup if not coming from mass storage
calStatus = cal_warmup;
//Set the compensation value to zero
calComp = 0;
}
//Set the compensation value to zero
calComp = 0;
//Activate auto mode
autoMode = true;
//Deactivate limits Locked
Binary file not shown.
Binary file not shown.
@@ -13,8 +13,8 @@ If you just want to flash the newest version of the firmware to your device, fol
Download and install the following programs:
1. Arduino 1.8.2: https://www.arduino.cc/en/Main/Software
2. Teensyduino 1.36: https://www.pjrc.com/teensy/td_download.html
1. Arduino 1.8.4+: https://www.arduino.cc/en/Main/Software
2. Teensyduino 1.39+: https://www.pjrc.com/teensy/td_download.html
3. Visual Studio 2015/2017 Community: https://www.visualstudio.com/en-us/products/visual-studio-community-vs.aspx
4. Visual Micro: http://www.visualmicro.com/page/Arduino-Visual-Studio-Downloads.aspx
@@ -33,9 +33,14 @@ float calFunction(uint16_t rawValue) {
if (leptonVersion == leptonVersion_2_5_shutter)
calOffset = -273.15;
//Calculate offset out of ambient temp
else if ((calStatus != cal_manual) && (autoMode) && (!limitsLocked))
//For non-radiometric Lepton
else {
//Refresh MLX90614 ambient temp
ambTemp = mlx90614_getAmb();
//Calculate offset out of ambient temp and compensation factor
calOffset = ambTemp - (calSlope * 8192) + calComp;
}
//Calculate the temperature in Celcius out of the coefficients
float temp = (calSlope * rawValue) + calOffset;
@@ -56,9 +61,14 @@ uint16_t tempToRaw(float temp) {
if (leptonVersion == leptonVersion_2_5_shutter)
calOffset = -273.15;
//Otherwise calculate offset out of ambient temp
else if ((calStatus != cal_manual) && (autoMode) && (!limitsLocked))
//For non-radiometric Lepton
else {
//Refresh MLX90614 ambient temp
ambTemp = mlx90614_getAmb();
//Calculate offset out of ambient temp and compensation factor
calOffset = ambTemp - (calSlope * 8192) + calComp;
}
//Calcualte the raw value
uint16_t rawValue = (temp - calOffset) / calSlope;
@@ -84,11 +94,8 @@ uint16_t calcAverage() {
/* Compensate the calibration with MLX90614 values */
void compensateCalib() {
//Refresh MLX90614 ambient temp
ambTemp = mlx90614_getAmb();
//Calculate compensation if auto mode enabled, no limits locked and no radiometric lepton used
if ((autoMode) && (!limitsLocked) && (leptonVersion != leptonVersion_2_5_shutter) && (calStatus != cal_manual)) {
//Calculate compensation if auto mode enabled and no limits locked
if ((autoMode) && (!limitsLocked)) {
//Calculate min & max
int16_t min = round(calFunction(minValue));
int16_t max = round(calFunction(maxValue));
@@ -100,9 +107,6 @@ void compensateCalib() {
//If spot temp is higher than current maximum by one degree, raise maximum
else if (spotTemp > (max + 1))
calComp = spotTemp - max;
//Calculate offset out of ambient temp
calOffset = ambTemp - (calSlope * 8192) + calComp;
}
}
@@ -127,7 +131,7 @@ void checkWarmup() {
if (leptonShutter == leptonShutter_auto)
lepton_ffcMode(false);
//Disable auto mode and limits locked
//Disable limits locked
limitsLocked = false;
}
}
@@ -273,11 +277,11 @@ void calibrationProcess(bool serial, bool firstStart) {
//Calculate the calibration formula with least square fit
linreg(100, calLepton, calMLX90614, &calSlope, &calOffset, &calCorrelation);
//Set calibration to manual
calStatus = cal_manual;
//Refresh MLX90614 ambient temp
ambTemp = mlx90614_getAmb();
//Set compensation to zero
calComp = 0;
//Calculate compensation
calComp = calOffset - ambTemp + (calSlope * 8192);
//When in serial mode, store and send ACK
if (serial)
@@ -350,11 +354,7 @@ bool calibration() {
return false;
}
//If there is a calibration
else if (calStatus == cal_manual)
return calibrationChooser();
//If there is none, do a new one
//Do a new one
calibrationProcess();
return true;
@@ -1027,8 +1027,6 @@ void loadAlloc() {
/* Change settings for load menu */
void loadSettings() {
//Set calibration status to manual
calStatus = cal_manual;
//Do not show additional information that are not required
batteryEnabled = false;
dateEnabled = false;
@@ -571,7 +571,7 @@ void liveMode() {
videoMode();
//Long touch handler
if (longTouch)
if ((longTouch) && (calStatus == cal_standard))
longTouchHandler();
}
}

0 comments on commit 0c1953d

Please sign in to comment.