2019-02-10 10:54:23 +00:00
|
|
|
/**
|
|
|
|
* Marlin 3D Printer Firmware
|
2020-02-03 14:00:57 +00:00
|
|
|
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
2019-02-10 10:54:23 +00:00
|
|
|
*
|
|
|
|
* Based on Sprinter and grbl.
|
2019-06-28 04:57:50 +00:00
|
|
|
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
2019-02-10 10:54:23 +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
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
//
|
|
|
|
// Mixer Menu
|
|
|
|
//
|
|
|
|
|
|
|
|
#include "../../inc/MarlinConfigPre.h"
|
|
|
|
|
|
|
|
#if HAS_LCD_MENU && ENABLED(MIXING_EXTRUDER)
|
|
|
|
|
|
|
|
#include "menu.h"
|
2019-10-26 00:49:48 +00:00
|
|
|
#include "menu_addon.h"
|
2019-02-10 10:54:23 +00:00
|
|
|
|
2019-10-26 00:49:48 +00:00
|
|
|
#include "../../feature/mixing.h"
|
2019-02-10 10:54:23 +00:00
|
|
|
|
|
|
|
#define CHANNEL_MIX_EDITING !DUAL_MIXING_EXTRUDER
|
|
|
|
|
|
|
|
#if ENABLED(GRADIENT_MIX)
|
|
|
|
|
|
|
|
void lcd_mixer_gradient_z_start_edit() {
|
2019-03-23 21:30:43 +00:00
|
|
|
ui.defer_status_screen();
|
2019-02-10 10:54:23 +00:00
|
|
|
ENCODER_RATE_MULTIPLY(true);
|
|
|
|
if (ui.encoderPosition != 0) {
|
2019-10-21 23:34:29 +00:00
|
|
|
mixer.gradient.start_z += float(int32_t(ui.encoderPosition)) * 0.1;
|
2019-02-10 10:54:23 +00:00
|
|
|
ui.encoderPosition = 0;
|
|
|
|
NOLESS(mixer.gradient.start_z, 0);
|
|
|
|
NOMORE(mixer.gradient.start_z, Z_MAX_POS);
|
|
|
|
}
|
|
|
|
if (ui.should_draw()) {
|
|
|
|
char tmp[21];
|
2019-10-10 00:46:10 +00:00
|
|
|
strcpy_P(tmp, GET_TEXT(MSG_START_Z));
|
|
|
|
sprintf_P(tmp + strlen(tmp), PSTR(": %4d.%d mm"), int(mixer.gradient.start_z), int(mixer.gradient.start_z * 10) % 10);
|
2019-02-10 10:54:23 +00:00
|
|
|
SETCURSOR(2, (LCD_HEIGHT - 1) / 2);
|
2019-10-10 01:41:44 +00:00
|
|
|
lcd_put_u8str(tmp);
|
2019-02-10 10:54:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (ui.lcd_clicked) {
|
|
|
|
if (mixer.gradient.start_z > mixer.gradient.end_z)
|
|
|
|
mixer.gradient.end_z = mixer.gradient.start_z;
|
|
|
|
mixer.refresh_gradient();
|
|
|
|
ui.goto_previous_screen();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void lcd_mixer_gradient_z_end_edit() {
|
2019-03-23 21:30:43 +00:00
|
|
|
ui.defer_status_screen();
|
2019-02-10 10:54:23 +00:00
|
|
|
ENCODER_RATE_MULTIPLY(true);
|
|
|
|
if (ui.encoderPosition != 0) {
|
2019-10-21 23:34:29 +00:00
|
|
|
mixer.gradient.end_z += float(int32_t(ui.encoderPosition)) * 0.1;
|
2019-02-10 10:54:23 +00:00
|
|
|
ui.encoderPosition = 0;
|
|
|
|
NOLESS(mixer.gradient.end_z, 0);
|
|
|
|
NOMORE(mixer.gradient.end_z, Z_MAX_POS);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ui.should_draw()) {
|
|
|
|
char tmp[21];
|
2019-10-10 00:46:10 +00:00
|
|
|
strcpy_P(tmp, GET_TEXT(MSG_END_Z));
|
|
|
|
sprintf_P(tmp + strlen(tmp), PSTR(": %4d.%d mm"), int(mixer.gradient.end_z), int(mixer.gradient.end_z * 10) % 10);
|
2019-02-10 10:54:23 +00:00
|
|
|
SETCURSOR(2, (LCD_HEIGHT - 1) / 2);
|
2019-10-10 01:41:44 +00:00
|
|
|
lcd_put_u8str(tmp);
|
2019-02-10 10:54:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (ui.lcd_clicked) {
|
|
|
|
if (mixer.gradient.end_z < mixer.gradient.start_z)
|
|
|
|
mixer.gradient.start_z = mixer.gradient.end_z;
|
|
|
|
mixer.refresh_gradient();
|
|
|
|
ui.goto_previous_screen();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void lcd_mixer_edit_gradient_menu() {
|
|
|
|
START_MENU();
|
2019-10-03 10:38:30 +00:00
|
|
|
BACK_ITEM(MSG_MIXER);
|
2019-02-10 10:54:23 +00:00
|
|
|
|
2019-10-03 10:38:30 +00:00
|
|
|
EDIT_ITEM(int8, MSG_START_VTOOL, &mixer.gradient.start_vtool, 0, MIXING_VIRTUAL_TOOLS - 1, mixer.refresh_gradient);
|
|
|
|
EDIT_ITEM(int8, MSG_END_VTOOL, &mixer.gradient.end_vtool, 0, MIXING_VIRTUAL_TOOLS - 1, mixer.refresh_gradient);
|
2019-02-10 10:54:23 +00:00
|
|
|
|
|
|
|
#if ENABLED(GRADIENT_VTOOL)
|
2019-10-03 10:38:30 +00:00
|
|
|
EDIT_ITEM(int8, MSG_GRADIENT_ALIAS, &mixer.gradient.vtool_index, 0, MIXING_VIRTUAL_TOOLS - 1, mixer.refresh_gradient);
|
2019-02-10 10:54:23 +00:00
|
|
|
#endif
|
|
|
|
|
2019-05-02 02:55:58 +00:00
|
|
|
char tmp[18];
|
2019-02-10 10:54:23 +00:00
|
|
|
|
2019-10-10 00:46:10 +00:00
|
|
|
SUBMENU(MSG_START_Z, lcd_mixer_gradient_z_start_edit);
|
2019-02-10 10:54:23 +00:00
|
|
|
MENU_ITEM_ADDON_START(9);
|
|
|
|
sprintf_P(tmp, PSTR("%4d.%d mm"), int(mixer.gradient.start_z), int(mixer.gradient.start_z * 10) % 10);
|
2019-10-10 01:41:44 +00:00
|
|
|
lcd_put_u8str(tmp);
|
2019-02-10 10:54:23 +00:00
|
|
|
MENU_ITEM_ADDON_END();
|
|
|
|
|
2019-10-10 00:46:10 +00:00
|
|
|
SUBMENU(MSG_END_Z, lcd_mixer_gradient_z_end_edit);
|
2019-02-10 10:54:23 +00:00
|
|
|
MENU_ITEM_ADDON_START(9);
|
|
|
|
sprintf_P(tmp, PSTR("%4d.%d mm"), int(mixer.gradient.end_z), int(mixer.gradient.end_z * 10) % 10);
|
2019-10-10 01:41:44 +00:00
|
|
|
lcd_put_u8str(tmp);
|
2019-02-10 10:54:23 +00:00
|
|
|
MENU_ITEM_ADDON_END();
|
|
|
|
|
|
|
|
END_MENU();
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // GRADIENT_MIX
|
|
|
|
|
|
|
|
static uint8_t v_index;
|
|
|
|
|
|
|
|
#if DUAL_MIXING_EXTRUDER
|
|
|
|
void _lcd_draw_mix(const uint8_t y) {
|
2019-10-28 21:26:37 +00:00
|
|
|
char tmp[20]; // "100%_100%"
|
2019-10-10 00:46:10 +00:00
|
|
|
sprintf_P(tmp, PSTR("%3d%% %3d%%"), int(mixer.mix[0]), int(mixer.mix[1]));
|
2019-10-28 21:26:37 +00:00
|
|
|
SETCURSOR(2, y); lcd_put_u8str_P(GET_TEXT(MSG_MIX));
|
|
|
|
SETCURSOR_RJ(9, y); lcd_put_u8str(tmp);
|
2019-02-10 10:54:23 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
void _lcd_mixer_select_vtool() {
|
|
|
|
mixer.T(v_index);
|
|
|
|
#if DUAL_MIXING_EXTRUDER
|
|
|
|
_lcd_draw_mix(LCD_HEIGHT - 1);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
#if CHANNEL_MIX_EDITING
|
|
|
|
|
|
|
|
void _lcd_mixer_cycle_mix() {
|
|
|
|
uint16_t bits = 0;
|
|
|
|
MIXER_STEPPER_LOOP(i) if (mixer.collector[i]) SBI(bits, i);
|
|
|
|
bits = (bits + 1) & (_BV(MIXING_STEPPERS) - 1);
|
|
|
|
if (!bits) ++bits;
|
|
|
|
MIXER_STEPPER_LOOP(i) mixer.collector[i] = TEST(bits, i) ? 10.0f : 0.0f;
|
|
|
|
ui.refresh();
|
|
|
|
}
|
|
|
|
|
|
|
|
void _lcd_mixer_commit_vtool() {
|
|
|
|
mixer.normalize();
|
|
|
|
ui.goto_previous_screen();
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
void lcd_mixer_mix_edit() {
|
|
|
|
|
2019-11-15 02:30:30 +00:00
|
|
|
#if DUAL_MIXING_EXTRUDER && !CHANNEL_MIX_EDITING
|
2019-02-10 10:54:23 +00:00
|
|
|
|
2019-11-15 02:30:30 +00:00
|
|
|
// Adjust 2-channel mix from the encoder
|
2019-02-10 10:54:23 +00:00
|
|
|
if (ui.encoderPosition != 0) {
|
2019-10-21 23:34:29 +00:00
|
|
|
mixer.mix[0] += int32_t(ui.encoderPosition);
|
2019-02-10 10:54:23 +00:00
|
|
|
ui.encoderPosition = 0;
|
|
|
|
if (mixer.mix[0] < 0) mixer.mix[0] += 101;
|
|
|
|
if (mixer.mix[0] > 100) mixer.mix[0] -= 101;
|
|
|
|
mixer.mix[1] = 100 - mixer.mix[0];
|
|
|
|
}
|
|
|
|
_lcd_draw_mix((LCD_HEIGHT - 1) / 2);
|
|
|
|
|
2019-11-15 02:30:30 +00:00
|
|
|
// Click to commit the change
|
2019-02-10 10:54:23 +00:00
|
|
|
if (ui.lcd_clicked) {
|
|
|
|
mixer.update_vtool_from_mix();
|
|
|
|
ui.goto_previous_screen();
|
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
START_MENU();
|
2019-10-03 10:38:30 +00:00
|
|
|
BACK_ITEM(MSG_MIXER);
|
2019-11-15 02:30:30 +00:00
|
|
|
|
|
|
|
#if CHANNEL_MIX_EDITING
|
|
|
|
|
2020-03-14 04:18:16 +00:00
|
|
|
LOOP_S_LE_N(n, 1, MIXING_STEPPERS)
|
2020-03-17 20:12:52 +00:00
|
|
|
EDIT_ITEM_FAST_N(float42_52, n, MSG_MIX_COMPONENT_N, &mixer.collector[n-1], 0, 10);
|
2019-11-15 02:30:30 +00:00
|
|
|
|
|
|
|
ACTION_ITEM(MSG_CYCLE_MIX, _lcd_mixer_cycle_mix);
|
|
|
|
ACTION_ITEM(MSG_COMMIT_VTOOL, _lcd_mixer_commit_vtool);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2019-02-10 10:54:23 +00:00
|
|
|
END_MENU();
|
|
|
|
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
#if DUAL_MIXING_EXTRUDER
|
|
|
|
|
|
|
|
//
|
|
|
|
// Toggle Dual-Mix
|
|
|
|
//
|
|
|
|
inline void _lcd_mixer_toggle_mix() {
|
|
|
|
mixer.mix[0] = mixer.mix[0] == 100 ? 0 : 100;
|
|
|
|
mixer.mix[1] = 100 - mixer.mix[0];
|
|
|
|
mixer.update_vtool_from_mix();
|
|
|
|
ui.refresh(LCDVIEW_CALL_REDRAW_NEXT);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if CHANNEL_MIX_EDITING
|
|
|
|
|
|
|
|
//
|
|
|
|
// Prepare and Edit Mix
|
|
|
|
//
|
|
|
|
inline void _lcd_goto_mix_edit() {
|
|
|
|
mixer.refresh_collector(10, v_index);
|
|
|
|
ui.goto_screen(lcd_mixer_mix_edit);
|
|
|
|
lcd_mixer_mix_edit();
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if ENABLED(GRADIENT_MIX)
|
|
|
|
//
|
|
|
|
// Reverse Gradient
|
|
|
|
//
|
|
|
|
inline void _lcd_mixer_reverse_gradient() {
|
|
|
|
const uint8_t sv = mixer.gradient.start_vtool;
|
|
|
|
mixer.gradient.start_vtool = mixer.gradient.end_vtool;
|
|
|
|
mixer.gradient.end_vtool = sv;
|
|
|
|
mixer.refresh_gradient();
|
|
|
|
ui.refresh(LCDVIEW_CALL_REDRAW_NEXT);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
void menu_mixer() {
|
|
|
|
START_MENU();
|
2019-10-03 10:38:30 +00:00
|
|
|
BACK_ITEM(MSG_MAIN);
|
2019-02-10 10:54:23 +00:00
|
|
|
|
|
|
|
v_index = mixer.get_current_vtool();
|
2019-10-03 10:38:30 +00:00
|
|
|
EDIT_ITEM(uint8, MSG_ACTIVE_VTOOL, &v_index, 0, MIXING_VIRTUAL_TOOLS - 1, _lcd_mixer_select_vtool
|
2019-02-10 10:54:23 +00:00
|
|
|
#if DUAL_MIXING_EXTRUDER
|
|
|
|
, true
|
|
|
|
#endif
|
|
|
|
);
|
|
|
|
|
|
|
|
#if DUAL_MIXING_EXTRUDER
|
|
|
|
{
|
|
|
|
char tmp[10];
|
2019-10-03 10:38:30 +00:00
|
|
|
SUBMENU(MSG_MIX, lcd_mixer_mix_edit);
|
2019-02-10 10:54:23 +00:00
|
|
|
MENU_ITEM_ADDON_START(10);
|
|
|
|
mixer.update_mix_from_vtool();
|
|
|
|
sprintf_P(tmp, PSTR("%3d;%3d%%"), int(mixer.mix[0]), int(mixer.mix[1]));
|
2019-10-10 01:41:44 +00:00
|
|
|
lcd_put_u8str(tmp);
|
2019-02-10 10:54:23 +00:00
|
|
|
MENU_ITEM_ADDON_END();
|
2019-10-03 10:38:30 +00:00
|
|
|
ACTION_ITEM(MSG_TOGGLE_MIX, _lcd_mixer_toggle_mix);
|
2019-02-10 10:54:23 +00:00
|
|
|
}
|
2019-07-30 02:57:02 +00:00
|
|
|
#else
|
2019-10-03 10:38:30 +00:00
|
|
|
SUBMENU(MSG_MIX, _lcd_goto_mix_edit);
|
2019-02-10 10:54:23 +00:00
|
|
|
#endif
|
|
|
|
|
2019-11-02 12:28:20 +00:00
|
|
|
//
|
|
|
|
// Reset All V-Tools
|
|
|
|
//
|
|
|
|
CONFIRM_ITEM(MSG_RESET_VTOOLS,
|
|
|
|
MSG_BUTTON_RESET, MSG_BUTTON_CANCEL,
|
|
|
|
[]{
|
|
|
|
mixer.reset_vtools();
|
|
|
|
LCD_MESSAGEPGM(MSG_VTOOLS_RESET);
|
|
|
|
ui.return_to_status();
|
|
|
|
},
|
|
|
|
ui.goto_previous_screen,
|
|
|
|
GET_TEXT(MSG_RESET_VTOOLS), (PGM_P)nullptr, PSTR("?")
|
|
|
|
);
|
2019-02-10 10:54:23 +00:00
|
|
|
|
|
|
|
#if ENABLED(GRADIENT_MIX)
|
|
|
|
{
|
2019-05-02 02:55:58 +00:00
|
|
|
char tmp[13];
|
2019-10-03 10:38:30 +00:00
|
|
|
SUBMENU(MSG_GRADIENT, lcd_mixer_edit_gradient_menu);
|
2019-02-10 10:54:23 +00:00
|
|
|
MENU_ITEM_ADDON_START(10);
|
|
|
|
sprintf_P(tmp, PSTR("T%i->T%i"), mixer.gradient.start_vtool, mixer.gradient.end_vtool);
|
2019-10-10 01:41:44 +00:00
|
|
|
lcd_put_u8str(tmp);
|
2019-02-10 10:54:23 +00:00
|
|
|
MENU_ITEM_ADDON_END();
|
2019-10-03 10:38:30 +00:00
|
|
|
ACTION_ITEM(MSG_REVERSE_GRADIENT, _lcd_mixer_reverse_gradient);
|
2019-02-10 10:54:23 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
END_MENU();
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // HAS_LCD_MENU && MIXING_EXTRUDER
|