2018-10-23 00:37:48 +00:00
|
|
|
/**
|
|
|
|
* Marlin 3D Printer Firmware
|
2020-02-03 14:00:57 +00:00
|
|
|
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
2018-10-23 00:37:48 +00:00
|
|
|
*
|
|
|
|
* Based on Sprinter and grbl.
|
2019-06-28 04:57:50 +00:00
|
|
|
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
2018-10-23 00:37:48 +00:00
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2020-07-23 03:20:14 +00:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2018-10-23 00:37:48 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2018-10-08 20:44:05 +00:00
|
|
|
/**************
|
|
|
|
* ui_api.cpp *
|
|
|
|
**************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Written By Marcio Teixeira 2018 - Aleph Objects, Inc. *
|
|
|
|
* *
|
|
|
|
* This program is free software: you can redistribute it and/or modify *
|
|
|
|
* it under the terms of the GNU General Public License as published by *
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or *
|
|
|
|
* (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
* This program is distributed in the hope that it will be useful, *
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
* GNU General Public License for more details. *
|
|
|
|
* *
|
|
|
|
* To view a copy of the GNU General Public License, go to the following *
|
2020-11-07 01:09:29 +00:00
|
|
|
* location: <https://www.gnu.org/licenses/>. *
|
2018-10-08 20:44:05 +00:00
|
|
|
****************************************************************************/
|
|
|
|
|
2018-10-31 22:07:52 +00:00
|
|
|
#include "../../inc/MarlinConfigPre.h"
|
2018-10-08 20:44:05 +00:00
|
|
|
|
|
|
|
#if ENABLED(EXTENSIBLE_UI)
|
|
|
|
|
2020-10-17 00:36:25 +00:00
|
|
|
#include "../marlinui.h"
|
2018-10-08 20:44:05 +00:00
|
|
|
#include "../../gcode/queue.h"
|
|
|
|
#include "../../module/motion.h"
|
|
|
|
#include "../../module/planner.h"
|
|
|
|
#include "../../module/probe.h"
|
|
|
|
#include "../../module/temperature.h"
|
2019-03-05 12:39:15 +00:00
|
|
|
#include "../../module/printcounter.h"
|
2018-10-08 20:44:05 +00:00
|
|
|
#include "../../libs/duration_t.h"
|
2018-10-23 00:37:48 +00:00
|
|
|
#include "../../HAL/shared/Delay.h"
|
2020-05-04 18:57:12 +00:00
|
|
|
#include "../../sd/cardreader.h"
|
2018-10-08 20:44:05 +00:00
|
|
|
|
2019-03-05 12:39:15 +00:00
|
|
|
#if ENABLED(PRINTCOUNTER)
|
|
|
|
#include "../../core/utility.h"
|
2019-06-11 10:58:43 +00:00
|
|
|
#include "../../libs/numtostr.h"
|
2019-03-05 12:39:15 +00:00
|
|
|
#endif
|
|
|
|
|
2020-09-20 23:29:08 +00:00
|
|
|
#if HAS_MULTI_EXTRUDER
|
2018-10-08 20:44:05 +00:00
|
|
|
#include "../../module/tool_change.h"
|
|
|
|
#endif
|
|
|
|
|
2019-02-12 21:55:47 +00:00
|
|
|
#if ENABLED(EMERGENCY_PARSER)
|
2020-03-13 21:29:29 +00:00
|
|
|
#include "../../feature/e_parser.h"
|
2019-02-12 21:55:47 +00:00
|
|
|
#endif
|
|
|
|
|
2020-03-02 18:03:43 +00:00
|
|
|
#if HAS_TRINAMIC_CONFIG
|
2019-01-18 00:48:29 +00:00
|
|
|
#include "../../feature/tmc_util.h"
|
2019-09-01 00:44:45 +00:00
|
|
|
#include "../../module/stepper/indirection.h"
|
2019-01-18 00:48:29 +00:00
|
|
|
#endif
|
|
|
|
|
2018-10-08 20:44:05 +00:00
|
|
|
#include "ui_api.h"
|
|
|
|
|
|
|
|
#if ENABLED(BACKLASH_GCODE)
|
2019-05-04 04:53:15 +00:00
|
|
|
#include "../../feature/backlash.h"
|
2018-10-08 20:44:05 +00:00
|
|
|
#endif
|
|
|
|
|
2019-03-17 12:57:54 +00:00
|
|
|
#if HAS_LEVELING
|
2019-03-26 01:41:38 +00:00
|
|
|
#include "../../feature/bedlevel/bedlevel.h"
|
2019-03-17 12:57:54 +00:00
|
|
|
#endif
|
|
|
|
|
2019-02-13 02:08:34 +00:00
|
|
|
#if HAS_FILAMENT_SENSOR
|
2018-10-16 12:28:52 +00:00
|
|
|
#include "../../feature/runout.h"
|
|
|
|
#endif
|
|
|
|
|
2019-11-24 12:08:05 +00:00
|
|
|
#if ENABLED(CASE_LIGHT_ENABLE)
|
|
|
|
#include "../../feature/caselight.h"
|
|
|
|
#endif
|
|
|
|
|
2019-04-06 23:04:34 +00:00
|
|
|
#if ENABLED(BABYSTEPPING)
|
|
|
|
#include "../../feature/babystep.h"
|
|
|
|
#endif
|
|
|
|
|
2019-07-17 09:07:41 +00:00
|
|
|
#if ENABLED(HOST_PROMPT_SUPPORT)
|
|
|
|
#include "../../feature/host_actions.h"
|
|
|
|
#endif
|
|
|
|
|
2018-11-14 19:13:51 +00:00
|
|
|
namespace ExtUI {
|
2019-09-19 00:35:03 +00:00
|
|
|
static struct {
|
2019-09-25 23:46:36 +00:00
|
|
|
uint8_t printer_killed : 1;
|
2020-04-22 21:35:03 +00:00
|
|
|
TERN_(JOYSTICK, uint8_t jogging : 1);
|
|
|
|
TERN_(SDSUPPORT, uint8_t was_sd_printing : 1);
|
2019-09-19 00:35:03 +00:00
|
|
|
} flags;
|
|
|
|
|
2018-10-23 00:37:48 +00:00
|
|
|
#ifdef __SAM3X8E__
|
|
|
|
/**
|
|
|
|
* Implement a special millis() to allow time measurement
|
|
|
|
* within an ISR (such as when the printer is killed).
|
|
|
|
*
|
|
|
|
* To keep proper time, must be called at least every 1s.
|
|
|
|
*/
|
|
|
|
uint32_t safe_millis() {
|
|
|
|
// Not killed? Just call millis()
|
2018-10-31 00:42:26 +00:00
|
|
|
if (!flags.printer_killed) return millis();
|
2018-10-23 00:37:48 +00:00
|
|
|
|
|
|
|
static uint32_t currTimeHI = 0; /* Current time */
|
|
|
|
|
|
|
|
// Machine was killed, reinit SysTick so we are able to compute time without ISRs
|
|
|
|
if (currTimeHI == 0) {
|
|
|
|
// Get the last time the Arduino time computed (from CMSIS) and convert it to SysTick
|
2018-10-31 22:07:52 +00:00
|
|
|
currTimeHI = (uint32_t)((GetTickCount() * (uint64_t)(F_CPU / 8000)) >> 24);
|
2018-10-23 00:37:48 +00:00
|
|
|
|
|
|
|
// Reinit the SysTick timer to maximize its period
|
|
|
|
SysTick->LOAD = SysTick_LOAD_RELOAD_Msk; // get the full range for the systick timer
|
|
|
|
SysTick->VAL = 0; // Load the SysTick Counter Value
|
|
|
|
SysTick->CTRL = // MCLK/8 as source
|
|
|
|
// No interrupts
|
|
|
|
SysTick_CTRL_ENABLE_Msk; // Enable SysTick Timer
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check if there was a timer overflow from the last read
|
|
|
|
if (SysTick->CTRL & SysTick_CTRL_COUNTFLAG_Msk) {
|
|
|
|
// There was. This means (SysTick_LOAD_RELOAD_Msk * 1000 * 8)/F_CPU ms has elapsed
|
|
|
|
currTimeHI++;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Calculate current time in milliseconds
|
|
|
|
uint32_t currTimeLO = SysTick_LOAD_RELOAD_Msk - SysTick->VAL; // (in MCLK/8)
|
|
|
|
uint64_t currTime = ((uint64_t)currTimeLO) | (((uint64_t)currTimeHI) << 24);
|
|
|
|
|
|
|
|
// The ms count is
|
|
|
|
return (uint32_t)(currTime / (F_CPU / 8000));
|
|
|
|
}
|
2018-11-18 04:21:44 +00:00
|
|
|
#endif // __SAM3X8E__
|
2018-10-23 00:37:48 +00:00
|
|
|
|
2019-05-10 20:56:13 +00:00
|
|
|
void delay_us(unsigned long us) { DELAY_US(us); }
|
2018-10-08 20:44:05 +00:00
|
|
|
|
|
|
|
void delay_ms(unsigned long ms) {
|
2018-10-31 00:42:26 +00:00
|
|
|
if (flags.printer_killed)
|
2018-10-23 00:37:48 +00:00
|
|
|
DELAY_US(ms * 1000);
|
|
|
|
else
|
|
|
|
safe_delay(ms);
|
2018-10-08 20:44:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void yield() {
|
2020-04-29 00:14:43 +00:00
|
|
|
if (!flags.printer_killed) thermalManager.manage_heater();
|
2018-10-08 20:44:05 +00:00
|
|
|
}
|
|
|
|
|
2019-05-10 20:56:13 +00:00
|
|
|
void enableHeater(const extruder_t extruder) {
|
2020-04-28 03:35:25 +00:00
|
|
|
#if HAS_HOTEND && HEATER_IDLE_HANDLER
|
2020-01-30 09:24:43 +00:00
|
|
|
thermalManager.reset_hotend_idle_timer(extruder - E0);
|
2019-09-16 21:49:46 +00:00
|
|
|
#else
|
|
|
|
UNUSED(extruder);
|
2019-05-10 20:56:13 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void enableHeater(const heater_t heater) {
|
|
|
|
#if HEATER_IDLE_HANDLER
|
2019-06-07 12:08:41 +00:00
|
|
|
switch (heater) {
|
|
|
|
#if HAS_HEATED_BED
|
2020-04-29 00:14:43 +00:00
|
|
|
case BED: thermalManager.reset_bed_idle_timer(); return;
|
2019-06-07 12:08:41 +00:00
|
|
|
#endif
|
2020-04-29 00:14:43 +00:00
|
|
|
TERN_(HAS_HEATED_CHAMBER, case CHAMBER: return); // Chamber has no idle timer
|
2019-09-10 07:20:49 +00:00
|
|
|
default:
|
2020-04-22 21:35:03 +00:00
|
|
|
TERN_(HAS_HOTEND, thermalManager.reset_hotend_idle_timer(heater - H0));
|
2019-09-10 07:20:49 +00:00
|
|
|
break;
|
2019-06-07 12:08:41 +00:00
|
|
|
}
|
2019-09-16 21:49:46 +00:00
|
|
|
#else
|
|
|
|
UNUSED(heater);
|
2019-05-10 20:56:13 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2019-09-25 23:46:36 +00:00
|
|
|
#if ENABLED(JOYSTICK)
|
|
|
|
/**
|
|
|
|
* Jogs in the direction given by the vector (dx, dy, dz).
|
|
|
|
* The values range from -1 to 1 mapping to the maximum
|
|
|
|
* feedrate for an axis.
|
|
|
|
*
|
|
|
|
* The axis will continue to jog until this function is
|
|
|
|
* called with all zeros.
|
|
|
|
*/
|
2019-09-29 09:25:39 +00:00
|
|
|
void jog(const xyz_float_t &dir) {
|
2019-09-25 23:46:36 +00:00
|
|
|
// The "destination" variable is used as a scratchpad in
|
|
|
|
// Marlin by GCODE routines, but should remain untouched
|
|
|
|
// during manual jogging, allowing us to reuse the space
|
|
|
|
// for our direction vector.
|
2019-09-29 09:25:39 +00:00
|
|
|
destination = dir;
|
|
|
|
flags.jogging = !NEAR_ZERO(dir.x) || !NEAR_ZERO(dir.y) || !NEAR_ZERO(dir.z);
|
2019-09-25 23:46:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Called by the polling routine in "joystick.cpp"
|
2019-09-29 09:25:39 +00:00
|
|
|
void _joystick_update(xyz_float_t &norm_jog) {
|
2019-09-25 23:46:36 +00:00
|
|
|
if (flags.jogging) {
|
|
|
|
#define OUT_OF_RANGE(VALUE) (VALUE < -1.0f || VALUE > 1.0f)
|
|
|
|
|
2019-09-29 09:25:39 +00:00
|
|
|
if (OUT_OF_RANGE(destination.x) || OUT_OF_RANGE(destination.y) || OUT_OF_RANGE(destination.z)) {
|
|
|
|
// If destination on any axis is out of range, it
|
2019-09-25 23:46:36 +00:00
|
|
|
// probably means the UI forgot to stop jogging and
|
2019-09-29 09:25:39 +00:00
|
|
|
// ran GCODE that wrote a position to destination.
|
2019-09-25 23:46:36 +00:00
|
|
|
// To prevent a disaster, stop jogging.
|
|
|
|
flags.jogging = false;
|
|
|
|
return;
|
|
|
|
}
|
2019-09-29 09:25:39 +00:00
|
|
|
norm_jog = destination;
|
2019-09-25 23:46:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2019-09-19 00:35:03 +00:00
|
|
|
|
2019-05-10 20:56:13 +00:00
|
|
|
bool isHeaterIdle(const extruder_t extruder) {
|
2020-04-29 00:14:43 +00:00
|
|
|
#if HAS_HOTEND && HEATER_IDLE_HANDLER
|
2020-09-14 04:58:39 +00:00
|
|
|
return thermalManager.heater_idle[extruder - E0].timed_out;
|
2020-04-29 00:14:43 +00:00
|
|
|
#else
|
|
|
|
UNUSED(extruder);
|
|
|
|
return false;
|
|
|
|
#endif
|
2019-05-10 20:56:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool isHeaterIdle(const heater_t heater) {
|
2019-06-07 12:08:41 +00:00
|
|
|
#if HEATER_IDLE_HANDLER
|
|
|
|
switch (heater) {
|
2020-09-14 04:58:39 +00:00
|
|
|
TERN_(HAS_HEATED_BED, case BED: return thermalManager.heater_idle[thermalManager.IDLE_INDEX_BED].timed_out);
|
2020-04-29 00:14:43 +00:00
|
|
|
TERN_(HAS_HEATED_CHAMBER, case CHAMBER: return false); // Chamber has no idle timer
|
2019-09-10 07:20:49 +00:00
|
|
|
default:
|
2020-09-14 04:58:39 +00:00
|
|
|
return TERN0(HAS_HOTEND, thermalManager.heater_idle[heater - H0].timed_out);
|
2019-06-07 12:08:41 +00:00
|
|
|
}
|
|
|
|
#else
|
2019-09-16 21:49:46 +00:00
|
|
|
UNUSED(heater);
|
2019-06-07 12:08:41 +00:00
|
|
|
return false;
|
|
|
|
#endif
|
2019-05-10 20:56:13 +00:00
|
|
|
}
|
|
|
|
|
2019-11-24 12:08:05 +00:00
|
|
|
#ifdef TOUCH_UI_LCD_TEMP_SCALING
|
2020-12-23 22:37:17 +00:00
|
|
|
#define GET_TEMP_ADJUSTMENT(A) (float(A) / (TOUCH_UI_LCD_TEMP_SCALING))
|
2019-11-24 12:08:05 +00:00
|
|
|
#else
|
|
|
|
#define GET_TEMP_ADJUSTMENT(A) A
|
|
|
|
#endif
|
|
|
|
|
2018-10-31 00:42:26 +00:00
|
|
|
float getActualTemp_celsius(const heater_t heater) {
|
2019-06-07 12:08:41 +00:00
|
|
|
switch (heater) {
|
2020-04-22 21:35:03 +00:00
|
|
|
TERN_(HAS_HEATED_BED, case BED: return GET_TEMP_ADJUSTMENT(thermalManager.degBed()));
|
|
|
|
TERN_(HAS_HEATED_CHAMBER, case CHAMBER: return GET_TEMP_ADJUSTMENT(thermalManager.degChamber()));
|
2019-11-24 12:08:05 +00:00
|
|
|
default: return GET_TEMP_ADJUSTMENT(thermalManager.degHotend(heater - H0));
|
2019-06-07 12:08:41 +00:00
|
|
|
}
|
2018-10-31 00:42:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
float getActualTemp_celsius(const extruder_t extruder) {
|
2019-11-24 12:08:05 +00:00
|
|
|
return GET_TEMP_ADJUSTMENT(thermalManager.degHotend(extruder - E0));
|
2018-10-08 20:44:05 +00:00
|
|
|
}
|
|
|
|
|
2018-10-31 00:42:26 +00:00
|
|
|
float getTargetTemp_celsius(const heater_t heater) {
|
2019-06-07 12:08:41 +00:00
|
|
|
switch (heater) {
|
2020-04-22 21:35:03 +00:00
|
|
|
TERN_(HAS_HEATED_BED, case BED: return GET_TEMP_ADJUSTMENT(thermalManager.degTargetBed()));
|
|
|
|
TERN_(HAS_HEATED_CHAMBER, case CHAMBER: return GET_TEMP_ADJUSTMENT(thermalManager.degTargetChamber()));
|
2019-11-24 12:08:05 +00:00
|
|
|
default: return GET_TEMP_ADJUSTMENT(thermalManager.degTargetHotend(heater - H0));
|
2019-06-07 12:08:41 +00:00
|
|
|
}
|
2018-10-31 00:42:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
float getTargetTemp_celsius(const extruder_t extruder) {
|
2019-11-24 12:08:05 +00:00
|
|
|
return GET_TEMP_ADJUSTMENT(thermalManager.degTargetHotend(extruder - E0));
|
2018-10-08 20:44:05 +00:00
|
|
|
}
|
|
|
|
|
2019-01-12 06:41:48 +00:00
|
|
|
float getTargetFan_percent(const fan_t fan) {
|
2020-04-27 09:41:18 +00:00
|
|
|
#if HAS_FAN
|
2019-06-29 05:23:57 +00:00
|
|
|
return thermalManager.fanPercent(thermalManager.fan_speed[fan - FAN0]);
|
|
|
|
#else
|
|
|
|
UNUSED(fan);
|
|
|
|
return 0;
|
|
|
|
#endif
|
2019-01-12 06:41:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
float getActualFan_percent(const fan_t fan) {
|
2020-04-27 09:41:18 +00:00
|
|
|
#if HAS_FAN
|
2019-06-29 05:23:57 +00:00
|
|
|
return thermalManager.fanPercent(thermalManager.scaledFanSpeed(fan - FAN0));
|
|
|
|
#else
|
|
|
|
UNUSED(fan);
|
|
|
|
return 0;
|
|
|
|
#endif
|
2019-01-12 06:41:48 +00:00
|
|
|
}
|
2018-10-08 20:44:05 +00:00
|
|
|
|
|
|
|
float getAxisPosition_mm(const axis_t axis) {
|
2020-04-29 00:14:43 +00:00
|
|
|
return TERN_(JOYSTICK, flags.jogging ? destination[axis] :) current_position[axis];
|
2018-10-08 20:44:05 +00:00
|
|
|
}
|
|
|
|
|
2019-08-20 08:44:17 +00:00
|
|
|
float getAxisPosition_mm(const extruder_t extruder) {
|
2019-08-21 09:15:37 +00:00
|
|
|
const extruder_t old_tool = getActiveTool();
|
2019-08-20 08:44:17 +00:00
|
|
|
setActiveTool(extruder, true);
|
2020-04-29 00:14:43 +00:00
|
|
|
const float epos = TERN_(JOYSTICK, flags.jogging ? destination.e :) current_position.e;
|
2019-08-20 08:44:17 +00:00
|
|
|
setActiveTool(old_tool, true);
|
2019-09-29 09:25:39 +00:00
|
|
|
return epos;
|
2018-10-31 00:42:26 +00:00
|
|
|
}
|
|
|
|
|
2020-08-06 10:38:18 +00:00
|
|
|
void setAxisPosition_mm(const float position, const axis_t axis, const feedRate_t feedrate/*=0*/) {
|
2020-10-12 21:48:04 +00:00
|
|
|
// Get motion limit from software endstops, if any
|
|
|
|
float min, max;
|
|
|
|
soft_endstop.get_manual_axis_limits((AxisEnum)axis, min, max);
|
2018-10-31 00:42:26 +00:00
|
|
|
|
|
|
|
// Delta limits XY based on the current offset from center
|
|
|
|
// This assumes the center is 0,0
|
|
|
|
#if ENABLED(DELTA)
|
2020-05-04 19:37:43 +00:00
|
|
|
if (axis != Z) {
|
|
|
|
max = SQRT(sq(float(DELTA_PRINTABLE_RADIUS)) - sq(current_position[Y - axis])); // (Y - axis) == the other axis
|
2018-10-31 00:42:26 +00:00
|
|
|
min = -max;
|
|
|
|
}
|
2018-10-08 20:44:05 +00:00
|
|
|
#endif
|
2018-10-31 00:42:26 +00:00
|
|
|
|
2019-09-26 06:28:09 +00:00
|
|
|
current_position[axis] = constrain(position, min, max);
|
2020-08-06 10:38:18 +00:00
|
|
|
line_to_current_position(feedrate ?: manual_feedrate_mm_s[axis]);
|
2018-10-31 00:42:26 +00:00
|
|
|
}
|
|
|
|
|
2020-08-06 10:38:18 +00:00
|
|
|
void setAxisPosition_mm(const float position, const extruder_t extruder, const feedRate_t feedrate/*=0*/) {
|
2018-10-31 00:42:26 +00:00
|
|
|
setActiveTool(extruder, true);
|
|
|
|
|
2019-09-29 09:25:39 +00:00
|
|
|
current_position.e = position;
|
2020-08-06 10:38:18 +00:00
|
|
|
line_to_current_position(feedrate ?: manual_feedrate_mm_s.e);
|
2018-10-08 20:44:05 +00:00
|
|
|
}
|
|
|
|
|
2018-10-31 00:42:26 +00:00
|
|
|
void setActiveTool(const extruder_t extruder, bool no_move) {
|
2020-09-20 23:29:08 +00:00
|
|
|
#if HAS_MULTI_EXTRUDER
|
2018-11-18 04:21:44 +00:00
|
|
|
const uint8_t e = extruder - E0;
|
2019-08-20 08:44:17 +00:00
|
|
|
if (e != active_extruder) tool_change(e, no_move);
|
2018-11-18 04:21:44 +00:00
|
|
|
active_extruder = e;
|
2019-06-29 05:23:57 +00:00
|
|
|
#else
|
|
|
|
UNUSED(extruder);
|
|
|
|
UNUSED(no_move);
|
2018-10-24 21:36:11 +00:00
|
|
|
#endif
|
2018-10-08 20:44:05 +00:00
|
|
|
}
|
|
|
|
|
2018-10-31 00:42:26 +00:00
|
|
|
extruder_t getActiveTool() {
|
|
|
|
switch (active_extruder) {
|
|
|
|
case 5: return E5;
|
|
|
|
case 4: return E4;
|
|
|
|
case 3: return E3;
|
|
|
|
case 2: return E2;
|
|
|
|
case 1: return E1;
|
|
|
|
default: return E0;
|
|
|
|
}
|
|
|
|
}
|
2018-10-08 20:44:05 +00:00
|
|
|
|
|
|
|
bool isMoving() { return planner.has_blocks_queued(); }
|
|
|
|
|
2018-10-31 00:42:26 +00:00
|
|
|
bool canMove(const axis_t axis) {
|
2018-10-08 20:44:05 +00:00
|
|
|
switch (axis) {
|
2018-10-31 00:42:26 +00:00
|
|
|
#if IS_KINEMATIC || ENABLED(NO_MOTION_BEFORE_HOMING)
|
2020-11-30 01:06:40 +00:00
|
|
|
case X: return axis_should_home(X_AXIS);
|
|
|
|
case Y: return axis_should_home(Y_AXIS);
|
|
|
|
case Z: return axis_should_home(Z_AXIS);
|
2018-10-31 00:42:26 +00:00
|
|
|
#else
|
|
|
|
case X: case Y: case Z: return true;
|
|
|
|
#endif
|
|
|
|
default: return false;
|
2018-10-08 20:44:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-31 00:42:26 +00:00
|
|
|
bool canMove(const extruder_t extruder) {
|
|
|
|
return !thermalManager.tooColdToExtrude(extruder - E0);
|
|
|
|
}
|
|
|
|
|
2019-03-24 04:09:18 +00:00
|
|
|
#if HAS_SOFTWARE_ENDSTOPS
|
2020-10-12 21:48:04 +00:00
|
|
|
bool getSoftEndstopState() { return soft_endstop._enabled; }
|
|
|
|
void setSoftEndstopState(const bool value) { soft_endstop._enabled = value; }
|
2019-03-24 04:09:18 +00:00
|
|
|
#endif
|
|
|
|
|
2020-03-02 18:03:43 +00:00
|
|
|
#if HAS_TRINAMIC_CONFIG
|
2019-03-24 04:09:18 +00:00
|
|
|
float getAxisCurrent_mA(const axis_t axis) {
|
|
|
|
switch (axis) {
|
|
|
|
#if AXIS_IS_TMC(X)
|
|
|
|
case X: return stepperX.getMilliamps();
|
|
|
|
#endif
|
2020-10-02 22:30:32 +00:00
|
|
|
#if AXIS_IS_TMC(X2)
|
|
|
|
case X2: return stepperX2.getMilliamps();
|
|
|
|
#endif
|
2019-03-24 04:09:18 +00:00
|
|
|
#if AXIS_IS_TMC(Y)
|
|
|
|
case Y: return stepperY.getMilliamps();
|
|
|
|
#endif
|
2020-10-02 22:30:32 +00:00
|
|
|
#if AXIS_IS_TMC(Y2)
|
|
|
|
case Y2: return stepperY2.getMilliamps();
|
|
|
|
#endif
|
2019-03-24 04:09:18 +00:00
|
|
|
#if AXIS_IS_TMC(Z)
|
|
|
|
case Z: return stepperZ.getMilliamps();
|
|
|
|
#endif
|
2020-10-02 22:30:32 +00:00
|
|
|
#if AXIS_IS_TMC(Z2)
|
|
|
|
case Z2: return stepperZ2.getMilliamps();
|
|
|
|
#endif
|
2019-03-24 04:09:18 +00:00
|
|
|
default: return NAN;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
float getAxisCurrent_mA(const extruder_t extruder) {
|
|
|
|
switch (extruder) {
|
|
|
|
#if AXIS_IS_TMC(E0)
|
|
|
|
case E0: return stepperE0.getMilliamps();
|
|
|
|
#endif
|
|
|
|
#if AXIS_IS_TMC(E1)
|
|
|
|
case E1: return stepperE1.getMilliamps();
|
|
|
|
#endif
|
|
|
|
#if AXIS_IS_TMC(E2)
|
|
|
|
case E2: return stepperE2.getMilliamps();
|
|
|
|
#endif
|
|
|
|
#if AXIS_IS_TMC(E3)
|
|
|
|
case E3: return stepperE3.getMilliamps();
|
|
|
|
#endif
|
|
|
|
#if AXIS_IS_TMC(E4)
|
|
|
|
case E4: return stepperE4.getMilliamps();
|
|
|
|
#endif
|
|
|
|
#if AXIS_IS_TMC(E5)
|
|
|
|
case E5: return stepperE5.getMilliamps();
|
|
|
|
#endif
|
2020-02-04 18:37:20 +00:00
|
|
|
#if AXIS_IS_TMC(E6)
|
|
|
|
case E6: return stepperE6.getMilliamps();
|
|
|
|
#endif
|
|
|
|
#if AXIS_IS_TMC(E7)
|
|
|
|
case E7: return stepperE7.getMilliamps();
|
|
|
|
#endif
|
2019-03-24 04:09:18 +00:00
|
|
|
default: return NAN;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
void setAxisCurrent_mA(const float mA, const axis_t axis) {
|
|
|
|
switch (axis) {
|
|
|
|
#if AXIS_IS_TMC(X)
|
2020-10-02 22:30:32 +00:00
|
|
|
case X: stepperX.rms_current(constrain(mA, 400, 1500)); break;
|
|
|
|
#endif
|
|
|
|
#if AXIS_IS_TMC(X2)
|
|
|
|
case X2: stepperX2.rms_current(constrain(mA, 400, 1500)); break;
|
2019-03-24 04:09:18 +00:00
|
|
|
#endif
|
|
|
|
#if AXIS_IS_TMC(Y)
|
2020-10-02 22:30:32 +00:00
|
|
|
case Y: stepperY.rms_current(constrain(mA, 400, 1500)); break;
|
|
|
|
#endif
|
|
|
|
#if AXIS_IS_TMC(Y2)
|
|
|
|
case Y2: stepperY2.rms_current(constrain(mA, 400, 1500)); break;
|
2019-03-24 04:09:18 +00:00
|
|
|
#endif
|
|
|
|
#if AXIS_IS_TMC(Z)
|
2020-10-02 22:30:32 +00:00
|
|
|
case Z: stepperZ.rms_current(constrain(mA, 400, 1500)); break;
|
|
|
|
#endif
|
|
|
|
#if AXIS_IS_TMC(Z2)
|
|
|
|
case Z2: stepperZ2.rms_current(constrain(mA, 400, 1500)); break;
|
2019-03-24 04:09:18 +00:00
|
|
|
#endif
|
2019-03-26 01:41:38 +00:00
|
|
|
default: break;
|
2019-03-24 04:09:18 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
void setAxisCurrent_mA(const float mA, const extruder_t extruder) {
|
|
|
|
switch (extruder) {
|
|
|
|
#if AXIS_IS_TMC(E0)
|
2020-10-02 22:30:32 +00:00
|
|
|
case E0: stepperE0.rms_current(constrain(mA, 400, 1500)); break;
|
2019-03-24 04:09:18 +00:00
|
|
|
#endif
|
|
|
|
#if AXIS_IS_TMC(E1)
|
2020-10-02 22:30:32 +00:00
|
|
|
case E1: stepperE1.rms_current(constrain(mA, 400, 1500)); break;
|
2019-03-24 04:09:18 +00:00
|
|
|
#endif
|
|
|
|
#if AXIS_IS_TMC(E2)
|
2020-10-02 22:30:32 +00:00
|
|
|
case E2: stepperE2.rms_current(constrain(mA, 400, 1500)); break;
|
2019-03-24 04:09:18 +00:00
|
|
|
#endif
|
|
|
|
#if AXIS_IS_TMC(E3)
|
2020-10-02 22:30:32 +00:00
|
|
|
case E3: stepperE3.rms_current(constrain(mA, 400, 1500)); break;
|
2019-03-24 04:09:18 +00:00
|
|
|
#endif
|
|
|
|
#if AXIS_IS_TMC(E4)
|
2020-10-02 22:30:32 +00:00
|
|
|
case E4: stepperE4.rms_current(constrain(mA, 400, 1500)); break;
|
2019-03-24 04:09:18 +00:00
|
|
|
#endif
|
|
|
|
#if AXIS_IS_TMC(E5)
|
2020-10-02 22:30:32 +00:00
|
|
|
case E5: stepperE5.rms_current(constrain(mA, 400, 1500)); break;
|
2019-03-24 04:09:18 +00:00
|
|
|
#endif
|
2020-02-04 18:37:20 +00:00
|
|
|
#if AXIS_IS_TMC(E6)
|
2020-10-02 22:30:32 +00:00
|
|
|
case E6: stepperE6.rms_current(constrain(mA, 400, 1500)); break;
|
2020-02-04 18:37:20 +00:00
|
|
|
#endif
|
|
|
|
#if AXIS_IS_TMC(E7)
|
2020-10-02 22:30:32 +00:00
|
|
|
case E7: stepperE7.rms_current(constrain(mA, 400, 1500)); break;
|
2020-02-04 18:37:20 +00:00
|
|
|
#endif
|
2019-03-26 01:41:38 +00:00
|
|
|
default: break;
|
2019-03-24 04:09:18 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
int getTMCBumpSensitivity(const axis_t axis) {
|
|
|
|
switch (axis) {
|
2020-05-01 03:52:33 +00:00
|
|
|
TERN_(X_SENSORLESS, case X: return stepperX.homing_threshold());
|
|
|
|
TERN_(X2_SENSORLESS, case X2: return stepperX2.homing_threshold());
|
|
|
|
TERN_(Y_SENSORLESS, case Y: return stepperY.homing_threshold());
|
|
|
|
TERN_(Y2_SENSORLESS, case Y2: return stepperY2.homing_threshold());
|
|
|
|
TERN_(Z_SENSORLESS, case Z: return stepperZ.homing_threshold());
|
|
|
|
TERN_(Z2_SENSORLESS, case Z2: return stepperZ2.homing_threshold());
|
|
|
|
TERN_(Z3_SENSORLESS, case Z3: return stepperZ3.homing_threshold());
|
|
|
|
TERN_(Z4_SENSORLESS, case Z4: return stepperZ4.homing_threshold());
|
2019-03-26 01:41:38 +00:00
|
|
|
default: return 0;
|
2019-03-24 04:09:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void setTMCBumpSensitivity(const float value, const axis_t axis) {
|
|
|
|
switch (axis) {
|
2019-10-01 02:45:00 +00:00
|
|
|
#if X_SENSORLESS || Y_SENSORLESS || Z_SENSORLESS
|
|
|
|
#if X_SENSORLESS
|
2020-05-01 03:52:33 +00:00
|
|
|
case X: stepperX.homing_threshold(value); break;
|
|
|
|
#endif
|
|
|
|
#if X2_SENSORLESS
|
|
|
|
case X2: stepperX2.homing_threshold(value); break;
|
2019-10-01 02:45:00 +00:00
|
|
|
#endif
|
|
|
|
#if Y_SENSORLESS
|
|
|
|
case Y: stepperY.homing_threshold(value); break;
|
|
|
|
#endif
|
2020-05-01 03:52:33 +00:00
|
|
|
#if Y2_SENSORLESS
|
|
|
|
case Y2: stepperY2.homing_threshold(value); break;
|
|
|
|
#endif
|
2019-10-01 02:45:00 +00:00
|
|
|
#if Z_SENSORLESS
|
|
|
|
case Z: stepperZ.homing_threshold(value); break;
|
|
|
|
#endif
|
2020-05-01 03:52:33 +00:00
|
|
|
#if Z2_SENSORLESS
|
|
|
|
case Z2: stepperZ2.homing_threshold(value); break;
|
|
|
|
#endif
|
|
|
|
#if Z3_SENSORLESS
|
|
|
|
case Z3: stepperZ3.homing_threshold(value); break;
|
|
|
|
#endif
|
|
|
|
#if Z4_SENSORLESS
|
|
|
|
case Z4: stepperZ4.homing_threshold(value); break;
|
|
|
|
#endif
|
2019-09-17 00:45:05 +00:00
|
|
|
#else
|
|
|
|
UNUSED(value);
|
2019-03-24 04:09:18 +00:00
|
|
|
#endif
|
2019-03-26 01:41:38 +00:00
|
|
|
default: break;
|
2019-03-24 04:09:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2018-10-31 00:42:26 +00:00
|
|
|
float getAxisSteps_per_mm(const axis_t axis) {
|
|
|
|
return planner.settings.axis_steps_per_mm[axis];
|
|
|
|
}
|
|
|
|
|
|
|
|
float getAxisSteps_per_mm(const extruder_t extruder) {
|
2019-06-29 05:23:57 +00:00
|
|
|
UNUSED_E(extruder);
|
2018-10-31 00:42:26 +00:00
|
|
|
return planner.settings.axis_steps_per_mm[E_AXIS_N(extruder - E0)];
|
|
|
|
}
|
|
|
|
|
|
|
|
void setAxisSteps_per_mm(const float value, const axis_t axis) {
|
|
|
|
planner.settings.axis_steps_per_mm[axis] = value;
|
2020-09-13 04:32:00 +00:00
|
|
|
planner.refresh_positioning();
|
2018-10-31 00:42:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void setAxisSteps_per_mm(const float value, const extruder_t extruder) {
|
2019-06-29 05:23:57 +00:00
|
|
|
UNUSED_E(extruder);
|
2020-08-14 13:45:48 +00:00
|
|
|
planner.settings.axis_steps_per_mm[E_AXIS_N(extruder - E0)] = value;
|
2020-09-13 04:32:00 +00:00
|
|
|
planner.refresh_positioning();
|
2018-10-08 20:44:05 +00:00
|
|
|
}
|
|
|
|
|
2019-09-26 06:28:09 +00:00
|
|
|
feedRate_t getAxisMaxFeedrate_mm_s(const axis_t axis) {
|
2018-10-31 00:42:26 +00:00
|
|
|
return planner.settings.max_feedrate_mm_s[axis];
|
2018-10-08 20:44:05 +00:00
|
|
|
}
|
|
|
|
|
2019-09-26 06:28:09 +00:00
|
|
|
feedRate_t getAxisMaxFeedrate_mm_s(const extruder_t extruder) {
|
2019-06-29 05:23:57 +00:00
|
|
|
UNUSED_E(extruder);
|
2020-08-14 13:45:48 +00:00
|
|
|
return planner.settings.max_feedrate_mm_s[E_AXIS_N(extruder - E0)];
|
2018-10-31 00:42:26 +00:00
|
|
|
}
|
|
|
|
|
2019-09-26 06:28:09 +00:00
|
|
|
void setAxisMaxFeedrate_mm_s(const feedRate_t value, const axis_t axis) {
|
2019-10-02 00:59:48 +00:00
|
|
|
planner.set_max_feedrate(axis, value);
|
2018-10-31 00:42:26 +00:00
|
|
|
}
|
|
|
|
|
2019-09-26 06:28:09 +00:00
|
|
|
void setAxisMaxFeedrate_mm_s(const feedRate_t value, const extruder_t extruder) {
|
2019-11-11 00:49:41 +00:00
|
|
|
UNUSED_E(extruder);
|
2019-10-02 00:59:48 +00:00
|
|
|
planner.set_max_feedrate(E_AXIS_N(extruder - E0), value);
|
2018-10-08 20:44:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
float getAxisMaxAcceleration_mm_s2(const axis_t axis) {
|
2018-10-31 00:42:26 +00:00
|
|
|
return planner.settings.max_acceleration_mm_per_s2[axis];
|
2018-10-08 20:44:05 +00:00
|
|
|
}
|
|
|
|
|
2018-10-31 00:42:26 +00:00
|
|
|
float getAxisMaxAcceleration_mm_s2(const extruder_t extruder) {
|
2019-06-29 05:23:57 +00:00
|
|
|
UNUSED_E(extruder);
|
2018-10-31 00:42:26 +00:00
|
|
|
return planner.settings.max_acceleration_mm_per_s2[E_AXIS_N(extruder - E0)];
|
|
|
|
}
|
|
|
|
|
|
|
|
void setAxisMaxAcceleration_mm_s2(const float value, const axis_t axis) {
|
2019-10-02 00:59:48 +00:00
|
|
|
planner.set_max_acceleration(axis, value);
|
2020-09-13 04:32:00 +00:00
|
|
|
planner.reset_acceleration_rates();
|
2018-10-31 00:42:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void setAxisMaxAcceleration_mm_s2(const float value, const extruder_t extruder) {
|
2019-11-11 00:49:41 +00:00
|
|
|
UNUSED_E(extruder);
|
2019-10-02 00:59:48 +00:00
|
|
|
planner.set_max_acceleration(E_AXIS_N(extruder - E0), value);
|
2020-09-13 04:32:00 +00:00
|
|
|
planner.reset_acceleration_rates();
|
2018-10-08 20:44:05 +00:00
|
|
|
}
|
|
|
|
|
2019-02-13 02:08:34 +00:00
|
|
|
#if HAS_FILAMENT_SENSOR
|
2018-10-31 00:42:26 +00:00
|
|
|
bool getFilamentRunoutEnabled() { return runout.enabled; }
|
|
|
|
void setFilamentRunoutEnabled(const bool value) { runout.enabled = value; }
|
2020-06-28 03:02:28 +00:00
|
|
|
bool getFilamentRunoutState() { return runout.filament_ran_out; }
|
|
|
|
void setFilamentRunoutState(const bool value) { runout.filament_ran_out = value; }
|
2018-10-16 12:28:52 +00:00
|
|
|
|
2020-05-06 04:18:23 +00:00
|
|
|
#if HAS_FILAMENT_RUNOUT_DISTANCE
|
2019-05-10 20:56:13 +00:00
|
|
|
float getFilamentRunoutDistance_mm() { return runout.runout_distance(); }
|
2019-09-18 08:18:03 +00:00
|
|
|
void setFilamentRunoutDistance_mm(const float value) { runout.set_runout_distance(constrain(value, 0, 999)); }
|
2018-10-16 12:28:52 +00:00
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2020-08-06 13:14:00 +00:00
|
|
|
#if ENABLED(CASE_LIGHT_ENABLE)
|
|
|
|
bool getCaseLightState() { return caselight.on; }
|
2019-11-24 12:08:05 +00:00
|
|
|
void setCaseLightState(const bool value) {
|
2020-08-06 13:14:00 +00:00
|
|
|
caselight.on = value;
|
|
|
|
caselight.update_enabled();
|
2019-11-24 12:08:05 +00:00
|
|
|
}
|
|
|
|
|
2020-10-23 03:31:48 +00:00
|
|
|
#if CASELIGHT_USES_BRIGHTNESS
|
2020-08-06 13:14:00 +00:00
|
|
|
float getCaseLightBrightness_percent() { return ui8_to_percent(caselight.brightness); }
|
2019-11-24 12:08:05 +00:00
|
|
|
void setCaseLightBrightness_percent(const float value) {
|
2020-08-06 13:14:00 +00:00
|
|
|
caselight.brightness = map(constrain(value, 0, 100), 0, 100, 0, 255);
|
|
|
|
caselight.update_brightness();
|
2019-11-24 12:08:05 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2018-10-08 20:44:05 +00:00
|
|
|
#if ENABLED(LIN_ADVANCE)
|
2018-10-31 00:42:26 +00:00
|
|
|
float getLinearAdvance_mm_mm_s(const extruder_t extruder) {
|
|
|
|
return (extruder < EXTRUDERS) ? planner.extruder_advance_K[extruder - E0] : 0;
|
2018-10-08 20:44:05 +00:00
|
|
|
}
|
|
|
|
|
2018-10-31 00:42:26 +00:00
|
|
|
void setLinearAdvance_mm_mm_s(const float value, const extruder_t extruder) {
|
2018-10-08 20:44:05 +00:00
|
|
|
if (extruder < EXTRUDERS)
|
2020-11-18 05:56:51 +00:00
|
|
|
planner.extruder_advance_K[extruder - E0] = constrain(value, 0, 10);
|
2018-10-08 20:44:05 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2020-04-24 01:49:11 +00:00
|
|
|
#if HAS_JUNCTION_DEVIATION
|
2018-10-31 22:07:52 +00:00
|
|
|
|
2018-10-08 20:44:05 +00:00
|
|
|
float getJunctionDeviation_mm() {
|
|
|
|
return planner.junction_deviation_mm;
|
|
|
|
}
|
|
|
|
|
2018-10-31 00:42:26 +00:00
|
|
|
void setJunctionDeviation_mm(const float value) {
|
2020-04-24 06:14:34 +00:00
|
|
|
planner.junction_deviation_mm = constrain(value, 0.001, 0.3);
|
2020-04-22 21:35:03 +00:00
|
|
|
TERN_(LIN_ADVANCE, planner.recalculate_max_e_jerk());
|
2018-10-08 20:44:05 +00:00
|
|
|
}
|
2018-10-31 22:07:52 +00:00
|
|
|
|
2018-10-08 20:44:05 +00:00
|
|
|
#else
|
2018-10-31 22:07:52 +00:00
|
|
|
|
2018-10-08 20:44:05 +00:00
|
|
|
float getAxisMaxJerk_mm_s(const axis_t axis) {
|
2018-10-31 22:07:52 +00:00
|
|
|
return planner.max_jerk[axis];
|
2018-10-08 20:44:05 +00:00
|
|
|
}
|
|
|
|
|
2019-06-29 05:23:57 +00:00
|
|
|
float getAxisMaxJerk_mm_s(const extruder_t) {
|
2019-09-29 09:25:39 +00:00
|
|
|
return planner.max_jerk.e;
|
2018-10-31 00:42:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void setAxisMaxJerk_mm_s(const float value, const axis_t axis) {
|
2019-10-02 00:59:48 +00:00
|
|
|
planner.set_max_jerk((AxisEnum)axis, value);
|
2018-10-31 00:42:26 +00:00
|
|
|
}
|
|
|
|
|
2019-06-29 05:23:57 +00:00
|
|
|
void setAxisMaxJerk_mm_s(const float value, const extruder_t) {
|
2019-10-02 00:59:48 +00:00
|
|
|
planner.set_max_jerk(E_AXIS, value);
|
2018-10-08 20:44:05 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2019-09-26 06:28:09 +00:00
|
|
|
feedRate_t getFeedrate_mm_s() { return feedrate_mm_s; }
|
2019-11-30 13:23:53 +00:00
|
|
|
int16_t getFlowPercentage(const extruder_t extr) { return planner.flow_percentage[extr]; }
|
2019-09-26 06:28:09 +00:00
|
|
|
feedRate_t getMinFeedrate_mm_s() { return planner.settings.min_feedrate_mm_s; }
|
|
|
|
feedRate_t getMinTravelFeedrate_mm_s() { return planner.settings.min_travel_feedrate_mm_s; }
|
2018-10-16 21:58:29 +00:00
|
|
|
float getPrintingAcceleration_mm_s2() { return planner.settings.acceleration; }
|
|
|
|
float getRetractAcceleration_mm_s2() { return planner.settings.retract_acceleration; }
|
|
|
|
float getTravelAcceleration_mm_s2() { return planner.settings.travel_acceleration; }
|
2019-09-26 06:28:09 +00:00
|
|
|
void setFeedrate_mm_s(const feedRate_t fr) { feedrate_mm_s = fr; }
|
2020-04-23 02:03:28 +00:00
|
|
|
void setFlow_percent(const int16_t flow, const extruder_t extr) { planner.set_flow(extr, flow); }
|
2019-09-26 06:28:09 +00:00
|
|
|
void setMinFeedrate_mm_s(const feedRate_t fr) { planner.settings.min_feedrate_mm_s = fr; }
|
|
|
|
void setMinTravelFeedrate_mm_s(const feedRate_t fr) { planner.settings.min_travel_feedrate_mm_s = fr; }
|
2018-10-16 21:58:29 +00:00
|
|
|
void setPrintingAcceleration_mm_s2(const float acc) { planner.settings.acceleration = acc; }
|
|
|
|
void setRetractAcceleration_mm_s2(const float acc) { planner.settings.retract_acceleration = acc; }
|
|
|
|
void setTravelAcceleration_mm_s2(const float acc) { planner.settings.travel_acceleration = acc; }
|
2018-10-08 20:44:05 +00:00
|
|
|
|
2019-02-06 13:16:54 +00:00
|
|
|
#if ENABLED(BABYSTEPPING)
|
|
|
|
bool babystepAxis_steps(const int16_t steps, const axis_t axis) {
|
|
|
|
switch (axis) {
|
|
|
|
#if ENABLED(BABYSTEP_XY)
|
2019-04-06 23:04:34 +00:00
|
|
|
case X: babystep.add_steps(X_AXIS, steps); break;
|
|
|
|
case Y: babystep.add_steps(Y_AXIS, steps); break;
|
2019-02-06 13:16:54 +00:00
|
|
|
#endif
|
2019-04-06 23:04:34 +00:00
|
|
|
case Z: babystep.add_steps(Z_AXIS, steps); break;
|
2019-02-06 13:16:54 +00:00
|
|
|
default: return false;
|
|
|
|
};
|
|
|
|
return true;
|
2018-10-08 20:44:05 +00:00
|
|
|
}
|
|
|
|
|
2019-02-06 13:16:54 +00:00
|
|
|
/**
|
|
|
|
* This function adjusts an axis during a print.
|
|
|
|
*
|
|
|
|
* When linked_nozzles is false, each nozzle in a multi-nozzle
|
|
|
|
* printer can be babystepped independently of the others. This
|
|
|
|
* lets the user to fine tune the Z-offset and Nozzle Offsets
|
|
|
|
* while observing the first layer of a print, regardless of
|
|
|
|
* what nozzle is printing.
|
|
|
|
*/
|
|
|
|
void smartAdjustAxis_steps(const int16_t steps, const axis_t axis, bool linked_nozzles) {
|
|
|
|
const float mm = steps * planner.steps_to_mm[axis];
|
2020-09-20 23:29:08 +00:00
|
|
|
UNUSED(mm);
|
2018-10-08 20:44:05 +00:00
|
|
|
|
2019-02-06 13:16:54 +00:00
|
|
|
if (!babystepAxis_steps(steps, axis)) return;
|
|
|
|
|
|
|
|
#if ENABLED(BABYSTEP_ZPROBE_OFFSET)
|
|
|
|
// Make it so babystepping in Z adjusts the Z probe offset.
|
2020-09-23 00:58:06 +00:00
|
|
|
if (axis == Z && TERN1(HAS_MULTI_EXTRUDER, (linked_nozzles || active_extruder == 0)))
|
2020-09-20 23:29:08 +00:00
|
|
|
probe.offset.z += mm;
|
2019-02-06 13:16:54 +00:00
|
|
|
#endif
|
|
|
|
|
2020-09-20 23:29:08 +00:00
|
|
|
#if HAS_MULTI_EXTRUDER && HAS_HOTEND_OFFSET
|
2019-02-06 13:16:54 +00:00
|
|
|
/**
|
|
|
|
* When linked_nozzles is false, as an axis is babystepped
|
|
|
|
* adjust the hotend offsets so that the other nozzles are
|
|
|
|
* unaffected by the babystepping of the active nozzle.
|
|
|
|
*/
|
|
|
|
if (!linked_nozzles) {
|
|
|
|
HOTEND_LOOP()
|
|
|
|
if (e != active_extruder)
|
2019-09-29 09:25:39 +00:00
|
|
|
hotend_offset[e][axis] += mm;
|
2019-02-06 13:16:54 +00:00
|
|
|
|
|
|
|
normalizeNozzleOffset(X);
|
|
|
|
normalizeNozzleOffset(Y);
|
|
|
|
normalizeNozzleOffset(Z);
|
|
|
|
}
|
2018-10-08 20:44:05 +00:00
|
|
|
#else
|
2019-02-06 13:16:54 +00:00
|
|
|
UNUSED(linked_nozzles);
|
2018-10-08 20:44:05 +00:00
|
|
|
#endif
|
2019-02-06 13:16:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Converts a mm displacement to a number of whole number of
|
|
|
|
* steps that is at least mm long.
|
|
|
|
*/
|
|
|
|
int16_t mmToWholeSteps(const float mm, const axis_t axis) {
|
|
|
|
const float steps = mm / planner.steps_to_mm[axis];
|
2020-04-19 03:56:23 +00:00
|
|
|
return steps > 0 ? CEIL(steps) : FLOOR(steps);
|
2019-02-06 13:16:54 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2019-08-25 09:46:02 +00:00
|
|
|
float getZOffset_mm() {
|
2020-04-28 03:35:25 +00:00
|
|
|
return (0.0f
|
|
|
|
#if HAS_BED_PROBE
|
|
|
|
+ probe.offset.z
|
|
|
|
#elif ENABLED(BABYSTEP_DISPLAY_TOTAL)
|
|
|
|
+ planner.steps_to_mm[Z_AXIS] * babystep.axis_total[BS_AXIS_IND(Z_AXIS)]
|
|
|
|
#endif
|
|
|
|
);
|
2019-08-25 09:46:02 +00:00
|
|
|
}
|
2019-02-06 13:16:54 +00:00
|
|
|
|
2019-08-25 09:46:02 +00:00
|
|
|
void setZOffset_mm(const float value) {
|
|
|
|
#if HAS_BED_PROBE
|
|
|
|
if (WITHIN(value, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX))
|
2020-02-01 10:21:36 +00:00
|
|
|
probe.offset.z = value;
|
2019-08-25 09:46:02 +00:00
|
|
|
#elif ENABLED(BABYSTEP_DISPLAY_TOTAL)
|
2020-09-14 07:48:45 +00:00
|
|
|
babystep.add_mm(Z_AXIS, value - getZOffset_mm());
|
2019-08-25 09:46:02 +00:00
|
|
|
#else
|
|
|
|
UNUSED(value);
|
|
|
|
#endif
|
|
|
|
}
|
2018-10-08 20:44:05 +00:00
|
|
|
|
2019-03-12 01:48:49 +00:00
|
|
|
#if HAS_HOTEND_OFFSET
|
2019-02-06 13:16:54 +00:00
|
|
|
|
2018-10-31 00:42:26 +00:00
|
|
|
float getNozzleOffset_mm(const axis_t axis, const extruder_t extruder) {
|
|
|
|
if (extruder - E0 >= HOTENDS) return 0;
|
2019-09-29 09:25:39 +00:00
|
|
|
return hotend_offset[extruder - E0][axis];
|
2018-10-08 20:44:05 +00:00
|
|
|
}
|
|
|
|
|
2018-10-31 00:42:26 +00:00
|
|
|
void setNozzleOffset_mm(const float value, const axis_t axis, const extruder_t extruder) {
|
|
|
|
if (extruder - E0 >= HOTENDS) return;
|
2019-09-29 09:25:39 +00:00
|
|
|
hotend_offset[extruder - E0][axis] = value;
|
2018-10-08 20:44:05 +00:00
|
|
|
}
|
2019-02-06 13:16:54 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The UI should call this if needs to guarantee the first
|
|
|
|
* nozzle offset is zero (such as when it doesn't allow the
|
|
|
|
* user to edit the offset the first nozzle).
|
|
|
|
*/
|
|
|
|
void normalizeNozzleOffset(const axis_t axis) {
|
2019-09-29 09:25:39 +00:00
|
|
|
const float offs = hotend_offset[0][axis];
|
|
|
|
HOTEND_LOOP() hotend_offset[e][axis] -= offs;
|
2019-02-06 13:16:54 +00:00
|
|
|
}
|
|
|
|
|
2019-03-12 01:48:49 +00:00
|
|
|
#endif // HAS_HOTEND_OFFSET
|
2018-10-08 20:44:05 +00:00
|
|
|
|
2020-02-09 18:22:54 +00:00
|
|
|
#if HAS_BED_PROBE
|
|
|
|
float getProbeOffset_mm(const axis_t axis) {
|
|
|
|
return probe.offset.pos[axis];
|
|
|
|
}
|
|
|
|
void setProbeOffset_mm(const float val, const axis_t axis) {
|
|
|
|
probe.offset.pos[axis] = val;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2018-10-08 20:44:05 +00:00
|
|
|
#if ENABLED(BACKLASH_GCODE)
|
2019-05-04 04:53:15 +00:00
|
|
|
float getAxisBacklash_mm(const axis_t axis) { return backlash.distance_mm[axis]; }
|
2018-10-31 00:42:26 +00:00
|
|
|
void setAxisBacklash_mm(const float value, const axis_t axis)
|
2019-09-18 08:18:03 +00:00
|
|
|
{ backlash.distance_mm[axis] = constrain(value,0,5); }
|
2018-10-08 20:44:05 +00:00
|
|
|
|
2019-05-04 04:53:15 +00:00
|
|
|
float getBacklashCorrection_percent() { return ui8_to_percent(backlash.correction); }
|
2019-09-18 08:18:03 +00:00
|
|
|
void setBacklashCorrection_percent(const float value) { backlash.correction = map(constrain(value, 0, 100), 0, 100, 0, 255); }
|
2018-10-08 20:44:05 +00:00
|
|
|
|
|
|
|
#ifdef BACKLASH_SMOOTHING_MM
|
2019-05-04 04:53:15 +00:00
|
|
|
float getBacklashSmoothing_mm() { return backlash.smoothing_mm; }
|
2019-09-18 08:18:03 +00:00
|
|
|
void setBacklashSmoothing_mm(const float value) { backlash.smoothing_mm = constrain(value, 0, 999); }
|
2018-10-08 20:44:05 +00:00
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
uint32_t getProgress_seconds_elapsed() {
|
2018-10-31 00:42:26 +00:00
|
|
|
const duration_t elapsed = print_job_timer.duration();
|
|
|
|
return elapsed.value;
|
2018-10-08 20:44:05 +00:00
|
|
|
}
|
|
|
|
|
2019-03-13 05:45:52 +00:00
|
|
|
#if HAS_LEVELING
|
|
|
|
bool getLevelingActive() { return planner.leveling_active; }
|
2019-03-17 12:57:54 +00:00
|
|
|
void setLevelingActive(const bool state) { set_bed_leveling_enabled(state); }
|
2019-05-18 01:37:23 +00:00
|
|
|
bool getMeshValid() { return leveling_is_valid(); }
|
2019-03-13 05:45:52 +00:00
|
|
|
#if HAS_MESH
|
2019-09-17 23:16:28 +00:00
|
|
|
bed_mesh_t& getMeshArray() { return Z_VALUES_ARR; }
|
2019-09-29 09:25:39 +00:00
|
|
|
float getMeshPoint(const xy_uint8_t &pos) { return Z_VALUES(pos.x, pos.y); }
|
|
|
|
void setMeshPoint(const xy_uint8_t &pos, const float zoff) {
|
|
|
|
if (WITHIN(pos.x, 0, GRID_MAX_POINTS_X) && WITHIN(pos.y, 0, GRID_MAX_POINTS_Y)) {
|
|
|
|
Z_VALUES(pos.x, pos.y) = zoff;
|
2020-04-22 21:35:03 +00:00
|
|
|
TERN_(ABL_BILINEAR_SUBDIVISION, bed_level_virt_interpolate());
|
2019-03-13 05:45:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if ENABLED(HOST_PROMPT_SUPPORT)
|
|
|
|
void setHostResponse(const uint8_t response) { host_response_handler(response); }
|
|
|
|
#endif
|
|
|
|
|
2018-10-16 21:58:29 +00:00
|
|
|
#if ENABLED(PRINTCOUNTER)
|
2019-01-12 22:01:04 +00:00
|
|
|
char* getTotalPrints_str(char buffer[21]) { strcpy(buffer,i16tostr3left(print_job_timer.getStats().totalPrints)); return buffer; }
|
|
|
|
char* getFinishedPrints_str(char buffer[21]) { strcpy(buffer,i16tostr3left(print_job_timer.getStats().finishedPrints)); return buffer; }
|
2019-09-27 07:59:49 +00:00
|
|
|
char* getTotalPrintTime_str(char buffer[21]) { return duration_t(print_job_timer.getStats().printTime).toString(buffer); }
|
|
|
|
char* getLongestPrint_str(char buffer[21]) { return duration_t(print_job_timer.getStats().longestPrint).toString(buffer); }
|
2018-10-16 21:58:29 +00:00
|
|
|
char* getFilamentUsed_str(char buffer[21]) {
|
|
|
|
printStatistics stats = print_job_timer.getStats();
|
|
|
|
sprintf_P(buffer, PSTR("%ld.%im"), long(stats.filamentUsed / 1000), int16_t(stats.filamentUsed / 100) % 10);
|
|
|
|
return buffer;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2018-10-31 00:42:26 +00:00
|
|
|
float getFeedrate_percent() { return feedrate_percentage; }
|
2018-10-08 20:44:05 +00:00
|
|
|
|
2020-02-10 22:48:22 +00:00
|
|
|
#if ENABLED(PIDTEMP)
|
2020-04-28 03:35:25 +00:00
|
|
|
float getPIDValues_Kp(const extruder_t tool) { return PID_PARAM(Kp, tool); }
|
|
|
|
float getPIDValues_Ki(const extruder_t tool) { return unscalePID_i(PID_PARAM(Ki, tool)); }
|
|
|
|
float getPIDValues_Kd(const extruder_t tool) { return unscalePID_d(PID_PARAM(Kd, tool)); }
|
2020-02-10 22:48:22 +00:00
|
|
|
|
|
|
|
void setPIDValues(const float p, const float i, const float d, extruder_t tool) {
|
|
|
|
thermalManager.temp_hotend[tool].pid.Kp = p;
|
|
|
|
thermalManager.temp_hotend[tool].pid.Ki = scalePID_i(i);
|
|
|
|
thermalManager.temp_hotend[tool].pid.Kd = scalePID_d(d);
|
|
|
|
thermalManager.updatePID();
|
|
|
|
}
|
|
|
|
|
2020-04-28 03:35:25 +00:00
|
|
|
void startPIDTune(const float temp, extruder_t tool) {
|
2020-09-13 23:06:14 +00:00
|
|
|
thermalManager.PID_autotune(temp, (heater_id_t)tool, 8, true);
|
2020-02-10 22:48:22 +00:00
|
|
|
}
|
|
|
|
#endif
|
2020-02-24 11:29:13 +00:00
|
|
|
|
2020-02-10 22:48:22 +00:00
|
|
|
#if ENABLED(PIDTEMPBED)
|
2020-04-28 03:35:25 +00:00
|
|
|
float getBedPIDValues_Kp() { return thermalManager.temp_bed.pid.Kp; }
|
|
|
|
float getBedPIDValues_Ki() { return unscalePID_i(thermalManager.temp_bed.pid.Ki); }
|
|
|
|
float getBedPIDValues_Kd() { return unscalePID_d(thermalManager.temp_bed.pid.Kd); }
|
2020-02-24 11:29:13 +00:00
|
|
|
|
2020-02-09 18:22:54 +00:00
|
|
|
void setBedPIDValues(const float p, const float i, const float d) {
|
|
|
|
thermalManager.temp_bed.pid.Kp = p;
|
|
|
|
thermalManager.temp_bed.pid.Ki = scalePID_i(i);
|
|
|
|
thermalManager.temp_bed.pid.Kd = scalePID_d(d);
|
|
|
|
thermalManager.updatePID();
|
|
|
|
}
|
2020-02-24 11:29:13 +00:00
|
|
|
|
2020-02-09 18:22:54 +00:00
|
|
|
void startBedPIDTune(const float temp) {
|
|
|
|
thermalManager.PID_autotune(temp, H_BED, 4, true);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2020-04-28 03:35:25 +00:00
|
|
|
void injectCommands_P(PGM_P const gcode) { queue.inject_P(gcode); }
|
2020-06-28 03:02:28 +00:00
|
|
|
void injectCommands(char * const gcode) { queue.inject(gcode); }
|
2018-10-08 20:44:05 +00:00
|
|
|
|
2019-06-29 05:23:57 +00:00
|
|
|
bool commandsInQueue() { return (planner.movesplanned() || queue.has_commands_queued()); }
|
2019-05-04 04:53:15 +00:00
|
|
|
|
2020-11-30 01:06:40 +00:00
|
|
|
bool isAxisPositionKnown(const axis_t axis) { return axis_is_trusted((AxisEnum)axis); }
|
|
|
|
bool isAxisPositionKnown(const extruder_t) { return axis_is_trusted(E_AXIS); }
|
|
|
|
bool isPositionKnown() { return all_axes_trusted(); }
|
2019-04-26 07:32:01 +00:00
|
|
|
bool isMachineHomed() { return all_axes_homed(); }
|
|
|
|
|
2018-11-18 04:21:44 +00:00
|
|
|
PGM_P getFirmwareName_str() {
|
2020-05-06 04:34:04 +00:00
|
|
|
static PGMSTR(firmware_name, "Marlin " SHORT_BUILD_VERSION);
|
2018-11-18 04:21:44 +00:00
|
|
|
return firmware_name;
|
2018-10-08 20:44:05 +00:00
|
|
|
}
|
|
|
|
|
2018-10-31 00:42:26 +00:00
|
|
|
void setTargetTemp_celsius(float value, const heater_t heater) {
|
2019-11-24 12:08:05 +00:00
|
|
|
#ifdef TOUCH_UI_LCD_TEMP_SCALING
|
|
|
|
value *= TOUCH_UI_LCD_TEMP_SCALING;
|
|
|
|
#endif
|
2019-05-10 20:56:13 +00:00
|
|
|
enableHeater(heater);
|
2019-11-24 12:08:05 +00:00
|
|
|
#if HAS_HEATED_CHAMBER
|
|
|
|
if (heater == CHAMBER)
|
|
|
|
thermalManager.setTargetChamber(LROUND(constrain(value, 0, CHAMBER_MAXTEMP - 10)));
|
|
|
|
else
|
|
|
|
#endif
|
2018-10-08 20:44:05 +00:00
|
|
|
#if HAS_HEATED_BED
|
2018-11-18 04:21:44 +00:00
|
|
|
if (heater == BED)
|
2020-04-27 09:41:18 +00:00
|
|
|
thermalManager.setTargetBed(LROUND(constrain(value, 0, BED_MAX_TARGET)));
|
2018-11-18 04:21:44 +00:00
|
|
|
else
|
2018-10-08 20:44:05 +00:00
|
|
|
#endif
|
2019-09-10 07:20:49 +00:00
|
|
|
{
|
2020-04-20 04:56:55 +00:00
|
|
|
#if HAS_HOTEND
|
2019-09-10 07:20:49 +00:00
|
|
|
const int16_t e = heater - H0;
|
2020-04-27 12:53:58 +00:00
|
|
|
thermalManager.setTargetHotend(LROUND(constrain(value, 0, thermalManager.heater_maxtemp[e] - HOTEND_OVERSHOOT)), e);
|
2019-09-10 07:20:49 +00:00
|
|
|
#endif
|
|
|
|
}
|
2018-10-31 00:42:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void setTargetTemp_celsius(float value, const extruder_t extruder) {
|
2019-11-24 12:08:05 +00:00
|
|
|
#ifdef TOUCH_UI_LCD_TEMP_SCALING
|
|
|
|
value *= TOUCH_UI_LCD_TEMP_SCALING;
|
|
|
|
#endif
|
2020-04-20 04:56:55 +00:00
|
|
|
#if HAS_HOTEND
|
2019-09-10 07:20:49 +00:00
|
|
|
const int16_t e = extruder - E0;
|
|
|
|
enableHeater(extruder);
|
2020-04-27 12:53:58 +00:00
|
|
|
thermalManager.setTargetHotend(LROUND(constrain(value, 0, thermalManager.heater_maxtemp[e] - HOTEND_OVERSHOOT)), e);
|
2019-09-10 07:20:49 +00:00
|
|
|
#endif
|
2018-10-08 20:44:05 +00:00
|
|
|
}
|
|
|
|
|
2019-01-12 06:41:48 +00:00
|
|
|
void setTargetFan_percent(const float value, const fan_t fan) {
|
2020-04-27 09:41:18 +00:00
|
|
|
#if HAS_FAN
|
2019-06-29 05:23:57 +00:00
|
|
|
if (fan < FAN_COUNT)
|
2019-09-18 08:18:03 +00:00
|
|
|
thermalManager.set_fan_speed(fan - FAN0, map(constrain(value, 0, 100), 0, 100, 0, 255));
|
2019-06-29 05:23:57 +00:00
|
|
|
#else
|
|
|
|
UNUSED(value);
|
|
|
|
UNUSED(fan);
|
|
|
|
#endif
|
2018-10-08 20:44:05 +00:00
|
|
|
}
|
|
|
|
|
2018-10-31 00:42:26 +00:00
|
|
|
void setFeedrate_percent(const float value) {
|
2019-09-18 08:18:03 +00:00
|
|
|
feedrate_percentage = constrain(value, 10, 500);
|
2018-10-08 20:44:05 +00:00
|
|
|
}
|
|
|
|
|
2021-01-15 19:59:27 +00:00
|
|
|
bool awaitingUserConfirm() {
|
|
|
|
return wait_for_user;
|
|
|
|
}
|
|
|
|
|
2019-09-17 01:31:08 +00:00
|
|
|
void setUserConfirmed() {
|
2020-04-22 21:35:03 +00:00
|
|
|
TERN_(HAS_RESUME_CONTINUE, wait_for_user = false);
|
2019-03-09 20:13:50 +00:00
|
|
|
}
|
|
|
|
|
2018-10-08 20:44:05 +00:00
|
|
|
void printFile(const char *filename) {
|
2019-11-11 00:49:41 +00:00
|
|
|
UNUSED(filename);
|
2018-10-31 00:42:26 +00:00
|
|
|
IFSD(card.openAndPrintFile(filename), NOOP);
|
2018-10-20 06:44:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool isPrintingFromMediaPaused() {
|
2018-11-07 02:52:39 +00:00
|
|
|
return IFSD(isPrintingFromMedia() && !IS_SD_PRINTING(), false);
|
2018-10-08 20:44:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool isPrintingFromMedia() {
|
2020-04-02 19:24:55 +00:00
|
|
|
#if ENABLED(SDSUPPORT)
|
|
|
|
// Account for when IS_SD_PRINTING() reports the end of the
|
|
|
|
// print when there is still SD card data in the planner.
|
|
|
|
flags.was_sd_printing = card.isFileOpen() || (flags.was_sd_printing && commandsInQueue());
|
|
|
|
return flags.was_sd_printing;
|
|
|
|
#else
|
|
|
|
return false;
|
|
|
|
#endif
|
2018-10-08 20:44:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool isPrinting() {
|
2020-10-28 17:23:46 +00:00
|
|
|
return (commandsInQueue() || isPrintingFromMedia() || IFSD(IS_SD_PRINTING(), false)) || print_job_timer.isRunning() || print_job_timer.isPaused();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isPrintingPaused() {
|
|
|
|
return isPrinting() && (isPrintingFromMediaPaused() || print_job_timer.isPaused());
|
2018-10-08 20:44:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool isMediaInserted() {
|
2019-09-15 08:10:59 +00:00
|
|
|
return IFSD(IS_SD_INSERTED() && card.isMounted(), false);
|
2018-10-08 20:44:05 +00:00
|
|
|
}
|
|
|
|
|
2020-04-28 03:35:25 +00:00
|
|
|
void pausePrint() { ui.pause_print(); }
|
|
|
|
void resumePrint() { ui.resume_print(); }
|
|
|
|
void stopPrint() { ui.abort_print(); }
|
2018-10-08 20:44:05 +00:00
|
|
|
|
2019-10-10 00:46:10 +00:00
|
|
|
void onUserConfirmRequired_P(PGM_P const pstr) {
|
|
|
|
char msg[strlen_P(pstr) + 1];
|
|
|
|
strcpy_P(msg, pstr);
|
|
|
|
onUserConfirmRequired(msg);
|
|
|
|
}
|
|
|
|
|
2020-04-16 05:33:31 +00:00
|
|
|
void onStatusChanged_P(PGM_P const pstr) {
|
|
|
|
char msg[strlen_P(pstr) + 1];
|
|
|
|
strcpy_P(msg, pstr);
|
|
|
|
onStatusChanged(msg);
|
|
|
|
}
|
|
|
|
|
2018-10-31 00:42:26 +00:00
|
|
|
FileList::FileList() { refresh(); }
|
2018-10-08 20:44:05 +00:00
|
|
|
|
2018-10-31 00:42:26 +00:00
|
|
|
void FileList::refresh() { num_files = 0xFFFF; }
|
2018-10-08 20:44:05 +00:00
|
|
|
|
2018-11-18 04:21:44 +00:00
|
|
|
bool FileList::seek(const uint16_t pos, const bool skip_range_check) {
|
2018-10-08 20:44:05 +00:00
|
|
|
#if ENABLED(SDSUPPORT)
|
2019-03-02 22:43:08 +00:00
|
|
|
if (!skip_range_check && (pos + 1) > count()) return false;
|
2020-09-08 20:31:20 +00:00
|
|
|
card.getfilename_sorted(SD_ORDER(pos, count()));
|
2019-01-03 14:36:43 +00:00
|
|
|
return card.filename[0] != '\0';
|
2018-11-18 04:21:44 +00:00
|
|
|
#else
|
2019-11-11 00:49:41 +00:00
|
|
|
UNUSED(pos);
|
|
|
|
UNUSED(skip_range_check);
|
2018-11-18 04:21:44 +00:00
|
|
|
return false;
|
2018-10-08 20:44:05 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
const char* FileList::filename() {
|
2020-12-23 06:51:59 +00:00
|
|
|
return IFSD(card.longest_filename(), "");
|
2018-10-08 20:44:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const char* FileList::shortFilename() {
|
2018-10-20 06:44:46 +00:00
|
|
|
return IFSD(card.filename, "");
|
2018-10-08 20:44:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const char* FileList::longFilename() {
|
2018-10-20 06:44:46 +00:00
|
|
|
return IFSD(card.longFilename, "");
|
2018-10-08 20:44:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool FileList::isDir() {
|
2018-11-17 04:39:16 +00:00
|
|
|
return IFSD(card.flag.filenameIsDir, false);
|
2018-10-08 20:44:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
uint16_t FileList::count() {
|
2018-10-20 06:44:46 +00:00
|
|
|
return IFSD((num_files = (num_files == 0xFFFF ? card.get_num_Files() : num_files)), 0);
|
2018-10-08 20:44:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool FileList::isAtRootDir() {
|
2020-04-29 00:14:43 +00:00
|
|
|
return IFSD(card.flag.workDirIsRoot, true);
|
2018-10-08 20:44:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void FileList::upDir() {
|
|
|
|
#if ENABLED(SDSUPPORT)
|
2019-09-28 20:28:05 +00:00
|
|
|
card.cdup();
|
2018-10-08 20:44:05 +00:00
|
|
|
num_files = 0xFFFF;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2018-11-18 04:21:44 +00:00
|
|
|
void FileList::changeDir(const char * const dirname) {
|
2018-10-08 20:44:05 +00:00
|
|
|
#if ENABLED(SDSUPPORT)
|
2019-09-28 20:28:05 +00:00
|
|
|
card.cd(dirname);
|
2018-10-08 20:44:05 +00:00
|
|
|
num_files = 0xFFFF;
|
2019-11-11 00:49:41 +00:00
|
|
|
#else
|
|
|
|
UNUSED(dirname);
|
2018-10-08 20:44:05 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2018-11-14 19:13:51 +00:00
|
|
|
} // namespace ExtUI
|
2018-10-08 20:44:05 +00:00
|
|
|
|
2020-10-17 00:36:25 +00:00
|
|
|
// At the moment we hook into MarlinUI methods, but this could be cleaned up in the future
|
2018-10-08 20:44:05 +00:00
|
|
|
|
2020-10-17 00:36:25 +00:00
|
|
|
void MarlinUI::init() { ExtUI::onStartup(); }
|
2018-10-08 20:44:05 +00:00
|
|
|
|
2020-04-04 05:08:25 +00:00
|
|
|
void MarlinUI::update() { ExtUI::onIdle(); }
|
2018-10-08 20:44:05 +00:00
|
|
|
|
2019-10-10 00:46:10 +00:00
|
|
|
void MarlinUI::kill_screen(PGM_P const error, PGM_P const component) {
|
2019-09-19 00:35:03 +00:00
|
|
|
using namespace ExtUI;
|
2018-10-31 00:42:26 +00:00
|
|
|
if (!flags.printer_killed) {
|
|
|
|
flags.printer_killed = true;
|
2019-10-10 00:46:10 +00:00
|
|
|
onPrinterKilled(error, component);
|
2018-10-23 00:37:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-08 20:44:05 +00:00
|
|
|
#endif // EXTENSIBLE_UI
|