aboutsummaryrefslogtreecommitdiff
path: root/Marlin/src/gcode/lcd
diff options
context:
space:
mode:
authorGeorgiy Bondarenko <69736697+nehilo@users.noreply.github.com>2021-03-04 20:54:23 +0300
committerGeorgiy Bondarenko <69736697+nehilo@users.noreply.github.com>2021-03-04 20:54:23 +0300
commite8701195e66f2d27ffe17fb514eae8173795aaf7 (patch)
tree9f519c4abf6556b9ae7190a6210d87ead1dfadde /Marlin/src/gcode/lcd
downloadkp3s-lgvl-e8701195e66f2d27ffe17fb514eae8173795aaf7.tar.xz
kp3s-lgvl-e8701195e66f2d27ffe17fb514eae8173795aaf7.zip
Initial commit
Diffstat (limited to 'Marlin/src/gcode/lcd')
-rw-r--r--Marlin/src/gcode/lcd/M0_M1.cpp87
-rw-r--r--Marlin/src/gcode/lcd/M117.cpp36
-rw-r--r--Marlin/src/gcode/lcd/M145.cpp59
-rw-r--r--Marlin/src/gcode/lcd/M250.cpp38
-rw-r--r--Marlin/src/gcode/lcd/M300.cpp45
-rw-r--r--Marlin/src/gcode/lcd/M414.cpp44
-rw-r--r--Marlin/src/gcode/lcd/M73.cpp48
-rw-r--r--Marlin/src/gcode/lcd/M995.cpp48
8 files changed, 405 insertions, 0 deletions
diff --git a/Marlin/src/gcode/lcd/M0_M1.cpp b/Marlin/src/gcode/lcd/M0_M1.cpp
new file mode 100644
index 0000000..414c4ce
--- /dev/null
+++ b/Marlin/src/gcode/lcd/M0_M1.cpp
@@ -0,0 +1,87 @@
+/**
+ * Marlin 3D Printer Firmware
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ *
+ * Based on Sprinter and grbl.
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
+ *
+ * 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
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "../../inc/MarlinConfigPre.h"
+
+#if HAS_RESUME_CONTINUE
+
+#include "../../inc/MarlinConfig.h"
+
+#include "../gcode.h"
+
+#include "../../module/planner.h" // for synchronize()
+#include "../../MarlinCore.h" // for wait_for_user_response()
+
+#if HAS_LCD_MENU
+ #include "../../lcd/marlinui.h"
+#elif ENABLED(EXTENSIBLE_UI)
+ #include "../../lcd/extui/ui_api.h"
+#endif
+
+#if ENABLED(HOST_PROMPT_SUPPORT)
+ #include "../../feature/host_actions.h"
+#endif
+
+/**
+ * M0: Unconditional stop - Wait for user button press on LCD
+ * M1: Conditional stop - Wait for user button press on LCD
+ */
+void GcodeSuite::M0_M1() {
+ millis_t ms = 0;
+ if (parser.seenval('P')) ms = parser.value_millis(); // Milliseconds to wait
+ if (parser.seenval('S')) ms = parser.value_millis_from_seconds(); // Seconds to wait
+
+ planner.synchronize();
+
+ #if HAS_LCD_MENU
+
+ if (parser.string_arg)
+ ui.set_status(parser.string_arg, true);
+ else {
+ LCD_MESSAGEPGM(MSG_USERWAIT);
+ #if ENABLED(LCD_PROGRESS_BAR) && PROGRESS_MSG_EXPIRE > 0
+ ui.reset_progress_bar_timeout();
+ #endif
+ }
+
+ #elif ENABLED(EXTENSIBLE_UI)
+ if (parser.string_arg)
+ ExtUI::onUserConfirmRequired(parser.string_arg); // Can this take an SRAM string??
+ else
+ ExtUI::onUserConfirmRequired_P(GET_TEXT(MSG_USERWAIT));
+ #else
+
+ if (parser.string_arg) {
+ SERIAL_ECHO_START();
+ SERIAL_ECHOLN(parser.string_arg);
+ }
+
+ #endif
+
+ TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_USER_CONTINUE, parser.codenum ? PSTR("M1 Stop") : PSTR("M0 Stop"), CONTINUE_STR));
+
+ wait_for_user_response(ms);
+
+ TERN_(HAS_LCD_MENU, ui.reset_status());
+}
+
+#endif // HAS_RESUME_CONTINUE
diff --git a/Marlin/src/gcode/lcd/M117.cpp b/Marlin/src/gcode/lcd/M117.cpp
new file mode 100644
index 0000000..59305d9
--- /dev/null
+++ b/Marlin/src/gcode/lcd/M117.cpp
@@ -0,0 +1,36 @@
+/**
+ * Marlin 3D Printer Firmware
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ *
+ * Based on Sprinter and grbl.
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
+ *
+ * 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
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "../gcode.h"
+#include "../../lcd/marlinui.h"
+
+/**
+ * M117: Set LCD Status Message
+ */
+void GcodeSuite::M117() {
+
+ if (parser.string_arg && parser.string_arg[0])
+ ui.set_status(parser.string_arg);
+ else
+ ui.reset_status();
+
+}
diff --git a/Marlin/src/gcode/lcd/M145.cpp b/Marlin/src/gcode/lcd/M145.cpp
new file mode 100644
index 0000000..84a7e75
--- /dev/null
+++ b/Marlin/src/gcode/lcd/M145.cpp
@@ -0,0 +1,59 @@
+/**
+ * Marlin 3D Printer Firmware
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ *
+ * Based on Sprinter and grbl.
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
+ *
+ * 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
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "../../inc/MarlinConfig.h"
+
+#if PREHEAT_COUNT
+
+#include "../gcode.h"
+#include "../../lcd/marlinui.h"
+
+/**
+ * M145: Set the heatup state for a material in the LCD menu
+ *
+ * S<material>
+ * H<hotend temp>
+ * B<bed temp>
+ * F<fan speed>
+ */
+void GcodeSuite::M145() {
+ const uint8_t material = (uint8_t)parser.intval('S');
+ if (material >= PREHEAT_COUNT)
+ SERIAL_ERROR_MSG(STR_ERR_MATERIAL_INDEX);
+ else {
+ preheat_t &mat = ui.material_preset[material];
+ #if HAS_HOTEND
+ if (parser.seenval('H'))
+ mat.hotend_temp = constrain(parser.value_int(), EXTRUDE_MINTEMP, (HEATER_0_MAXTEMP) - (HOTEND_OVERSHOOT));
+ #endif
+ #if HAS_HEATED_BED
+ if (parser.seenval('B'))
+ mat.bed_temp = constrain(parser.value_int(), BED_MINTEMP, BED_MAX_TARGET);
+ #endif
+ #if HAS_FAN
+ if (parser.seenval('F'))
+ mat.fan_speed = constrain(parser.value_int(), 0, 255);
+ #endif
+ }
+}
+
+#endif // PREHEAT_COUNT
diff --git a/Marlin/src/gcode/lcd/M250.cpp b/Marlin/src/gcode/lcd/M250.cpp
new file mode 100644
index 0000000..f553044
--- /dev/null
+++ b/Marlin/src/gcode/lcd/M250.cpp
@@ -0,0 +1,38 @@
+/**
+ * Marlin 3D Printer Firmware
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ *
+ * Based on Sprinter and grbl.
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
+ *
+ * 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
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "../../inc/MarlinConfig.h"
+
+#if HAS_LCD_CONTRAST
+
+#include "../gcode.h"
+#include "../../lcd/marlinui.h"
+
+/**
+ * M250: Read and optionally set the LCD contrast
+ */
+void GcodeSuite::M250() {
+ if (parser.seen('C')) ui.set_contrast(parser.value_int());
+ SERIAL_ECHOLNPAIR("LCD Contrast: ", ui.contrast);
+}
+
+#endif // HAS_LCD_CONTRAST
diff --git a/Marlin/src/gcode/lcd/M300.cpp b/Marlin/src/gcode/lcd/M300.cpp
new file mode 100644
index 0000000..5250774
--- /dev/null
+++ b/Marlin/src/gcode/lcd/M300.cpp
@@ -0,0 +1,45 @@
+/**
+ * Marlin 3D Printer Firmware
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ *
+ * Based on Sprinter and grbl.
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
+ *
+ * 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
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "../../inc/MarlinConfig.h"
+
+#if HAS_BUZZER
+
+#include "../gcode.h"
+
+#include "../../lcd/marlinui.h" // i2c-based BUZZ
+#include "../../libs/buzzer.h" // Buzzer, if possible
+
+/**
+ * M300: Play beep sound S<frequency Hz> P<duration ms>
+ */
+void GcodeSuite::M300() {
+ uint16_t const frequency = parser.ushortval('S', 260);
+ uint16_t duration = parser.ushortval('P', 1000);
+
+ // Limits the tone duration to 0-5 seconds.
+ NOMORE(duration, 5000U);
+
+ BUZZ(duration, frequency);
+}
+
+#endif // HAS_BUZZER
diff --git a/Marlin/src/gcode/lcd/M414.cpp b/Marlin/src/gcode/lcd/M414.cpp
new file mode 100644
index 0000000..760028a
--- /dev/null
+++ b/Marlin/src/gcode/lcd/M414.cpp
@@ -0,0 +1,44 @@
+/**
+ * Marlin 3D Printer Firmware
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ *
+ * Based on Sprinter and grbl.
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
+ *
+ * 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
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "../../inc/MarlinConfig.h"
+
+#if HAS_MULTI_LANGUAGE
+
+#include "../gcode.h"
+#include "../../MarlinCore.h"
+#include "../../lcd/marlinui.h"
+
+/**
+ * M414: Set the language for the UI
+ *
+ * Parameters
+ * S<index> : The language to select
+ */
+void GcodeSuite::M414() {
+
+ if (parser.seenval('S'))
+ ui.set_language(parser.value_byte());
+
+}
+
+#endif // HAS_MULTI_LANGUAGE
diff --git a/Marlin/src/gcode/lcd/M73.cpp b/Marlin/src/gcode/lcd/M73.cpp
new file mode 100644
index 0000000..5b135bd
--- /dev/null
+++ b/Marlin/src/gcode/lcd/M73.cpp
@@ -0,0 +1,48 @@
+/**
+ * Marlin 3D Printer Firmware
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ *
+ * Based on Sprinter and grbl.
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
+ *
+ * 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
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "../../inc/MarlinConfig.h"
+
+#if ENABLED(LCD_SET_PROGRESS_MANUALLY)
+
+#include "../gcode.h"
+#include "../../lcd/marlinui.h"
+#include "../../sd/cardreader.h"
+
+/**
+ * M73: Set percentage complete (for display on LCD)
+ *
+ * Example:
+ * M73 P25 ; Set progress to 25%
+ */
+void GcodeSuite::M73() {
+ if (parser.seen('P'))
+ ui.set_progress((PROGRESS_SCALE) > 1
+ ? parser.value_float() * (PROGRESS_SCALE)
+ : parser.value_byte()
+ );
+ #if BOTH(LCD_SET_PROGRESS_MANUALLY, USE_M73_REMAINING_TIME)
+ if (parser.seen('R')) ui.set_remaining_time(60 * parser.value_ulong());
+ #endif
+}
+
+#endif // LCD_SET_PROGRESS_MANUALLY
diff --git a/Marlin/src/gcode/lcd/M995.cpp b/Marlin/src/gcode/lcd/M995.cpp
new file mode 100644
index 0000000..bc8dc35
--- /dev/null
+++ b/Marlin/src/gcode/lcd/M995.cpp
@@ -0,0 +1,48 @@
+/**
+ * Marlin 3D Printer Firmware
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
+ *
+ * Based on Sprinter and grbl.
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
+ *
+ * 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
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "../../inc/MarlinConfig.h"
+
+#if ENABLED(TOUCH_SCREEN_CALIBRATION)
+
+#include "../gcode.h"
+
+#if ENABLED(TFT_LVGL_UI)
+ #include "../../lcd/extui/lib/mks_ui/draw_touch_calibration.h"
+#else
+ #include "../../lcd/menu/menu.h"
+#endif
+
+/**
+ * M995: Touch screen calibration for TFT display
+ */
+void GcodeSuite::M995() {
+
+ #if ENABLED(TFT_LVGL_UI)
+ lv_draw_touch_calibration_screen();
+ #else
+ ui.goto_screen(touch_screen_calibration);
+ #endif
+
+}
+
+#endif // TOUCH_SCREEN_CALIBRATION