fix. warning "Macro expansion producing 'defined' has undefined

behavior"
update screen layout comments
This commit is contained in:
D.R.racer 2020-03-26 14:40:47 +01:00
parent ff479afd88
commit 34ac2917ae
8 changed files with 42 additions and 43 deletions

View File

@ -9445,7 +9445,7 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) //default argument s
{ {
#ifdef FILAMENT_SENSOR #ifdef FILAMENT_SENSOR
bool bInhibitFlag; bool bInhibitFlag;
#if IR_SENSOR_ANALOG #ifdef IR_SENSOR_ANALOG
static uint8_t nFSCheckCount=0; static uint8_t nFSCheckCount=0;
#endif // IR_SENSOR_ANALOG #endif // IR_SENSOR_ANALOG
@ -9457,7 +9457,7 @@ static uint8_t nFSCheckCount=0;
#endif // PAT9125 #endif // PAT9125
#ifdef IR_SENSOR #ifdef IR_SENSOR
bInhibitFlag=(menu_menu==lcd_menu_show_sensors_state); // Support::SensorInfo menu active bInhibitFlag=(menu_menu==lcd_menu_show_sensors_state); // Support::SensorInfo menu active
#if IR_SENSOR_ANALOG #ifdef IR_SENSOR_ANALOG
bInhibitFlag=bInhibitFlag||bMenuFSDetect; // Settings::HWsetup::FSdetect menu active bInhibitFlag=bInhibitFlag||bMenuFSDetect; // Settings::HWsetup::FSdetect menu active
#endif // IR_SENSOR_ANALOG #endif // IR_SENSOR_ANALOG
#endif // IR_SENSOR #endif // IR_SENSOR
@ -9465,7 +9465,7 @@ static uint8_t nFSCheckCount=0;
{ {
if (!moves_planned() && !IS_SD_PRINTING && !is_usb_printing && (lcd_commands_type != LcdCommands::Layer1Cal) && ! eeprom_read_byte((uint8_t*)EEPROM_WIZARD_ACTIVE)) if (!moves_planned() && !IS_SD_PRINTING && !is_usb_printing && (lcd_commands_type != LcdCommands::Layer1Cal) && ! eeprom_read_byte((uint8_t*)EEPROM_WIZARD_ACTIVE))
{ {
#if IR_SENSOR_ANALOG #ifdef IR_SENSOR_ANALOG
bool bTemp=current_voltage_raw_IR>IRsensor_Hmin_TRESHOLD; bool bTemp=current_voltage_raw_IR>IRsensor_Hmin_TRESHOLD;
bTemp=bTemp&&current_voltage_raw_IR<IRsensor_Hopen_TRESHOLD; bTemp=bTemp&&current_voltage_raw_IR<IRsensor_Hopen_TRESHOLD;
bTemp=bTemp&&(!CHECK_ALL_HEATERS); bTemp=bTemp&&(!CHECK_ALL_HEATERS);

View File

@ -5,10 +5,12 @@
#include "Configuration_prusa.h" #include "Configuration_prusa.h"
#include "pins.h" #include "pins.h"
#define IR_SENSOR_ANALOG (defined(VOLT_IR_PIN) && defined(IR_SENSOR)) #if (defined(VOLT_IR_PIN) && defined(IR_SENSOR))
# define IR_SENSOR_ANALOG
#endif
//ADC configuration //ADC configuration
#if !IR_SENSOR_ANALOG #ifndef IR_SENSOR_ANALOG
#define ADC_CHAN_MSK 0b0000001001011111 //used AD channels bit mask (0,1,2,3,4,6,9) #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_DIDR_MSK 0b0000001001011111 //AD channels DIDR mask (1 ~ disabled digital input)
#define ADC_CHAN_CNT 7 //number of used channels) #define ADC_CHAN_CNT 7 //number of used channels)

View File

@ -111,7 +111,7 @@ int16_t fsensor_oq_yd_max;
uint16_t fsensor_oq_sh_sum; uint16_t fsensor_oq_sh_sum;
//! @} //! @}
#if IR_SENSOR_ANALOG #ifdef IR_SENSOR_ANALOG
ClFsensorPCB oFsensorPCB; ClFsensorPCB oFsensorPCB;
ClFsensorActionNA oFsensorActionNA; ClFsensorActionNA oFsensorActionNA;
bool bIRsensorStateFlag=false; bool bIRsensorStateFlag=false;
@ -160,7 +160,7 @@ void fsensor_init(void)
fsensor_not_responding = true; fsensor_not_responding = true;
} }
#endif //PAT9125 #endif //PAT9125
#if IR_SENSOR_ANALOG #ifdef IR_SENSOR_ANALOG
bIRsensorStateFlag=false; bIRsensorStateFlag=false;
oFsensorPCB=(ClFsensorPCB)eeprom_read_byte((uint8_t*)EEPROM_FSENSOR_PCB); oFsensorPCB=(ClFsensorPCB)eeprom_read_byte((uint8_t*)EEPROM_FSENSOR_PCB);
oFsensorActionNA=(ClFsensorActionNA)eeprom_read_byte((uint8_t*)EEPROM_FSENSOR_ACTION_NA); oFsensorActionNA=(ClFsensorActionNA)eeprom_read_byte((uint8_t*)EEPROM_FSENSOR_ACTION_NA);
@ -170,7 +170,7 @@ void fsensor_init(void)
else else
fsensor_disable(false); // (in this case) EEPROM update is not necessary fsensor_disable(false); // (in this case) EEPROM update is not necessary
printf_P(PSTR("FSensor %S"), (fsensor_enabled?PSTR("ENABLED"):PSTR("DISABLED"))); printf_P(PSTR("FSensor %S"), (fsensor_enabled?PSTR("ENABLED"):PSTR("DISABLED")));
#if IR_SENSOR_ANALOG #ifdef IR_SENSOR_ANALOG
printf_P(PSTR(" (sensor board revision: %S)\n"),(oFsensorPCB==ClFsensorPCB::_Rev03b)?PSTR("03b or newer"):PSTR("03 or older")); printf_P(PSTR(" (sensor board revision: %S)\n"),(oFsensorPCB==ClFsensorPCB::_Rev03b)?PSTR("03b or newer"):PSTR("03 or older"));
#else //IR_SENSOR_ANALOG #else //IR_SENSOR_ANALOG
printf_P(PSTR("\n")); printf_P(PSTR("\n"));
@ -204,7 +204,7 @@ bool fsensor_enable(bool bUpdateEEPROM)
FSensorStateMenu = 1; FSensorStateMenu = 1;
} }
#else // PAT9125 #else // PAT9125
#if IR_SENSOR_ANALOG #ifdef IR_SENSOR_ANALOG
if(!fsensor_IR_check()) if(!fsensor_IR_check())
{ {
bUpdateEEPROM=true; bUpdateEEPROM=true;
@ -217,7 +217,7 @@ bool fsensor_enable(bool bUpdateEEPROM)
fsensor_enabled=true; fsensor_enabled=true;
fsensor_not_responding=false; fsensor_not_responding=false;
FSensorStateMenu=1; FSensorStateMenu=1;
#if IR_SENSOR_ANALOG #ifdef IR_SENSOR_ANALOG
} }
#endif //IR_SENSOR_ANALOG #endif //IR_SENSOR_ANALOG
if(bUpdateEEPROM) if(bUpdateEEPROM)
@ -608,7 +608,7 @@ void fsensor_update(void)
{ {
if(digitalRead(IR_SENSOR_PIN)) if(digitalRead(IR_SENSOR_PIN))
{ // IR_SENSOR_PIN ~ H { // IR_SENSOR_PIN ~ H
#if IR_SENSOR_ANALOG #ifdef IR_SENSOR_ANALOG
if(!bIRsensorStateFlag) if(!bIRsensorStateFlag)
{ {
bIRsensorStateFlag=true; bIRsensorStateFlag=true;
@ -651,7 +651,7 @@ void fsensor_update(void)
#endif //IR_SENSOR_ANALOG #endif //IR_SENSOR_ANALOG
fsensor_checkpoint_print(); fsensor_checkpoint_print();
fsensor_enque_M600(); fsensor_enque_M600();
#if IR_SENSOR_ANALOG #ifdef IR_SENSOR_ANALOG
} }
} }
} }
@ -665,7 +665,7 @@ void fsensor_update(void)
#endif //PAT9125 #endif //PAT9125
} }
#if IR_SENSOR_ANALOG #ifdef IR_SENSOR_ANALOG
bool fsensor_IR_check() bool fsensor_IR_check()
{ {
uint16_t volt_IR_int; uint16_t volt_IR_int;

View File

@ -72,7 +72,7 @@ extern void fsensor_st_block_chunk(int cnt);
//! @} //! @}
#if IR_SENSOR_ANALOG #ifdef IR_SENSOR_ANALOG
#define IR_SENSOR_STEADY 10 // [ms] #define IR_SENSOR_STEADY 10 // [ms]
enum class ClFsensorPCB:uint_least8_t enum class ClFsensorPCB:uint_least8_t

View File

@ -73,7 +73,7 @@ int current_voltage_raw_pwr = 0;
int current_voltage_raw_bed = 0; int current_voltage_raw_bed = 0;
#endif #endif
#if IR_SENSOR_ANALOG #ifdef IR_SENSOR_ANALOG
int current_voltage_raw_IR = 0; int current_voltage_raw_IR = 0;
#endif //IR_SENSOR_ANALOG #endif //IR_SENSOR_ANALOG
@ -1595,7 +1595,7 @@ void adc_ready(void) //callback from adc when sampling finished
#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
#if IR_SENSOR_ANALOG #ifdef IR_SENSOR_ANALOG
current_voltage_raw_IR = adc_values[ADC_PIN_IDX(VOLT_IR_PIN)]; current_voltage_raw_IR = adc_values[ADC_PIN_IDX(VOLT_IR_PIN)];
#endif //IR_SENSOR_ANALOG #endif //IR_SENSOR_ANALOG
temp_meas_ready = true; temp_meas_ready = true;

View File

@ -78,7 +78,7 @@ extern int current_voltage_raw_pwr;
extern int current_voltage_raw_bed; extern int current_voltage_raw_bed;
#endif #endif
#if IR_SENSOR_ANALOG #ifdef IR_SENSOR_ANALOG
extern int current_voltage_raw_IR; extern int current_voltage_raw_IR;
#endif //IR_SENSOR_ANALOG #endif //IR_SENSOR_ANALOG

View File

@ -68,7 +68,7 @@ uint8_t SilentModeMenu_MMU = 1; //activate mmu unit stealth mode
int8_t FSensorStateMenu = 1; int8_t FSensorStateMenu = 1;
#if IR_SENSOR_ANALOG #ifdef IR_SENSOR_ANALOG
bool bMenuFSDetect=false; bool bMenuFSDetect=false;
#endif //IR_SENSOR_ANALOG #endif //IR_SENSOR_ANALOG
@ -239,7 +239,7 @@ static FanCheck lcd_selftest_fan_auto(int _fan);
static bool lcd_selftest_fsensor(); static bool lcd_selftest_fsensor();
#endif //PAT9125 #endif //PAT9125
static bool selftest_irsensor(); static bool selftest_irsensor();
#if IR_SENSOR_ANALOG #ifdef IR_SENSOR_ANALOG
static bool lcd_selftest_IRsensor(bool bStandalone=false); static bool lcd_selftest_IRsensor(bool bStandalone=false);
static void lcd_detect_IRsensor(); static void lcd_detect_IRsensor();
#endif //IR_SENSOR_ANALOG #endif //IR_SENSOR_ANALOG
@ -1945,7 +1945,7 @@ static void lcd_menu_temperatures()
menu_back_if_clicked(); menu_back_if_clicked();
} }
#if defined (VOLT_BED_PIN) || defined (VOLT_PWR_PIN) || IR_SENSOR_ANALOG #if defined (VOLT_BED_PIN) || defined (VOLT_PWR_PIN) || defined(IR_SENSOR_ANALOG)
#define VOLT_DIV_R1 10000 #define VOLT_DIV_R1 10000
#define VOLT_DIV_R2 2370 #define VOLT_DIV_R2 2370
#define VOLT_DIV_FAC ((float)VOLT_DIV_R2 / (VOLT_DIV_R2 + VOLT_DIV_R1)) #define VOLT_DIV_FAC ((float)VOLT_DIV_R2 / (VOLT_DIV_R2 + VOLT_DIV_R1))
@ -1957,7 +1957,7 @@ static void lcd_menu_temperatures()
//! | | //! | |
//! | PWR: 00.0V | c=12 r=1 //! | PWR: 00.0V | c=12 r=1
//! | Bed: 00.0V | c=12 r=1 //! | Bed: 00.0V | c=12 r=1
//! | | //! | IR : 00.0V | c=12 r=1 optional
//! ---------------------- //! ----------------------
//! @endcode //! @endcode
//! @todo Positioning of the messages and values on LCD aren't fixed to their exact place. This causes issues with translations. //! @todo Positioning of the messages and values on LCD aren't fixed to their exact place. This causes issues with translations.
@ -1967,17 +1967,14 @@ static void lcd_menu_voltages()
float volt_pwr = VOLT_DIV_REF * ((float)current_voltage_raw_pwr / (1023 * OVERSAMPLENR)) / VOLT_DIV_FAC; float volt_pwr = VOLT_DIV_REF * ((float)current_voltage_raw_pwr / (1023 * OVERSAMPLENR)) / VOLT_DIV_FAC;
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();
#if !IR_SENSOR_ANALOG
lcd_printf_P(PSTR("\n"));
#endif //!IR_SENSOR_ANALOG
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);
#if IR_SENSOR_ANALOG #ifdef IR_SENSOR_ANALOG
float volt_IR = VOLT_DIV_REF * ((float)current_voltage_raw_IR / (1023 * OVERSAMPLENR)); float volt_IR = VOLT_DIV_REF * ((float)current_voltage_raw_IR / (1023 * OVERSAMPLENR));
lcd_printf_P(PSTR("\n IR : %3.1fV"),volt_IR); lcd_printf_P(PSTR("\n IR : %3.1fV"),volt_IR);
#endif //IR_SENSOR_ANALOG #endif //IR_SENSOR_ANALOG
menu_back_if_clicked(); menu_back_if_clicked();
} }
#endif //defined (VOLT_BED_PIN) || defined (VOLT_PWR_PIN) || IR_SENSOR_ANALOG #endif //defined (VOLT_BED_PIN) || defined (VOLT_PWR_PIN) || defined(IR_SENSOR_ANALOG)
#ifdef TMC2130 #ifdef TMC2130
//! @brief Show Belt Status //! @brief Show Belt Status
@ -2151,7 +2148,7 @@ static void lcd_support_menu()
MENU_ITEM_BACK_P(_i("Date:"));////MSG_DATE c=17 r=1 MENU_ITEM_BACK_P(_i("Date:"));////MSG_DATE c=17 r=1
MENU_ITEM_BACK_P(PSTR(__DATE__)); MENU_ITEM_BACK_P(PSTR(__DATE__));
#if IR_SENSOR_ANALOG #ifdef IR_SENSOR_ANALOG
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.:"));
switch(oFsensorPCB) switch(oFsensorPCB)
@ -5653,7 +5650,7 @@ SETTINGS_VERSION;
MENU_END(); MENU_END();
} }
#if IR_SENSOR_ANALOG #ifdef IR_SENSOR_ANALOG
static void lcd_fsensor_actionNA_set(void) static void lcd_fsensor_actionNA_set(void)
{ {
switch(oFsensorActionNA) switch(oFsensorActionNA)
@ -5719,7 +5716,7 @@ void lcd_hw_setup_menu(void) // can not be "static"
SETTINGS_NOZZLE; SETTINGS_NOZZLE;
MENU_ITEM_SUBMENU_P(_i("Checks"), lcd_checking_menu); MENU_ITEM_SUBMENU_P(_i("Checks"), lcd_checking_menu);
#if IR_SENSOR_ANALOG #ifdef IR_SENSOR_ANALOG
FSENSOR_ACTION_NA; FSENSOR_ACTION_NA;
MENU_ITEM_FUNCTION_P(PSTR("FS Detect"), lcd_detect_IRsensor); MENU_ITEM_FUNCTION_P(PSTR("FS Detect"), lcd_detect_IRsensor);
#endif //IR_SENSOR_ANALOG #endif //IR_SENSOR_ANALOG
@ -7140,7 +7137,7 @@ static void lcd_tune_menu()
else { else {
MENU_ITEM_TOGGLE_P(_T(MSG_FSENSOR), _T(MSG_ON), lcd_fsensor_state_set); MENU_ITEM_TOGGLE_P(_T(MSG_FSENSOR), _T(MSG_ON), lcd_fsensor_state_set);
} }
#if IR_SENSOR_ANALOG #ifdef IR_SENSOR_ANALOG
FSENSOR_ACTION_NA; FSENSOR_ACTION_NA;
#endif //IR_SENSOR_ANALOG #endif //IR_SENSOR_ANALOG
#endif //FILAMENT_SENSOR #endif //FILAMENT_SENSOR
@ -7520,7 +7517,7 @@ void lcd_belttest()
} }
#endif //TMC2130 #endif //TMC2130
#if IR_SENSOR_ANALOG #ifdef IR_SENSOR_ANALOG
static bool lcd_selftest_IRsensor(bool bStandalone) static bool lcd_selftest_IRsensor(bool bStandalone)
{ {
bool bAction; bool bAction;
@ -7586,7 +7583,7 @@ bool lcd_selftest()
int _progress = 0; int _progress = 0;
bool _result = true; bool _result = true;
bool _swapped_fan = false; bool _swapped_fan = false;
//#if IR_SENSOR_ANALOG //#ifdef IR_SENSOR_ANALOG
#if (0) #if (0)
bool bAction; bool bAction;
bAction=lcd_show_fullscreen_message_yes_no_and_wait_P(_i("Is the filament unloaded?"),false,true); bAction=lcd_show_fullscreen_message_yes_no_and_wait_P(_i("Is the filament unloaded?"),false,true);
@ -7796,7 +7793,7 @@ 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 //PAT9125 #endif //PAT9125
//#if IR_SENSOR_ANALOG //#ifdef IR_SENSOR_ANALOG
#if (0) #if (0)
_progress = lcd_selftest_screen(TestScreen::Fsensor, _progress, 3, true, 2000); //check filament sensor _progress = lcd_selftest_screen(TestScreen::Fsensor, _progress, 3, true, 2000); //check filament sensor
_result = lcd_selftest_IRsensor(); _result = lcd_selftest_IRsensor();

View File

@ -140,7 +140,7 @@ extern uint8_t farm_status;
#define SILENT_MODE_OFF SILENT_MODE_POWER #define SILENT_MODE_OFF SILENT_MODE_POWER
#endif #endif
#if IR_SENSOR_ANALOG #ifdef IR_SENSOR_ANALOG
extern bool bMenuFSDetect; extern bool bMenuFSDetect;
#endif //IR_SENSOR_ANALOG #endif //IR_SENSOR_ANALOG
@ -257,7 +257,7 @@ enum class WizState : uint8_t
void lcd_wizard(WizState state); void lcd_wizard(WizState state);
#define VOLT_DIV_REF 5 #define VOLT_DIV_REF 5
#if IR_SENSOR_ANALOG #ifdef IR_SENSOR_ANALOG
#define IRsensor_Hmin_TRESHOLD (3.0*1023*OVERSAMPLENR/VOLT_DIV_REF) // ~3.0V (0.6*Vcc) #define IRsensor_Hmin_TRESHOLD (3.0*1023*OVERSAMPLENR/VOLT_DIV_REF) // ~3.0V (0.6*Vcc)
#define IRsensor_Lmax_TRESHOLD (1.5*1023*OVERSAMPLENR/VOLT_DIV_REF) // ~1.5V (0.3*Vcc) #define IRsensor_Lmax_TRESHOLD (1.5*1023*OVERSAMPLENR/VOLT_DIV_REF) // ~1.5V (0.3*Vcc)
#define IRsensor_Hopen_TRESHOLD (4.6*1023*OVERSAMPLENR/VOLT_DIV_REF) // ~4.6V (N.C. @ Ru~20-50k, Rd'=56k, Ru'=10k) #define IRsensor_Hopen_TRESHOLD (4.6*1023*OVERSAMPLENR/VOLT_DIV_REF) // ~4.6V (N.C. @ Ru~20-50k, Rd'=56k, Ru'=10k)