ALTFAN override

This commit is contained in:
Alex Voinea 2020-07-20 19:35:25 +03:00
parent 45e182911d
commit a95feb56d9
No known key found for this signature in database
GPG Key ID: F5034E7CFCF2F973
6 changed files with 52 additions and 5 deletions

View File

@ -8570,7 +8570,15 @@ Sigma_Exit:
break;
/*!
### M999 - Restart after being stopped <a href="https://reprap.org/wiki/G-code#M999:_Restart_after_being_stopped_by_error">M999: Restart after being stopped by error</a>
### M666 - Enter experimental menu
Only used by Prusa
*/
case 666:
menu_submenu(lcd_experimental_menu);
break;
/*!
### M999 - Restart after being stopped <a href="https://reprap.org/wiki/G-code#M999:_Restart_after_being_stopped_by_error">M999: Restart after being stopped by error</a>
@todo Usually doesn't work. Should be fixed or removed. Most of the time, if `Stopped` it set, the print fails and is unrecoverable.
*/
case 999:

View File

@ -561,8 +561,10 @@ static Sheets * const EEPROM_Sheets_base = (Sheets*)(EEPROM_SHEETS_BASE);
#define EEPROM_UVLO_LA_K (EEPROM_BACKLIGHT_TIMEOUT-4) // float
#define EEPROM_ALTFAN_OVERRIDE (EEPROM_UVLO_LA_K-1) //uint8
//This is supposed to point to last item to allow EEPROM overrun check. Please update when adding new items.
#define EEPROM_LAST_ITEM EEPROM_UVLO_LA_K
#define EEPROM_LAST_ITEM EEPROM_ALTFAN_OVERRIDE
// !!!!!
// !!!!! this is end of EEPROM section ... all updates MUST BE inserted before this mark !!!!!
// !!!!!

View File

@ -153,6 +153,7 @@ uint8_t fanSpeedBckp = 255;
uint8_t fanState = 0;
#ifdef EXTRUDER_ALTFAN_DETECT
bool extruderFanIsAltfan = false; //set to Noctua
uint8_t altfanOverride = 0;
#endif //EXTRUDER_ALTFAN_DETECT
#endif
@ -224,6 +225,14 @@ bool extruder_altfan_detect()
setExtruderAutoFanState(3);
SET_INPUT(TACH_0);
altfanOverride = eeprom_read_byte((uint8_t *)EEPROM_ALTFAN_OVERRIDE);
if (altfanOverride == EEPROM_EMPTY_VALUE)
{
altfanOverride = 0;
eeprom_update_byte((uint8_t *)EEPROM_ALTFAN_OVERRIDE, altfanOverride);
}
CRITICAL_SECTION_START;
EICRB &= ~(1 << ISC61);
EICRB |= (1 << ISC60);
@ -241,6 +250,18 @@ bool extruder_altfan_detect()
setExtruderAutoFanState(1);
return extruderFanIsAltfan;
}
void altfanOverride_toggle()
{
altfanOverride = !altfanOverride;
eeprom_update_byte((uint8_t *)EEPROM_ALTFAN_OVERRIDE, altfanOverride);
}
bool altfanOverride_get()
{
return altfanOverride;
}
#endif //EXTRUDER_ALTFAN_DETECT
// return "false", if all extruder-heaters are 'off' (ie. "true", if any heater is 'on')
@ -494,7 +515,7 @@ void setExtruderAutoFanState(uint8_t state)
if (fanState & 0x01)
{
#ifdef EXTRUDER_ALTFAN_DETECT
if (extruderFanIsAltfan) newFanSpeed = EXTRUDER_ALTFAN_SPEED_SILENT;
if (extruderFanIsAltfan && !altfanOverride) newFanSpeed = EXTRUDER_ALTFAN_SPEED_SILENT;
else newFanSpeed = EXTRUDER_AUTO_FAN_SPEED;
#else //EXTRUDER_ALTFAN_DETECT
newFanSpeed = EXTRUDER_AUTO_FAN_SPEED;
@ -1356,7 +1377,7 @@ void temp_runaway_stop(bool isPreheat, bool isBed)
SERIAL_ERROR_START;
isBed ? SERIAL_ERRORLNPGM(" THERMAL RUNAWAY ( PREHEAT HEATBED)") : SERIAL_ERRORLNPGM(" THERMAL RUNAWAY ( PREHEAT HOTEND)");
#ifdef EXTRUDER_ALTFAN_DETECT
extruderFanIsAltfan = false; //full speed
altfanOverride = true; //full speed
#endif //EXTRUDER_ALTFAN_DETECT
setExtruderAutoFanState(3);
SET_OUTPUT(FAN_PIN);
@ -1446,7 +1467,7 @@ void max_temp_error(uint8_t e) {
WRITE(FAN_PIN, 1);
WRITE(BEEPER, 1);
#ifdef EXTRUDER_ALTFAN_DETECT
extruderFanIsAltfan = false; //full speed
altfanOverride = true; //full speed
#endif //EXTRUDER_ALTFAN_DETECT
setExtruderAutoFanState(3);
// fanSpeed will consumed by the check_axes_activity() routine.

View File

@ -273,6 +273,8 @@ void check_max_temp();
#ifdef EXTRUDER_ALTFAN_DETECT
extern bool extruder_altfan_detect();
extern void altfanOverride_toggle();
extern bool altfanOverride_get();
#endif //EXTRUDER_ALTFAN_DETECT
extern unsigned long extruder_autofan_last_check;

View File

@ -9160,3 +9160,15 @@ void lcd_crash_detect_disable()
eeprom_update_byte((uint8_t*)EEPROM_CRASH_DET, 0x00);
}
#endif
void lcd_experimental_menu()
{
MENU_BEGIN();
MENU_ITEM_BACK_P(_T(MSG_BACK));
#ifdef EXTRUDER_ALTFAN_DETECT
MENU_ITEM_TOGGLE_P(_N("ALTFAN det."), altfanOverride_get()?_T(MSG_OFF):_T(MSG_ON), altfanOverride_toggle);
#endif //EXTRUDER_ALTFAN_DETECT
MENU_END();
}

View File

@ -257,4 +257,6 @@ enum class WizState : uint8_t
void lcd_wizard(WizState state);
extern void lcd_experimental_menu();
#endif //ULTRALCD_H