1
0
mirror of https://github.com/MarlinFirmware/Marlin.git synced 2024-11-30 15:26:18 +00:00

Reduce code with no heated bed

This commit is contained in:
Scott Lahteine 2017-12-13 17:56:25 -06:00
parent 172ea8c71c
commit f36f91dfb5
2 changed files with 52 additions and 45 deletions

View File

@ -874,7 +874,7 @@ void Temperature::manage_heater() {
// Derived from RepRap FiveD extruder::getTemperature() // Derived from RepRap FiveD extruder::getTemperature()
// For hot end temperature measurement. // For hot end temperature measurement.
float Temperature::analog2temp(int raw, uint8_t e) { float Temperature::analog2temp(const int raw, const uint8_t e) {
#if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT) #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
if (e > HOTENDS) if (e > HOTENDS)
#else #else
@ -915,39 +915,41 @@ float Temperature::analog2temp(int raw, uint8_t e) {
return ((raw * ((5.0 * 100.0) / 1024.0) / OVERSAMPLENR) * (TEMP_SENSOR_AD595_GAIN)) + TEMP_SENSOR_AD595_OFFSET; return ((raw * ((5.0 * 100.0) / 1024.0) / OVERSAMPLENR) * (TEMP_SENSOR_AD595_GAIN)) + TEMP_SENSOR_AD595_OFFSET;
} }
// Derived from RepRap FiveD extruder::getTemperature() #if HAS_TEMP_BED
// For bed temperature measurement. // Derived from RepRap FiveD extruder::getTemperature()
float Temperature::analog2tempBed(const int raw) { // For bed temperature measurement.
#if ENABLED(BED_USES_THERMISTOR) float Temperature::analog2tempBed(const int raw) {
float celsius = 0; #if ENABLED(BED_USES_THERMISTOR)
byte i; float celsius = 0;
byte i;
for (i = 1; i < BEDTEMPTABLE_LEN; i++) { for (i = 1; i < BEDTEMPTABLE_LEN; i++) {
if (PGM_RD_W(BEDTEMPTABLE[i][0]) > raw) { if (PGM_RD_W(BEDTEMPTABLE[i][0]) > raw) {
celsius = PGM_RD_W(BEDTEMPTABLE[i - 1][1]) + celsius = PGM_RD_W(BEDTEMPTABLE[i - 1][1]) +
(raw - PGM_RD_W(BEDTEMPTABLE[i - 1][0])) * (raw - PGM_RD_W(BEDTEMPTABLE[i - 1][0])) *
(float)(PGM_RD_W(BEDTEMPTABLE[i][1]) - PGM_RD_W(BEDTEMPTABLE[i - 1][1])) / (float)(PGM_RD_W(BEDTEMPTABLE[i][1]) - PGM_RD_W(BEDTEMPTABLE[i - 1][1])) /
(float)(PGM_RD_W(BEDTEMPTABLE[i][0]) - PGM_RD_W(BEDTEMPTABLE[i - 1][0])); (float)(PGM_RD_W(BEDTEMPTABLE[i][0]) - PGM_RD_W(BEDTEMPTABLE[i - 1][0]));
break; break;
}
} }
}
// Overflow: Set to last value in the table // Overflow: Set to last value in the table
if (i == BEDTEMPTABLE_LEN) celsius = PGM_RD_W(BEDTEMPTABLE[i - 1][1]); if (i == BEDTEMPTABLE_LEN) celsius = PGM_RD_W(BEDTEMPTABLE[i - 1][1]);
return celsius; return celsius;
#elif defined(BED_USES_AD595) #elif defined(BED_USES_AD595)
return ((raw * ((5.0 * 100.0) / 1024.0) / OVERSAMPLENR) * (TEMP_SENSOR_AD595_GAIN)) + TEMP_SENSOR_AD595_OFFSET; return ((raw * ((5.0 * 100.0) / 1024.0) / OVERSAMPLENR) * (TEMP_SENSOR_AD595_GAIN)) + TEMP_SENSOR_AD595_OFFSET;
#else #else
UNUSED(raw); UNUSED(raw);
return 0; return 0;
#endif #endif
} }
#endif // HAS_TEMP_BED
/** /**
* Get the raw values into the actual temperatures. * Get the raw values into the actual temperatures.
@ -1234,24 +1236,26 @@ void Temperature::init() {
#endif // HOTENDS > 2 #endif // HOTENDS > 2
#endif // HOTENDS > 1 #endif // HOTENDS > 1
#ifdef BED_MINTEMP #if HAS_TEMP_BED
while (analog2tempBed(bed_minttemp_raw) < BED_MINTEMP) { #ifdef BED_MINTEMP
#if HEATER_BED_RAW_LO_TEMP < HEATER_BED_RAW_HI_TEMP while (analog2tempBed(bed_minttemp_raw) < BED_MINTEMP) {
bed_minttemp_raw += OVERSAMPLENR; #if HEATER_BED_RAW_LO_TEMP < HEATER_BED_RAW_HI_TEMP
#else bed_minttemp_raw += OVERSAMPLENR;
bed_minttemp_raw -= OVERSAMPLENR; #else
#endif bed_minttemp_raw -= OVERSAMPLENR;
} #endif
#endif // BED_MINTEMP }
#ifdef BED_MAXTEMP #endif // BED_MINTEMP
while (analog2tempBed(bed_maxttemp_raw) > BED_MAXTEMP) { #ifdef BED_MAXTEMP
#if HEATER_BED_RAW_LO_TEMP < HEATER_BED_RAW_HI_TEMP while (analog2tempBed(bed_maxttemp_raw) > BED_MAXTEMP) {
bed_maxttemp_raw -= OVERSAMPLENR; #if HEATER_BED_RAW_LO_TEMP < HEATER_BED_RAW_HI_TEMP
#else bed_maxttemp_raw -= OVERSAMPLENR;
bed_maxttemp_raw += OVERSAMPLENR; #else
#endif bed_maxttemp_raw += OVERSAMPLENR;
} #endif
#endif // BED_MAXTEMP }
#endif // BED_MAXTEMP
#endif //HAS_TEMP_BED
#if ENABLED(PROBING_HEATERS_OFF) #if ENABLED(PROBING_HEATERS_OFF)
paused = false; paused = false;

View File

@ -293,8 +293,11 @@ class Temperature {
/** /**
* Static (class) methods * Static (class) methods
*/ */
static float analog2temp(int raw, uint8_t e); static float analog2temp(const int raw, const uint8_t e);
static float analog2tempBed(int raw);
#if HAS_TEMP_BED
static float analog2tempBed(const int raw);
#endif
/** /**
* Called from the Temperature ISR * Called from the Temperature ISR