Enable Analog IR sensor again

This commit is contained in:
Alex Voinea 2022-11-19 19:47:53 +01:00 committed by Guðni Már Gilbert
parent f5b9d2ac2e
commit f6135f2ed1
5 changed files with 17 additions and 36 deletions

View File

@ -5,21 +5,17 @@
#include "Configuration_var.h" #include "Configuration_var.h"
#include "pins.h" #include "pins.h"
#if (defined(VOLT_IR_PIN) && defined(IR_SENSOR))
// TODO: IR_SENSOR_ANALOG currently disabled as being incompatible with the new thermal regulation
// # define IR_SENSOR_ANALOG
#endif
//ADC configuration //ADC configuration
#ifndef IR_SENSOR_ANALOG #if defined(FILAMENT_SENSOR) && (FILAMENT_SENSOR_TYPE == FSENSOR_IR_ANALOG)
#define ADC_CHAN_MSK 0b0000001001011111 //used AD channels bit mask (0,1,2,3,4,6,9)
#define ADC_DIDR_MSK 0b0000001001011111 //AD channels DIDR mask (1 ~ disabled digital input)
#define ADC_CHAN_CNT 7 //number of used channels)
#else //!IR_SENSOR_ANALOG
#define ADC_CHAN_MSK 0b0000001101011111 //used AD channels bit mask (0,1,2,3,4,6,8,9) #define ADC_CHAN_MSK 0b0000001101011111 //used AD channels bit mask (0,1,2,3,4,6,8,9)
#define ADC_DIDR_MSK 0b0000001001011111 //AD channels DIDR mask (1 ~ disabled digital input) #define ADC_DIDR_MSK 0b0000001001011111 //AD channels DIDR mask (1 ~ disabled digital input)
#define ADC_CHAN_CNT 8 //number of used channels) #define ADC_CHAN_CNT 8 //number of used channels)
#endif //!IR_SENSOR_ANALOG #else
#define ADC_CHAN_MSK 0b0000001001011111 //used AD channels bit mask (0,1,2,3,4,6,9)
#define ADC_DIDR_MSK 0b0000001001011111 //AD channels DIDR mask (1 ~ disabled digital input)
#define ADC_CHAN_CNT 7 //number of used channels)
#endif
#define ADC_OVRSAMPL 16 //oversampling multiplier #define ADC_OVRSAMPL 16 //oversampling multiplier
#define ADC_CALLBACK adc_callback //callback function () #define ADC_CALLBACK adc_callback //callback function ()

View File

@ -2093,9 +2093,9 @@ void adc_callback()
#ifdef VOLT_BED_PIN #ifdef VOLT_BED_PIN
current_voltage_raw_bed = adc_values[ADC_PIN_IDX(VOLT_BED_PIN)]; // 6->9 current_voltage_raw_bed = adc_values[ADC_PIN_IDX(VOLT_BED_PIN)]; // 6->9
#endif #endif
#ifdef IR_SENSOR_ANALOG #if defined(FILAMENT_SENSOR) && (FILAMENT_SENSOR_TYPE == FSENSOR_IR_ANALOG)
current_voltage_raw_IR = adc_values[ADC_PIN_IDX(VOLT_IR_PIN)]; fsensor.voltUpdate(adc_values[ADC_PIN_IDX(VOLT_IR_PIN)]);
#endif //IR_SENSOR_ANALOG #endif //defined(FILAMENT_SENSOR) && (FILAMENT_SENSOR_TYPE == FSENSOR_IR_ANALOG)
adc_values_ready = true; adc_values_ready = true;
} }

View File

@ -62,10 +62,6 @@ extern int current_voltage_raw_pwr;
extern int current_voltage_raw_bed; extern int current_voltage_raw_bed;
#endif #endif
#ifdef IR_SENSOR_ANALOG
extern uint16_t current_voltage_raw_IR;
#endif //IR_SENSOR_ANALOG
extern bool bedPWMDisabled; extern bool bedPWMDisabled;
#ifdef PIDTEMP #ifdef PIDTEMP

View File

@ -1410,12 +1410,12 @@ static void lcd_menu_voltages()
float volt_bed = VOLT_DIV_REF * ((float)current_voltage_raw_bed / (1023 * OVERSAMPLENR)) / VOLT_DIV_FAC; float volt_bed = VOLT_DIV_REF * ((float)current_voltage_raw_bed / (1023 * OVERSAMPLENR)) / VOLT_DIV_FAC;
lcd_home(); lcd_home();
lcd_printf_P(PSTR(" PWR: %4.1fV\n" " BED: %4.1fV"), volt_pwr, volt_bed); lcd_printf_P(PSTR(" PWR: %4.1fV\n" " BED: %4.1fV"), volt_pwr, volt_bed);
#ifdef IR_SENSOR_ANALOG #if defined(FILAMENT_SENSOR) && (FILAMENT_SENSOR_TYPE == FSENSOR_IR_ANALOG)
lcd_printf_P(PSTR("\n IR : %3.1fV"), fsensor.Raw2Voltage(fsensor.getVoltRaw())); lcd_printf_P(PSTR("\n IR : %3.1fV"), Raw2Voltage(fsensor.getVoltRaw()));
#endif //IR_SENSOR_ANALOG #endif //defined(FILAMENT_SENSOR) && (FILAMENT_SENSOR_TYPE == FSENSOR_IR_ANALOG)
menu_back_if_clicked(); menu_back_if_clicked();
} }
#endif //defined (VOLT_BED_PIN) || defined (VOLT_PWR_PIN) || defined(IR_SENSOR_ANALOG) #endif //defined (VOLT_BED_PIN) || defined (VOLT_PWR_PIN) || (defined(FILAMENT_SENSOR) && (FILAMENT_SENSOR_TYPE == FSENSOR_IR_ANALOG))
#ifdef TMC2130 #ifdef TMC2130
//! @brief Show Belt Status //! @brief Show Belt Status
@ -1648,7 +1648,7 @@ static void lcd_support_menu()
MENU_ITEM_BACK_P(STR_SEPARATOR); MENU_ITEM_BACK_P(STR_SEPARATOR);
MENU_ITEM_BACK_P(PSTR("Fil. sensor v.:")); MENU_ITEM_BACK_P(PSTR("Fil. sensor v.:"));
MENU_ITEM_BACK_P(fsensor.getIRVersionText()); MENU_ITEM_BACK_P(fsensor.getIRVersionText());
#endif // IR_SENSOR_ANALOG #endif //defined(FILAMENT_SENSOR) && (FILAMENT_SENSOR_TYPE == FSENSOR_IR_ANALOG)
MENU_ITEM_BACK_P(STR_SEPARATOR); MENU_ITEM_BACK_P(STR_SEPARATOR);
if (MMU2::mmu2.Enabled()) if (MMU2::mmu2.Enabled())
@ -4505,7 +4505,7 @@ void lcd_hw_setup_menu(void) // can not be "static"
//! Fsensor Detection isn't ready for mmu yet it is temporarily disabled. //! Fsensor Detection isn't ready for mmu yet it is temporarily disabled.
//! @todo Don't forget to remove this as soon Fsensor Detection works with mmu //! @todo Don't forget to remove this as soon Fsensor Detection works with mmu
if(!MMU2::mmu2.Enabled()) MENU_ITEM_FUNCTION_P(PSTR("Fsensor Detection"), lcd_detect_IRsensor); if(!MMU2::mmu2.Enabled()) MENU_ITEM_FUNCTION_P(PSTR("Fsensor Detection"), lcd_detect_IRsensor);
#endif //IR_SENSOR_ANALOG #endif //defined(FILAMENT_SENSOR) && (FILAMENT_SENSOR_TYPE == FSENSOR_IR_ANALOG)
if (_md->experimental_menu_visibility) if (_md->experimental_menu_visibility)
{ {
@ -6010,7 +6010,7 @@ static void lcd_detect_IRsensor(){
lcd_show_fullscreen_message_and_wait_P(_i("Verification failed, remove the filament and try again."));////MSG_FIL_FAILED c=20 r=4 lcd_show_fullscreen_message_and_wait_P(_i("Verification failed, remove the filament and try again."));////MSG_FIL_FAILED c=20 r=4
} }
} }
#endif //IR_SENSOR_ANALOG #endif //defined(FILAMENT_SENSOR) && (FILAMENT_SENSOR_TYPE == FSENSOR_IR_ANALOG)
static void lcd_selftest_v() static void lcd_selftest_v()
{ {
@ -6236,17 +6236,6 @@ bool lcd_selftest()
_progress = lcd_selftest_screen(TestScreen::FsensorOk, _progress, 3, true, 2000); //fil sensor OK _progress = lcd_selftest_screen(TestScreen::FsensorOk, _progress, 3, true, 2000); //fil sensor OK
} }
#endif //FILAMENT_SENSOR_TYPE == FSENSOR_PAT9125 #endif //FILAMENT_SENSOR_TYPE == FSENSOR_PAT9125
#if 0
// Intentionally disabled - that's why we moved the detection to runtime by just checking the two voltages.
// The idea is not to force the user to remove and insert the filament on an assembled printer.
//defined(FILAMENT_SENSOR) && (FILAMENT_SENSOR_TYPE == FSENSOR_IR_ANALOG)
_progress = lcd_selftest_screen(TestScreen::Fsensor, _progress, 3, true, 2000); //check filament sensor
_result = lcd_selftest_IRsensor();
if (_result)
{
_progress = lcd_selftest_screen(TestScreen::FsensorOk, _progress, 3, true, 2000); //filament sensor OK
}
#endif //IR_SENSOR_ANALOG
} }
} }
#endif //FILAMENT_SENSOR #endif //FILAMENT_SENSOR

View File

@ -160,7 +160,7 @@ extern bool FarmOrUserECool();
#if defined(FILAMENT_SENSOR) && (FILAMENT_SENSOR_TYPE == FSENSOR_IR_ANALOG) #if defined(FILAMENT_SENSOR) && (FILAMENT_SENSOR_TYPE == FSENSOR_IR_ANALOG)
void printf_IRSensorAnalogBoardChange(); void printf_IRSensorAnalogBoardChange();
#endif //IR_SENSOR_ANALOG #endif //defined(FILAMENT_SENSOR) && (FILAMENT_SENSOR_TYPE == FSENSOR_IR_ANALOG)
extern int8_t SilentModeMenu; extern int8_t SilentModeMenu;