Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply FILAMENT_RUNOUT_SENSOR to MKS_UI #22595

Open
wants to merge 1 commit into
base: bugfix-2.1.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 24 additions & 61 deletions Marlin/src/lcd/extui/mks_ui/printer_operation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,8 @@
#include "../../../feature/powerloss.h"
#endif

#define FILAMENT_IS_OUT(N...) (READ(FIL_RUNOUT##N##_PIN) == FIL_RUNOUT##N##_STATE)
#ifndef FILAMENT_RUNOUT_THRESHOLD
#define FILAMENT_RUNOUT_THRESHOLD 20
#if ENABLED(FILAMENT_RUNOUT_SENSOR)
#include "../../../feature/runout.h"
#endif

extern uint32_t To_pre_view;
Expand Down Expand Up @@ -147,71 +146,35 @@ void printer_state_polling() {
}
#endif

if (uiCfg.print_state == WORKING) filament_check();
#if ENABLED(FILAMENT_RUNOUT_SENSOR)
if (uiCfg.print_state == WORKING) filament_check();
#endif

TERN_(MKS_WIFI_MODULE, wifi_looping());
}

void filament_pin_setup() {
#if PIN_EXISTS(FIL_RUNOUT1)
SET_INPUT_PULLUP(FIL_RUNOUT1_PIN);
#endif
#if PIN_EXISTS(FIL_RUNOUT2)
SET_INPUT_PULLUP(FIL_RUNOUT2_PIN);
#endif
#if PIN_EXISTS(FIL_RUNOUT3)
SET_INPUT_PULLUP(FIL_RUNOUT3_PIN);
#endif
}

void filament_check() {
#if PIN_EXISTS(FIL_RUNOUT1)
static int fil_det_count_1 = 0;
if (FILAMENT_IS_OUT(1))
fil_det_count_1++;
else if (fil_det_count_1 > 0)
fil_det_count_1--;
#endif
#if ENABLED(FILAMENT_RUNOUT_SENSOR)

#if PIN_EXISTS(FIL_RUNOUT2)
static int fil_det_count_2 = 0;
if (FILAMENT_IS_OUT(2))
fil_det_count_2++;
else if (fil_det_count_2 > 0)
fil_det_count_2--;
#endif
void filament_check() {
static bool ranout = false;
if (runout.filament_ran_out != ranout) {
ranout = runout.filament_ran_out;
if (ranout) {
clear_cur_ui();
card.pauseSDPrint();
stop_print_time();
uiCfg.print_state = PAUSING;

#if PIN_EXISTS(FIL_RUNOUT3)
static int fil_det_count_3 = 0;
if (FILAMENT_IS_OUT(3))
fil_det_count_3++;
else if (fil_det_count_3 > 0)
fil_det_count_3--;
#endif
if (gCfgItems.from_flash_pic)
flash_preview_begin = true;
else
default_preview_flg = true;

if (false
#if PIN_EXISTS(FIL_RUNOUT1)
|| fil_det_count_1 >= FILAMENT_RUNOUT_THRESHOLD
#endif
#if PIN_EXISTS(FIL_RUNOUT2)
|| fil_det_count_2 >= FILAMENT_RUNOUT_THRESHOLD
#endif
#if PIN_EXISTS(FIL_RUNOUT3)
|| fil_det_count_3 >= FILAMENT_RUNOUT_THRESHOLD
#endif
) {
clear_cur_ui();
card.pauseSDPrint();
stop_print_time();
uiCfg.print_state = PAUSING;

if (gCfgItems.from_flash_pic)
flash_preview_begin = true;
else
default_preview_flg = true;

lv_draw_printing();
lv_draw_printing();
}
}
}
}

#endif // FILAMENT_RUNOUT_SENSOR

#endif // HAS_TFT_LVGL_UI
1 change: 0 additions & 1 deletion Marlin/src/lcd/extui/mks_ui/printer_operation.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
#define MIN_FILE_PRINTED 100 //5000

void printer_state_polling();
void filament_pin_setup();
void filament_check();

#ifdef __cplusplus
Expand Down
1 change: 0 additions & 1 deletion Marlin/src/lcd/extui/mks_ui/tft_lvgl_configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,6 @@ void tft_lvgl_init() {
TERN_(HAS_SPI_FLASH_FONT, init_gb2312_font());

tft_style_init();
filament_pin_setup();

#if ENABLED(MKS_WIFI_MODULE)
mks_esp_wifi_init();
Expand Down