Browse Source

Correct ifdefs for all IR sensor types

Alex Voinea 3 years ago
parent
commit
bbe1b1145e

+ 6 - 0
Firmware/Filament_sensor.cpp

@@ -1,3 +1,9 @@
 #include "Filament_sensor.h"
 
+#ifdef FILAMENT_SENSOR
+#if FILAMENT_SENSOR_TYPE == FSENSOR_IR
+IR_sensor fsensor;
+#elif FILAMENT_SENSOR_TYPE == FSENSOR_IR_ANALOG
 IR_sensor_analog fsensor;
+#endif
+#endif //FILAMENT_SENSOR

+ 15 - 0
Firmware/Filament_sensor.h

@@ -16,6 +16,11 @@
 #include "fastio.h"
 #include "adc.h"
 
+#define FSENSOR_IR 1
+#define FSENSOR_IR_ANALOG 2
+#define FSENSOR_PAT9125 3
+
+#ifdef FILAMENT_SENSOR
 class Filament_sensor {
 public:
     virtual void init() = 0;
@@ -167,6 +172,7 @@ protected:
     SensorActionOnError sensorActionOnError;
 };
 
+#if (FILAMENT_SENSOR_TYPE == FSENSOR_IR) || (FILAMENT_SENSOR_TYPE == FSENSOR_IR_ANALOG)
 class IR_sensor: public Filament_sensor {
 public:
     void init() {
@@ -207,6 +213,7 @@ public:
 protected:
 };
 
+#if (FILAMENT_SENSOR_TYPE == FSENSOR_IR_ANALOG)
 class IR_sensor_analog: public IR_sensor {
 public:
     void init() {
@@ -403,5 +410,13 @@ private:
         }
     }
 };
+#endif //(FILAMENT_SENSOR_TYPE == FSENSOR_IR_ANALOG)
+#endif //(FILAMENT_SENSOR_TYPE == FSENSOR_IR) || (FILAMENT_SENSOR_TYPE == FSENSOR_IR_ANALOG)
 
+#if FILAMENT_SENSOR_TYPE == FSENSOR_IR
+extern IR_sensor fsensor;
+#elif FILAMENT_SENSOR_TYPE == FSENSOR_IR_ANALOG
 extern IR_sensor_analog fsensor;
+#endif
+
+#endif //FILAMENT_SENSOR

+ 8 - 8
Firmware/ultralcd.cpp

@@ -222,7 +222,7 @@ static FanCheck lcd_selftest_fan_auto(uint8_t _fan);
 static bool lcd_selftest_fsensor();
 #endif //PAT9125
 static bool selftest_irsensor();
-#ifdef IR_SENSOR_ANALOG
+#if defined(FILAMENT_SENSOR) && (FILAMENT_SENSOR_TYPE == FSENSOR_IR_ANALOG)
 static bool lcd_selftest_IRsensor(bool bStandalone=false);
 static void lcd_detect_IRsensor();
 #endif //IR_SENSOR_ANALOG
@@ -1415,7 +1415,7 @@ static void lcd_menu_temperatures()
     menu_back_if_clicked();
 }
 
-#if defined (VOLT_BED_PIN) || defined (VOLT_PWR_PIN) || defined(IR_SENSOR_ANALOG)
+#if defined (VOLT_BED_PIN) || defined (VOLT_PWR_PIN) || (defined(FILAMENT_SENSOR) && (FILAMENT_SENSOR_TYPE == FSENSOR_IR_ANALOG))
 #define VOLT_DIV_R1 10000
 #define VOLT_DIV_R2 2370
 #define VOLT_DIV_FAC ((float)VOLT_DIV_R2 / (VOLT_DIV_R2 + VOLT_DIV_R1))
@@ -1673,7 +1673,7 @@ static void lcd_support_menu()
   MENU_ITEM_BACK_P(_i("Date:"));////MSG_DATE c=17
   MENU_ITEM_BACK_P(PSTR(__DATE__));
 
-#ifdef IR_SENSOR_ANALOG
+#if defined(FILAMENT_SENSOR) && (FILAMENT_SENSOR_TYPE == FSENSOR_IR_ANALOG)
   MENU_ITEM_BACK_P(STR_SEPARATOR);
   MENU_ITEM_BACK_P(PSTR("Fil. sensor v.:"));
   MENU_ITEM_BACK_P(fsensor.getIRVersionText());
@@ -4692,7 +4692,7 @@ void lcd_hw_setup_menu(void)                      // can not be "static"
     SETTINGS_NOZZLE;
     MENU_ITEM_SUBMENU_P(_i("Checks"), lcd_checking_menu);  ////MSG_CHECKS c=18
 
-#ifdef IR_SENSOR_ANALOG
+#if defined(FILAMENT_SENSOR) && (FILAMENT_SENSOR_TYPE == FSENSOR_IR_ANALOG)
     //! 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
     if(!mmu_enabled) MENU_ITEM_FUNCTION_P(PSTR("Fsensor Detection"), lcd_detect_IRsensor);
@@ -6118,7 +6118,7 @@ void lcd_belttest()
 }
 #endif //TMC2130
 
-#ifdef IR_SENSOR_ANALOG
+#if defined(FILAMENT_SENSOR) && (FILAMENT_SENSOR_TYPE == FSENSOR_IR_ANALOG)
 // called also from marlin_main.cpp
 void printf_IRSensorAnalogBoardChange(){
     printf_P(PSTR("Filament sensor board change detected: revision%S\n"), fsensor.getIRVersionText());
@@ -6190,7 +6190,7 @@ bool lcd_selftest()
 	uint8_t _progress = 0;
 	bool _result = true;
 	bool _swapped_fan = false;
-#ifdef IR_SENSOR_ANALOG
+#if defined(FILAMENT_SENSOR) && (FILAMENT_SENSOR_TYPE == FSENSOR_IR_ANALOG)
 	//!   Check if IR sensor is in unknown state, if so run Fsensor Detection
 	//!   As the Fsensor Detection isn't yet ready for the mmu2s we set temporarily the IR sensor 0.3 or older for mmu2s
 	//! @todo Don't forget to remove this as soon Fsensor Detection works with mmu
@@ -6202,7 +6202,7 @@ bool lcd_selftest()
 			fsensor.setSensorRevision(IR_sensor_analog::SensorRevision::_Old, true);
 		}
 	}
-#endif //IR_SENSOR_ANALOG
+#endif
 	lcd_wait_for_cool_down();
 	lcd_clear();
 	lcd_puts_at_P(0, 0, _i("Self test start"));////MSG_SELFTEST_START c=20
@@ -6412,7 +6412,7 @@ bool lcd_selftest()
 #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.
-//def IR_SENSOR_ANALOG
+//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)

+ 1 - 1
Firmware/ultralcd.h

@@ -142,7 +142,7 @@ extern bool FarmOrUserECool();
 #define SILENT_MODE_OFF SILENT_MODE_POWER
 #endif
 
-#ifdef IR_SENSOR_ANALOG
+#if defined(FILAMENT_SENSOR) && (FILAMENT_SENSOR_TYPE == FSENSOR_IR_ANALOG)
 void printf_IRSensorAnalogBoardChange();
 #endif //IR_SENSOR_ANALOG
 

+ 1 - 1
Firmware/variants/1_75mm_MK25S-RAMBo10a-E3Dv6full.h

@@ -125,7 +125,7 @@
 
 // Filament sensor
 #define FILAMENT_SENSOR
-#define IR_SENSOR
+#define FILAMENT_SENSOR_TYPE FSENSOR_IR
 
 #define DEBUG_DCODE2
 #define DEBUG_DCODE3

+ 1 - 1
Firmware/variants/1_75mm_MK25S-RAMBo13a-E3Dv6full.h

@@ -126,7 +126,7 @@
 
 // Filament sensor
 #define FILAMENT_SENSOR
-#define IR_SENSOR
+#define FILAMENT_SENSOR_TYPE FSENSOR_IR
 
 #define DEBUG_DCODE2
 #define DEBUG_DCODE3

+ 1 - 1
Firmware/variants/1_75mm_MK3S-EINSy10a-E3Dv6full.h

@@ -152,7 +152,7 @@
 
 // Filament sensor
 #define FILAMENT_SENSOR
-#define IR_SENSOR
+#define FILAMENT_SENSOR_TYPE FSENSOR_IR_ANALOG
 
 // Backlash - 
 //#define BACKLASH_X