mirror of
https://github.com/Ralim/IronOS.git
synced 2025-02-26 07:53:55 +00:00
Add tip coeff as setting parameter
This commit is contained in:
@@ -106,5 +106,6 @@ void resetSettings() {
|
||||
systemSettings.TempChangeShortStep = TEMP_CHANGE_SHORT_STEP; //
|
||||
systemSettings.TempChangeLongStep = TEMP_CHANGE_LONG_STEP; //
|
||||
systemSettings.KeepAwakePulse= POWER_PULSE_DEFAULT;
|
||||
systemSettings.TipGain = TIP_GAIN;
|
||||
saveSettings(); // Save defaults
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
* This was bought to my attention by <Kuba Sztandera>
|
||||
*/
|
||||
|
||||
#define op_amp_gain_stage (1+(OP_AMP_Rf/OP_AMP_Rin))
|
||||
|
||||
uint32_t TipThermoModel::convertTipRawADCTouV(uint16_t rawADC) {
|
||||
// This takes the raw ADC samples, converts these to uV
|
||||
// Then divides this down by the gain to convert to the uV on the input to the op-amp (A+B terminals)
|
||||
@@ -39,7 +39,7 @@ uint32_t TipThermoModel::convertTipRawADCTouV(uint16_t rawADC) {
|
||||
|
||||
uint32_t valueuV = rawInputmVX10 * 100; // shift into uV
|
||||
//Now to divide this down by the gain
|
||||
valueuV = (valueuV) / op_amp_gain_stage;
|
||||
valueuV = (valueuV) / OP_AMP_GAIN_STAGE;
|
||||
//Remove uV tipOffset
|
||||
if (valueuV >= systemSettings.CalibrationOffset)
|
||||
valueuV -= systemSettings.CalibrationOffset;
|
||||
@@ -73,17 +73,19 @@ int32_t LinearInterpolate(int32_t x1, int32_t y1, int32_t x2, int32_t y2,
|
||||
uint32_t TipThermoModel::convertuVToDegC(uint32_t tipuVDelta) {
|
||||
//based on new measurements, tip is quite linear
|
||||
//
|
||||
tipuVDelta *= TIP_GAIN;
|
||||
tipuVDelta /= 10000;
|
||||
tipuVDelta *= 10;
|
||||
tipuVDelta /= systemSettings.TipGain;
|
||||
|
||||
#ifdef MODEL_TS80
|
||||
tipuVDelta /= OP_AMP_GAIN_STAGE_TS100 / OP_AMP_GAIN_STAGE_TS80;
|
||||
#endif
|
||||
|
||||
return tipuVDelta;
|
||||
}
|
||||
|
||||
#ifdef ENABLED_FAHRENHEIT_SUPPORT
|
||||
uint32_t TipThermoModel::convertuVToDegF(uint32_t tipuVDelta) {
|
||||
tipuVDelta *= TIP_GAIN;
|
||||
tipuVDelta /= 1000;
|
||||
return ((tipuVDelta * 9) / 50) + 32;
|
||||
//(Y °C × 9/5) + 32 =Y°F
|
||||
return convertCtoF(convertuVToDegC(tipuVDelta));
|
||||
}
|
||||
|
||||
uint32_t TipThermoModel::convertCtoF(uint32_t degC) {
|
||||
|
||||
@@ -60,6 +60,8 @@ static void settings_setResetSettings(void);
|
||||
static void settings_displayResetSettings(void);
|
||||
static void settings_setCalibrate(void);
|
||||
static void settings_displayCalibrate(void);
|
||||
static void settings_setTipGain(void);
|
||||
static void settings_displayTipGain(void);
|
||||
static void settings_setCalibrateVIN(void);
|
||||
static void settings_displayCalibrateVIN(void);
|
||||
static void settings_displayReverseButtonTempChangeEnabled(void);
|
||||
@@ -236,6 +238,8 @@ const menuitem advancedMenu[] = {
|
||||
settings_displayCalibrateVIN } }, /*Voltage input cal*/
|
||||
{ (const char*) SettingsDescriptions[26], { settings_setPowerPulse }, {
|
||||
settings_displayPowerPulse } }, /*Power Pulse adjustment */
|
||||
{ (const char*) SettingsDescriptions[27], { settings_setTipGain }, {
|
||||
settings_displayTipGain } }, /*TipGain*/
|
||||
{ NULL, { NULL }, { NULL } } // end of menu marker. DO NOT REMOVE
|
||||
};
|
||||
|
||||
@@ -752,6 +756,53 @@ static void settings_setCalibrateVIN(void) {
|
||||
}
|
||||
}
|
||||
|
||||
static void settings_setTipGain(void) {
|
||||
OLED::setFont(0);
|
||||
OLED::clearScreen();
|
||||
|
||||
for (;;) {
|
||||
OLED::setCursor(0, 0);
|
||||
OLED::printNumber(systemSettings.TipGain / 10, 2);
|
||||
OLED::print(SymbolDot);
|
||||
OLED::printNumber(systemSettings.TipGain % 10, 1);
|
||||
|
||||
ButtonState buttons = getButtonState();
|
||||
switch (buttons) {
|
||||
case BUTTON_F_SHORT:
|
||||
systemSettings.TipGain -= 1;
|
||||
break;
|
||||
|
||||
case BUTTON_B_SHORT:
|
||||
systemSettings.TipGain += 1;
|
||||
break;
|
||||
|
||||
case BUTTON_BOTH:
|
||||
case BUTTON_F_LONG:
|
||||
case BUTTON_B_LONG:
|
||||
saveSettings();
|
||||
return;
|
||||
break;
|
||||
case BUTTON_NONE:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
OLED::refresh();
|
||||
osDelay(40);
|
||||
|
||||
// Cap to sensible values
|
||||
if (systemSettings.TipGain < 150) {
|
||||
systemSettings.TipGain = 150;
|
||||
} else if (systemSettings.TipGain > 300) {
|
||||
systemSettings.TipGain = 300;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void settings_displayTipGain(void) {
|
||||
printShortDescription(27, 5);
|
||||
}
|
||||
|
||||
static void settings_setReverseButtonTempChangeEnabled(void) {
|
||||
systemSettings.ReverseButtonTempChangeEnabled =
|
||||
!systemSettings.ReverseButtonTempChangeEnabled;
|
||||
|
||||
Reference in New Issue
Block a user