diff --git a/CMakeLists.txt b/CMakeLists.txt index 0a48c9309..aa08d6ba8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -182,6 +182,7 @@ set(FW_SOURCES Filament_sensor.cpp first_lay_cal.cpp heatbed_pwm.cpp + host.cpp la10compat.cpp language.c lcd.cpp diff --git a/Firmware/Configuration_adv.h b/Firmware/Configuration_adv.h index 94b86c608..34c683ce2 100644 --- a/Firmware/Configuration_adv.h +++ b/Firmware/Configuration_adv.h @@ -66,6 +66,9 @@ */ #define AUTO_REPORT +// Keepalive period which is restarted with M79 +#define M79_TIMEOUT 30 * 1000 // ms + //=========================================================================== //=============================Mechanical Settings=========================== //=========================================================================== diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 5cc53da95..eb703187a 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -68,6 +68,7 @@ #include "backlight.h" #include "planner.h" +#include "host.h" #include "stepper.h" #include "temperature.h" #include "fancheck.h" @@ -5850,6 +5851,20 @@ Sigma_Exit: } break; } + + /*! + ### M79 - TODO + Restart the printer-host enable keepalive timer. While the timer has not expired, the printer will enable host specific features. + #### Usage + + M79 + #### Parameters + None + */ + case 79: + M79_timer_restart(); + break; + /*! ### M104 - Set hotend temperature M104: Set Extruder Temperature #### Usage @@ -6306,7 +6321,6 @@ Sigma_Exit: case 113: if (code_seen('S')) { host_keepalive_interval = code_value_uint8(); -// NOMORE(host_keepalive_interval, 60); } else { SERIAL_ECHO_START; @@ -9424,6 +9438,7 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) //default argument s host_autoreport(); #endif //AUTO_REPORT host_keepalive(); + M79_timer_update_status(); } void kill(const char *full_screen_message) { diff --git a/Firmware/host.cpp b/Firmware/host.cpp new file mode 100644 index 000000000..bd3c7c1e3 --- /dev/null +++ b/Firmware/host.cpp @@ -0,0 +1,17 @@ +#include "Configuration_adv.h" +#include "host.h" +#include "Timer.h" + +static LongTimer M79_timer; + +void M79_timer_restart() { + M79_timer.start(); +} + +bool M79_timer_get_status() { + return M79_timer.running(); +} + +void M79_timer_update_status() { + M79_timer.expired(M79_TIMEOUT); +} diff --git a/Firmware/host.h b/Firmware/host.h new file mode 100644 index 000000000..373d6a28f --- /dev/null +++ b/Firmware/host.h @@ -0,0 +1,12 @@ +#pragma once + +/// Restart the M79 timer +void M79_timer_restart(); + +/// Get the current M79 timer status +/// @returns true if running, false otherwise +bool M79_timer_get_status(); + +/// Checks if the timer period has expired. If the timer +/// has expired, the timer is stopped +void M79_timer_update_status();