Fix raw_filwidth_value error

This commit is contained in:
Scott Lahteine 2018-09-12 04:29:18 -05:00
parent 1933d5d6fb
commit b220a825a7

View File

@ -1679,6 +1679,10 @@ void Temperature::set_current_temp_raw() {
temp_meas_ready = true; temp_meas_ready = true;
} }
#if ENABLED(FILAMENT_WIDTH_SENSOR)
uint32_t raw_filwidth_value; // = 0
#endif
void Temperature::readings_ready() { void Temperature::readings_ready() {
// Update the raw values if they've been read. Else we could be updating them during reading. // Update the raw values if they've been read. Else we could be updating them during reading.
if (!temp_meas_ready) set_current_temp_raw(); if (!temp_meas_ready) set_current_temp_raw();
@ -1819,10 +1823,6 @@ void Temperature::isr() {
ISR_STATICS(BED); ISR_STATICS(BED);
#endif #endif
#if ENABLED(FILAMENT_WIDTH_SENSOR)
static unsigned long raw_filwidth_value = 0;
#endif
#if DISABLED(SLOW_PWM_HEATERS) #if DISABLED(SLOW_PWM_HEATERS)
constexpr uint8_t pwm_mask = constexpr uint8_t pwm_mask =
#if ENABLED(SOFT_PWM_DITHER) #if ENABLED(SOFT_PWM_DITHER)
@ -2177,8 +2177,8 @@ void Temperature::isr() {
if (!HAL_ADC_READY()) if (!HAL_ADC_READY())
next_sensor_state = adc_sensor_state; // redo this state next_sensor_state = adc_sensor_state; // redo this state
else if (HAL_READ_ADC() > 102) { // Make sure ADC is reading > 0.5 volts, otherwise don't read. else if (HAL_READ_ADC() > 102) { // Make sure ADC is reading > 0.5 volts, otherwise don't read.
raw_filwidth_value -= (raw_filwidth_value >> 7); // Subtract 1/128th of the raw_filwidth_value raw_filwidth_value -= raw_filwidth_value >> 7; // Subtract 1/128th of the raw_filwidth_value
raw_filwidth_value += ((unsigned long)HAL_READ_ADC() << 7); // Add new ADC reading, scaled by 128 raw_filwidth_value += uint32_t(HAL_READ_ADC()) << 7; // Add new ADC reading, scaled by 128
} }
break; break;
#endif #endif