Skip to content

Commit

Permalink
Filament runout acoustic warning (#1428)
Browse files Browse the repository at this point in the history
  • Loading branch information
kisslorand authored Dec 24, 2020
1 parent 43a9f40 commit 6d87753
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ label_save:保存参数
label_restore:恢复
label_reset:重置
label_default:默认
label_clear:清楚
label_clear:清除
label_next:下一个
label_distance:距离
label_invalid_value:没有有效的条件!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ label_u_disk_removed:U Disk removed!
label_onboardsd:OnboardSD
label_read_onboardsd_error:Read Onboard SD card error!
label_filament_sensor:Filament sensor
label_filament_runout:filament runout!
label_filament_runout:Filament runout!
label_preheat:Preheat
label_preheat_both:Both
label_is_pause:Unable to extrude when\nprinting.\nPause printing?
Expand Down
2 changes: 1 addition & 1 deletion TFT/src/User/API/Language/language_en.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@
#define STRING_ONBOARDSD "OnboardSD"
#define STRING_READ_ONBOARDSD_ERROR "Read Onboard SD card error!"
#define STRING_FILAMENT_SENSOR "Filament sensor"
#define STRING_FILAMENT_RUNOUT "filament runout!"
#define STRING_FILAMENT_RUNOUT "Filament runout!"
#define STRING_PREHEAT "Preheat"
#define STRING_PREHEAT_BOTH "Both"
#define STRING_IS_PAUSE "Unable to extrude when\nprinting.\nPause printing?"
Expand Down
34 changes: 29 additions & 5 deletions TFT/src/User/API/Printing.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

PRINTING infoPrinting;

bool filamentRunoutAlarm;

static bool updateM27_waiting = false;
static float last_E_pos;

Expand Down Expand Up @@ -86,6 +88,21 @@ void setPrintRunout(bool runout)
infoPrinting.runout = runout;
}

void setRunoutAlarmTrue(void)
{
filamentRunoutAlarm = true;
}

void setRunoutAlarmFalse(void)
{
filamentRunoutAlarm = false;
}

bool getRunoutAlarm(void)
{
return filamentRunoutAlarm;
}

void setPrintModelIcon(bool exist)
{
infoPrinting.model_icon = exist;
Expand Down Expand Up @@ -171,8 +188,12 @@ bool setPrintPause(bool is_pause, bool is_m0pause)
case TFT_UDISK:
case TFT_SD:
infoPrinting.pause = is_pause;
if(infoPrinting.pause == true && is_m0pause == false){
while (infoCmd.count != 0) {loopProcess();}
if(infoPrinting.pause == true && is_m0pause == false)
{
while (infoCmd.count != 0)
{
loopProcess();
}
}

bool isCoorRelative = coorGetRelative();
Expand Down Expand Up @@ -404,17 +425,20 @@ void getGcodeFromFile(void)

void breakAndContinue(void)
{
Serial_Puts(SERIAL_PORT, "M108\n");
setRunoutAlarmFalse();
Serial_Puts(SERIAL_PORT, "M108\n");
}

void resumeAndPurge(void)
{
Serial_Puts(SERIAL_PORT, "M876 S0\n");
setRunoutAlarmFalse();
Serial_Puts(SERIAL_PORT, "M876 S0\n");
}

void resumeAndContinue(void)
{
Serial_Puts(SERIAL_PORT, "M876 S1\n");
setRunoutAlarmFalse();
Serial_Puts(SERIAL_PORT, "M876 S1\n");
}

bool hasPrintingMenu(void)
Expand Down
3 changes: 3 additions & 0 deletions TFT/src/User/API/Printing.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ uint32_t getPrintSize(void);
uint32_t getPrintCur(void);
bool getPrintRunout(void);
void setPrintRunout(bool runout);
void setRunoutAlarmFalse(void);
void setRunoutAlarmTrue(void);
bool getRunoutAlarm(void);
void setPrintModelIcon(bool exist);
bool getPrintModelIcon(void);

Expand Down
16 changes: 13 additions & 3 deletions TFT/src/User/API/extend.c
Original file line number Diff line number Diff line change
Expand Up @@ -209,12 +209,22 @@ void loopBackEndFILRunoutDetect(void)

void loopFrontEndFILRunoutDetect(void)
{
if (!getPrintRunout()) return;
static uint32_t nextTime = 0;
#define ALARM_REMINDER_TIME 10000
if (!getPrintRunout() && !getRunoutAlarm()) return;

if (setPrintPause(true,false))
if (setPrintPause(true,false) && !getRunoutAlarm())
{
setPrintRunout(false);
popupReminder(DIALOG_TYPE_ERROR, LABEL_WARNING, LABEL_FILAMENT_RUNOUT);
setRunoutAlarmTrue();
setDialogText(LABEL_WARNING, LABEL_FILAMENT_RUNOUT, LABEL_CONFIRM, LABEL_BACKGROUND);
showDialog(DIALOG_TYPE_ALERT, setRunoutAlarmFalse, NULL, NULL);
}

if ((OS_GetTimeMs() > nextTime) && (getRunoutAlarm() == true))
{
BUZZER_PLAY(sound_error);
nextTime = OS_GetTimeMs() + ALARM_REMINDER_TIME;
}
}

Expand Down
7 changes: 6 additions & 1 deletion TFT/src/User/API/parseACK.c
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,8 @@ void hostActionCommands(void)
{
case 0:
BUZZER_PLAY(sound_notify);
popupReminder(DIALOG_TYPE_ALERT,(u8 *)"Message", (u8 *)hostAction.prompt_begin);
setDialogText((uint8_t *)"Message", (uint8_t *)hostAction.prompt_begin, LABEL_CONFIRM, LABEL_BACKGROUND);
showDialog(DIALOG_TYPE_ALERT, setRunoutAlarmFalse, NULL, NULL);
break;
case 1:
BUZZER_PLAY(sound_notify);
Expand All @@ -255,6 +256,10 @@ void hostActionCommands(void)
if (ack_seen("paused") || ack_seen("pause"))
{
infoPrinting.pause = true;
if (ack_seen ("filament_runout"))
{
setRunoutAlarmTrue();
}
}
else if (ack_seen("cancel")) //To be added to Marlin abortprint routine
{
Expand Down

0 comments on commit 6d87753

Please sign in to comment.