diff --git a/src/common/marlin_server.cpp b/src/common/marlin_server.cpp index ef7d3d2e6a..642d451eb9 100644 --- a/src/common/marlin_server.cpp +++ b/src/common/marlin_server.cpp @@ -2071,6 +2071,8 @@ static void _server_update_vars() { uint8_t progress = 0; if (oProgressData.oPercentDone.mIsActual(marlin_vars()->print_duration)) progress = static_cast(oProgressData.oPercentDone.mGetValue()); + else if (oProgressData.oPercentDirectControl.mIsActual(marlin_vars() ->print_duration)) + progress = static_cast(oProgressData.oPercentDirectControl.mGetValue()); else progress = static_cast(media_print_get_percent_done()); diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index d59f6c7112..be86e6ba9e 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -83,6 +83,7 @@ target_sources( window_file_list.cpp window_filebrowser.cpp window_header.cpp + window_lcd_message.cpp window_msgbox_wrong_printer.cpp window_print_progress.cpp window_temp_graph.cpp diff --git a/src/gui/res/png/serial_printing_172x138.png b/src/gui/res/png/serial_printing_172x138.png deleted file mode 100644 index eebdfa6fb3..0000000000 Binary files a/src/gui/res/png/serial_printing_172x138.png and /dev/null differ diff --git a/src/gui/res/png/serial_printing_172x69.png b/src/gui/res/png/serial_printing_172x69.png new file mode 100644 index 0000000000..b68fc6c8b1 Binary files /dev/null and b/src/gui/res/png/serial_printing_172x69.png differ diff --git a/src/gui/screen_printing_serial.cpp b/src/gui/screen_printing_serial.cpp index ff0a219315..4ee9251d30 100644 --- a/src/gui/screen_printing_serial.cpp +++ b/src/gui/screen_printing_serial.cpp @@ -16,7 +16,10 @@ screen_printing_serial_data_t::screen_printing_serial_data_t() : AddSuperWindow(_(caption)) - , octo_icon(this, Rect16((240 - png::serial_printing_172x138.w) / 2, GuiDefaults::RectScreenBody.Top(), png::serial_printing_172x138.w, png::serial_printing_172x138.h), &png::serial_printing_172x138) + , octo_icon(this, Rect16((120 - png::serial_printing_172x69.w) / 2, GuiDefaults::RectScreenBody.Top() + 8, png::serial_printing_172x69.w, png::serial_printing_172x69.h), &png::serial_printing_172x69) + , w_progress(this, Rect16(10, GuiDefaults::RectScreenBody.Top() + png::serial_printing_172x69.h + 14, GuiDefaults::RectScreen.Width() - 2 * 10, 16)) + , w_progress_txt(this, Rect16(10, GuiDefaults::RectScreenBody.Top() + png::serial_printing_172x69.h + 34, GuiDefaults::RectScreen.Width() - 2 * 10, 30)) + , w_message(this, Rect16(10, GuiDefaults::RectScreenBody.Top() + png::serial_printing_172x69.h + 60, GuiDefaults::RectScreen.Width() - 2 * 10, 20)) , last_tick(0) , connection(connection_state_t::connected) { ClrMenuTimeoutClose(); @@ -26,6 +29,10 @@ screen_printing_serial_data_t::screen_printing_serial_data_t() octo_icon.Unshadow(); SetButtonIconAndLabel(BtnSocket::Right, BtnRes::Disconnect, LabelRes::Disconnect); + + w_message.font = resource_font(IDR_FNT_SMALL); + w_message.SetAlignment(Align_t::CenterBottom()); + w_message.SetPadding({ 0, 2, 0, 2 }); } void screen_printing_serial_data_t::windowEvent(EventLock /*has private ctor*/, window_t *sender, GUI_event_t event, void *param) { diff --git a/src/gui/screen_printing_serial.hpp b/src/gui/screen_printing_serial.hpp index 233ffc9eb5..7e12ec8181 100644 --- a/src/gui/screen_printing_serial.hpp +++ b/src/gui/screen_printing_serial.hpp @@ -4,7 +4,9 @@ #include "gui.hpp" #include "window_header.hpp" #include "status_footer.hpp" +#include "window_print_progress.hpp" #include "window_text.hpp" +#include "window_lcd_message.hpp" #include #include "non_file_printing_counter.hpp" @@ -14,6 +16,10 @@ class screen_printing_serial_data_t : public AddSuperWindow window_icon_t octo_icon; + WindowPrintProgress w_progress; + WindowNumbPrintProgress w_progress_txt; + WindowLCDMessage w_message; + int last_tick; enum class connection_state_t { connected, disconnect, diff --git a/src/gui/window_lcd_message.cpp b/src/gui/window_lcd_message.cpp new file mode 100644 index 0000000000..a63ffa4ad4 --- /dev/null +++ b/src/gui/window_lcd_message.cpp @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2021 Matthew Lloyd + * All rights reserved. + * + * This file is part of Llama Mini. + * + * Llama Mini 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. + * + * Llama Mini 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 Llama Mini. If not, see . + */ + +#include "window_lcd_message.hpp" +#include "gui.hpp" +#include +#include "ScreenHandler.hpp" +#include "marlin_client.hpp" + +char lcd_message_text[LCD_MESSAGE_MAX_LEN + 1]; + +/*****************************************************************************/ +//WindowLCDMessage +WindowLCDMessage::WindowLCDMessage(window_t *parent, Rect16 rect) + : AddSuperWindow(parent, rect, is_multiline::no) { + last_lcd_message_text[0] = 0; + last_lcd_message_text[LCD_MESSAGE_MAX_LEN] = 0; + lcd_message_text[0] = 0; + lcd_message_text[LCD_MESSAGE_MAX_LEN] = 0; + font = resource_font(IDR_FNT_SMALL); + SetAlignment(Align_t::Center()); +} + +void WindowLCDMessage::windowEvent(EventLock /*has private ctor*/, window_t *sender, GUI_event_t event, void *param) { + if (event == GUI_event_t::LOOP) { + if (strncmp(lcd_message_text, last_lcd_message_text, LCD_MESSAGE_MAX_LEN) != 0) { + strncpy(last_lcd_message_text, lcd_message_text, LCD_MESSAGE_MAX_LEN); + SetText(string_view_utf8::MakeRAM((const uint8_t *)lcd_message_text)); + Invalidate(); + } + } + SuperWindowEvent(sender, event, param); +} diff --git a/src/gui/window_lcd_message.hpp b/src/gui/window_lcd_message.hpp new file mode 100644 index 0000000000..7b56e9d7b9 --- /dev/null +++ b/src/gui/window_lcd_message.hpp @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2021 Matthew Lloyd + * All rights reserved. + * + * This file is part of Llama Mini. + * + * Llama Mini 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. + * + * Llama Mini 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 Llama Mini. If not, see . + */ + +#pragma once + +#include "window_text.hpp" + +#define LCD_MESSAGE_MAX_LEN 30 +extern char lcd_message_text[LCD_MESSAGE_MAX_LEN + 1]; + +class WindowLCDMessage : public AddSuperWindow { + char last_lcd_message_text[LCD_MESSAGE_MAX_LEN + 1]; + +public: + WindowLCDMessage(window_t *parent, Rect16 rect); + +protected: + void windowEvent(EventLock /*has private ctor*/, window_t *sender, GUI_event_t event, void *param) override; +}; diff --git a/src/marlin_stubs/CMakeLists.txt b/src/marlin_stubs/CMakeLists.txt index 439d18677d..5593d737c5 100644 --- a/src/marlin_stubs/CMakeLists.txt +++ b/src/marlin_stubs/CMakeLists.txt @@ -3,6 +3,7 @@ target_sources( PRIVATE G26.cpp G64.cpp gcode.cpp + M117.cpp M300.cpp M330.cpp M505.cpp diff --git a/src/marlin_stubs/M117.cpp b/src/marlin_stubs/M117.cpp new file mode 100644 index 0000000000..433e67968c --- /dev/null +++ b/src/marlin_stubs/M117.cpp @@ -0,0 +1,15 @@ +#include "window_lcd_message.hpp" +#include "../../lib/Marlin/Marlin/src/gcode/gcode.h" + +#include "M117.hpp" +#include + +/** + * M117: LCD message + */ +void PrusaGcodeSuite::M117() { + if (parser.string_arg && parser.string_arg[0]) + strncpy(lcd_message_text, parser.string_arg, LCD_MESSAGE_MAX_LEN); + else + lcd_message_text[0] = 0; +} diff --git a/src/marlin_stubs/M117.hpp b/src/marlin_stubs/M117.hpp new file mode 100644 index 0000000000..950f0e8a86 --- /dev/null +++ b/src/marlin_stubs/M117.hpp @@ -0,0 +1,5 @@ +#pragma once + +namespace PrusaGcodeSuite { +void M117(); // LCD message +} diff --git a/src/marlin_stubs/PrusaGcodeSuite.hpp b/src/marlin_stubs/PrusaGcodeSuite.hpp index d4d37431e8..74ee3b34bc 100644 --- a/src/marlin_stubs/PrusaGcodeSuite.hpp +++ b/src/marlin_stubs/PrusaGcodeSuite.hpp @@ -13,6 +13,8 @@ void G163(); /// measure length of axis void M50(); /// selftest +void M117(); /// M117 LCD message (print status) + void M300(); /// beep void M505(); /// set eeprom variable diff --git a/src/marlin_stubs/gcode.cpp b/src/marlin_stubs/gcode.cpp index fc2bae73e1..eb66257e6f 100644 --- a/src/marlin_stubs/gcode.cpp +++ b/src/marlin_stubs/gcode.cpp @@ -31,6 +31,11 @@ bool GcodeSuite::process_parsed_command_custom(bool no_ok) { case 50: PrusaGcodeSuite::M50(); // selftest break; + case 117: + PrusaGcodeSuite::M117(); + if (!no_ok) + queue.ok_to_send(); + return true; #if HAS_LEDS case 150: PrusaGcodeSuite::M150();