Initial commit. Unusable Marlin 2.0.5.3 core without any custimization.
This commit is contained in:
207
Marlin/src/lcd/menu/game/brickout.cpp
Executable file
207
Marlin/src/lcd/menu/game/brickout.cpp
Executable file
@@ -0,0 +1,207 @@
|
||||
/**
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "../../../inc/MarlinConfigPre.h"
|
||||
|
||||
#if ENABLED(MARLIN_BRICKOUT)
|
||||
|
||||
#include "game.h"
|
||||
|
||||
#define BRICK_H 5
|
||||
#define BRICK_TOP MENU_FONT_ASCENT
|
||||
|
||||
#define PADDLE_H 2
|
||||
#define PADDLE_VEL 3
|
||||
#define PADDLE_W ((LCD_PIXEL_WIDTH) / 8)
|
||||
#define PADDLE_Y (LCD_PIXEL_HEIGHT - 1 - PADDLE_H)
|
||||
|
||||
#define BRICK_W ((LCD_PIXEL_WIDTH) / (BRICK_COLS))
|
||||
#define BRICK_BOT (BRICK_TOP + BRICK_H * BRICK_ROWS - 1)
|
||||
|
||||
#define BRICK_COL(X) ((X) / (BRICK_W))
|
||||
#define BRICK_ROW(Y) ((Y - (BRICK_TOP)) / (BRICK_H))
|
||||
|
||||
brickout_data_t &bdat = marlin_game_data.brickout;
|
||||
|
||||
inline void reset_bricks(const uint16_t v) {
|
||||
bdat.brick_count = (BRICK_COLS) * (BRICK_ROWS);
|
||||
LOOP_L_N(i, BRICK_ROWS) bdat.bricks[i] = v;
|
||||
}
|
||||
|
||||
void reset_ball() {
|
||||
constexpr uint8_t ball_dist = 24;
|
||||
bdat.bally = BTOF(PADDLE_Y - ball_dist);
|
||||
bdat.ballv = FTOP(1.3f);
|
||||
bdat.ballh = -FTOP(1.25f);
|
||||
uint8_t bx = bdat.paddle_x + (PADDLE_W) / 2 + ball_dist;
|
||||
if (bx >= LCD_PIXEL_WIDTH - 10) { bx -= ball_dist * 2; bdat.ballh = -bdat.ballh; }
|
||||
bdat.ballx = BTOF(bx);
|
||||
bdat.hit_dir = -1;
|
||||
}
|
||||
|
||||
void BrickoutGame::game_screen() {
|
||||
if (game_frame()) { // Run logic twice for finer resolution
|
||||
// Update Paddle Position
|
||||
bdat.paddle_x = constrain(int8_t(ui.encoderPosition), 0, (LCD_PIXEL_WIDTH - (PADDLE_W)) / (PADDLE_VEL));
|
||||
ui.encoderPosition = bdat.paddle_x;
|
||||
bdat.paddle_x *= (PADDLE_VEL);
|
||||
|
||||
// Run the ball logic
|
||||
if (game_state) do {
|
||||
|
||||
// Provisionally update the ball position
|
||||
const fixed_t newx = bdat.ballx + bdat.ballh, newy = bdat.bally + bdat.ballv; // current next position
|
||||
if (!WITHIN(newx, 0, BTOF(LCD_PIXEL_WIDTH - 1))) { // out in x?
|
||||
bdat.ballh = -bdat.ballh; _BUZZ(5, 220); // bounce x
|
||||
}
|
||||
if (newy < 0) { // out in y?
|
||||
bdat.ballv = -bdat.ballv; _BUZZ(5, 280); // bounce v
|
||||
bdat.hit_dir = 1;
|
||||
}
|
||||
// Did the ball go below the bottom?
|
||||
else if (newy > BTOF(LCD_PIXEL_HEIGHT)) {
|
||||
_BUZZ(500, 75);
|
||||
if (--bdat.balls_left) reset_ball(); else game_state = 0;
|
||||
break; // done
|
||||
}
|
||||
|
||||
// Is the ball colliding with a brick?
|
||||
if (WITHIN(newy, BTOF(BRICK_TOP), BTOF(BRICK_BOT))) {
|
||||
const int8_t bit = BRICK_COL(FTOB(newx)), row = BRICK_ROW(FTOB(newy));
|
||||
const uint16_t mask = _BV(bit);
|
||||
if (bdat.bricks[row] & mask) {
|
||||
// Yes. Remove it!
|
||||
bdat.bricks[row] &= ~mask;
|
||||
// Score!
|
||||
score += BRICK_ROWS - row;
|
||||
// If bricks are gone, go to reset state
|
||||
if (!--bdat.brick_count) game_state = 2;
|
||||
// Bounce the ball cleverly
|
||||
if ((bdat.ballv < 0) == (bdat.hit_dir < 0)) { bdat.ballv = -bdat.ballv; bdat.ballh += fixed_t(random(-16, 16)); _BUZZ(5, 880); }
|
||||
else { bdat.ballh = -bdat.ballh; bdat.ballv += fixed_t(random(-16, 16)); _BUZZ(5, 640); }
|
||||
}
|
||||
}
|
||||
// Is the ball moving down and in paddle range?
|
||||
else if (bdat.ballv > 0 && WITHIN(newy, BTOF(PADDLE_Y), BTOF(PADDLE_Y + PADDLE_H))) {
|
||||
// Ball actually hitting paddle
|
||||
const int8_t diff = FTOB(newx) - bdat.paddle_x;
|
||||
if (WITHIN(diff, 0, PADDLE_W - 1)) {
|
||||
|
||||
// Reverse Y direction
|
||||
bdat.ballv = -bdat.ballv; _BUZZ(3, 880);
|
||||
bdat.hit_dir = -1;
|
||||
|
||||
// Near edges affects X velocity
|
||||
const bool is_left_edge = (diff <= 1);
|
||||
if (is_left_edge || diff >= PADDLE_W-1 - 1) {
|
||||
if ((bdat.ballh > 0) == is_left_edge) bdat.ballh = -bdat.ballh;
|
||||
}
|
||||
else if (diff <= 3) {
|
||||
bdat.ballh += fixed_t(random(-64, 0));
|
||||
NOLESS(bdat.ballh, BTOF(-2));
|
||||
NOMORE(bdat.ballh, BTOF(2));
|
||||
}
|
||||
else if (diff >= PADDLE_W-1 - 3) {
|
||||
bdat.ballh += fixed_t(random( 0, 64));
|
||||
NOLESS(bdat.ballh, BTOF(-2));
|
||||
NOMORE(bdat.ballh, BTOF(2));
|
||||
}
|
||||
|
||||
// Paddle hit after clearing the board? Reset the board.
|
||||
if (game_state == 2) { reset_bricks(0xFFFF); game_state = 1; }
|
||||
}
|
||||
}
|
||||
|
||||
bdat.ballx += bdat.ballh; bdat.bally += bdat.ballv; // update with new velocity
|
||||
|
||||
} while (false);
|
||||
}
|
||||
|
||||
u8g.setColorIndex(1);
|
||||
|
||||
// Draw bricks
|
||||
if (PAGE_CONTAINS(BRICK_TOP, BRICK_BOT)) {
|
||||
LOOP_L_N(y, BRICK_ROWS) {
|
||||
const uint8_t yy = y * BRICK_H + BRICK_TOP;
|
||||
if (PAGE_CONTAINS(yy, yy + BRICK_H - 1)) {
|
||||
LOOP_L_N(x, BRICK_COLS) {
|
||||
if (TEST(bdat.bricks[y], x)) {
|
||||
const uint8_t xx = x * BRICK_W;
|
||||
LOOP_L_N(v, BRICK_H - 1)
|
||||
if (PAGE_CONTAINS(yy + v, yy + v))
|
||||
u8g.drawHLine(xx, yy + v, BRICK_W - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Draw paddle
|
||||
if (PAGE_CONTAINS(PADDLE_Y-1, PADDLE_Y)) {
|
||||
u8g.drawHLine(bdat.paddle_x, PADDLE_Y, PADDLE_W);
|
||||
#if PADDLE_H > 1
|
||||
u8g.drawHLine(bdat.paddle_x, PADDLE_Y-1, PADDLE_W);
|
||||
#if PADDLE_H > 2
|
||||
u8g.drawHLine(bdat.paddle_x, PADDLE_Y-2, PADDLE_W);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
// Draw ball while game is running
|
||||
if (game_state) {
|
||||
const uint8_t by = FTOB(bdat.bally);
|
||||
if (PAGE_CONTAINS(by, by+1))
|
||||
u8g.drawFrame(FTOB(bdat.ballx), by, 2, 2);
|
||||
}
|
||||
// Or draw GAME OVER
|
||||
else
|
||||
draw_game_over();
|
||||
|
||||
if (PAGE_UNDER(MENU_FONT_ASCENT)) {
|
||||
// Score Digits
|
||||
//const uint8_t sx = (LCD_PIXEL_WIDTH - (score >= 10 ? score >= 100 ? score >= 1000 ? 4 : 3 : 2 : 1) * MENU_FONT_WIDTH) / 2;
|
||||
constexpr uint8_t sx = 0;
|
||||
lcd_put_int(sx, MENU_FONT_ASCENT - 1, score);
|
||||
|
||||
// Balls Left
|
||||
lcd_moveto(LCD_PIXEL_WIDTH - MENU_FONT_WIDTH * 3, MENU_FONT_ASCENT - 1);
|
||||
PGM_P const ohs = PSTR("ooo\0\0");
|
||||
lcd_put_u8str_P(ohs + 3 - bdat.balls_left);
|
||||
}
|
||||
|
||||
// A click always exits this game
|
||||
if (ui.use_click()) exit_game();
|
||||
}
|
||||
|
||||
#define SCREEN_M ((LCD_PIXEL_WIDTH) / 2)
|
||||
|
||||
void BrickoutGame::enter_game() {
|
||||
init_game(2, game_screen); // 2 = reset bricks on paddle hit
|
||||
constexpr uint8_t paddle_start = SCREEN_M - (PADDLE_W) / 2;
|
||||
bdat.paddle_x = paddle_start;
|
||||
bdat.balls_left = 3;
|
||||
reset_bricks(0x0000);
|
||||
reset_ball();
|
||||
ui.encoderPosition = paddle_start / (PADDLE_VEL);
|
||||
}
|
||||
|
||||
#endif // MARLIN_BRICKOUT
|
38
Marlin/src/lcd/menu/game/brickout.h
Executable file
38
Marlin/src/lcd/menu/game/brickout.h
Executable file
@@ -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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "types.h"
|
||||
|
||||
#define BRICK_ROWS 4
|
||||
#define BRICK_COLS 16
|
||||
|
||||
typedef struct {
|
||||
uint8_t balls_left, brick_count;
|
||||
uint16_t bricks[BRICK_ROWS];
|
||||
int8_t paddle_x, hit_dir;
|
||||
fixed_t ballx, bally, ballh, ballv;
|
||||
} brickout_data_t;
|
||||
|
||||
class BrickoutGame : MarlinGame { public: static void enter_game(), game_screen(); };
|
||||
|
||||
extern BrickoutGame brickout;
|
66
Marlin/src/lcd/menu/game/game.cpp
Executable file
66
Marlin/src/lcd/menu/game/game.cpp
Executable file
@@ -0,0 +1,66 @@
|
||||
/**
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "../../../inc/MarlinConfigPre.h"
|
||||
|
||||
#if HAS_GAMES
|
||||
|
||||
#include "game.h"
|
||||
|
||||
int MarlinGame::score;
|
||||
uint8_t MarlinGame::game_state;
|
||||
millis_t MarlinGame::next_frame;
|
||||
|
||||
MarlinGameData marlin_game_data;
|
||||
|
||||
bool MarlinGame::game_frame() {
|
||||
static int8_t slew;
|
||||
if (ui.first_page) slew = 2;
|
||||
ui.refresh(LCDVIEW_CALL_NO_REDRAW); // Refresh as often as possible
|
||||
return (game_state && slew-- > 0);
|
||||
}
|
||||
|
||||
void MarlinGame::draw_game_over() {
|
||||
constexpr int8_t gowide = (MENU_FONT_WIDTH) * 9,
|
||||
gohigh = MENU_FONT_ASCENT - 3,
|
||||
lx = (LCD_PIXEL_WIDTH - gowide) / 2,
|
||||
ly = (LCD_PIXEL_HEIGHT + gohigh) / 2;
|
||||
if (PAGE_CONTAINS(ly - gohigh - 1, ly + 1)) {
|
||||
u8g.setColorIndex(0);
|
||||
u8g.drawBox(lx - 1, ly - gohigh - 1, gowide + 2, gohigh + 2);
|
||||
u8g.setColorIndex(1);
|
||||
if (ui.get_blink()) lcd_put_u8str_P(lx, ly, PSTR("GAME OVER"));
|
||||
}
|
||||
}
|
||||
|
||||
void MarlinGame::init_game(const uint8_t init_state, const screenFunc_t screen) {
|
||||
score = 0;
|
||||
game_state = init_state;
|
||||
ui.goto_screen(screen);
|
||||
ui.defer_status_screen();
|
||||
}
|
||||
|
||||
void MarlinGame::exit_game() {
|
||||
ui.goto_previous_screen_no_defer();
|
||||
}
|
||||
|
||||
#endif // HAS_GAMES
|
70
Marlin/src/lcd/menu/game/game.h
Executable file
70
Marlin/src/lcd/menu/game/game.h
Executable file
@@ -0,0 +1,70 @@
|
||||
/**
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "../../../inc/MarlinConfigPre.h"
|
||||
#include "../../dogm/ultralcd_DOGM.h"
|
||||
#include "../../lcdprint.h"
|
||||
#include "../../ultralcd.h"
|
||||
|
||||
//#define MUTE_GAMES
|
||||
|
||||
#if ENABLED(MUTE_GAMES) || !HAS_BUZZER
|
||||
#define _BUZZ(D,F) NOOP
|
||||
#else
|
||||
#define _BUZZ(D,F) BUZZ(D,F)
|
||||
#endif
|
||||
|
||||
#if HAS_GAME_MENU
|
||||
void menu_game();
|
||||
#endif
|
||||
|
||||
#if ENABLED(MARLIN_BRICKOUT)
|
||||
#include "brickout.h"
|
||||
#endif
|
||||
#if ENABLED(MARLIN_INVADERS)
|
||||
#include "invaders.h"
|
||||
#endif
|
||||
#if ENABLED(MARLIN_MAZE)
|
||||
#include "maze.h"
|
||||
#endif
|
||||
#if ENABLED(MARLIN_SNAKE)
|
||||
#include "snake.h"
|
||||
#endif
|
||||
|
||||
// Pool game data to save SRAM
|
||||
union MarlinGameData {
|
||||
#if ENABLED(MARLIN_BRICKOUT)
|
||||
brickout_data_t brickout;
|
||||
#endif
|
||||
#if ENABLED(MARLIN_INVADERS)
|
||||
invaders_data_t invaders;
|
||||
#endif
|
||||
#if ENABLED(MARLIN_SNAKE)
|
||||
snake_data_t snake;
|
||||
#endif
|
||||
#if ENABLED(MARLIN_MAZE)
|
||||
maze_data_t maze;
|
||||
#endif
|
||||
};
|
||||
|
||||
extern MarlinGameData marlin_game_data;
|
438
Marlin/src/lcd/menu/game/invaders.cpp
Executable file
438
Marlin/src/lcd/menu/game/invaders.cpp
Executable file
@@ -0,0 +1,438 @@
|
||||
/**
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "../../../inc/MarlinConfigPre.h"
|
||||
|
||||
#if ENABLED(MARLIN_INVADERS)
|
||||
|
||||
#include "game.h"
|
||||
|
||||
#define CANNON_W 11
|
||||
#define CANNON_H 8
|
||||
#define CANNON_VEL 4
|
||||
#define CANNON_Y (LCD_PIXEL_HEIGHT - 1 - CANNON_H)
|
||||
|
||||
#define INVADER_VEL 3
|
||||
|
||||
#define INVADER_TOP MENU_FONT_ASCENT
|
||||
#define INVADERS_WIDE ((INVADER_COL_W) * (INVADER_COLS))
|
||||
#define INVADERS_HIGH ((INVADER_ROW_H) * (INVADER_ROWS))
|
||||
|
||||
#define UFO_H 5
|
||||
#define UFO_W 13
|
||||
|
||||
#define LASER_H 4
|
||||
#define SHOT_H 3
|
||||
#define EXPL_W 11
|
||||
#define LIFE_W 8
|
||||
#define LIFE_H 5
|
||||
|
||||
#define INVADER_RIGHT ((INVADER_COLS) * (INVADER_COL_W))
|
||||
|
||||
// 11x8
|
||||
const unsigned char invader[3][2][16] PROGMEM = {
|
||||
{ { B00000110,B00000000,
|
||||
B00001111,B00000000,
|
||||
B00011111,B10000000,
|
||||
B00110110,B11000000,
|
||||
B00111111,B11000000,
|
||||
B00001001,B00000000,
|
||||
B00010110,B10000000,
|
||||
B00101001,B01000000
|
||||
}, {
|
||||
B00000110,B00000000,
|
||||
B00001111,B00000000,
|
||||
B00011111,B10000000,
|
||||
B00110110,B11000000,
|
||||
B00111111,B11000000,
|
||||
B00010110,B10000000,
|
||||
B00100000,B01000000,
|
||||
B00010000,B10000000
|
||||
}
|
||||
}, {
|
||||
{ B00010000,B01000000,
|
||||
B00001000,B10000000,
|
||||
B00011111,B11000000,
|
||||
B00110111,B01100000,
|
||||
B01111111,B11110000,
|
||||
B01011111,B11010000,
|
||||
B01010000,B01010000,
|
||||
B00001101,B10000000
|
||||
}, {
|
||||
B00010000,B01000000,
|
||||
B01001000,B10010000,
|
||||
B01011111,B11010000,
|
||||
B01110111,B01110000,
|
||||
B01111111,B11110000,
|
||||
B00011111,B11000000,
|
||||
B00010000,B01000000,
|
||||
B00100000,B00100000
|
||||
}
|
||||
}, {
|
||||
{ B00001111,B00000000,
|
||||
B01111111,B11100000,
|
||||
B11111111,B11110000,
|
||||
B11100110,B01110000,
|
||||
B11111111,B11110000,
|
||||
B00011001,B10000000,
|
||||
B00110110,B11000000,
|
||||
B11000000,B00110000
|
||||
}, {
|
||||
B00001111,B00000000,
|
||||
B01111111,B11100000,
|
||||
B11111111,B11110000,
|
||||
B11100110,B01110000,
|
||||
B11111111,B11110000,
|
||||
B00011001,B10000000,
|
||||
B00110110,B11000000,
|
||||
B00011001,B10000000
|
||||
}
|
||||
}
|
||||
};
|
||||
const unsigned char cannon[] PROGMEM = {
|
||||
B00000100,B00000000,
|
||||
B00001110,B00000000,
|
||||
B00001110,B00000000,
|
||||
B01111111,B11000000,
|
||||
B11111111,B11100000,
|
||||
B11111111,B11100000,
|
||||
B11111111,B11100000,
|
||||
B11111111,B11100000
|
||||
};
|
||||
const unsigned char life[] PROGMEM = {
|
||||
B00010000,
|
||||
B01111100,
|
||||
B11111110,
|
||||
B11111110,
|
||||
B11111110
|
||||
};
|
||||
const unsigned char explosion[] PROGMEM = {
|
||||
B01000100,B01000000,
|
||||
B00100100,B10000000,
|
||||
B00000000,B00000000,
|
||||
B00110001,B10000000,
|
||||
B00000000,B00000000,
|
||||
B00100100,B10000000,
|
||||
B01000100,B01000000
|
||||
};
|
||||
const unsigned char ufo[] PROGMEM = {
|
||||
B00011111,B11000000,
|
||||
B01111111,B11110000,
|
||||
B11011101,B11011000,
|
||||
B11111111,B11111000,
|
||||
B01111111,B11110000
|
||||
};
|
||||
|
||||
constexpr uint8_t inv_type[] = {
|
||||
#if INVADER_ROWS == 5
|
||||
0, 1, 1, 2, 2
|
||||
#elif INVADER_ROWS == 4
|
||||
0, 1, 1, 2
|
||||
#elif INVADER_ROWS == 3
|
||||
0, 1, 2
|
||||
#else
|
||||
#error "INVASION_SIZE must be 3, 4, or 5."
|
||||
#endif
|
||||
};
|
||||
|
||||
invaders_data_t &idat = marlin_game_data.invaders;
|
||||
|
||||
#define INV_X_LEFT(C,T) (idat.pos.x + (C) * (INVADER_COL_W) + inv_off[T])
|
||||
#define INV_X_CTR(C,T) (INV_X_LEFT(C,T) + inv_wide[T] / 2)
|
||||
#define INV_Y_BOT(R) (idat.pos.y + (R + 1) * (INVADER_ROW_H) - 2)
|
||||
|
||||
constexpr uint8_t inv_off[] = { 2, 1, 0 }, inv_wide[] = { 8, 11, 12 };
|
||||
|
||||
inline void update_invader_data() {
|
||||
uint8_t inv_mask = 0;
|
||||
// Get a list of all active invaders
|
||||
uint8_t sc = 0;
|
||||
LOOP_L_N(y, INVADER_ROWS) {
|
||||
uint8_t m = idat.bugs[y];
|
||||
if (m) idat.botmost = y + 1;
|
||||
inv_mask |= m;
|
||||
LOOP_L_N(x, INVADER_COLS)
|
||||
if (TEST(m, x)) idat.shooters[sc++] = (y << 4) | x;
|
||||
}
|
||||
idat.leftmost = 0;
|
||||
LOOP_L_N(i, INVADER_COLS) { if (TEST(inv_mask, i)) break; idat.leftmost -= INVADER_COL_W; }
|
||||
idat.rightmost = LCD_PIXEL_WIDTH - (INVADERS_WIDE);
|
||||
for (uint8_t i = INVADER_COLS; i--;) { if (TEST(inv_mask, i)) break; idat.rightmost += INVADER_COL_W; }
|
||||
if (idat.count == 2) idat.dir = idat.dir > 0 ? INVADER_VEL + 1 : -(INVADER_VEL + 1);
|
||||
}
|
||||
|
||||
inline void reset_bullets() {
|
||||
LOOP_L_N(i, COUNT(idat.bullet)) idat.bullet[i].v = 0;
|
||||
}
|
||||
|
||||
inline void reset_invaders() {
|
||||
idat.pos.x = 0; idat.pos.y = INVADER_TOP;
|
||||
idat.dir = INVADER_VEL;
|
||||
idat.count = (INVADER_COLS) * (INVADER_ROWS);
|
||||
LOOP_L_N(i, INVADER_ROWS) idat.bugs[i] = _BV(INVADER_COLS) - 1;
|
||||
update_invader_data();
|
||||
reset_bullets();
|
||||
}
|
||||
|
||||
|
||||
inline void spawn_ufo() {
|
||||
idat.ufov = random(0, 2) ? 1 : -1;
|
||||
idat.ufox = idat.ufov > 0 ? -(UFO_W) : LCD_PIXEL_WIDTH - 1;
|
||||
}
|
||||
|
||||
inline void reset_player() {
|
||||
idat.cannon_x = 0;
|
||||
ui.encoderPosition = 0;
|
||||
}
|
||||
|
||||
inline void fire_cannon() {
|
||||
idat.laser.x = idat.cannon_x + CANNON_W / 2;
|
||||
idat.laser.y = LCD_PIXEL_HEIGHT - CANNON_H - (LASER_H);
|
||||
idat.laser.v = -(LASER_H);
|
||||
}
|
||||
|
||||
inline void explode(const int8_t x, const int8_t y, const int8_t v=4) {
|
||||
idat.explod.x = x - (EXPL_W) / 2;
|
||||
idat.explod.y = y;
|
||||
idat.explod.v = v;
|
||||
}
|
||||
|
||||
inline void kill_cannon(uint8_t &game_state, const uint8_t st) {
|
||||
reset_bullets();
|
||||
explode(idat.cannon_x + (CANNON_W) / 2, CANNON_Y, 6);
|
||||
_BUZZ(1000, 10);
|
||||
if (--idat.cannons_left) {
|
||||
idat.laser.v = 0;
|
||||
game_state = st;
|
||||
reset_player();
|
||||
}
|
||||
else
|
||||
game_state = 0;
|
||||
}
|
||||
|
||||
void InvadersGame::game_screen() {
|
||||
ui.refresh(LCDVIEW_CALL_NO_REDRAW); // Call as often as possible
|
||||
|
||||
// Run game logic once per full screen
|
||||
if (ui.first_page) {
|
||||
|
||||
// Update Cannon Position
|
||||
int16_t ep = constrain(int16_t(ui.encoderPosition), 0, (LCD_PIXEL_WIDTH - (CANNON_W)) / (CANNON_VEL));
|
||||
ui.encoderPosition = ep;
|
||||
|
||||
ep *= (CANNON_VEL);
|
||||
if (ep > idat.cannon_x) { idat.cannon_x += CANNON_VEL - 1; if (ep - idat.cannon_x < 2) idat.cannon_x = ep; }
|
||||
if (ep < idat.cannon_x) { idat.cannon_x -= CANNON_VEL - 1; if (idat.cannon_x - ep < 2) idat.cannon_x = ep; }
|
||||
|
||||
// Run the game logic
|
||||
if (game_state) do {
|
||||
|
||||
// Move the UFO, if any
|
||||
if (idat.ufov) { idat.ufox += idat.ufov; if (!WITHIN(idat.ufox, -(UFO_W), LCD_PIXEL_WIDTH - 1)) idat.ufov = 0; }
|
||||
|
||||
if (game_state > 1) { if (--game_state == 2) { reset_invaders(); } else if (game_state == 100) { game_state = 1; } break; }
|
||||
|
||||
const bool did_blink = (++idat.blink_count > idat.count >> 1);
|
||||
if (did_blink) {
|
||||
idat.game_blink = !idat.game_blink;
|
||||
idat.blink_count = 0;
|
||||
}
|
||||
|
||||
if (idat.count && did_blink) {
|
||||
const int8_t newx = idat.pos.x + idat.dir;
|
||||
if (!WITHIN(newx, idat.leftmost, idat.rightmost)) { // Invaders reached the edge?
|
||||
idat.dir *= -1; // Invaders change direction
|
||||
idat.pos.y += (INVADER_ROW_H) / 2; // Invaders move down
|
||||
idat.pos.x -= idat.dir; // ...and only move down this time.
|
||||
if (idat.pos.y + idat.botmost * (INVADER_ROW_H) - 2 >= CANNON_Y) // Invaders reached the bottom?
|
||||
kill_cannon(game_state, 20); // Kill the cannon. Reset invaders.
|
||||
}
|
||||
|
||||
idat.pos.x += idat.dir; // Invaders take one step left/right
|
||||
|
||||
// Randomly shoot if invaders are listed
|
||||
if (idat.count && !random(0, 20)) {
|
||||
|
||||
// Find a free bullet
|
||||
laser_t *b = nullptr;
|
||||
LOOP_L_N(i, COUNT(idat.bullet)) if (!idat.bullet[i].v) { b = &idat.bullet[i]; break; }
|
||||
if (b) {
|
||||
// Pick a random shooter and update the bullet
|
||||
//SERIAL_ECHOLNPGM("free bullet found");
|
||||
const uint8_t inv = idat.shooters[random(0, idat.count + 1)], col = inv & 0x0F, row = inv >> 4, type = inv_type[row];
|
||||
b->x = INV_X_CTR(col, type);
|
||||
b->y = INV_Y_BOT(row);
|
||||
b->v = 2 + random(0, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update the laser position
|
||||
if (idat.laser.v) {
|
||||
idat.laser.y += idat.laser.v;
|
||||
if (idat.laser.y < 0) idat.laser.v = 0;
|
||||
}
|
||||
|
||||
// Did the laser collide with an invader?
|
||||
if (idat.laser.v && WITHIN(idat.laser.y, idat.pos.y, idat.pos.y + INVADERS_HIGH - 1)) {
|
||||
const int8_t col = idat.laser_col();
|
||||
if (WITHIN(col, 0, INVADER_COLS - 1)) {
|
||||
const int8_t row = idat.laser_row();
|
||||
if (WITHIN(row, 0, INVADER_ROWS - 1)) {
|
||||
const uint8_t mask = _BV(col);
|
||||
if (idat.bugs[row] & mask) {
|
||||
const uint8_t type = inv_type[row];
|
||||
const int8_t invx = INV_X_LEFT(col, type);
|
||||
if (WITHIN(idat.laser.x, invx, invx + inv_wide[type] - 1)) {
|
||||
// Turn off laser
|
||||
idat.laser.v = 0;
|
||||
// Remove the invader!
|
||||
idat.bugs[row] &= ~mask;
|
||||
// Score!
|
||||
score += INVADER_ROWS - row;
|
||||
// Explode sound!
|
||||
_BUZZ(40, 10);
|
||||
// Explosion bitmap!
|
||||
explode(invx + inv_wide[type] / 2, idat.pos.y + row * (INVADER_ROW_H));
|
||||
// If invaders are gone, go to reset invaders state
|
||||
if (--idat.count) update_invader_data(); else { game_state = 20; reset_bullets(); }
|
||||
} // laser x hit
|
||||
} // invader exists
|
||||
} // good row
|
||||
} // good col
|
||||
} // laser in invader zone
|
||||
|
||||
// Handle alien bullets
|
||||
LOOP_L_N(s, COUNT(idat.bullet)) {
|
||||
laser_t *b = &idat.bullet[s];
|
||||
if (b->v) {
|
||||
// Update alien bullet position
|
||||
b->y += b->v;
|
||||
if (b->y >= LCD_PIXEL_HEIGHT)
|
||||
b->v = 0; // Offscreen
|
||||
else if (b->y >= CANNON_Y && WITHIN(b->x, idat.cannon_x, idat.cannon_x + CANNON_W - 1))
|
||||
kill_cannon(game_state, 120); // Hit the cannon
|
||||
}
|
||||
}
|
||||
|
||||
// Randomly spawn a UFO
|
||||
if (!idat.ufov && !random(0,500)) spawn_ufo();
|
||||
|
||||
// Did the laser hit a ufo?
|
||||
if (idat.laser.v && idat.ufov && idat.laser.y < UFO_H + 2 && WITHIN(idat.laser.x, idat.ufox, idat.ufox + UFO_W - 1)) {
|
||||
// Turn off laser and UFO
|
||||
idat.laser.v = idat.ufov = 0;
|
||||
// Score!
|
||||
score += 10;
|
||||
// Explode!
|
||||
_BUZZ(40, 10);
|
||||
// Explosion bitmap
|
||||
explode(idat.ufox + (UFO_W) / 2, 1);
|
||||
}
|
||||
|
||||
} while (false);
|
||||
|
||||
}
|
||||
|
||||
// Click-and-hold to abort
|
||||
if (ui.button_pressed()) --idat.quit_count; else idat.quit_count = 10;
|
||||
|
||||
// Click to fire or exit
|
||||
if (ui.use_click()) {
|
||||
if (!game_state)
|
||||
idat.quit_count = 0;
|
||||
else if (game_state == 1 && !idat.laser.v)
|
||||
fire_cannon();
|
||||
}
|
||||
|
||||
if (!idat.quit_count) exit_game();
|
||||
|
||||
u8g.setColorIndex(1);
|
||||
|
||||
// Draw invaders
|
||||
if (PAGE_CONTAINS(idat.pos.y, idat.pos.y + idat.botmost * (INVADER_ROW_H) - 2 - 1)) {
|
||||
int8_t yy = idat.pos.y;
|
||||
LOOP_L_N(y, INVADER_ROWS) {
|
||||
const uint8_t type = inv_type[y];
|
||||
if (PAGE_CONTAINS(yy, yy + INVADER_H - 1)) {
|
||||
int8_t xx = idat.pos.x;
|
||||
LOOP_L_N(x, INVADER_COLS) {
|
||||
if (TEST(idat.bugs[y], x))
|
||||
u8g.drawBitmapP(xx, yy, 2, INVADER_H, invader[type][idat.game_blink]);
|
||||
xx += INVADER_COL_W;
|
||||
}
|
||||
}
|
||||
yy += INVADER_ROW_H;
|
||||
}
|
||||
}
|
||||
|
||||
// Draw UFO
|
||||
if (idat.ufov && PAGE_UNDER(UFO_H + 2))
|
||||
u8g.drawBitmapP(idat.ufox, 2, 2, UFO_H, ufo);
|
||||
|
||||
// Draw cannon
|
||||
if (game_state && PAGE_CONTAINS(CANNON_Y, CANNON_Y + CANNON_H - 1) && (game_state < 2 || (game_state & 0x02)))
|
||||
u8g.drawBitmapP(idat.cannon_x, CANNON_Y, 2, CANNON_H, cannon);
|
||||
|
||||
// Draw laser
|
||||
if (idat.laser.v && PAGE_CONTAINS(idat.laser.y, idat.laser.y + LASER_H - 1))
|
||||
u8g.drawVLine(idat.laser.x, idat.laser.y, LASER_H);
|
||||
|
||||
// Draw invader bullets
|
||||
LOOP_L_N (i, COUNT(idat.bullet)) {
|
||||
if (idat.bullet[i].v && PAGE_CONTAINS(idat.bullet[i].y - (SHOT_H - 1), idat.bullet[i].y))
|
||||
u8g.drawVLine(idat.bullet[i].x, idat.bullet[i].y - (SHOT_H - 1), SHOT_H);
|
||||
}
|
||||
|
||||
// Draw explosion
|
||||
if (idat.explod.v && PAGE_CONTAINS(idat.explod.y, idat.explod.y + 7 - 1)) {
|
||||
u8g.drawBitmapP(idat.explod.x, idat.explod.y, 2, 7, explosion);
|
||||
--idat.explod.v;
|
||||
}
|
||||
|
||||
// Blink GAME OVER when game is over
|
||||
if (!game_state) draw_game_over();
|
||||
|
||||
if (PAGE_UNDER(MENU_FONT_ASCENT - 1)) {
|
||||
// Draw Score
|
||||
//const uint8_t sx = (LCD_PIXEL_WIDTH - (score >= 10 ? score >= 100 ? score >= 1000 ? 4 : 3 : 2 : 1) * MENU_FONT_WIDTH) / 2;
|
||||
constexpr uint8_t sx = 0;
|
||||
lcd_put_int(sx, MENU_FONT_ASCENT - 1, score);
|
||||
|
||||
// Draw lives
|
||||
if (idat.cannons_left)
|
||||
for (uint8_t i = 1; i <= idat.cannons_left; ++i)
|
||||
u8g.drawBitmapP(LCD_PIXEL_WIDTH - i * (LIFE_W), 6 - (LIFE_H), 1, LIFE_H, life);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void InvadersGame::enter_game() {
|
||||
init_game(20, game_screen); // countdown to reset invaders
|
||||
idat.cannons_left = 3;
|
||||
idat.quit_count = 10;
|
||||
idat.laser.v = 0;
|
||||
reset_invaders();
|
||||
reset_player();
|
||||
}
|
||||
|
||||
#endif // MARLIN_INVADERS
|
62
Marlin/src/lcd/menu/game/invaders.h
Executable file
62
Marlin/src/lcd/menu/game/invaders.h
Executable file
@@ -0,0 +1,62 @@
|
||||
/**
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "types.h"
|
||||
|
||||
#define INVASION_SIZE 3
|
||||
|
||||
#if INVASION_SIZE == 3
|
||||
#define INVADER_COLS 5
|
||||
#elif INVASION_SIZE == 4
|
||||
#define INVADER_COLS 6
|
||||
#else
|
||||
#define INVADER_COLS 8
|
||||
#undef INVASION_SIZE
|
||||
#define INVASION_SIZE 5
|
||||
#endif
|
||||
|
||||
#define INVADER_ROWS INVASION_SIZE
|
||||
|
||||
#define INVADER_COL_W 14
|
||||
#define INVADER_H 8
|
||||
#define INVADER_ROW_H (INVADER_H + 2)
|
||||
|
||||
typedef struct { int8_t x, y, v; } laser_t;
|
||||
|
||||
typedef struct {
|
||||
pos_t pos;
|
||||
uint8_t cannons_left;
|
||||
int8_t cannon_x;
|
||||
laser_t bullet[10], laser, explod;
|
||||
int8_t dir, leftmost, rightmost, botmost;
|
||||
uint8_t count, quit_count, blink_count;
|
||||
uint8_t bugs[INVADER_ROWS], shooters[(INVADER_ROWS) * (INVADER_COLS)];
|
||||
int8_t ufox, ufov;
|
||||
bool game_blink;
|
||||
int8_t laser_col() { return ((laser.x - pos.x) / (INVADER_COL_W)); };
|
||||
int8_t laser_row() { return ((laser.y - pos.y + 2) / (INVADER_ROW_H)); };
|
||||
} invaders_data_t;
|
||||
|
||||
class InvadersGame : MarlinGame { public: static void enter_game(), game_screen(); };
|
||||
|
||||
extern InvadersGame invaders;
|
134
Marlin/src/lcd/menu/game/maze.cpp
Executable file
134
Marlin/src/lcd/menu/game/maze.cpp
Executable file
@@ -0,0 +1,134 @@
|
||||
/**
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "../../../inc/MarlinConfigPre.h"
|
||||
|
||||
#if ENABLED(MARLIN_MAZE)
|
||||
|
||||
#include "game.h"
|
||||
|
||||
int8_t move_dir, last_move_dir, // NESW0
|
||||
prizex, prizey, prize_cnt, old_encoder;
|
||||
fixed_t playerx, playery;
|
||||
|
||||
// Up to 50 lines, then you win!
|
||||
typedef struct { int8_t x, y; } pos_t;
|
||||
uint8_t head_ind;
|
||||
pos_t maze_walls[50] = {
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
// Turn the player cw or ccw
|
||||
inline void turn_player(const bool cw) {
|
||||
if (move_dir == 4) move_dir = last_move_dir;
|
||||
move_dir += cw ? 1 : -1;
|
||||
move_dir &= 0x03;
|
||||
last_move_dir = move_dir;
|
||||
}
|
||||
|
||||
// Reset the player for a new game
|
||||
void player_reset() {
|
||||
// Init position
|
||||
playerx = BTOF(1);
|
||||
playery = BTOF(GAME_H / 2);
|
||||
|
||||
// Init motion with a ccw turn
|
||||
move_dir = 0;
|
||||
turn_player(false);
|
||||
|
||||
// Clear prize flag
|
||||
prize_cnt = 255;
|
||||
|
||||
// Clear the controls
|
||||
ui.encoderPosition = 0;
|
||||
old_encoder = 0;
|
||||
}
|
||||
|
||||
void MazeGame::game_screen() {
|
||||
// Run the sprite logic
|
||||
if (game_frame()) do { // Run logic twice for finer resolution
|
||||
|
||||
// Move the man one unit in the current direction
|
||||
// Direction index 4 is for the stopped man
|
||||
const int8_t oldx = FTOB(playerx), oldy = FTOB(playery);
|
||||
pos_t dir_add[] = { { 0, -1 }, { 1, 0 }, { 0, 1 }, { -1, 0 }, { 0, 0 } };
|
||||
playerx += dir_add[move_dir].x;
|
||||
playery += dir_add[move_dir].y;
|
||||
const int8_t x = FTOB(playerx), y = FTOB(playery);
|
||||
|
||||
} while(0);
|
||||
|
||||
u8g.setColorIndex(1);
|
||||
|
||||
// Draw Score
|
||||
if (PAGE_UNDER(HEADER_H)) lcd_put_int(0, HEADER_H - 1, score);
|
||||
|
||||
// Draw the maze
|
||||
// LOOP_L_N(n, head_ind) {
|
||||
// const pos_t &p = maze_walls[n], &q = maze_walls[n + 1];
|
||||
// if (p.x == q.x) {
|
||||
// const int8_t y1 = GAMEY(_MIN(p.y, q.y)), y2 = GAMEY(_MAX(p.y, q.y));
|
||||
// if (PAGE_CONTAINS(y1, y2))
|
||||
// u8g.drawVLine(GAMEX(p.x), y1, y2 - y1 + 1);
|
||||
// }
|
||||
// else if (PAGE_CONTAINS(GAMEY(p.y), GAMEY(p.y))) {
|
||||
// const int8_t x1 = GAMEX(_MIN(p.x, q.x)), x2 = GAMEX(_MAX(p.x, q.x));
|
||||
// u8g.drawHLine(x1, GAMEY(p.y), x2 - x1 + 1);
|
||||
// }
|
||||
// }
|
||||
|
||||
// Draw Man
|
||||
// const int8_t fy = GAMEY(foody);
|
||||
// if (PAGE_CONTAINS(fy, fy + FOOD_WH - 1)) {
|
||||
// const int8_t fx = GAMEX(foodx);
|
||||
// u8g.drawFrame(fx, fy, FOOD_WH, FOOD_WH);
|
||||
// if (FOOD_WH == 5) u8g.drawPixel(fx + 2, fy + 2);
|
||||
// }
|
||||
|
||||
// Draw Ghosts
|
||||
// const int8_t fy = GAMEY(foody);
|
||||
// if (PAGE_CONTAINS(fy, fy + FOOD_WH - 1)) {
|
||||
// const int8_t fx = GAMEX(foodx);
|
||||
// u8g.drawFrame(fx, fy, FOOD_WH, FOOD_WH);
|
||||
// if (FOOD_WH == 5) u8g.drawPixel(fx + 2, fy + 2);
|
||||
// }
|
||||
|
||||
// Draw Prize
|
||||
// if (PAGE_CONTAINS(prizey, prizey + PRIZE_WH - 1)) {
|
||||
// u8g.drawFrame(prizex, prizey, PRIZE_WH, PRIZE_WH);
|
||||
// if (PRIZE_WH == 5) u8g.drawPixel(prizex + 2, prizey + 2);
|
||||
// }
|
||||
|
||||
// Draw GAME OVER
|
||||
if (!game_state) draw_game_over();
|
||||
|
||||
// A click always exits this game
|
||||
if (ui.use_click()) exit_game();
|
||||
}
|
||||
|
||||
void MazeGame::enter_game() {
|
||||
init_game(1, game_screen); // Game running
|
||||
reset_player();
|
||||
reset_enemies();
|
||||
}
|
||||
|
||||
#endif // MARLIN_MAZE
|
30
Marlin/src/lcd/menu/game/maze.h
Executable file
30
Marlin/src/lcd/menu/game/maze.h
Executable file
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "types.h"
|
||||
|
||||
typedef struct { pos_t pos; } maze_data_t;
|
||||
|
||||
class MazeGame : MarlinGame { public: static void enter_game(), game_screen(); };
|
||||
|
||||
extern MazeGame maze;
|
323
Marlin/src/lcd/menu/game/snake.cpp
Executable file
323
Marlin/src/lcd/menu/game/snake.cpp
Executable file
@@ -0,0 +1,323 @@
|
||||
/**
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "../../../inc/MarlinConfigPre.h"
|
||||
|
||||
#if ENABLED(MARLIN_SNAKE)
|
||||
|
||||
#include "game.h"
|
||||
|
||||
#define SNAKE_BOX 4
|
||||
|
||||
#define HEADER_H (MENU_FONT_ASCENT - 2)
|
||||
#define SNAKE_WH (SNAKE_BOX + 1)
|
||||
|
||||
#define IDEAL_L 2
|
||||
#define IDEAL_R (LCD_PIXEL_WIDTH - 1 - 2)
|
||||
#define IDEAL_T (HEADER_H + 2)
|
||||
#define IDEAL_B (LCD_PIXEL_HEIGHT - 1 - 2)
|
||||
#define IDEAL_W (IDEAL_R - (IDEAL_L) + 1)
|
||||
#define IDEAL_H (IDEAL_B - (IDEAL_T) + 1)
|
||||
|
||||
#define GAME_W int((IDEAL_W) / (SNAKE_WH))
|
||||
#define GAME_H int((IDEAL_H) / (SNAKE_WH))
|
||||
|
||||
#define BOARD_W ((SNAKE_WH) * (GAME_W) + 1)
|
||||
#define BOARD_H ((SNAKE_WH) * (GAME_H) + 1)
|
||||
#define BOARD_L ((LCD_PIXEL_WIDTH - (BOARD_W) + 1) / 2)
|
||||
#define BOARD_R (BOARD_L + BOARD_W - 1)
|
||||
#define BOARD_T (((LCD_PIXEL_HEIGHT + IDEAL_T) - (BOARD_H)) / 2)
|
||||
#define BOARD_B (BOARD_T + BOARD_H - 1)
|
||||
|
||||
#define GAMEX(X) (BOARD_L + ((X) * (SNAKE_WH)))
|
||||
#define GAMEY(Y) (BOARD_T + ((Y) * (SNAKE_WH)))
|
||||
|
||||
#if SNAKE_BOX > 2
|
||||
#define FOOD_WH SNAKE_BOX
|
||||
#else
|
||||
#define FOOD_WH 2
|
||||
#endif
|
||||
|
||||
#if SNAKE_BOX < 1
|
||||
#define SNAKE_SIZ 1
|
||||
#else
|
||||
#define SNAKE_SIZ SNAKE_BOX
|
||||
#endif
|
||||
|
||||
constexpr fixed_t snakev = FTOP(0.20);
|
||||
|
||||
snake_data_t &sdat = marlin_game_data.snake;
|
||||
|
||||
// Remove the first pixel from the tail.
|
||||
// If needed, shift out the first segment.
|
||||
void shorten_tail() {
|
||||
pos_t &p = sdat.snake_tail[0], &q = sdat.snake_tail[1];
|
||||
bool shift = false;
|
||||
if (p.x == q.x) {
|
||||
// Vertical line
|
||||
p.y += (q.y > p.y) ? 1 : -1;
|
||||
shift = p.y == q.y;
|
||||
}
|
||||
else {
|
||||
// Horizontal line
|
||||
p.x += (q.x > p.x) ? 1 : -1;
|
||||
shift = p.x == q.x;
|
||||
}
|
||||
if (shift) {
|
||||
sdat.head_ind--;
|
||||
LOOP_LE_N(i, sdat.head_ind)
|
||||
sdat.snake_tail[i] = sdat.snake_tail[i + 1];
|
||||
}
|
||||
}
|
||||
|
||||
// The food is on a line
|
||||
inline bool food_on_line() {
|
||||
LOOP_L_N(n, sdat.head_ind) {
|
||||
pos_t &p = sdat.snake_tail[n], &q = sdat.snake_tail[n + 1];
|
||||
if (p.x == q.x) {
|
||||
if ((sdat.foodx == p.x - 1 || sdat.foodx == p.x) && WITHIN(sdat.foody, _MIN(p.y, q.y), _MAX(p.y, q.y)))
|
||||
return true;
|
||||
}
|
||||
else if ((sdat.foody == p.y - 1 || sdat.foody == p.y) && WITHIN(sdat.foodx, _MIN(p.x, q.x), _MAX(p.x, q.x)))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Add a new food blob
|
||||
void food_reset() {
|
||||
do {
|
||||
sdat.foodx = random(0, GAME_W);
|
||||
sdat.foody = random(0, GAME_H);
|
||||
} while (food_on_line());
|
||||
}
|
||||
|
||||
// Turn the snake cw or ccw
|
||||
inline void turn_snake(const bool cw) {
|
||||
sdat.snake_dir += cw ? 1 : -1;
|
||||
sdat.snake_dir &= 0x03;
|
||||
sdat.head_ind++;
|
||||
sdat.snake_tail[sdat.head_ind].x = FTOB(sdat.snakex);
|
||||
sdat.snake_tail[sdat.head_ind].y = FTOB(sdat.snakey);
|
||||
}
|
||||
|
||||
// Reset the snake for a new game
|
||||
void snake_reset() {
|
||||
// Init the head and velocity
|
||||
sdat.snakex = BTOF(1);
|
||||
sdat.snakey = BTOF(GAME_H / 2);
|
||||
//snakev = FTOP(0.25);
|
||||
|
||||
// Init the tail with a cw turn
|
||||
sdat.snake_dir = 0;
|
||||
sdat.head_ind = 0;
|
||||
sdat.snake_tail[0].x = 0;
|
||||
sdat.snake_tail[0].y = GAME_H / 2;
|
||||
turn_snake(true);
|
||||
|
||||
// Clear food flag
|
||||
sdat.food_cnt = 5;
|
||||
|
||||
// Clear the controls
|
||||
ui.encoderPosition = 0;
|
||||
sdat.old_encoder = 0;
|
||||
}
|
||||
|
||||
// Check if head segment overlaps another
|
||||
bool snake_overlap() {
|
||||
// 4 lines must exist before a collision is possible
|
||||
if (sdat.head_ind < 4) return false;
|
||||
// Is the last segment crossing any others?
|
||||
const pos_t &h1 = sdat.snake_tail[sdat.head_ind - 1], &h2 = sdat.snake_tail[sdat.head_ind];
|
||||
// VERTICAL head segment?
|
||||
if (h1.x == h2.x) {
|
||||
// Loop from oldest to segment two away from head
|
||||
LOOP_L_N(n, sdat.head_ind - 2) {
|
||||
// Segment p to q
|
||||
const pos_t &p = sdat.snake_tail[n], &q = sdat.snake_tail[n + 1];
|
||||
if (p.x != q.x) {
|
||||
// Crossing horizontal segment
|
||||
if (WITHIN(h1.x, _MIN(p.x, q.x), _MAX(p.x, q.x)) && (h1.y <= p.y) == (h2.y >= p.y)) return true;
|
||||
} // Overlapping vertical segment
|
||||
else if (h1.x == p.x && _MIN(h1.y, h2.y) <= _MAX(p.y, q.y) && _MAX(h1.y, h2.y) >= _MIN(p.y, q.y)) return true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Loop from oldest to segment two away from head
|
||||
LOOP_L_N(n, sdat.head_ind - 2) {
|
||||
// Segment p to q
|
||||
const pos_t &p = sdat.snake_tail[n], &q = sdat.snake_tail[n + 1];
|
||||
if (p.y != q.y) {
|
||||
// Crossing vertical segment
|
||||
if (WITHIN(h1.y, _MIN(p.y, q.y), _MAX(p.y, q.y)) && (h1.x <= p.x) == (h2.x >= p.x)) return true;
|
||||
} // Overlapping horizontal segment
|
||||
else if (h1.y == p.y && _MIN(h1.x, h2.x) <= _MAX(p.x, q.x) && _MAX(h1.x, h2.x) >= _MIN(p.x, q.x)) return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void SnakeGame::game_screen() {
|
||||
// Run the snake logic
|
||||
if (game_frame()) do { // Run logic twice for finer resolution
|
||||
|
||||
// Move the snake's head one unit in the current direction
|
||||
const int8_t oldx = FTOB(sdat.snakex), oldy = FTOB(sdat.snakey);
|
||||
switch (sdat.snake_dir) {
|
||||
case 0: sdat.snakey -= snakev; break;
|
||||
case 1: sdat.snakex += snakev; break;
|
||||
case 2: sdat.snakey += snakev; break;
|
||||
case 3: sdat.snakex -= snakev; break;
|
||||
}
|
||||
const int8_t x = FTOB(sdat.snakex), y = FTOB(sdat.snakey);
|
||||
|
||||
// If movement took place...
|
||||
if (oldx != x || oldy != y) {
|
||||
|
||||
if (!WITHIN(x, 0, GAME_W - 1) || !WITHIN(y, 0, GAME_H - 1)) {
|
||||
game_state = 0; // Game Over
|
||||
_BUZZ(400, 40); // Bzzzt!
|
||||
break; // ...out of do-while
|
||||
}
|
||||
|
||||
sdat.snake_tail[sdat.head_ind].x = x;
|
||||
sdat.snake_tail[sdat.head_ind].y = y;
|
||||
|
||||
// Change snake direction if set
|
||||
const int8_t enc = int8_t(ui.encoderPosition), diff = enc - sdat.old_encoder;
|
||||
if (diff) {
|
||||
sdat.old_encoder = enc;
|
||||
turn_snake(diff > 0);
|
||||
}
|
||||
|
||||
if (sdat.food_cnt) --sdat.food_cnt; else shorten_tail();
|
||||
|
||||
// Did the snake collide with itself or go out of bounds?
|
||||
if (snake_overlap()) {
|
||||
game_state = 0; // Game Over
|
||||
_BUZZ(400, 40); // Bzzzt!
|
||||
}
|
||||
// Is the snake at the food?
|
||||
else if (x == sdat.foodx && y == sdat.foody) {
|
||||
_BUZZ(5, 220);
|
||||
_BUZZ(5, 280);
|
||||
score++;
|
||||
sdat.food_cnt = 2;
|
||||
food_reset();
|
||||
}
|
||||
}
|
||||
|
||||
} while(0);
|
||||
|
||||
u8g.setColorIndex(1);
|
||||
|
||||
// Draw Score
|
||||
if (PAGE_UNDER(HEADER_H)) lcd_put_int(0, HEADER_H - 1, score);
|
||||
|
||||
// DRAW THE PLAYFIELD BORDER
|
||||
u8g.drawFrame(BOARD_L - 2, BOARD_T - 2, BOARD_R - BOARD_L + 4, BOARD_B - BOARD_T + 4);
|
||||
|
||||
// Draw the snake (tail)
|
||||
#if SNAKE_WH < 2
|
||||
|
||||
// At this scale just draw a line
|
||||
LOOP_L_N(n, sdat.head_ind) {
|
||||
const pos_t &p = sdat.snake_tail[n], &q = sdat.snake_tail[n + 1];
|
||||
if (p.x == q.x) {
|
||||
const int8_t y1 = GAMEY(_MIN(p.y, q.y)), y2 = GAMEY(_MAX(p.y, q.y));
|
||||
if (PAGE_CONTAINS(y1, y2))
|
||||
u8g.drawVLine(GAMEX(p.x), y1, y2 - y1 + 1);
|
||||
}
|
||||
else if (PAGE_CONTAINS(GAMEY(p.y), GAMEY(p.y))) {
|
||||
const int8_t x1 = GAMEX(_MIN(p.x, q.x)), x2 = GAMEX(_MAX(p.x, q.x));
|
||||
u8g.drawHLine(x1, GAMEY(p.y), x2 - x1 + 1);
|
||||
}
|
||||
}
|
||||
|
||||
#elif SNAKE_WH == 2
|
||||
|
||||
// At this scale draw two lines
|
||||
LOOP_L_N(n, sdat.head_ind) {
|
||||
const pos_t &p = sdat.snake_tail[n], &q = sdat.snake_tail[n + 1];
|
||||
if (p.x == q.x) {
|
||||
const int8_t y1 = GAMEY(_MIN(p.y, q.y)), y2 = GAMEY(_MAX(p.y, q.y));
|
||||
if (PAGE_CONTAINS(y1, y2 + 1))
|
||||
u8g.drawFrame(GAMEX(p.x), y1, 2, y2 - y1 + 1 + 1);
|
||||
}
|
||||
else {
|
||||
const int8_t py = GAMEY(p.y);
|
||||
if (PAGE_CONTAINS(py, py + 1)) {
|
||||
const int8_t x1 = GAMEX(_MIN(p.x, q.x)), x2 = GAMEX(_MAX(p.x, q.x));
|
||||
u8g.drawFrame(x1, py, x2 - x1 + 1 + 1, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
// Draw a series of boxes
|
||||
LOOP_L_N(n, sdat.head_ind) {
|
||||
const pos_t &p = sdat.snake_tail[n], &q = sdat.snake_tail[n + 1];
|
||||
if (p.x == q.x) {
|
||||
const int8_t y1 = _MIN(p.y, q.y), y2 = _MAX(p.y, q.y);
|
||||
if (PAGE_CONTAINS(GAMEY(y1), GAMEY(y2) + SNAKE_SIZ - 1)) {
|
||||
for (int8_t i = y1; i <= y2; ++i) {
|
||||
const int8_t y = GAMEY(i);
|
||||
if (PAGE_CONTAINS(y, y + SNAKE_SIZ - 1))
|
||||
u8g.drawBox(GAMEX(p.x), y, SNAKE_SIZ, SNAKE_SIZ);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
const int8_t py = GAMEY(p.y);
|
||||
if (PAGE_CONTAINS(py, py + SNAKE_SIZ - 1)) {
|
||||
const int8_t x1 = _MIN(p.x, q.x), x2 = _MAX(p.x, q.x);
|
||||
for (int8_t i = x1; i <= x2; ++i)
|
||||
u8g.drawBox(GAMEX(i), py, SNAKE_SIZ, SNAKE_SIZ);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// Draw food
|
||||
const int8_t fy = GAMEY(sdat.foody);
|
||||
if (PAGE_CONTAINS(fy, fy + FOOD_WH - 1)) {
|
||||
const int8_t fx = GAMEX(sdat.foodx);
|
||||
u8g.drawFrame(fx, fy, FOOD_WH, FOOD_WH);
|
||||
if (FOOD_WH == 5) u8g.drawPixel(fx + 2, fy + 2);
|
||||
}
|
||||
|
||||
// Draw GAME OVER
|
||||
if (!game_state) draw_game_over();
|
||||
|
||||
// A click always exits this game
|
||||
if (ui.use_click()) exit_game();
|
||||
}
|
||||
|
||||
void SnakeGame::enter_game() {
|
||||
init_game(1, game_screen); // 1 = Game running
|
||||
snake_reset();
|
||||
food_reset();
|
||||
}
|
||||
|
||||
#endif // MARLIN_SNAKE
|
38
Marlin/src/lcd/menu/game/snake.h
Executable file
38
Marlin/src/lcd/menu/game/snake.h
Executable file
@@ -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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "types.h"
|
||||
|
||||
typedef struct {
|
||||
int8_t snake_dir, // NESW
|
||||
foodx, foody,
|
||||
food_cnt,
|
||||
old_encoder;
|
||||
pos_t snake_tail[50];
|
||||
fixed_t snakex, snakey;
|
||||
uint8_t head_ind;
|
||||
} snake_data_t;
|
||||
|
||||
class SnakeGame : MarlinGame { public: static void enter_game(), game_screen(); };
|
||||
|
||||
extern SnakeGame snake;
|
46
Marlin/src/lcd/menu/game/types.h
Executable file
46
Marlin/src/lcd/menu/game/types.h
Executable file
@@ -0,0 +1,46 @@
|
||||
/**
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
typedef struct { int8_t x, y; } pos_t;
|
||||
|
||||
// Simple 8:8 fixed-point
|
||||
typedef int16_t fixed_t;
|
||||
#define FTOP(F) fixed_t((F)*256.0f)
|
||||
#define PTOF(P) (float(P)*(1.0f/256.0f))
|
||||
#define BTOF(X) (fixed_t(X)<<8)
|
||||
#define FTOB(X) int8_t(fixed_t(X)>>8)
|
||||
|
||||
class MarlinGame {
|
||||
protected:
|
||||
static int score;
|
||||
static uint8_t game_state;
|
||||
static millis_t next_frame;
|
||||
|
||||
static bool game_frame();
|
||||
static void draw_game_over();
|
||||
static void exit_game();
|
||||
public:
|
||||
static void init_game(const uint8_t init_state, const screenFunc_t screen);
|
||||
};
|
505
Marlin/src/lcd/menu/menu.cpp
Executable file
505
Marlin/src/lcd/menu/menu.cpp
Executable file
@@ -0,0 +1,505 @@
|
||||
/**
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "../../inc/MarlinConfigPre.h"
|
||||
|
||||
#if HAS_LCD_MENU
|
||||
|
||||
#include "menu.h"
|
||||
#include "../../module/planner.h"
|
||||
#include "../../module/motion.h"
|
||||
#include "../../module/printcounter.h"
|
||||
#include "../../gcode/queue.h"
|
||||
|
||||
#if HAS_BUZZER
|
||||
#include "../../libs/buzzer.h"
|
||||
#endif
|
||||
|
||||
#if ENABLED(EEPROM_SETTINGS)
|
||||
#include "../../module/configuration_store.h"
|
||||
#endif
|
||||
|
||||
#if WATCH_HOTENDS || WATCH_BED
|
||||
#include "../../module/temperature.h"
|
||||
#endif
|
||||
|
||||
#if ENABLED(BABYSTEP_ZPROBE_OFFSET)
|
||||
#include "../../module/probe.h"
|
||||
#endif
|
||||
|
||||
#if EITHER(ENABLE_LEVELING_FADE_HEIGHT, AUTO_BED_LEVELING_UBL)
|
||||
#include "../../feature/bedlevel/bedlevel.h"
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////
|
||||
///////////// Global Variables /////////////
|
||||
////////////////////////////////////////////
|
||||
|
||||
// Menu Navigation
|
||||
int8_t encoderTopLine, encoderLine, screen_items;
|
||||
|
||||
typedef struct {
|
||||
screenFunc_t menu_function;
|
||||
uint32_t encoder_position;
|
||||
int8_t top_line, items;
|
||||
} menuPosition;
|
||||
menuPosition screen_history[6];
|
||||
uint8_t screen_history_depth = 0;
|
||||
|
||||
uint8_t MenuItemBase::itemIndex; // Index number for draw and action
|
||||
chimera_t editable; // Value Editing
|
||||
|
||||
// Menu Edit Items
|
||||
PGM_P MenuEditItemBase::editLabel;
|
||||
void* MenuEditItemBase::editValue;
|
||||
int32_t MenuEditItemBase::minEditValue,
|
||||
MenuEditItemBase::maxEditValue;
|
||||
screenFunc_t MenuEditItemBase::callbackFunc;
|
||||
bool MenuEditItemBase::liveEdit;
|
||||
|
||||
// Prevent recursion into screen handlers
|
||||
bool no_reentry = false;
|
||||
|
||||
////////////////////////////////////////////
|
||||
//////// Menu Navigation & History /////////
|
||||
////////////////////////////////////////////
|
||||
|
||||
void MarlinUI::return_to_status() { goto_screen(status_screen); }
|
||||
|
||||
void MarlinUI::save_previous_screen() {
|
||||
if (screen_history_depth < COUNT(screen_history))
|
||||
screen_history[screen_history_depth++] = { currentScreen, encoderPosition, encoderTopLine, screen_items };
|
||||
}
|
||||
|
||||
void MarlinUI::_goto_previous_screen(
|
||||
#if ENABLED(TURBO_BACK_MENU_ITEM)
|
||||
const bool is_back/*=false*/
|
||||
#endif
|
||||
) {
|
||||
#if DISABLED(TURBO_BACK_MENU_ITEM)
|
||||
constexpr bool is_back = false;
|
||||
#endif
|
||||
if (screen_history_depth > 0) {
|
||||
menuPosition &sh = screen_history[--screen_history_depth];
|
||||
goto_screen(sh.menu_function,
|
||||
is_back ? 0 : sh.encoder_position,
|
||||
is_back ? 0 : sh.top_line,
|
||||
sh.items
|
||||
);
|
||||
}
|
||||
else
|
||||
return_to_status();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////
|
||||
/////////// Common Menu Actions ////////////
|
||||
////////////////////////////////////////////
|
||||
|
||||
void MenuItem_gcode::action(PGM_P const, PGM_P const pgcode) { queue.inject_P(pgcode); }
|
||||
|
||||
////////////////////////////////////////////
|
||||
/////////// Menu Editing Actions ///////////
|
||||
////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Functions for editing single values
|
||||
*
|
||||
* The "DEFINE_MENU_EDIT_ITEM" macro generates the classes needed to edit a numerical value.
|
||||
*
|
||||
* The prerequisite is that in the header the type was already declared:
|
||||
*
|
||||
* DEFINE_MENU_EDIT_ITEM_TYPE(int3, int16_t, i16tostr3rj, 1)
|
||||
*
|
||||
* For example, DEFINE_MENU_EDIT_ITEM(int3) expands into:
|
||||
*
|
||||
* template class TMenuEditItem<MenuEditItemInfo_int3>
|
||||
*
|
||||
* You can then use one of the menu macros to present the edit interface:
|
||||
* EDIT_ITEM(int3, MSG_SPEED, &feedrate_percentage, 10, 999)
|
||||
*
|
||||
* This expands into a more primitive menu item:
|
||||
* _MENU_ITEM_P(int3, false, GET_TEXT(MSG_SPEED), &feedrate_percentage, 10, 999)
|
||||
*
|
||||
* ...which calls:
|
||||
* MenuItem_int3::action(plabel, &feedrate_percentage, 10, 999)
|
||||
* MenuItem_int3::draw(encoderLine == _thisItemNr, _lcdLineNr, plabel, &feedrate_percentage, 10, 999)
|
||||
*/
|
||||
void MenuEditItemBase::edit_screen(strfunc_t strfunc, loadfunc_t loadfunc) {
|
||||
#if ENABLED(TOUCH_BUTTONS)
|
||||
ui.repeat_delay = BUTTON_DELAY_EDIT;
|
||||
#endif
|
||||
if (int32_t(ui.encoderPosition) < 0) ui.encoderPosition = 0;
|
||||
if (int32_t(ui.encoderPosition) > maxEditValue) ui.encoderPosition = maxEditValue;
|
||||
if (ui.should_draw())
|
||||
draw_edit_screen(strfunc(ui.encoderPosition + minEditValue));
|
||||
if (ui.lcd_clicked || (liveEdit && ui.should_draw())) {
|
||||
if (editValue != nullptr) loadfunc(editValue, ui.encoderPosition + minEditValue);
|
||||
if (callbackFunc && (liveEdit || ui.lcd_clicked)) (*callbackFunc)();
|
||||
if (ui.use_click()) ui.goto_previous_screen();
|
||||
}
|
||||
}
|
||||
|
||||
void MenuEditItemBase::goto_edit_screen(
|
||||
PGM_P const el, // Edit label
|
||||
void * const ev, // Edit value pointer
|
||||
const int32_t minv, // Encoder minimum
|
||||
const int32_t maxv, // Encoder maximum
|
||||
const uint16_t ep, // Initial encoder value
|
||||
const screenFunc_t cs, // MenuItem_type::draw_edit_screen => MenuEditItemBase::edit()
|
||||
const screenFunc_t cb, // Callback after edit
|
||||
const bool le // Flag to call cb() during editing
|
||||
) {
|
||||
ui.screen_changed = true;
|
||||
ui.save_previous_screen();
|
||||
ui.refresh();
|
||||
editLabel = el;
|
||||
editValue = ev;
|
||||
minEditValue = minv;
|
||||
maxEditValue = maxv;
|
||||
ui.encoderPosition = ep;
|
||||
ui.currentScreen = cs;
|
||||
callbackFunc = cb;
|
||||
liveEdit = le;
|
||||
}
|
||||
|
||||
// TODO: Remove these but test build size with and without
|
||||
#define DEFINE_MENU_EDIT_ITEM(NAME) template class TMenuEditItem<MenuEditItemInfo_##NAME>
|
||||
|
||||
DEFINE_MENU_EDIT_ITEM(percent); // 100% right-justified
|
||||
DEFINE_MENU_EDIT_ITEM(int3); // 123, -12 right-justified
|
||||
DEFINE_MENU_EDIT_ITEM(int4); // 1234, -123 right-justified
|
||||
DEFINE_MENU_EDIT_ITEM(int8); // 123, -12 right-justified
|
||||
DEFINE_MENU_EDIT_ITEM(uint8); // 123 right-justified
|
||||
DEFINE_MENU_EDIT_ITEM(uint16_3); // 123 right-justified
|
||||
DEFINE_MENU_EDIT_ITEM(uint16_4); // 1234 right-justified
|
||||
DEFINE_MENU_EDIT_ITEM(uint16_5); // 12345 right-justified
|
||||
DEFINE_MENU_EDIT_ITEM(float3); // 123 right-justified
|
||||
DEFINE_MENU_EDIT_ITEM(float42_52); // _2.34, 12.34, -2.34 or 123.45, -23.45
|
||||
DEFINE_MENU_EDIT_ITEM(float43); // 1.234
|
||||
DEFINE_MENU_EDIT_ITEM(float5); // 12345 right-justified
|
||||
DEFINE_MENU_EDIT_ITEM(float5_25); // 12345 right-justified (25 increment)
|
||||
DEFINE_MENU_EDIT_ITEM(float51); // 1234.5 right-justified
|
||||
DEFINE_MENU_EDIT_ITEM(float41sign); // +123.4
|
||||
DEFINE_MENU_EDIT_ITEM(float51sign); // +1234.5
|
||||
DEFINE_MENU_EDIT_ITEM(float52sign); // +123.45
|
||||
DEFINE_MENU_EDIT_ITEM(long5); // 12345 right-justified
|
||||
DEFINE_MENU_EDIT_ITEM(long5_25); // 12345 right-justified (25 increment)
|
||||
|
||||
void MenuItem_bool::action(PGM_P const, bool * const ptr, screenFunc_t callback) {
|
||||
*ptr ^= true; ui.refresh();
|
||||
if (callback) (*callback)();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////
|
||||
///////////////// Menu Tree ////////////////
|
||||
////////////////////////////////////////////
|
||||
|
||||
#include "../../MarlinCore.h"
|
||||
|
||||
bool printer_busy() {
|
||||
return planner.movesplanned() || printingIsActive();
|
||||
}
|
||||
|
||||
/**
|
||||
* General function to go directly to a screen
|
||||
*/
|
||||
void MarlinUI::goto_screen(screenFunc_t screen, const uint16_t encoder/*=0*/, const uint8_t top/*=0*/, const uint8_t items/*=0*/) {
|
||||
if (currentScreen != screen) {
|
||||
|
||||
#if ENABLED(TOUCH_BUTTONS)
|
||||
repeat_delay = BUTTON_DELAY_MENU;
|
||||
#endif
|
||||
|
||||
#if ENABLED(LCD_SET_PROGRESS_MANUALLY)
|
||||
progress_reset();
|
||||
#endif
|
||||
|
||||
#if BOTH(DOUBLECLICK_FOR_Z_BABYSTEPPING, BABYSTEPPING)
|
||||
static millis_t doubleclick_expire_ms = 0;
|
||||
// Going to menu_main from status screen? Remember first click time.
|
||||
// Going back to status screen within a very short time? Go to Z babystepping.
|
||||
if (screen == menu_main) {
|
||||
if (on_status_screen())
|
||||
doubleclick_expire_ms = millis() + DOUBLECLICK_MAX_INTERVAL;
|
||||
}
|
||||
else if (screen == status_screen && currentScreen == menu_main && PENDING(millis(), doubleclick_expire_ms)) {
|
||||
|
||||
#if ENABLED(BABYSTEP_WITHOUT_HOMING)
|
||||
constexpr bool can_babystep = true;
|
||||
#else
|
||||
const bool can_babystep = all_axes_known();
|
||||
#endif
|
||||
#if ENABLED(BABYSTEP_ALWAYS_AVAILABLE)
|
||||
constexpr bool should_babystep = true;
|
||||
#else
|
||||
const bool should_babystep = printer_busy();
|
||||
#endif
|
||||
|
||||
if (should_babystep && can_babystep) {
|
||||
screen =
|
||||
#if ENABLED(BABYSTEP_ZPROBE_OFFSET)
|
||||
lcd_babystep_zoffset
|
||||
#else
|
||||
lcd_babystep_z
|
||||
#endif
|
||||
;
|
||||
}
|
||||
#if ENABLED(MOVE_Z_WHEN_IDLE)
|
||||
else {
|
||||
move_menu_scale = MOVE_Z_IDLE_MULTIPLICATOR;
|
||||
screen = lcd_move_z;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
currentScreen = screen;
|
||||
encoderPosition = encoder;
|
||||
encoderTopLine = top;
|
||||
screen_items = items;
|
||||
if (screen == status_screen) {
|
||||
defer_status_screen(false);
|
||||
#if ENABLED(AUTO_BED_LEVELING_UBL)
|
||||
ubl.lcd_map_control = false;
|
||||
#endif
|
||||
screen_history_depth = 0;
|
||||
}
|
||||
|
||||
clear_lcd();
|
||||
|
||||
// Re-initialize custom characters that may be re-used
|
||||
#if HAS_CHARACTER_LCD
|
||||
if (true
|
||||
#if ENABLED(AUTO_BED_LEVELING_UBL)
|
||||
&& !ubl.lcd_map_control
|
||||
#endif
|
||||
) set_custom_characters(screen == status_screen ? CHARSET_INFO : CHARSET_MENU);
|
||||
#endif
|
||||
|
||||
refresh(LCDVIEW_CALL_REDRAW_NEXT);
|
||||
screen_changed = true;
|
||||
#if HAS_GRAPHICAL_LCD
|
||||
drawing_screen = false;
|
||||
#endif
|
||||
|
||||
#if HAS_LCD_MENU
|
||||
encoder_direction_normal();
|
||||
#endif
|
||||
|
||||
set_selection(false);
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////
|
||||
///////////// Manual Movement //////////////
|
||||
////////////////////////////////////////////
|
||||
|
||||
//
|
||||
// Display the synchronize screen until moves are
|
||||
// finished, and don't return to the caller until
|
||||
// done. ** This blocks the command queue! **
|
||||
//
|
||||
static PGM_P sync_message;
|
||||
|
||||
void MarlinUI::_synchronize() {
|
||||
if (should_draw()) MenuItem_static::draw(LCD_HEIGHT >= 4, sync_message);
|
||||
if (no_reentry) return;
|
||||
// Make this the current handler till all moves are done
|
||||
const screenFunc_t old_screen = currentScreen;
|
||||
goto_screen(_synchronize);
|
||||
no_reentry = true;
|
||||
planner.synchronize(); // idle() is called until moves complete
|
||||
no_reentry = false;
|
||||
goto_screen(old_screen);
|
||||
}
|
||||
|
||||
// Display the synchronize screen with a custom message
|
||||
// ** This blocks the command queue! **
|
||||
void MarlinUI::synchronize(PGM_P const msg/*=nullptr*/) {
|
||||
sync_message = msg ?: GET_TEXT(MSG_MOVING);
|
||||
_synchronize();
|
||||
}
|
||||
|
||||
/**
|
||||
* Scrolling for menus and other line-based screens
|
||||
*
|
||||
* encoderLine is the position based on the encoder
|
||||
* encoderTopLine is the top menu line to display
|
||||
* _lcdLineNr is the index of the LCD line (e.g., 0-3)
|
||||
* _menuLineNr is the menu item to draw and process
|
||||
* _thisItemNr is the index of each MENU_ITEM or STATIC_ITEM
|
||||
* screen_items is the total number of items in the menu (after one call)
|
||||
*/
|
||||
void scroll_screen(const uint8_t limit, const bool is_menu) {
|
||||
ui.encoder_direction_menus();
|
||||
ENCODER_RATE_MULTIPLY(false);
|
||||
if (int32_t(ui.encoderPosition) < 0) ui.encoderPosition = 0;
|
||||
if (ui.first_page) {
|
||||
encoderLine = ui.encoderPosition / (ENCODER_STEPS_PER_MENU_ITEM);
|
||||
ui.screen_changed = false;
|
||||
}
|
||||
if (screen_items > 0 && encoderLine >= screen_items - limit) {
|
||||
encoderLine = _MAX(0, screen_items - limit);
|
||||
ui.encoderPosition = encoderLine * (ENCODER_STEPS_PER_MENU_ITEM);
|
||||
}
|
||||
if (is_menu) {
|
||||
NOMORE(encoderTopLine, encoderLine);
|
||||
if (encoderLine >= encoderTopLine + LCD_HEIGHT)
|
||||
encoderTopLine = encoderLine - LCD_HEIGHT + 1;
|
||||
}
|
||||
else
|
||||
encoderTopLine = encoderLine;
|
||||
}
|
||||
|
||||
#if HAS_BUZZER
|
||||
void MarlinUI::completion_feedback(const bool good/*=true*/) {
|
||||
if (good) {
|
||||
BUZZ(100, 659);
|
||||
BUZZ(100, 698);
|
||||
}
|
||||
else BUZZ(20, 440);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if HAS_LINE_TO_Z
|
||||
|
||||
void line_to_z(const float &z) {
|
||||
current_position.z = z;
|
||||
line_to_current_position(manual_feedrate_mm_s.z);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if ENABLED(BABYSTEP_ZPROBE_OFFSET)
|
||||
|
||||
#include "../../feature/babystep.h"
|
||||
|
||||
void lcd_babystep_zoffset() {
|
||||
if (ui.use_click()) return ui.goto_previous_screen_no_defer();
|
||||
ui.defer_status_screen();
|
||||
const bool do_probe = DISABLED(BABYSTEP_HOTEND_Z_OFFSET) || active_extruder == 0;
|
||||
if (ui.encoderPosition) {
|
||||
const int16_t babystep_increment = int16_t(ui.encoderPosition) * (BABYSTEP_MULTIPLICATOR_Z);
|
||||
ui.encoderPosition = 0;
|
||||
|
||||
const float diff = planner.steps_to_mm[Z_AXIS] * babystep_increment,
|
||||
new_probe_offset = probe.offset.z + diff,
|
||||
new_offs =
|
||||
#if ENABLED(BABYSTEP_HOTEND_Z_OFFSET)
|
||||
do_probe ? new_probe_offset : hotend_offset[active_extruder].z - diff
|
||||
#else
|
||||
new_probe_offset
|
||||
#endif
|
||||
;
|
||||
if (WITHIN(new_offs, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX)) {
|
||||
|
||||
babystep.add_steps(Z_AXIS, babystep_increment);
|
||||
|
||||
if (do_probe) probe.offset.z = new_offs;
|
||||
#if ENABLED(BABYSTEP_HOTEND_Z_OFFSET)
|
||||
else hotend_offset[active_extruder].z = new_offs;
|
||||
#endif
|
||||
|
||||
ui.refresh(LCDVIEW_CALL_REDRAW_NEXT);
|
||||
}
|
||||
}
|
||||
if (ui.should_draw()) {
|
||||
#if ENABLED(BABYSTEP_HOTEND_Z_OFFSET)
|
||||
if (!do_probe)
|
||||
MenuEditItemBase::draw_edit_screen(GET_TEXT(MSG_HOTEND_OFFSET_Z), ftostr54sign(hotend_offset[active_extruder].z));
|
||||
#endif
|
||||
if (do_probe) {
|
||||
MenuEditItemBase::draw_edit_screen(GET_TEXT(MSG_ZPROBE_ZOFFSET), BABYSTEP_TO_STR(probe.offset.z));
|
||||
#if ENABLED(BABYSTEP_ZPROBE_GFX_OVERLAY)
|
||||
_lcd_zoffset_overlay_gfx(probe.offset.z);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif // BABYSTEP_ZPROBE_OFFSET
|
||||
|
||||
#if ANY(AUTO_BED_LEVELING_UBL, PID_AUTOTUNE_MENU, ADVANCED_PAUSE_FEATURE)
|
||||
|
||||
void lcd_enqueue_one_now(const char * const cmd) {
|
||||
no_reentry = true;
|
||||
queue.enqueue_one_now(cmd);
|
||||
no_reentry = false;
|
||||
}
|
||||
|
||||
void lcd_enqueue_one_now_P(PGM_P const cmd) {
|
||||
no_reentry = true;
|
||||
queue.enqueue_now_P(cmd);
|
||||
no_reentry = false;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if ENABLED(EEPROM_SETTINGS)
|
||||
void lcd_store_settings() {
|
||||
const bool saved = settings.save();
|
||||
#if HAS_BUZZER
|
||||
ui.completion_feedback(saved);
|
||||
#endif
|
||||
UNUSED(saved);
|
||||
}
|
||||
void lcd_load_settings() {
|
||||
const bool loaded = settings.load();
|
||||
#if HAS_BUZZER
|
||||
ui.completion_feedback(loaded);
|
||||
#endif
|
||||
UNUSED(loaded);
|
||||
}
|
||||
#endif
|
||||
|
||||
void _lcd_draw_homing() {
|
||||
constexpr uint8_t line = (LCD_HEIGHT - 1) / 2;
|
||||
if (ui.should_draw()) MenuItem_static::draw(line, GET_TEXT(MSG_LEVEL_BED_HOMING));
|
||||
}
|
||||
|
||||
#if ENABLED(LCD_BED_LEVELING) || (HAS_LEVELING && DISABLED(SLIM_LCD_MENUS))
|
||||
#include "../../feature/bedlevel/bedlevel.h"
|
||||
void _lcd_toggle_bed_leveling() { set_bed_leveling_enabled(!planner.leveling_active); }
|
||||
#endif
|
||||
|
||||
//
|
||||
// Selection screen presents a prompt and two options
|
||||
//
|
||||
bool MarlinUI::selection; // = false
|
||||
bool MarlinUI::update_selection() {
|
||||
encoder_direction_select();
|
||||
if (encoderPosition) {
|
||||
selection = int16_t(encoderPosition) > 0;
|
||||
encoderPosition = 0;
|
||||
}
|
||||
return selection;
|
||||
}
|
||||
|
||||
void MenuItem_confirm::select_screen(PGM_P const yes, PGM_P const no, selectFunc_t yesFunc, selectFunc_t noFunc, PGM_P const pref, const char * const string/*=nullptr*/, PGM_P const suff/*=nullptr*/) {
|
||||
const bool ui_selection = ui.update_selection(), got_click = ui.use_click();
|
||||
if (got_click || ui.should_draw()) {
|
||||
draw_select_screen(yes, no, ui_selection, pref, string, suff);
|
||||
if (got_click) { ui_selection ? yesFunc() : noFunc(); }
|
||||
}
|
||||
}
|
||||
|
||||
#endif // HAS_LCD_MENU
|
582
Marlin/src/lcd/menu/menu.h
Executable file
582
Marlin/src/lcd/menu/menu.h
Executable file
@@ -0,0 +1,582 @@
|
||||
/**
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "../ultralcd.h"
|
||||
#include "../../libs/numtostr.h"
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
|
||||
#include "limits.h"
|
||||
|
||||
extern int8_t encoderLine, encoderTopLine, screen_items;
|
||||
|
||||
#if HOTENDS
|
||||
constexpr int16_t heater_maxtemp[HOTENDS] = ARRAY_BY_HOTENDS(HEATER_0_MAXTEMP, HEATER_1_MAXTEMP, HEATER_2_MAXTEMP, HEATER_3_MAXTEMP, HEATER_4_MAXTEMP, HEATER_5_MAXTEMP, HEATER_6_MAXTEMP, HEATER_7_MAXTEMP);
|
||||
#endif
|
||||
|
||||
void scroll_screen(const uint8_t limit, const bool is_menu);
|
||||
bool printer_busy();
|
||||
|
||||
typedef void (*selectFunc_t)();
|
||||
|
||||
#define SS_LEFT 0x00
|
||||
#define SS_CENTER 0x01
|
||||
#define SS_INVERT 0x02
|
||||
#define SS_DEFAULT SS_CENTER
|
||||
|
||||
#if HAS_GRAPHICAL_LCD && EITHER(BABYSTEP_ZPROBE_GFX_OVERLAY, MESH_EDIT_GFX_OVERLAY)
|
||||
void _lcd_zoffset_overlay_gfx(const float zvalue);
|
||||
#endif
|
||||
|
||||
#if HAS_BED_PROBE
|
||||
#if Z_PROBE_OFFSET_RANGE_MIN >= -9 && Z_PROBE_OFFSET_RANGE_MAX <= 9
|
||||
#define LCD_Z_OFFSET_TYPE float43 // Values from -9.000 to +9.000
|
||||
#else
|
||||
#define LCD_Z_OFFSET_TYPE float42_52 // Values from -99.99 to 99.99
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if ENABLED(BABYSTEP_ZPROBE_OFFSET) && Z_PROBE_OFFSET_RANGE_MIN >= -9 && Z_PROBE_OFFSET_RANGE_MAX <= 9
|
||||
#define BABYSTEP_TO_STR(N) ftostr43sign(N)
|
||||
#elif ENABLED(BABYSTEPPING)
|
||||
#define BABYSTEP_TO_STR(N) ftostr53sign(N)
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////
|
||||
///////////// Base Menu Items //////////////
|
||||
////////////////////////////////////////////
|
||||
|
||||
class MenuItemBase {
|
||||
public:
|
||||
// An index to interject in the item label and for
|
||||
// use by the action
|
||||
static uint8_t itemIndex;
|
||||
|
||||
// Store the index of the item ahead of use by indexed items
|
||||
FORCE_INLINE static void init(const uint8_t ind) { itemIndex = ind; }
|
||||
|
||||
// Draw an item either selected (pre_char) or not (space) with post_char
|
||||
static void _draw(const bool sel, const uint8_t row, PGM_P const pstr, const char pre_char, const char post_char);
|
||||
|
||||
// Draw an item either selected ('>') or not (space) with post_char
|
||||
FORCE_INLINE static void _draw(const bool sel, const uint8_t row, PGM_P const pstr, const char post_char) {
|
||||
_draw(sel, row, pstr, '>', post_char);
|
||||
}
|
||||
};
|
||||
|
||||
class MenuItem_static : public MenuItemBase {
|
||||
public:
|
||||
static void draw(const uint8_t row, PGM_P const pstr, const uint8_t style=SS_DEFAULT, const char * const valstr=nullptr);
|
||||
};
|
||||
|
||||
// CONFIRM_ITEM(LABEL,Y,N,FY,FN,V...),
|
||||
// YESNO_ITEM(LABEL,FY,FN,V...)
|
||||
class MenuItem_confirm : public MenuItemBase {
|
||||
public:
|
||||
FORCE_INLINE static void draw(const bool sel, const uint8_t row, PGM_P const pstr, ...) {
|
||||
_draw(sel, row, pstr, '>', LCD_STR_ARROW_RIGHT[0]);
|
||||
}
|
||||
// Implemented for HD44780 and DOGM
|
||||
// Draw the prompt, buttons, and state
|
||||
static void draw_select_screen(
|
||||
PGM_P const yes, // Right option label
|
||||
PGM_P const no, // Left option label
|
||||
const bool yesno, // Is "yes" selected?
|
||||
PGM_P const pref, // Prompt prefix
|
||||
const char * const string, // Prompt runtime string
|
||||
PGM_P const suff // Prompt suffix
|
||||
);
|
||||
static void select_screen(
|
||||
PGM_P const yes, PGM_P const no,
|
||||
selectFunc_t yesFunc, selectFunc_t noFunc,
|
||||
PGM_P const pref, const char * const string=nullptr, PGM_P const suff=nullptr
|
||||
);
|
||||
static inline void select_screen(
|
||||
PGM_P const yes, PGM_P const no,
|
||||
selectFunc_t yesFunc, selectFunc_t noFunc,
|
||||
PGM_P const pref, const progmem_str string, PGM_P const suff=nullptr
|
||||
) {
|
||||
char str[strlen_P((PGM_P)string) + 1];
|
||||
strcpy_P(str, (PGM_P)string);
|
||||
select_screen(yes, no, yesFunc, noFunc, pref, str, suff);
|
||||
}
|
||||
// Shortcut for prompt with "NO"/ "YES" labels
|
||||
FORCE_INLINE static void confirm_screen(selectFunc_t yesFunc, selectFunc_t noFunc, PGM_P const pref, const char * const string=nullptr, PGM_P const suff=nullptr) {
|
||||
select_screen(GET_TEXT(MSG_YES), GET_TEXT(MSG_NO), yesFunc, noFunc, pref, string, suff);
|
||||
}
|
||||
};
|
||||
|
||||
// BACK_ITEM(LABEL)
|
||||
class MenuItem_back : public MenuItemBase {
|
||||
public:
|
||||
FORCE_INLINE static void draw(const bool sel, const uint8_t row, PGM_P const pstr) {
|
||||
_draw(sel, row, pstr, LCD_STR_UPLEVEL[0], LCD_STR_UPLEVEL[0]);
|
||||
}
|
||||
// Back Item action goes back one step in history
|
||||
FORCE_INLINE static void action(PGM_P const=nullptr) { ui.go_back(); }
|
||||
};
|
||||
|
||||
// SUBMENU(LABEL, screen_handler)
|
||||
class MenuItem_submenu : public MenuItemBase {
|
||||
public:
|
||||
FORCE_INLINE static void draw(const bool sel, const uint8_t row, PGM_P const pstr, ...) {
|
||||
_draw(sel, row, pstr, '>', LCD_STR_ARROW_RIGHT[0]);
|
||||
}
|
||||
static inline void action(PGM_P const, const screenFunc_t func) { ui.save_previous_screen(); ui.goto_screen(func); }
|
||||
};
|
||||
|
||||
// Any menu item that invokes an immediate action
|
||||
class MenuItem_button : public MenuItemBase {
|
||||
public:
|
||||
// Button-y Items are selectable lines with no other indicator
|
||||
static inline void draw(const bool sel, const uint8_t row, PGM_P const pstr, ...) {
|
||||
_draw(sel, row, pstr, '>', ' ');
|
||||
}
|
||||
};
|
||||
|
||||
// GCODES_ITEM(LABEL, GCODES)
|
||||
class MenuItem_gcode : public MenuItem_button {
|
||||
public:
|
||||
FORCE_INLINE static void draw(const bool sel, const uint8_t row, PGM_P const pstr, ...) {
|
||||
_draw(sel, row, pstr, '>', ' ');
|
||||
}
|
||||
static void action(PGM_P const, const char * const pgcode);
|
||||
static inline void action(PGM_P const pstr, const uint8_t, const char * const pgcode) { action(pstr, pgcode); }
|
||||
};
|
||||
|
||||
// ACTION_ITEM(LABEL, FUNC)
|
||||
class MenuItem_function : public MenuItem_button {
|
||||
public:
|
||||
//static inline void action(PGM_P const, const uint8_t, const menuAction_t func) { (*func)(); };
|
||||
static inline void action(PGM_P const, const menuAction_t func) { (*func)(); };
|
||||
};
|
||||
|
||||
#if ENABLED(SDSUPPORT)
|
||||
class CardReader;
|
||||
class MenuItem_sdbase {
|
||||
public:
|
||||
// Implemented for HD44780 and DOGM
|
||||
static void draw(const bool sel, const uint8_t row, PGM_P const pstr, CardReader &theCard, const bool isDir);
|
||||
};
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////
|
||||
///////////// Edit Menu Items //////////////
|
||||
////////////////////////////////////////////
|
||||
|
||||
// The Menu Edit shadow value
|
||||
typedef union {
|
||||
bool state;
|
||||
float decimal;
|
||||
int8_t int8;
|
||||
int16_t int16;
|
||||
int32_t int32;
|
||||
uint8_t uint8;
|
||||
uint16_t uint16;
|
||||
uint32_t uint32;
|
||||
} chimera_t;
|
||||
extern chimera_t editable;
|
||||
|
||||
// Base class for Menu Edit Items
|
||||
class MenuEditItemBase : public MenuItemBase {
|
||||
private:
|
||||
// These values are statically constructed by init() via action()
|
||||
// The action() method acts like the instantiator. The entire lifespan
|
||||
// of a menu item is within its declaration, so all these values decompose
|
||||
// into behavior and unused items get optimized out.
|
||||
static PGM_P editLabel;
|
||||
static void *editValue;
|
||||
static int32_t minEditValue, maxEditValue; // Encoder value range
|
||||
static screenFunc_t callbackFunc;
|
||||
static bool liveEdit;
|
||||
protected:
|
||||
typedef const char* (*strfunc_t)(const int32_t);
|
||||
typedef void (*loadfunc_t)(void *, const int32_t);
|
||||
static void goto_edit_screen(
|
||||
PGM_P const el, // Edit label
|
||||
void * const ev, // Edit value pointer
|
||||
const int32_t minv, // Encoder minimum
|
||||
const int32_t maxv, // Encoder maximum
|
||||
const uint16_t ep, // Initial encoder value
|
||||
const screenFunc_t cs, // MenuItem_type::draw_edit_screen => MenuEditItemBase::edit()
|
||||
const screenFunc_t cb, // Callback after edit
|
||||
const bool le // Flag to call cb() during editing
|
||||
);
|
||||
static void edit_screen(strfunc_t, loadfunc_t); // Edit value handler
|
||||
public:
|
||||
// Implemented for HD44780 and DOGM
|
||||
// Draw the current item at specified row with edit data
|
||||
static void draw(const bool sel, const uint8_t row, PGM_P const pstr, const char* const data, const bool pgm=false);
|
||||
|
||||
// Implemented for HD44780 and DOGM
|
||||
// This low-level method is good to draw from anywhere
|
||||
static void draw_edit_screen(PGM_P const pstr, const char* const value);
|
||||
|
||||
// This method is for the current menu item
|
||||
static inline void draw_edit_screen(const char* const value) { draw_edit_screen(editLabel, value); }
|
||||
};
|
||||
|
||||
// Template for specific Menu Edit Item Types
|
||||
template<typename NAME>
|
||||
class TMenuEditItem : MenuEditItemBase {
|
||||
private:
|
||||
typedef typename NAME::type_t type_t;
|
||||
static inline float scale(const float value) { return NAME::scale(value); }
|
||||
static inline float unscale(const float value) { return NAME::unscale(value); }
|
||||
static const char* to_string(const int32_t value) { return NAME::strfunc(unscale(value)); }
|
||||
static void load(void *ptr, const int32_t value) { *((type_t*)ptr) = unscale(value); }
|
||||
public:
|
||||
FORCE_INLINE static void draw(const bool sel, const uint8_t row, PGM_P const pstr, type_t * const data, ...) {
|
||||
MenuEditItemBase::draw(sel, row, pstr, NAME::strfunc(*(data)));
|
||||
}
|
||||
FORCE_INLINE static void draw(const bool sel, const uint8_t row, PGM_P const pstr, type_t (*pget)(), ...) {
|
||||
MenuEditItemBase::draw(sel, row, pstr, NAME::strfunc(pget()));
|
||||
}
|
||||
// Edit screen for this type of item
|
||||
static void edit_screen() { MenuEditItemBase::edit_screen(to_string, load); }
|
||||
static void action(
|
||||
PGM_P const pstr, // Edit label
|
||||
type_t * const ptr, // Value pointer
|
||||
const type_t minValue, // Value range
|
||||
const type_t maxValue,
|
||||
const screenFunc_t callback=nullptr, // Value update callback
|
||||
const bool live=false // Callback during editing
|
||||
) {
|
||||
// Make sure minv and maxv fit within int32_t
|
||||
const int32_t minv = _MAX(scale(minValue), INT32_MIN),
|
||||
maxv = _MIN(scale(maxValue), INT32_MAX);
|
||||
goto_edit_screen(pstr, ptr, minv, maxv - minv, scale(*ptr) - minv,
|
||||
edit_screen, callback, live);
|
||||
}
|
||||
};
|
||||
|
||||
// Provide a set of Edit Item Types which encompass a primitive
|
||||
// type, a string function, and a scale factor for edit and display.
|
||||
// These items call the Edit Item draw method passing the prepared string.
|
||||
#define __DOFIXfloat PROBE()
|
||||
#define _DOFIX(TYPE,V) TYPE(TERN(IS_PROBE(__DOFIX##TYPE),FIXFLOAT(V),(V)))
|
||||
#define DEFINE_MENU_EDIT_ITEM_TYPE(NAME, TYPE, STRFUNC, SCALE, V...) \
|
||||
struct MenuEditItemInfo_##NAME { \
|
||||
typedef TYPE type_t; \
|
||||
static inline float scale(const float value) { return value * (SCALE) + (V+0); } \
|
||||
static inline float unscale(const float value) { return value / (SCALE) + (V+0); } \
|
||||
static inline const char* strfunc(const float value) { return STRFUNC(_DOFIX(TYPE,value)); } \
|
||||
}; \
|
||||
typedef TMenuEditItem<MenuEditItemInfo_##NAME> MenuItem_##NAME
|
||||
|
||||
// NAME TYPE STRFUNC SCALE +ROUND
|
||||
DEFINE_MENU_EDIT_ITEM_TYPE(percent ,uint8_t ,ui8tostr4pctrj , 100.f/255.f, 0.5f); // 100% right-justified
|
||||
DEFINE_MENU_EDIT_ITEM_TYPE(int3 ,int16_t ,i16tostr3rj , 1 ); // 123, -12 right-justified
|
||||
DEFINE_MENU_EDIT_ITEM_TYPE(int4 ,int16_t ,i16tostr4signrj , 1 ); // 1234, -123 right-justified
|
||||
DEFINE_MENU_EDIT_ITEM_TYPE(int8 ,int8_t ,i8tostr3rj , 1 ); // 123, -12 right-justified
|
||||
DEFINE_MENU_EDIT_ITEM_TYPE(uint8 ,uint8_t ,ui8tostr3rj , 1 ); // 123 right-justified
|
||||
DEFINE_MENU_EDIT_ITEM_TYPE(uint16_3 ,uint16_t ,ui16tostr3rj , 1 ); // 123 right-justified
|
||||
DEFINE_MENU_EDIT_ITEM_TYPE(uint16_4 ,uint16_t ,ui16tostr4rj , 0.1f ); // 1234 right-justified
|
||||
DEFINE_MENU_EDIT_ITEM_TYPE(uint16_5 ,uint16_t ,ui16tostr5rj , 0.01f ); // 12345 right-justified
|
||||
DEFINE_MENU_EDIT_ITEM_TYPE(float3 ,float ,ftostr3 , 1 ); // 123 right-justified
|
||||
DEFINE_MENU_EDIT_ITEM_TYPE(float42_52 ,float ,ftostr42_52 , 100 ); // _2.34, 12.34, -2.34 or 123.45, -23.45
|
||||
DEFINE_MENU_EDIT_ITEM_TYPE(float43 ,float ,ftostr43sign ,1000 ); // -1.234, _1.234, +1.234
|
||||
DEFINE_MENU_EDIT_ITEM_TYPE(float5 ,float ,ftostr5rj , 1 ); // 12345 right-justified
|
||||
DEFINE_MENU_EDIT_ITEM_TYPE(float5_25 ,float ,ftostr5rj , 0.04f ); // 12345 right-justified (25 increment)
|
||||
DEFINE_MENU_EDIT_ITEM_TYPE(float51 ,float ,ftostr51rj , 10 ); // 1234.5 right-justified
|
||||
DEFINE_MENU_EDIT_ITEM_TYPE(float41sign ,float ,ftostr41sign , 10 ); // +123.4
|
||||
DEFINE_MENU_EDIT_ITEM_TYPE(float51sign ,float ,ftostr51sign , 10 ); // +1234.5
|
||||
DEFINE_MENU_EDIT_ITEM_TYPE(float52sign ,float ,ftostr52sign , 100 ); // +123.45
|
||||
DEFINE_MENU_EDIT_ITEM_TYPE(long5 ,uint32_t ,ftostr5rj , 0.01f ); // 12345 right-justified
|
||||
DEFINE_MENU_EDIT_ITEM_TYPE(long5_25 ,uint32_t ,ftostr5rj , 0.04f ); // 12345 right-justified (25 increment)
|
||||
|
||||
class MenuItem_bool : public MenuEditItemBase {
|
||||
public:
|
||||
FORCE_INLINE static void draw(const bool sel, const uint8_t row, PGM_P const pstr, const bool onoff) {
|
||||
MenuEditItemBase::draw(sel, row, pstr, onoff ? GET_TEXT(MSG_LCD_ON) : GET_TEXT(MSG_LCD_OFF), true);
|
||||
}
|
||||
FORCE_INLINE static void draw(const bool sel, const uint8_t row, PGM_P const pstr, bool * const data, ...) {
|
||||
draw(sel, row, pstr, *data);
|
||||
}
|
||||
FORCE_INLINE static void draw(const bool sel, const uint8_t row, PGM_P const pstr, PGM_P const, bool (*pget)(), ...) {
|
||||
draw(sel, row, pstr, pget());
|
||||
}
|
||||
static void action(PGM_P const pstr, bool * const ptr, const screenFunc_t callbackFunc=nullptr);
|
||||
};
|
||||
|
||||
////////////////////////////////////////////
|
||||
//////////// Menu System Macros ////////////
|
||||
////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* SCREEN_OR_MENU_LOOP generates init code for a screen or menu
|
||||
*
|
||||
* encoderTopLine is the top menu line to display
|
||||
* _lcdLineNr is the index of the LCD line (e.g., 0-3)
|
||||
* _menuLineNr is the menu item to draw and process
|
||||
* _thisItemNr is the index of each MENU_ITEM or STATIC_ITEM
|
||||
*/
|
||||
#define SCREEN_OR_MENU_LOOP(IS_MENU) \
|
||||
scroll_screen(IS_MENU ? 1 : LCD_HEIGHT, IS_MENU); \
|
||||
int8_t _menuLineNr = encoderTopLine, _thisItemNr = 0; \
|
||||
bool _skipStatic = IS_MENU; UNUSED(_thisItemNr); \
|
||||
for (int8_t _lcdLineNr = 0; _lcdLineNr < LCD_HEIGHT; _lcdLineNr++, _menuLineNr++) { \
|
||||
_thisItemNr = 0
|
||||
|
||||
/**
|
||||
* START_SCREEN Opening code for a screen having only static items.
|
||||
* Do simplified scrolling of the entire screen.
|
||||
*
|
||||
* START_MENU Opening code for a screen with menu items.
|
||||
* Scroll as-needed to keep the selected line in view.
|
||||
*/
|
||||
#define START_SCREEN() SCREEN_OR_MENU_LOOP(false)
|
||||
#define START_MENU() SCREEN_OR_MENU_LOOP(true)
|
||||
#define NEXT_ITEM() (++_thisItemNr)
|
||||
#define SKIP_ITEM() NEXT_ITEM()
|
||||
#define END_SCREEN() } screen_items = _thisItemNr
|
||||
#define END_MENU() END_SCREEN(); UNUSED(_skipStatic)
|
||||
|
||||
#if ENABLED(ENCODER_RATE_MULTIPLIER)
|
||||
#define ENCODER_RATE_MULTIPLY(F) (ui.encoderRateMultiplierEnabled = F)
|
||||
#define _MENU_ITEM_MULTIPLIER_CHECK(USE_MULTIPLIER) do{ if (USE_MULTIPLIER) ui.enable_encoder_multiplier(true); }while(0)
|
||||
//#define ENCODER_RATE_MULTIPLIER_DEBUG // If defined, output the encoder steps per second value
|
||||
#else
|
||||
#define ENCODER_RATE_MULTIPLY(F) NOOP
|
||||
#define _MENU_ITEM_MULTIPLIER_CHECK(USE_MULTIPLIER)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* MENU_ITEM generates draw & handler code for a menu item, potentially calling:
|
||||
*
|
||||
* MenuItem_<type>::draw(sel, row, label, arg3...)
|
||||
* MenuItem_<type>::action(arg3...)
|
||||
*
|
||||
* Examples:
|
||||
* BACK_ITEM(MSG_INFO_SCREEN)
|
||||
* MenuItem_back::action(plabel, ...)
|
||||
* MenuItem_back::draw(sel, row, plabel, ...)
|
||||
*
|
||||
* ACTION_ITEM(MSG_PAUSE_PRINT, lcd_sdcard_pause)
|
||||
* MenuItem_function::action(plabel, lcd_sdcard_pause)
|
||||
* MenuItem_function::draw(sel, row, plabel, lcd_sdcard_pause)
|
||||
*
|
||||
* EDIT_ITEM(int3, MSG_SPEED, &feedrate_percentage, 10, 999)
|
||||
* MenuItem_int3::action(plabel, &feedrate_percentage, 10, 999)
|
||||
* MenuItem_int3::draw(sel, row, plabel, &feedrate_percentage, 10, 999)
|
||||
*/
|
||||
|
||||
#define _MENU_INNER_P(TYPE, USE_MULTIPLIER, PLABEL, V...) do { \
|
||||
PGM_P const plabel = PLABEL; \
|
||||
if (encoderLine == _thisItemNr && ui.use_click()) { \
|
||||
_MENU_ITEM_MULTIPLIER_CHECK(USE_MULTIPLIER); \
|
||||
MenuItem_##TYPE::action(plabel, ##V); \
|
||||
if (ui.screen_changed) return; \
|
||||
} \
|
||||
if (ui.should_draw()) \
|
||||
MenuItem_##TYPE::draw \
|
||||
(encoderLine == _thisItemNr, _lcdLineNr, plabel, ##V); \
|
||||
}while(0)
|
||||
|
||||
#define _MENU_ITEM_P(TYPE, V...) do { \
|
||||
_skipStatic = false; \
|
||||
if (_menuLineNr == _thisItemNr) \
|
||||
_MENU_INNER_P(TYPE, ##V); \
|
||||
NEXT_ITEM(); \
|
||||
}while(0)
|
||||
|
||||
// Indexed items set a global index value
|
||||
#define _MENU_ITEM_N_P(TYPE, N, V...) do{ \
|
||||
_skipStatic = false; \
|
||||
if (_menuLineNr == _thisItemNr) { \
|
||||
MenuItemBase::init(N); \
|
||||
_MENU_INNER_P(TYPE, ##V); \
|
||||
} \
|
||||
NEXT_ITEM(); \
|
||||
}while(0)
|
||||
|
||||
// STATIC_ITEM draws a styled string with no highlight.
|
||||
// Parameters: label [, style [, char *value] ]
|
||||
|
||||
#define STATIC_ITEM_INNER_P(PLABEL, V...) do{ \
|
||||
if (_skipStatic && encoderLine <= _thisItemNr) { \
|
||||
ui.encoderPosition += ENCODER_STEPS_PER_MENU_ITEM; \
|
||||
++encoderLine; \
|
||||
} \
|
||||
if (ui.should_draw()) \
|
||||
MenuItem_static::draw(_lcdLineNr, PLABEL, ##V); \
|
||||
} while(0)
|
||||
|
||||
#define STATIC_ITEM_P(PLABEL, V...) do{ \
|
||||
if (_menuLineNr == _thisItemNr) \
|
||||
STATIC_ITEM_INNER_P(PLABEL, ##V); \
|
||||
NEXT_ITEM(); \
|
||||
} while(0)
|
||||
|
||||
#define STATIC_ITEM_N_P(PLABEL, N, V...) do{ \
|
||||
if (_menuLineNr == _thisItemNr) { \
|
||||
MenuItemBase::init(N); \
|
||||
STATIC_ITEM_INNER_P(PLABEL, ##V); \
|
||||
} \
|
||||
NEXT_ITEM(); \
|
||||
}while(0)
|
||||
|
||||
#define STATIC_ITEM(LABEL, V...) STATIC_ITEM_P( GET_TEXT(LABEL), ##V)
|
||||
#define STATIC_ITEM_N(LABEL, N, V...) STATIC_ITEM_N_P(GET_TEXT(LABEL), ##V)
|
||||
|
||||
#define MENU_ITEM_P(TYPE, PLABEL, V...) _MENU_ITEM_P(TYPE, false, PLABEL, ##V)
|
||||
#define MENU_ITEM(TYPE, LABEL, V...) MENU_ITEM_P(TYPE, GET_TEXT(LABEL), ##V)
|
||||
|
||||
#define MENU_ITEM_N_P(TYPE, N, PLABEL, V...) _MENU_ITEM_N_P(TYPE, N, false, PLABEL, ##V)
|
||||
#define MENU_ITEM_N(TYPE, N, LABEL, V...) MENU_ITEM_N_P(TYPE, N, GET_TEXT(LABEL), ##V)
|
||||
|
||||
#define BACK_ITEM(LABEL) MENU_ITEM(back, LABEL)
|
||||
|
||||
#define ACTION_ITEM_P(PLABEL, ACTION) MENU_ITEM_P(function, PLABEL, ACTION)
|
||||
#define ACTION_ITEM(LABEL, ACTION) ACTION_ITEM_P(GET_TEXT(LABEL), ACTION)
|
||||
|
||||
#define ACTION_ITEM_N_P(N, PLABEL, ACTION) MENU_ITEM_N_P(function, N, PLABEL, ACTION)
|
||||
#define ACTION_ITEM_N(N, LABEL, ACTION) ACTION_ITEM_N_P(N, GET_TEXT(LABEL), ACTION)
|
||||
|
||||
#define GCODES_ITEM_P(PLABEL, GCODES) MENU_ITEM_P(gcode, PLABEL, GCODES)
|
||||
#define GCODES_ITEM(LABEL, GCODES) GCODES_ITEM_P(GET_TEXT(LABEL), GCODES)
|
||||
|
||||
#define GCODES_ITEM_N_P(N, PLABEL, GCODES) MENU_ITEM_N_P(gcode, N, PLABEL, GCODES)
|
||||
#define GCODES_ITEM_N(N, LABEL, GCODES) GCODES_ITEM_N_P(N, GET_TEXT(LABEL), GCODES)
|
||||
|
||||
#define SUBMENU_P(PLABEL, DEST) MENU_ITEM_P(submenu, PLABEL, DEST)
|
||||
#define SUBMENU(LABEL, DEST) SUBMENU_P(GET_TEXT(LABEL), DEST)
|
||||
|
||||
#define SUBMENU_N_P(N, PLABEL, DEST) MENU_ITEM_N_P(submenu, N, PLABEL, DEST)
|
||||
#define SUBMENU_N(N, LABEL, DEST) SUBMENU_N_P(N, GET_TEXT(LABEL), DEST)
|
||||
|
||||
#define EDIT_ITEM_P(TYPE, PLABEL, V...) MENU_ITEM_P(TYPE, PLABEL, ##V)
|
||||
#define EDIT_ITEM(TYPE, LABEL, V...) EDIT_ITEM_P(TYPE, GET_TEXT(LABEL), ##V)
|
||||
|
||||
#define EDIT_ITEM_N_P(TYPE, N, PLABEL, V...) MENU_ITEM_N_P(TYPE, N, PLABEL, ##V)
|
||||
#define EDIT_ITEM_N(TYPE, N, LABEL, V...) EDIT_ITEM_N_P(TYPE, N, GET_TEXT(LABEL), ##V)
|
||||
|
||||
#define EDIT_ITEM_FAST_P(TYPE, PLABEL, V...) _MENU_ITEM_P(TYPE, true, PLABEL, ##V)
|
||||
#define EDIT_ITEM_FAST(TYPE, LABEL, V...) EDIT_ITEM_FAST_P(TYPE, GET_TEXT(LABEL), ##V)
|
||||
|
||||
#define EDIT_ITEM_FAST_N_P(TYPE, N, PLABEL, V...) _MENU_ITEM_N_P(TYPE, N, true, PLABEL, ##V)
|
||||
#define EDIT_ITEM_FAST_N(TYPE, N, LABEL, V...) EDIT_ITEM_FAST_N_P(TYPE, N, GET_TEXT(LABEL), ##V)
|
||||
|
||||
#define _CONFIRM_ITEM_INNER_P(PLABEL, V...) do { \
|
||||
if (encoderLine == _thisItemNr && ui.use_click()) { \
|
||||
ui.goto_screen([]{MenuItem_confirm::select_screen(V);}); \
|
||||
return; \
|
||||
} \
|
||||
if (ui.should_draw()) MenuItem_confirm::draw \
|
||||
(encoderLine == _thisItemNr, _lcdLineNr, PLABEL, ##V); \
|
||||
}while(0)
|
||||
|
||||
#define _CONFIRM_ITEM_P(PLABEL, V...) do { \
|
||||
_skipStatic = false; \
|
||||
if (_menuLineNr == _thisItemNr) \
|
||||
_CONFIRM_ITEM_INNER_P(PLABEL, ##V); \
|
||||
NEXT_ITEM(); \
|
||||
}while(0)
|
||||
|
||||
// Indexed items set a global index value
|
||||
#define _CONFIRM_ITEM_N_P(N, V...) do{ \
|
||||
_skipStatic = false; \
|
||||
if (_menuLineNr == _thisItemNr) { \
|
||||
MenuItemBase::init(N); \
|
||||
_CONFIRM_ITEM_INNER_P(TYPE, ##V); \
|
||||
} \
|
||||
NEXT_ITEM(); \
|
||||
}while(0)
|
||||
|
||||
#define CONFIRM_ITEM_P(PLABEL,A,B,V...) _CONFIRM_ITEM_P(PLABEL, GET_TEXT(A), GET_TEXT(B), ##V)
|
||||
#define CONFIRM_ITEM(LABEL, V...) CONFIRM_ITEM_P(GET_TEXT(LABEL), ##V)
|
||||
|
||||
#define YESNO_ITEM_P(PLABEL, V...) _CONFIRM_ITEM_P(PLABEL, ##V)
|
||||
#define YESNO_ITEM(LABEL, V...) YESNO_ITEM_P(GET_TEXT(LABEL), ##V)
|
||||
|
||||
#define CONFIRM_ITEM_N_P(N,PLABEL,A,B,V...) _CONFIRM_ITEM_N_P(N, PLABEL, GET_TEXT(A), GET_TEXT(B), ##V)
|
||||
#define CONFIRM_ITEM_N(N,LABEL, V...) CONFIRM_ITEM_N_P(N, GET_TEXT(LABEL), ##V)
|
||||
|
||||
#define YESNO_ITEM_N_P(N,PLABEL, V...) _CONFIRM_ITEM_N_P(N, PLABEL, ##V)
|
||||
#define YESNO_ITEM_N(N,LABEL, V...) YESNO_ITEM_N_P(N, GET_TEXT(LABEL), ##V)
|
||||
|
||||
////////////////////////////////////////////
|
||||
/////////////// Menu Screens ///////////////
|
||||
////////////////////////////////////////////
|
||||
|
||||
void menu_main();
|
||||
void menu_move();
|
||||
|
||||
#if ENABLED(SDSUPPORT)
|
||||
void menu_media();
|
||||
#endif
|
||||
|
||||
// First Fan Speed title in "Tune" and "Control>Temperature" menus
|
||||
#if FAN_COUNT > 0 && HAS_FAN0
|
||||
#if FAN_COUNT > 1
|
||||
#define FAN_SPEED_1_SUFFIX " 1"
|
||||
#else
|
||||
#define FAN_SPEED_1_SUFFIX ""
|
||||
#endif
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////
|
||||
//////// Menu Item Helper Functions ////////
|
||||
////////////////////////////////////////////
|
||||
|
||||
void lcd_move_z();
|
||||
void _lcd_draw_homing();
|
||||
|
||||
#define HAS_LINE_TO_Z ANY(DELTA, PROBE_MANUALLY, MESH_BED_LEVELING, LEVEL_BED_CORNERS)
|
||||
|
||||
#if HAS_LINE_TO_Z
|
||||
void line_to_z(const float &z);
|
||||
#endif
|
||||
|
||||
#if ANY(AUTO_BED_LEVELING_UBL, PID_AUTOTUNE_MENU, ADVANCED_PAUSE_FEATURE)
|
||||
void lcd_enqueue_one_now(const char * const cmd);
|
||||
void lcd_enqueue_one_now_P(PGM_P const cmd);
|
||||
#endif
|
||||
|
||||
#if HAS_GRAPHICAL_LCD && EITHER(BABYSTEP_ZPROBE_GFX_OVERLAY, MESH_EDIT_GFX_OVERLAY)
|
||||
void _lcd_zoffset_overlay_gfx(const float zvalue);
|
||||
#endif
|
||||
|
||||
#if ENABLED(LEVEL_BED_CORNERS)
|
||||
void _lcd_level_bed_corners();
|
||||
#endif
|
||||
|
||||
#if ENABLED(LCD_BED_LEVELING) || (HAS_LEVELING && DISABLED(SLIM_LCD_MENUS))
|
||||
void _lcd_toggle_bed_leveling();
|
||||
#endif
|
||||
|
||||
#if ENABLED(BABYSTEPPING)
|
||||
#if ENABLED(BABYSTEP_ZPROBE_OFFSET)
|
||||
void lcd_babystep_zoffset();
|
||||
#else
|
||||
void lcd_babystep_z();
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if ENABLED(EEPROM_SETTINGS)
|
||||
void lcd_store_settings();
|
||||
void lcd_load_settings();
|
||||
#endif
|
||||
|
||||
#if ENABLED(POWER_LOSS_RECOVERY)
|
||||
void menu_job_recovery();
|
||||
#endif
|
33
Marlin/src/lcd/menu/menu_addon.h
Executable file
33
Marlin/src/lcd/menu/menu_addon.h
Executable file
@@ -0,0 +1,33 @@
|
||||
/**
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "../lcdprint.h"
|
||||
#if HAS_GRAPHICAL_LCD
|
||||
#include "../dogm/ultralcd_DOGM.h"
|
||||
#endif
|
||||
|
||||
#define MENU_ITEM_ADDON_START(X) do{ \
|
||||
if (ui.should_draw() && _menuLineNr == _thisItemNr - 1) { \
|
||||
SETCURSOR(X, _lcdLineNr)
|
||||
|
||||
#define MENU_ITEM_ADDON_END() } }while(0)
|
605
Marlin/src/lcd/menu/menu_advanced.cpp
Executable file
605
Marlin/src/lcd/menu/menu_advanced.cpp
Executable file
@@ -0,0 +1,605 @@
|
||||
/**
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
//
|
||||
// Advanced Settings Menus
|
||||
//
|
||||
|
||||
#include "../../inc/MarlinConfigPre.h"
|
||||
|
||||
#if HAS_LCD_MENU
|
||||
|
||||
#include "menu.h"
|
||||
#include "../../module/planner.h"
|
||||
|
||||
#if DISABLED(NO_VOLUMETRICS)
|
||||
#include "../../gcode/parser.h"
|
||||
#endif
|
||||
|
||||
#if HAS_BED_PROBE
|
||||
#include "../../module/probe.h"
|
||||
#endif
|
||||
|
||||
#if ENABLED(PIDTEMP)
|
||||
#include "../../module/temperature.h"
|
||||
#endif
|
||||
|
||||
#if ENABLED(FILAMENT_RUNOUT_SENSOR) && FILAMENT_RUNOUT_DISTANCE_MM
|
||||
#include "../../feature/runout.h"
|
||||
float lcd_runout_distance_mm;
|
||||
#endif
|
||||
|
||||
#if ENABLED(EEPROM_SETTINGS) && DISABLED(SLIM_LCD_MENUS)
|
||||
#include "../../module/configuration_store.h"
|
||||
#endif
|
||||
|
||||
void menu_tmc();
|
||||
void menu_backlash();
|
||||
void menu_cancelobject();
|
||||
|
||||
#if ENABLED(DAC_STEPPER_CURRENT)
|
||||
|
||||
#include "../../feature/dac/stepper_dac.h"
|
||||
|
||||
void menu_dac() {
|
||||
static xyze_uint8_t driverPercent;
|
||||
LOOP_XYZE(i) driverPercent[i] = dac_current_get_percent((AxisEnum)i);
|
||||
START_MENU();
|
||||
BACK_ITEM(MSG_ADVANCED_SETTINGS);
|
||||
#define EDIT_DAC_PERCENT(A) EDIT_ITEM(uint8, MSG_DAC_PERCENT_##A, &driverPercent[_AXIS(A)], 0, 100, []{ dac_current_set_percents(driverPercent); })
|
||||
EDIT_DAC_PERCENT(X);
|
||||
EDIT_DAC_PERCENT(Y);
|
||||
EDIT_DAC_PERCENT(Z);
|
||||
EDIT_DAC_PERCENT(E);
|
||||
ACTION_ITEM(MSG_DAC_EEPROM_WRITE, dac_commit_eeprom);
|
||||
END_MENU();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if HAS_MOTOR_CURRENT_PWM
|
||||
|
||||
#include "../../module/stepper.h"
|
||||
|
||||
void menu_pwm() {
|
||||
START_MENU();
|
||||
BACK_ITEM(MSG_ADVANCED_SETTINGS);
|
||||
#define EDIT_CURRENT_PWM(LABEL,I) EDIT_ITEM_P(long5, PSTR(LABEL), &stepper.motor_current_setting[I], 100, 2000, stepper.refresh_motor_power)
|
||||
#if ANY_PIN(MOTOR_CURRENT_PWM_XY, MOTOR_CURRENT_PWM_X, MOTOR_CURRENT_PWM_Y)
|
||||
EDIT_CURRENT_PWM(STR_X STR_Y, 0);
|
||||
#endif
|
||||
#if PIN_EXISTS(MOTOR_CURRENT_PWM_Z)
|
||||
EDIT_CURRENT_PWM(STR_Z, 1);
|
||||
#endif
|
||||
#if PIN_EXISTS(MOTOR_CURRENT_PWM_E)
|
||||
EDIT_CURRENT_PWM(STR_E, 2);
|
||||
#endif
|
||||
END_MENU();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if ENABLED(SD_FIRMWARE_UPDATE)
|
||||
#include "../../module/configuration_store.h"
|
||||
#endif
|
||||
|
||||
#if DISABLED(NO_VOLUMETRICS) || ENABLED(ADVANCED_PAUSE_FEATURE)
|
||||
//
|
||||
// Advanced Settings > Filament
|
||||
//
|
||||
void menu_advanced_filament() {
|
||||
START_MENU();
|
||||
BACK_ITEM(MSG_ADVANCED_SETTINGS);
|
||||
|
||||
#if ENABLED(LIN_ADVANCE)
|
||||
#if EXTRUDERS == 1
|
||||
EDIT_ITEM(float42_52, MSG_ADVANCE_K, &planner.extruder_advance_K[0], 0, 999);
|
||||
#elif EXTRUDERS > 1
|
||||
LOOP_L_N(n, EXTRUDERS)
|
||||
EDIT_ITEM_N(float42_52, n, MSG_ADVANCE_K_E, &planner.extruder_advance_K[n], 0, 999);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if DISABLED(NO_VOLUMETRICS)
|
||||
EDIT_ITEM(bool, MSG_VOLUMETRIC_ENABLED, &parser.volumetric_enabled, planner.calculate_volumetric_multipliers);
|
||||
|
||||
if (parser.volumetric_enabled) {
|
||||
EDIT_ITEM_FAST(float43, MSG_FILAMENT_DIAM, &planner.filament_size[active_extruder], 1.5f, 3.25f, planner.calculate_volumetric_multipliers);
|
||||
#if EXTRUDERS > 1
|
||||
LOOP_L_N(n, EXTRUDERS)
|
||||
EDIT_ITEM_FAST_N(float43, n, MSG_FILAMENT_DIAM_E, &planner.filament_size[n], 1.5f, 3.25f, planner.calculate_volumetric_multipliers);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#if ENABLED(ADVANCED_PAUSE_FEATURE)
|
||||
constexpr float extrude_maxlength =
|
||||
#if ENABLED(PREVENT_LENGTHY_EXTRUDE)
|
||||
EXTRUDE_MAXLENGTH
|
||||
#else
|
||||
999
|
||||
#endif
|
||||
;
|
||||
|
||||
EDIT_ITEM_FAST(float3, MSG_FILAMENT_UNLOAD, &fc_settings[active_extruder].unload_length, 0, extrude_maxlength);
|
||||
#if EXTRUDERS > 1
|
||||
LOOP_L_N(n, EXTRUDERS)
|
||||
EDIT_ITEM_FAST_N(float3, n, MSG_FILAMENTUNLOAD_E, &fc_settings[n].unload_length, 0, extrude_maxlength);
|
||||
#endif
|
||||
|
||||
EDIT_ITEM_FAST(float3, MSG_FILAMENT_LOAD, &fc_settings[active_extruder].load_length, 0, extrude_maxlength);
|
||||
#if EXTRUDERS > 1
|
||||
LOOP_L_N(n, EXTRUDERS)
|
||||
EDIT_ITEM_FAST_N(float3, n, MSG_FILAMENTLOAD_E, &fc_settings[n].load_length, 0, extrude_maxlength);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if ENABLED(FILAMENT_RUNOUT_SENSOR) && FILAMENT_RUNOUT_DISTANCE_MM
|
||||
EDIT_ITEM(float3, MSG_RUNOUT_DISTANCE_MM, &lcd_runout_distance_mm, 1, 30, []{
|
||||
runout.set_runout_distance(lcd_runout_distance_mm);
|
||||
});
|
||||
#endif
|
||||
|
||||
END_MENU();
|
||||
}
|
||||
|
||||
#endif // !NO_VOLUMETRICS || ADVANCED_PAUSE_FEATURE
|
||||
|
||||
//
|
||||
// Advanced Settings > Temperature helpers
|
||||
//
|
||||
|
||||
#if ENABLED(PID_AUTOTUNE_MENU)
|
||||
|
||||
#if ENABLED(PIDTEMP)
|
||||
int16_t autotune_temp[HOTENDS] = ARRAY_BY_HOTENDS1(150);
|
||||
#endif
|
||||
|
||||
#if ENABLED(PIDTEMPBED)
|
||||
int16_t autotune_temp_bed = 70;
|
||||
#endif
|
||||
|
||||
void _lcd_autotune(const int16_t e) {
|
||||
char cmd[30];
|
||||
sprintf_P(cmd, PSTR("M303 U1 E%i S%i"), e,
|
||||
#if HAS_PID_FOR_BOTH
|
||||
e < 0 ? autotune_temp_bed : autotune_temp[e]
|
||||
#elif ENABLED(PIDTEMPBED)
|
||||
autotune_temp_bed
|
||||
#else
|
||||
autotune_temp[e]
|
||||
#endif
|
||||
);
|
||||
lcd_enqueue_one_now(cmd);
|
||||
}
|
||||
|
||||
#endif // PID_AUTOTUNE_MENU
|
||||
|
||||
#if ENABLED(PID_EDIT_MENU)
|
||||
|
||||
float raw_Ki, raw_Kd; // place-holders for Ki and Kd edits
|
||||
|
||||
// Helpers for editing PID Ki & Kd values
|
||||
// grab the PID value out of the temp variable; scale it; then update the PID driver
|
||||
void copy_and_scalePID_i(int16_t e) {
|
||||
#if DISABLED(PID_PARAMS_PER_HOTEND) || HOTENDS == 1
|
||||
UNUSED(e);
|
||||
#endif
|
||||
PID_PARAM(Ki, e) = scalePID_i(raw_Ki);
|
||||
thermalManager.updatePID();
|
||||
}
|
||||
void copy_and_scalePID_d(int16_t e) {
|
||||
#if DISABLED(PID_PARAMS_PER_HOTEND) || HOTENDS == 1
|
||||
UNUSED(e);
|
||||
#endif
|
||||
PID_PARAM(Kd, e) = scalePID_d(raw_Kd);
|
||||
thermalManager.updatePID();
|
||||
}
|
||||
|
||||
#define _DEFINE_PIDTEMP_BASE_FUNCS(N) \
|
||||
void copy_and_scalePID_i_E##N() { copy_and_scalePID_i(N); } \
|
||||
void copy_and_scalePID_d_E##N() { copy_and_scalePID_d(N); }
|
||||
|
||||
#else
|
||||
|
||||
#define _DEFINE_PIDTEMP_BASE_FUNCS(N) //
|
||||
|
||||
#endif
|
||||
|
||||
#if ENABLED(PID_AUTOTUNE_MENU)
|
||||
#define DEFINE_PIDTEMP_FUNCS(N) \
|
||||
_DEFINE_PIDTEMP_BASE_FUNCS(N); \
|
||||
void lcd_autotune_callback_E##N() { _lcd_autotune(N); }
|
||||
#else
|
||||
#define DEFINE_PIDTEMP_FUNCS(N) _DEFINE_PIDTEMP_BASE_FUNCS(N);
|
||||
#endif
|
||||
|
||||
#if HOTENDS
|
||||
DEFINE_PIDTEMP_FUNCS(0);
|
||||
#if HOTENDS > 1 && ENABLED(PID_PARAMS_PER_HOTEND)
|
||||
REPEAT_S(1, HOTENDS, DEFINE_PIDTEMP_FUNCS)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define SHOW_MENU_ADVANCED_TEMPERATURE ((ENABLED(AUTOTEMP) && HAS_TEMP_HOTEND) || EITHER(PID_AUTOTUNE_MENU, PID_EDIT_MENU))
|
||||
|
||||
//
|
||||
// Advanced Settings > Temperature
|
||||
//
|
||||
#if SHOW_MENU_ADVANCED_TEMPERATURE
|
||||
|
||||
void menu_advanced_temperature() {
|
||||
START_MENU();
|
||||
BACK_ITEM(MSG_ADVANCED_SETTINGS);
|
||||
//
|
||||
// Autotemp, Min, Max, Fact
|
||||
//
|
||||
#if ENABLED(AUTOTEMP) && HAS_TEMP_HOTEND
|
||||
EDIT_ITEM(bool, MSG_AUTOTEMP, &planner.autotemp_enabled);
|
||||
EDIT_ITEM(float3, MSG_MIN, &planner.autotemp_min, 0, float(HEATER_0_MAXTEMP) - 15);
|
||||
EDIT_ITEM(float3, MSG_MAX, &planner.autotemp_max, 0, float(HEATER_0_MAXTEMP) - 15);
|
||||
EDIT_ITEM(float42_52, MSG_FACTOR, &planner.autotemp_factor, 0, 10);
|
||||
#endif
|
||||
|
||||
//
|
||||
// PID-P, PID-I, PID-D, PID-C, PID Autotune
|
||||
// PID-P E1, PID-I E1, PID-D E1, PID-C E1, PID Autotune E1
|
||||
// PID-P E2, PID-I E2, PID-D E2, PID-C E2, PID Autotune E2
|
||||
// PID-P E3, PID-I E3, PID-D E3, PID-C E3, PID Autotune E3
|
||||
// PID-P E4, PID-I E4, PID-D E4, PID-C E4, PID Autotune E4
|
||||
// PID-P E5, PID-I E5, PID-D E5, PID-C E5, PID Autotune E5
|
||||
//
|
||||
|
||||
#if ENABLED(PID_EDIT_MENU)
|
||||
#define __PID_BASE_MENU_ITEMS(N) \
|
||||
raw_Ki = unscalePID_i(PID_PARAM(Ki, N)); \
|
||||
raw_Kd = unscalePID_d(PID_PARAM(Kd, N)); \
|
||||
EDIT_ITEM_N(float52sign, N, MSG_PID_P_E, &PID_PARAM(Kp, N), 1, 9990); \
|
||||
EDIT_ITEM_N(float52sign, N, MSG_PID_I_E, &raw_Ki, 0.01f, 9990, []{ copy_and_scalePID_i(N); }); \
|
||||
EDIT_ITEM_N(float52sign, N, MSG_PID_D_E, &raw_Kd, 1, 9990, []{ copy_and_scalePID_d(N); })
|
||||
|
||||
#if ENABLED(PID_EXTRUSION_SCALING)
|
||||
#define _PID_BASE_MENU_ITEMS(N) \
|
||||
__PID_BASE_MENU_ITEMS(N); \
|
||||
EDIT_ITEM_N(float3, N, MSG_PID_C_E, &PID_PARAM(Kc, N), 1, 9990)
|
||||
#else
|
||||
#define _PID_BASE_MENU_ITEMS(N) __PID_BASE_MENU_ITEMS(N)
|
||||
#endif
|
||||
|
||||
#if ENABLED(PID_FAN_SCALING)
|
||||
#define _PID_EDIT_MENU_ITEMS(N) \
|
||||
_PID_BASE_MENU_ITEMS(N); \
|
||||
EDIT_ITEM_N(float3, N, MSG_PID_F_E, &PID_PARAM(Kf, N), 1, 9990)
|
||||
#else
|
||||
#define _PID_EDIT_MENU_ITEMS(N) _PID_BASE_MENU_ITEMS(N)
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
#define _PID_EDIT_MENU_ITEMS(N) NOOP
|
||||
|
||||
#endif
|
||||
|
||||
#if ENABLED(PID_AUTOTUNE_MENU)
|
||||
#define PID_EDIT_MENU_ITEMS(N) \
|
||||
_PID_EDIT_MENU_ITEMS(N); \
|
||||
EDIT_ITEM_FAST_N(int3, N, MSG_PID_AUTOTUNE_E, &autotune_temp[N], 150, heater_maxtemp[N] - 15, []{ _lcd_autotune(MenuItemBase::itemIndex); });
|
||||
#else
|
||||
#define PID_EDIT_MENU_ITEMS(N) _PID_EDIT_MENU_ITEMS(N);
|
||||
#endif
|
||||
|
||||
PID_EDIT_MENU_ITEMS(0);
|
||||
#if HOTENDS > 1 && ENABLED(PID_PARAMS_PER_HOTEND)
|
||||
REPEAT_S(1, HOTENDS, PID_EDIT_MENU_ITEMS)
|
||||
#endif
|
||||
|
||||
END_MENU();
|
||||
}
|
||||
|
||||
#endif // SHOW_MENU_ADVANCED_TEMPERATURE
|
||||
|
||||
#if DISABLED(SLIM_LCD_MENUS)
|
||||
|
||||
#if ENABLED(DISTINCT_E_FACTORS)
|
||||
inline void _reset_e_acceleration_rate(const uint8_t e) { if (e == active_extruder) planner.reset_acceleration_rates(); }
|
||||
inline void _planner_refresh_e_positioning(const uint8_t e) {
|
||||
if (e == active_extruder)
|
||||
planner.refresh_positioning();
|
||||
else
|
||||
planner.steps_to_mm[E_AXIS_N(e)] = 1.0f / planner.settings.axis_steps_per_mm[E_AXIS_N(e)];
|
||||
}
|
||||
#endif
|
||||
|
||||
// M203 / M205 Velocity options
|
||||
void menu_advanced_velocity() {
|
||||
START_MENU();
|
||||
BACK_ITEM(MSG_ADVANCED_SETTINGS);
|
||||
|
||||
// M203 Max Feedrate
|
||||
constexpr xyze_feedrate_t max_fr_edit =
|
||||
#ifdef MAX_FEEDRATE_EDIT_VALUES
|
||||
MAX_FEEDRATE_EDIT_VALUES
|
||||
#elif ENABLED(LIMITED_MAX_FR_EDITING)
|
||||
DEFAULT_MAX_FEEDRATE
|
||||
#else
|
||||
{ 999, 999, 999, 999 }
|
||||
#endif
|
||||
;
|
||||
#if ENABLED(LIMITED_MAX_FR_EDITING) && !defined(MAX_FEEDRATE_EDIT_VALUES)
|
||||
const xyze_feedrate_t max_fr_edit_scaled = max_fr_edit * 2;
|
||||
#else
|
||||
const xyze_feedrate_t &max_fr_edit_scaled = max_fr_edit;
|
||||
#endif
|
||||
#define EDIT_VMAX(N) EDIT_ITEM_FAST(float3, MSG_VMAX_##N, &planner.settings.max_feedrate_mm_s[_AXIS(N)], 1, max_fr_edit_scaled[_AXIS(N)])
|
||||
EDIT_VMAX(A);
|
||||
EDIT_VMAX(B);
|
||||
EDIT_VMAX(C);
|
||||
|
||||
#if E_STEPPERS
|
||||
EDIT_ITEM_FAST(float3, MSG_VMAX_E, &planner.settings.max_feedrate_mm_s[E_AXIS_N(active_extruder)], 1, max_fr_edit_scaled.e);
|
||||
#endif
|
||||
#if ENABLED(DISTINCT_E_FACTORS)
|
||||
LOOP_L_N(n, E_STEPPERS)
|
||||
EDIT_ITEM_FAST_N(float3, n, MSG_VMAX_EN, &planner.settings.max_feedrate_mm_s[E_AXIS_N(n)], 1, max_fr_edit_scaled.e);
|
||||
#endif
|
||||
|
||||
// M205 S Min Feedrate
|
||||
EDIT_ITEM_FAST(float3, MSG_VMIN, &planner.settings.min_feedrate_mm_s, 0, 999);
|
||||
|
||||
// M205 T Min Travel Feedrate
|
||||
EDIT_ITEM_FAST(float3, MSG_VTRAV_MIN, &planner.settings.min_travel_feedrate_mm_s, 0, 999);
|
||||
|
||||
END_MENU();
|
||||
}
|
||||
|
||||
// M201 / M204 Accelerations
|
||||
void menu_advanced_acceleration() {
|
||||
START_MENU();
|
||||
BACK_ITEM(MSG_ADVANCED_SETTINGS);
|
||||
|
||||
const float max_accel = _MAX(planner.settings.max_acceleration_mm_per_s2[A_AXIS], planner.settings.max_acceleration_mm_per_s2[B_AXIS], planner.settings.max_acceleration_mm_per_s2[C_AXIS]);
|
||||
// M204 P Acceleration
|
||||
EDIT_ITEM_FAST(float5_25, MSG_ACC, &planner.settings.acceleration, 25, max_accel);
|
||||
|
||||
// M204 R Retract Acceleration
|
||||
EDIT_ITEM_FAST(float5, MSG_A_RETRACT, &planner.settings.retract_acceleration, 100, planner.settings.max_acceleration_mm_per_s2[E_AXIS_N(active_extruder)]);
|
||||
|
||||
// M204 T Travel Acceleration
|
||||
EDIT_ITEM_FAST(float5_25, MSG_A_TRAVEL, &planner.settings.travel_acceleration, 25, max_accel);
|
||||
|
||||
// M201 settings
|
||||
constexpr xyze_ulong_t max_accel_edit =
|
||||
#ifdef MAX_ACCEL_EDIT_VALUES
|
||||
MAX_ACCEL_EDIT_VALUES
|
||||
#elif ENABLED(LIMITED_MAX_ACCEL_EDITING)
|
||||
DEFAULT_MAX_ACCELERATION
|
||||
#else
|
||||
{ 99000, 99000, 99000, 99000 }
|
||||
#endif
|
||||
;
|
||||
#if ENABLED(LIMITED_MAX_ACCEL_EDITING) && !defined(MAX_ACCEL_EDIT_VALUES)
|
||||
const xyze_ulong_t max_accel_edit_scaled = max_accel_edit * 2;
|
||||
#else
|
||||
const xyze_ulong_t &max_accel_edit_scaled = max_accel_edit;
|
||||
#endif
|
||||
|
||||
#define EDIT_AMAX(Q,L) EDIT_ITEM_FAST(long5_25, MSG_AMAX_##Q, &planner.settings.max_acceleration_mm_per_s2[_AXIS(Q)], L, max_accel_edit_scaled[_AXIS(Q)], []{ planner.reset_acceleration_rates(); })
|
||||
EDIT_AMAX(A,100);
|
||||
EDIT_AMAX(B,100);
|
||||
EDIT_AMAX(C, 10);
|
||||
|
||||
#if ENABLED(DISTINCT_E_FACTORS)
|
||||
EDIT_ITEM_FAST(long5_25, MSG_AMAX_E, &planner.settings.max_acceleration_mm_per_s2[E_AXIS_N(active_extruder)], 100, max_accel_edit_scaled.e, []{ planner.reset_acceleration_rates(); });
|
||||
LOOP_L_N(n, E_STEPPERS)
|
||||
EDIT_ITEM_FAST_N(long5_25, n, MSG_AMAX_EN, &planner.settings.max_acceleration_mm_per_s2[E_AXIS_N(n)], 100, max_accel_edit_scaled.e, []{ _reset_e_acceleration_rate(MenuItemBase::itemIndex); });
|
||||
#elif E_STEPPERS
|
||||
EDIT_ITEM_FAST(long5_25, MSG_AMAX_E, &planner.settings.max_acceleration_mm_per_s2[E_AXIS], 100, max_accel_edit_scaled.e, []{ planner.reset_acceleration_rates(); });
|
||||
#endif
|
||||
|
||||
END_MENU();
|
||||
}
|
||||
|
||||
// M205 Jerk
|
||||
void menu_advanced_jerk() {
|
||||
START_MENU();
|
||||
BACK_ITEM(MSG_ADVANCED_SETTINGS);
|
||||
|
||||
#if DISABLED(CLASSIC_JERK)
|
||||
#if ENABLED(LIN_ADVANCE)
|
||||
EDIT_ITEM(float43, MSG_JUNCTION_DEVIATION, &planner.junction_deviation_mm, 0.001f, 0.3f, planner.recalculate_max_e_jerk);
|
||||
#else
|
||||
EDIT_ITEM(float43, MSG_JUNCTION_DEVIATION, &planner.junction_deviation_mm, 0.001f, 0.5f);
|
||||
#endif
|
||||
#endif
|
||||
#if HAS_CLASSIC_JERK
|
||||
constexpr xyze_float_t max_jerk_edit =
|
||||
#ifdef MAX_ACCEL_EDIT_VALUES
|
||||
MAX_JERK_EDIT_VALUES
|
||||
#elif ENABLED(LIMITED_JERK_EDITING)
|
||||
{ (DEFAULT_XJERK) * 2, (DEFAULT_YJERK) * 2, (DEFAULT_ZJERK) * 2, (DEFAULT_EJERK) * 2 }
|
||||
#else
|
||||
{ 990, 990, 990, 990 }
|
||||
#endif
|
||||
;
|
||||
#define EDIT_JERK(N) EDIT_ITEM_FAST(float3, MSG_V##N##_JERK, &planner.max_jerk[_AXIS(N)], 1, max_jerk_edit[_AXIS(N)])
|
||||
EDIT_JERK(A);
|
||||
EDIT_JERK(B);
|
||||
#if ENABLED(DELTA)
|
||||
EDIT_JERK(C);
|
||||
#else
|
||||
EDIT_ITEM_FAST(float52sign, MSG_VC_JERK, &planner.max_jerk.c, 0.1f, max_jerk_edit.c);
|
||||
#endif
|
||||
#if HAS_CLASSIC_E_JERK
|
||||
EDIT_ITEM_FAST(float52sign, MSG_VE_JERK, &planner.max_jerk.e, 0.1f, max_jerk_edit.e);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
END_MENU();
|
||||
}
|
||||
|
||||
// M851 - Z Probe Offsets
|
||||
#if HAS_BED_PROBE
|
||||
void menu_probe_offsets() {
|
||||
START_MENU();
|
||||
BACK_ITEM(MSG_ADVANCED_SETTINGS);
|
||||
#if HAS_PROBE_XY_OFFSET
|
||||
EDIT_ITEM(float51sign, MSG_ZPROBE_XOFFSET, &probe.offset.x, -(X_BED_SIZE), X_BED_SIZE);
|
||||
EDIT_ITEM(float51sign, MSG_ZPROBE_YOFFSET, &probe.offset.y, -(Y_BED_SIZE), Y_BED_SIZE);
|
||||
#endif
|
||||
EDIT_ITEM(LCD_Z_OFFSET_TYPE, MSG_ZPROBE_ZOFFSET, &probe.offset.z, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX);
|
||||
END_MENU();
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // !SLIM_LCD_MENUS
|
||||
|
||||
// M92 Steps-per-mm
|
||||
void menu_advanced_steps_per_mm() {
|
||||
START_MENU();
|
||||
BACK_ITEM(MSG_ADVANCED_SETTINGS);
|
||||
|
||||
#define EDIT_QSTEPS(Q) EDIT_ITEM_FAST(float51, MSG_##Q##_STEPS, &planner.settings.axis_steps_per_mm[_AXIS(Q)], 5, 9999, []{ planner.refresh_positioning(); })
|
||||
EDIT_QSTEPS(A);
|
||||
EDIT_QSTEPS(B);
|
||||
EDIT_QSTEPS(C);
|
||||
|
||||
#if ENABLED(DISTINCT_E_FACTORS)
|
||||
EDIT_ITEM_FAST(float51, MSG_E_STEPS, &planner.settings.axis_steps_per_mm[E_AXIS_N(active_extruder)], 5, 9999, []{ planner.refresh_positioning(); });
|
||||
LOOP_L_N(n, E_STEPPERS)
|
||||
EDIT_ITEM_FAST_N(float51, n, MSG_EN_STEPS, &planner.settings.axis_steps_per_mm[E_AXIS_N(n)], 5, 9999, []{ _planner_refresh_e_positioning(MenuItemBase::itemIndex); });
|
||||
#elif E_STEPPERS
|
||||
EDIT_ITEM_FAST(float51, MSG_E_STEPS, &planner.settings.axis_steps_per_mm[E_AXIS], 5, 9999, []{ planner.refresh_positioning(); });
|
||||
#endif
|
||||
|
||||
END_MENU();
|
||||
}
|
||||
|
||||
void menu_advanced_settings() {
|
||||
#if ENABLED(FILAMENT_RUNOUT_SENSOR) && FILAMENT_RUNOUT_DISTANCE_MM
|
||||
lcd_runout_distance_mm = runout.runout_distance();
|
||||
#endif
|
||||
START_MENU();
|
||||
BACK_ITEM(MSG_CONFIGURATION);
|
||||
|
||||
#if DISABLED(SLIM_LCD_MENUS)
|
||||
|
||||
#if HAS_M206_COMMAND
|
||||
//
|
||||
// Set Home Offsets
|
||||
//
|
||||
ACTION_ITEM(MSG_SET_HOME_OFFSETS, []{ queue.inject_P(PSTR("M428")); ui.return_to_status(); });
|
||||
#endif
|
||||
|
||||
// M203 / M205 - Feedrate items
|
||||
SUBMENU(MSG_VELOCITY, menu_advanced_velocity);
|
||||
|
||||
// M201 - Acceleration items
|
||||
SUBMENU(MSG_ACCELERATION, menu_advanced_acceleration);
|
||||
|
||||
// M205 - Max Jerk
|
||||
SUBMENU(MSG_JERK, menu_advanced_jerk);
|
||||
|
||||
// M851 - Z Probe Offsets
|
||||
#if HAS_BED_PROBE
|
||||
if (!printer_busy())
|
||||
SUBMENU(MSG_ZPROBE_OFFSETS, menu_probe_offsets);
|
||||
#endif
|
||||
#endif // !SLIM_LCD_MENUS
|
||||
|
||||
// M92 - Steps Per mm
|
||||
if (!printer_busy())
|
||||
SUBMENU(MSG_STEPS_PER_MM, menu_advanced_steps_per_mm);
|
||||
|
||||
#if ENABLED(BACKLASH_GCODE)
|
||||
SUBMENU(MSG_BACKLASH, menu_backlash);
|
||||
#endif
|
||||
|
||||
#if ENABLED(CANCEL_OBJECTS)
|
||||
SUBMENU(MSG_CANCEL_OBJECT, []{ editable.int8 = -1; ui.goto_screen(menu_cancelobject); });
|
||||
#endif
|
||||
|
||||
#if ENABLED(DAC_STEPPER_CURRENT)
|
||||
SUBMENU(MSG_DRIVE_STRENGTH, menu_dac);
|
||||
#endif
|
||||
#if HAS_MOTOR_CURRENT_PWM
|
||||
SUBMENU(MSG_DRIVE_STRENGTH, menu_pwm);
|
||||
#endif
|
||||
|
||||
#if HAS_TRINAMIC_CONFIG
|
||||
SUBMENU(MSG_TMC_DRIVERS, menu_tmc);
|
||||
#endif
|
||||
|
||||
#if SHOW_MENU_ADVANCED_TEMPERATURE
|
||||
SUBMENU(MSG_TEMPERATURE, menu_advanced_temperature);
|
||||
#endif
|
||||
|
||||
#if DISABLED(NO_VOLUMETRICS) || ENABLED(ADVANCED_PAUSE_FEATURE)
|
||||
SUBMENU(MSG_FILAMENT, menu_advanced_filament);
|
||||
#elif ENABLED(LIN_ADVANCE)
|
||||
#if EXTRUDERS == 1
|
||||
EDIT_ITEM(float42_52, MSG_ADVANCE_K, &planner.extruder_advance_K[0], 0, 999);
|
||||
#elif EXTRUDERS > 1
|
||||
LOOP_L_N(n, E_STEPPERS)
|
||||
EDIT_ITEM_N(float42_52, n, MSG_ADVANCE_K_E, &planner.extruder_advance_K[n], 0, 999);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// M540 S - Abort on endstop hit when SD printing
|
||||
#if ENABLED(SD_ABORT_ON_ENDSTOP_HIT)
|
||||
EDIT_ITEM(bool, MSG_ENDSTOP_ABORT, &planner.abort_on_endstop_hit);
|
||||
#endif
|
||||
|
||||
#if ENABLED(SD_FIRMWARE_UPDATE)
|
||||
bool sd_update_state = settings.sd_update_status();
|
||||
EDIT_ITEM(bool, MSG_MEDIA_UPDATE, &sd_update_state, []{
|
||||
//
|
||||
// Toggle the SD Firmware Update state in EEPROM
|
||||
//
|
||||
const bool new_state = !settings.sd_update_status(),
|
||||
didset = settings.set_sd_update_status(new_state);
|
||||
#if HAS_BUZZER
|
||||
ui.completion_feedback(didset);
|
||||
#endif
|
||||
ui.return_to_status();
|
||||
if (new_state) LCD_MESSAGEPGM(MSG_RESET_PRINTER); else ui.reset_status();
|
||||
});
|
||||
#endif
|
||||
|
||||
#if ENABLED(EEPROM_SETTINGS) && DISABLED(SLIM_LCD_MENUS)
|
||||
CONFIRM_ITEM(MSG_INIT_EEPROM,
|
||||
MSG_BUTTON_INIT, MSG_BUTTON_CANCEL,
|
||||
[]{
|
||||
const bool inited = settings.init_eeprom();
|
||||
#if HAS_BUZZER
|
||||
ui.completion_feedback(inited);
|
||||
#endif
|
||||
UNUSED(inited);
|
||||
},
|
||||
ui.goto_previous_screen,
|
||||
GET_TEXT(MSG_INIT_EEPROM), (PGM_P)nullptr, PSTR("?")
|
||||
);
|
||||
#endif
|
||||
|
||||
END_MENU();
|
||||
}
|
||||
|
||||
#endif // HAS_LCD_MENU
|
53
Marlin/src/lcd/menu/menu_backlash.cpp
Executable file
53
Marlin/src/lcd/menu/menu_backlash.cpp
Executable file
@@ -0,0 +1,53 @@
|
||||
/**
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
//
|
||||
// Backlash Menu
|
||||
//
|
||||
|
||||
#include "../../inc/MarlinConfigPre.h"
|
||||
|
||||
#if HAS_LCD_MENU && ENABLED(BACKLASH_GCODE)
|
||||
|
||||
#include "menu.h"
|
||||
|
||||
#include "../../feature/backlash.h"
|
||||
|
||||
void menu_backlash() {
|
||||
START_MENU();
|
||||
BACK_ITEM(MSG_MAIN);
|
||||
|
||||
EDIT_ITEM_FAST(percent, MSG_BACKLASH_CORRECTION, &backlash.correction, all_off, all_on);
|
||||
|
||||
#define EDIT_BACKLASH_DISTANCE(N) EDIT_ITEM_FAST(float43, MSG_BACKLASH_##N, &backlash.distance_mm[_AXIS(N)], 0.0f, 9.9f);
|
||||
if (AXIS_CAN_CALIBRATE(A)) EDIT_BACKLASH_DISTANCE(A);
|
||||
if (AXIS_CAN_CALIBRATE(B)) EDIT_BACKLASH_DISTANCE(B);
|
||||
if (AXIS_CAN_CALIBRATE(C)) EDIT_BACKLASH_DISTANCE(C);
|
||||
|
||||
#ifdef BACKLASH_SMOOTHING_MM
|
||||
EDIT_ITEM_FAST(float43, MSG_BACKLASH_SMOOTHING, &backlash.smoothing_mm, 0.0f, 9.9f);
|
||||
#endif
|
||||
|
||||
END_MENU();
|
||||
}
|
||||
|
||||
#endif // HAS_LCD_MENU && BACKLASH_COMPENSATION
|
124
Marlin/src/lcd/menu/menu_bed_corners.cpp
Executable file
124
Marlin/src/lcd/menu/menu_bed_corners.cpp
Executable file
@@ -0,0 +1,124 @@
|
||||
/**
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
//
|
||||
// Level Bed Corners menu
|
||||
//
|
||||
|
||||
#include "../../inc/MarlinConfigPre.h"
|
||||
|
||||
#if HAS_LCD_MENU && ENABLED(LEVEL_BED_CORNERS)
|
||||
|
||||
#include "menu.h"
|
||||
#include "../../module/motion.h"
|
||||
#include "../../module/planner.h"
|
||||
|
||||
#if HAS_LEVELING
|
||||
#include "../../feature/bedlevel/bedlevel.h"
|
||||
#endif
|
||||
|
||||
#ifndef LEVEL_CORNERS_Z_HOP
|
||||
#define LEVEL_CORNERS_Z_HOP 4.0
|
||||
#endif
|
||||
|
||||
#ifndef LEVEL_CORNERS_HEIGHT
|
||||
#define LEVEL_CORNERS_HEIGHT 0.0
|
||||
#endif
|
||||
|
||||
static_assert(LEVEL_CORNERS_Z_HOP >= 0, "LEVEL_CORNERS_Z_HOP must be >= 0. Please update your configuration.");
|
||||
|
||||
#if HAS_LEVELING
|
||||
static bool leveling_was_active = false;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Level corners, starting in the front-left corner.
|
||||
*/
|
||||
static int8_t bed_corner;
|
||||
static inline void _lcd_goto_next_corner() {
|
||||
constexpr float lfrb[4] = LEVEL_CORNERS_INSET_LFRB;
|
||||
constexpr xy_pos_t lf { (X_MIN_BED) + lfrb[0], (Y_MIN_BED) + lfrb[1] },
|
||||
rb { (X_MAX_BED) - lfrb[2], (Y_MAX_BED) - lfrb[3] };
|
||||
line_to_z(LEVEL_CORNERS_Z_HOP);
|
||||
switch (bed_corner) {
|
||||
case 0: current_position = lf; break; // copy xy
|
||||
case 1: current_position.x = rb.x; break;
|
||||
case 2: current_position.y = rb.y; break;
|
||||
case 3: current_position.x = lf.x; break;
|
||||
#if ENABLED(LEVEL_CENTER_TOO)
|
||||
case 4: current_position.set(X_CENTER, Y_CENTER); break;
|
||||
#endif
|
||||
}
|
||||
line_to_current_position(manual_feedrate_mm_s.x);
|
||||
line_to_z(LEVEL_CORNERS_HEIGHT);
|
||||
if (++bed_corner > (3
|
||||
#if ENABLED(LEVEL_CENTER_TOO)
|
||||
+ 1
|
||||
#endif
|
||||
)) bed_corner = 0;
|
||||
}
|
||||
|
||||
static inline void _lcd_level_bed_corners_homing() {
|
||||
_lcd_draw_homing();
|
||||
if (all_axes_homed()) {
|
||||
bed_corner = 0;
|
||||
ui.goto_screen([]{
|
||||
MenuItem_confirm::select_screen(
|
||||
GET_TEXT(MSG_BUTTON_NEXT), GET_TEXT(MSG_BUTTON_DONE),
|
||||
_lcd_goto_next_corner,
|
||||
[]{
|
||||
#if HAS_LEVELING
|
||||
set_bed_leveling_enabled(leveling_was_active);
|
||||
#endif
|
||||
ui.goto_previous_screen_no_defer();
|
||||
},
|
||||
GET_TEXT(
|
||||
#if ENABLED(LEVEL_CENTER_TOO)
|
||||
MSG_LEVEL_BED_NEXT_POINT
|
||||
#else
|
||||
MSG_NEXT_CORNER
|
||||
#endif
|
||||
), (PGM_P)nullptr, PSTR("?")
|
||||
);
|
||||
});
|
||||
ui.set_selection(true);
|
||||
_lcd_goto_next_corner();
|
||||
}
|
||||
}
|
||||
|
||||
void _lcd_level_bed_corners() {
|
||||
ui.defer_status_screen();
|
||||
if (!all_axes_known()) {
|
||||
set_all_unhomed();
|
||||
queue.inject_P(G28_STR);
|
||||
}
|
||||
|
||||
// Disable leveling so the planner won't mess with us
|
||||
#if HAS_LEVELING
|
||||
leveling_was_active = planner.leveling_active;
|
||||
set_bed_leveling_enabled(false);
|
||||
#endif
|
||||
|
||||
ui.goto_screen(_lcd_level_bed_corners_homing);
|
||||
}
|
||||
|
||||
#endif // HAS_LCD_MENU && LEVEL_BED_CORNERS
|
296
Marlin/src/lcd/menu/menu_bed_leveling.cpp
Executable file
296
Marlin/src/lcd/menu/menu_bed_leveling.cpp
Executable file
@@ -0,0 +1,296 @@
|
||||
/**
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
//
|
||||
// Bed Leveling Menus
|
||||
//
|
||||
|
||||
#include "../../inc/MarlinConfigPre.h"
|
||||
|
||||
#if ENABLED(LCD_BED_LEVELING)
|
||||
|
||||
#include "menu.h"
|
||||
#include "../../module/planner.h"
|
||||
#include "../../feature/bedlevel/bedlevel.h"
|
||||
|
||||
#if HAS_BED_PROBE && DISABLED(BABYSTEP_ZPROBE_OFFSET)
|
||||
#include "../../module/probe.h"
|
||||
#endif
|
||||
|
||||
#if EITHER(PROBE_MANUALLY, MESH_BED_LEVELING)
|
||||
|
||||
#include "../../module/motion.h"
|
||||
#include "../../gcode/queue.h"
|
||||
|
||||
//
|
||||
// Motion > Level Bed handlers
|
||||
//
|
||||
|
||||
static uint8_t manual_probe_index;
|
||||
|
||||
// LCD probed points are from defaults
|
||||
constexpr uint8_t total_probe_points = (
|
||||
#if ENABLED(AUTO_BED_LEVELING_3POINT)
|
||||
3
|
||||
#elif ABL_GRID || ENABLED(MESH_BED_LEVELING)
|
||||
GRID_MAX_POINTS
|
||||
#endif
|
||||
);
|
||||
|
||||
//
|
||||
// Bed leveling is done. Wait for G29 to complete.
|
||||
// A flag is used so that this can release control
|
||||
// and allow the command queue to be processed.
|
||||
//
|
||||
// When G29 finishes the last move:
|
||||
// - Raise Z to the "manual probe height"
|
||||
// - Don't return until done.
|
||||
//
|
||||
// ** This blocks the command queue! **
|
||||
//
|
||||
void _lcd_level_bed_done() {
|
||||
if (!ui.wait_for_move) {
|
||||
#if MANUAL_PROBE_HEIGHT > 0 && DISABLED(MESH_BED_LEVELING)
|
||||
// Display "Done" screen and wait for moves to complete
|
||||
line_to_z(MANUAL_PROBE_HEIGHT);
|
||||
ui.synchronize(GET_TEXT(MSG_LEVEL_BED_DONE));
|
||||
#endif
|
||||
ui.goto_previous_screen_no_defer();
|
||||
#if HAS_BUZZER
|
||||
ui.completion_feedback();
|
||||
#endif
|
||||
}
|
||||
if (ui.should_draw()) MenuItem_static::draw(LCD_HEIGHT >= 4, GET_TEXT(MSG_LEVEL_BED_DONE));
|
||||
ui.refresh(LCDVIEW_CALL_REDRAW_NEXT);
|
||||
}
|
||||
|
||||
void _lcd_level_goto_next_point();
|
||||
|
||||
//
|
||||
// Step 7: Get the Z coordinate, click goes to the next point or exits
|
||||
//
|
||||
void _lcd_level_bed_get_z() {
|
||||
|
||||
if (ui.use_click()) {
|
||||
|
||||
//
|
||||
// Save the current Z position and move
|
||||
//
|
||||
|
||||
// If done...
|
||||
if (++manual_probe_index >= total_probe_points) {
|
||||
//
|
||||
// The last G29 records the point and enables bed leveling
|
||||
//
|
||||
ui.wait_for_move = true;
|
||||
ui.goto_screen(_lcd_level_bed_done);
|
||||
#if ENABLED(MESH_BED_LEVELING)
|
||||
queue.inject_P(PSTR("G29 S2"));
|
||||
#elif ENABLED(PROBE_MANUALLY)
|
||||
queue.inject_P(PSTR("G29 V1"));
|
||||
#endif
|
||||
}
|
||||
else
|
||||
_lcd_level_goto_next_point();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// Encoder knob or keypad buttons adjust the Z position
|
||||
//
|
||||
if (ui.encoderPosition) {
|
||||
const float z = current_position.z + float(int32_t(ui.encoderPosition)) * (MESH_EDIT_Z_STEP);
|
||||
line_to_z(constrain(z, -(LCD_PROBE_Z_RANGE) * 0.5f, (LCD_PROBE_Z_RANGE) * 0.5f));
|
||||
ui.refresh(LCDVIEW_CALL_REDRAW_NEXT);
|
||||
ui.encoderPosition = 0;
|
||||
}
|
||||
|
||||
//
|
||||
// Draw on first display, then only on Z change
|
||||
//
|
||||
if (ui.should_draw()) {
|
||||
const float v = current_position.z;
|
||||
MenuEditItemBase::draw_edit_screen(GET_TEXT(MSG_MOVE_Z), ftostr43sign(v + (v < 0 ? -0.0001f : 0.0001f), '+'));
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Step 6: Display "Next point: 1 / 9" while waiting for move to finish
|
||||
//
|
||||
void _lcd_level_bed_moving() {
|
||||
if (ui.should_draw()) {
|
||||
char msg[10];
|
||||
sprintf_P(msg, PSTR("%i / %u"), int(manual_probe_index + 1), total_probe_points);
|
||||
MenuEditItemBase::draw_edit_screen(GET_TEXT(MSG_LEVEL_BED_NEXT_POINT), msg);
|
||||
}
|
||||
ui.refresh(LCDVIEW_CALL_NO_REDRAW);
|
||||
if (!ui.wait_for_move) ui.goto_screen(_lcd_level_bed_get_z);
|
||||
}
|
||||
|
||||
//
|
||||
// Step 5: Initiate a move to the next point
|
||||
//
|
||||
void _lcd_level_goto_next_point() {
|
||||
ui.goto_screen(_lcd_level_bed_moving);
|
||||
|
||||
// G29 Records Z, moves, and signals when it pauses
|
||||
ui.wait_for_move = true;
|
||||
#if ENABLED(MESH_BED_LEVELING)
|
||||
queue.inject_P(manual_probe_index ? PSTR("G29 S2") : PSTR("G29 S1"));
|
||||
#elif ENABLED(PROBE_MANUALLY)
|
||||
queue.inject_P(PSTR("G29 V1"));
|
||||
#endif
|
||||
}
|
||||
|
||||
//
|
||||
// Step 4: Display "Click to Begin", wait for click
|
||||
// Move to the first probe position
|
||||
//
|
||||
void _lcd_level_bed_homing_done() {
|
||||
if (ui.should_draw()) MenuItem_static::draw(1, GET_TEXT(MSG_LEVEL_BED_WAITING));
|
||||
if (ui.use_click()) {
|
||||
manual_probe_index = 0;
|
||||
_lcd_level_goto_next_point();
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Step 3: Display "Homing XYZ" - Wait for homing to finish
|
||||
//
|
||||
void _lcd_level_bed_homing() {
|
||||
_lcd_draw_homing();
|
||||
if (all_axes_homed()) ui.goto_screen(_lcd_level_bed_homing_done);
|
||||
}
|
||||
|
||||
#if ENABLED(PROBE_MANUALLY)
|
||||
extern bool g29_in_progress;
|
||||
#endif
|
||||
|
||||
//
|
||||
// Step 2: Continue Bed Leveling...
|
||||
//
|
||||
void _lcd_level_bed_continue() {
|
||||
ui.defer_status_screen();
|
||||
set_all_unhomed();
|
||||
ui.goto_screen(_lcd_level_bed_homing);
|
||||
queue.inject_P(G28_STR);
|
||||
}
|
||||
|
||||
#endif // PROBE_MANUALLY || MESH_BED_LEVELING
|
||||
|
||||
#if ENABLED(MESH_EDIT_MENU)
|
||||
|
||||
inline void refresh_planner() {
|
||||
set_current_from_steppers_for_axis(ALL_AXES);
|
||||
sync_plan_position();
|
||||
}
|
||||
|
||||
void menu_edit_mesh() {
|
||||
static uint8_t xind, yind; // =0
|
||||
START_MENU();
|
||||
BACK_ITEM(MSG_BED_LEVELING);
|
||||
EDIT_ITEM(uint8, MSG_MESH_X, &xind, 0, GRID_MAX_POINTS_X - 1);
|
||||
EDIT_ITEM(uint8, MSG_MESH_Y, &yind, 0, GRID_MAX_POINTS_Y - 1);
|
||||
EDIT_ITEM_FAST(float43, MSG_MESH_EDIT_Z, &Z_VALUES(xind, yind), -(LCD_PROBE_Z_RANGE) * 0.5, (LCD_PROBE_Z_RANGE) * 0.5, refresh_planner);
|
||||
END_MENU();
|
||||
}
|
||||
|
||||
#endif // MESH_EDIT_MENU
|
||||
|
||||
/**
|
||||
* Step 1: Bed Level entry-point
|
||||
*
|
||||
* << Motion
|
||||
* Auto Home (if homing needed)
|
||||
* Leveling On/Off (if data exists, and homed)
|
||||
* Fade Height: --- (Req: ENABLE_LEVELING_FADE_HEIGHT)
|
||||
* Mesh Z Offset: --- (Req: MESH_BED_LEVELING)
|
||||
* Z Probe Offset: --- (Req: HAS_BED_PROBE, Opt: BABYSTEP_ZPROBE_OFFSET)
|
||||
* Level Bed >
|
||||
* Level Corners > (if homed)
|
||||
* Load Settings (Req: EEPROM_SETTINGS)
|
||||
* Save Settings (Req: EEPROM_SETTINGS)
|
||||
*/
|
||||
void menu_bed_leveling() {
|
||||
START_MENU();
|
||||
BACK_ITEM(MSG_MOTION);
|
||||
|
||||
const bool is_homed = all_axes_known();
|
||||
|
||||
// Auto Home if not using manual probing
|
||||
#if NONE(PROBE_MANUALLY, MESH_BED_LEVELING)
|
||||
if (!is_homed) GCODES_ITEM(MSG_AUTO_HOME, G28_STR);
|
||||
#endif
|
||||
|
||||
// Level Bed
|
||||
#if EITHER(PROBE_MANUALLY, MESH_BED_LEVELING)
|
||||
// Manual leveling uses a guided procedure
|
||||
SUBMENU(MSG_LEVEL_BED, _lcd_level_bed_continue);
|
||||
#else
|
||||
// Automatic leveling can just run the G-code
|
||||
GCODES_ITEM(MSG_LEVEL_BED, is_homed ? PSTR("G29") : PSTR("G28\nG29"));
|
||||
#endif
|
||||
|
||||
#if ENABLED(MESH_EDIT_MENU)
|
||||
if (leveling_is_valid())
|
||||
SUBMENU(MSG_EDIT_MESH, menu_edit_mesh);
|
||||
#endif
|
||||
|
||||
// Homed and leveling is valid? Then leveling can be toggled.
|
||||
if (is_homed && leveling_is_valid()) {
|
||||
bool show_state = planner.leveling_active;
|
||||
EDIT_ITEM(bool, MSG_BED_LEVELING, &show_state, _lcd_toggle_bed_leveling);
|
||||
}
|
||||
|
||||
// Z Fade Height
|
||||
#if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
|
||||
// Shadow for editing the fade height
|
||||
editable.decimal = planner.z_fade_height;
|
||||
EDIT_ITEM_FAST(float3, MSG_Z_FADE_HEIGHT, &editable.decimal, 0, 100, []{ set_z_fade_height(editable.decimal); });
|
||||
#endif
|
||||
|
||||
//
|
||||
// Mesh Bed Leveling Z-Offset
|
||||
//
|
||||
#if ENABLED(MESH_BED_LEVELING)
|
||||
EDIT_ITEM(float43, MSG_BED_Z, &mbl.z_offset, -1, 1);
|
||||
#endif
|
||||
|
||||
#if ENABLED(BABYSTEP_ZPROBE_OFFSET)
|
||||
SUBMENU(MSG_ZPROBE_ZOFFSET, lcd_babystep_zoffset);
|
||||
#elif HAS_BED_PROBE
|
||||
EDIT_ITEM(LCD_Z_OFFSET_TYPE, MSG_ZPROBE_ZOFFSET, &probe.offset.z, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX);
|
||||
#endif
|
||||
|
||||
#if ENABLED(LEVEL_BED_CORNERS)
|
||||
SUBMENU(MSG_LEVEL_CORNERS, _lcd_level_bed_corners);
|
||||
#endif
|
||||
|
||||
#if ENABLED(EEPROM_SETTINGS)
|
||||
ACTION_ITEM(MSG_LOAD_EEPROM, lcd_load_settings);
|
||||
ACTION_ITEM(MSG_STORE_EEPROM, lcd_store_settings);
|
||||
#endif
|
||||
END_MENU();
|
||||
}
|
||||
|
||||
#endif // LCD_BED_LEVELING
|
74
Marlin/src/lcd/menu/menu_cancelobject.cpp
Executable file
74
Marlin/src/lcd/menu/menu_cancelobject.cpp
Executable file
@@ -0,0 +1,74 @@
|
||||
/**
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
//
|
||||
// Cancel Object Menu
|
||||
//
|
||||
|
||||
#include "../../inc/MarlinConfigPre.h"
|
||||
|
||||
#if HAS_LCD_MENU && ENABLED(CANCEL_OBJECTS)
|
||||
|
||||
#include "menu.h"
|
||||
#include "menu_addon.h"
|
||||
|
||||
#include "../../feature/cancel_object.h"
|
||||
|
||||
static void lcd_cancel_object_confirm() {
|
||||
const int8_t v = MenuItemBase::itemIndex;
|
||||
const char item_num[] = {
|
||||
' ',
|
||||
char((v > 9) ? '0' + (v / 10) : ' '),
|
||||
char('0' + (v % 10)),
|
||||
'\0'
|
||||
};
|
||||
MenuItem_confirm::confirm_screen(
|
||||
[]{
|
||||
cancelable.cancel_object(MenuItemBase::itemIndex - 1);
|
||||
#if HAS_BUZZER
|
||||
ui.completion_feedback();
|
||||
#endif
|
||||
ui.goto_previous_screen();
|
||||
},
|
||||
ui.goto_previous_screen,
|
||||
GET_TEXT(MSG_CANCEL_OBJECT), item_num, PSTR("?")
|
||||
);
|
||||
}
|
||||
|
||||
void menu_cancelobject() {
|
||||
START_MENU();
|
||||
BACK_ITEM(MSG_MAIN);
|
||||
|
||||
// Draw cancelable items in a loop
|
||||
int8_t a = cancelable.active_object;
|
||||
for (int8_t i = -1; i < cancelable.object_count; i++) {
|
||||
if (i == a) continue;
|
||||
int8_t j = i < 0 ? a : i;
|
||||
if (!cancelable.is_canceled(j))
|
||||
SUBMENU_N(j, MSG_CANCEL_OBJECT_N, lcd_cancel_object_confirm);
|
||||
if (i < 0) SKIP_ITEM();
|
||||
}
|
||||
|
||||
END_MENU();
|
||||
}
|
||||
|
||||
#endif // HAS_LCD_MENU && CANCEL_OBJECTS
|
432
Marlin/src/lcd/menu/menu_configuration.cpp
Executable file
432
Marlin/src/lcd/menu/menu_configuration.cpp
Executable file
@@ -0,0 +1,432 @@
|
||||
/**
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
//
|
||||
// Configuration Menu
|
||||
//
|
||||
|
||||
#include "../../inc/MarlinConfigPre.h"
|
||||
|
||||
#if HAS_LCD_MENU
|
||||
|
||||
#include "menu.h"
|
||||
|
||||
#include "../../module/configuration_store.h"
|
||||
|
||||
#if HAS_FILAMENT_SENSOR
|
||||
#include "../../feature/runout.h"
|
||||
#endif
|
||||
|
||||
#if ENABLED(POWER_LOSS_RECOVERY)
|
||||
#include "../../feature/powerloss.h"
|
||||
#endif
|
||||
|
||||
#if HAS_BED_PROBE
|
||||
#include "../../module/probe.h"
|
||||
#if ENABLED(BLTOUCH)
|
||||
#include "../../feature/bltouch.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define HAS_DEBUG_MENU ENABLED(LCD_PROGRESS_BAR_TEST)
|
||||
|
||||
void menu_advanced_settings();
|
||||
#if EITHER(DELTA_CALIBRATION_MENU, DELTA_AUTO_CALIBRATION)
|
||||
void menu_delta_calibrate();
|
||||
#endif
|
||||
|
||||
#if ENABLED(LCD_PROGRESS_BAR_TEST)
|
||||
|
||||
#include "../lcdprint.h"
|
||||
|
||||
static void progress_bar_test() {
|
||||
static int8_t bar_percent = 0;
|
||||
if (ui.use_click()) {
|
||||
ui.goto_previous_screen();
|
||||
ui.set_custom_characters(CHARSET_MENU);
|
||||
return;
|
||||
}
|
||||
bar_percent += (int8_t)ui.encoderPosition;
|
||||
LIMIT(bar_percent, 0, 100);
|
||||
ui.encoderPosition = 0;
|
||||
MenuItem_static::draw(0, GET_TEXT(MSG_PROGRESS_BAR_TEST), SS_CENTER|SS_INVERT);
|
||||
lcd_put_int((LCD_WIDTH) / 2 - 2, LCD_HEIGHT - 2, bar_percent); lcd_put_wchar('%');
|
||||
lcd_moveto(0, LCD_HEIGHT - 1); ui.draw_progress_bar(bar_percent);
|
||||
}
|
||||
|
||||
void _progress_bar_test() {
|
||||
ui.goto_screen(progress_bar_test);
|
||||
ui.set_custom_characters(CHARSET_INFO);
|
||||
}
|
||||
|
||||
#endif // LCD_PROGRESS_BAR_TEST
|
||||
|
||||
#if HAS_DEBUG_MENU
|
||||
|
||||
void menu_debug() {
|
||||
START_MENU();
|
||||
|
||||
BACK_ITEM(MSG_CONFIGURATION);
|
||||
|
||||
#if ENABLED(LCD_PROGRESS_BAR_TEST)
|
||||
SUBMENU(MSG_PROGRESS_BAR_TEST, _progress_bar_test);
|
||||
#endif
|
||||
|
||||
END_MENU();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if EXTRUDERS > 1
|
||||
|
||||
#include "../../module/tool_change.h"
|
||||
|
||||
void menu_tool_change() {
|
||||
START_MENU();
|
||||
BACK_ITEM(MSG_CONFIGURATION);
|
||||
#if ENABLED(TOOLCHANGE_FILAMENT_SWAP)
|
||||
static constexpr float max_extrude =
|
||||
#if ENABLED(PREVENT_LENGTHY_EXTRUDE)
|
||||
EXTRUDE_MAXLENGTH
|
||||
#else
|
||||
500
|
||||
#endif
|
||||
;
|
||||
EDIT_ITEM(float3, MSG_FILAMENT_SWAP_LENGTH, &toolchange_settings.swap_length, 0, max_extrude);
|
||||
EDIT_ITEM(float3, MSG_FILAMENT_PURGE_LENGTH, &toolchange_settings.extra_prime, 0, max_extrude);
|
||||
EDIT_ITEM_FAST(int4, MSG_SINGLENOZZLE_RETRACT_SPD, &toolchange_settings.retract_speed, 10, 5400);
|
||||
EDIT_ITEM_FAST(int4, MSG_SINGLENOZZLE_PRIME_SPD, &toolchange_settings.prime_speed, 10, 5400);
|
||||
#endif
|
||||
EDIT_ITEM(float3, MSG_TOOL_CHANGE_ZLIFT, &toolchange_settings.z_raise, 0, 10);
|
||||
END_MENU();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if HAS_HOTEND_OFFSET
|
||||
#include "../../module/motion.h"
|
||||
#include "../../gcode/queue.h"
|
||||
|
||||
void menu_tool_offsets() {
|
||||
|
||||
auto _recalc_offsets = []{
|
||||
if (active_extruder && all_axes_known()) { // For the 2nd extruder re-home so the next tool-change gets the new offsets.
|
||||
queue.inject_P(G28_STR); // In future, we can babystep the 2nd extruder (if active), making homing unnecessary.
|
||||
active_extruder = 0;
|
||||
}
|
||||
};
|
||||
|
||||
START_MENU();
|
||||
BACK_ITEM(MSG_CONFIGURATION);
|
||||
#if ENABLED(DUAL_X_CARRIAGE)
|
||||
EDIT_ITEM_FAST(float42_52, MSG_HOTEND_OFFSET_X, &hotend_offset[1].x, float(X2_HOME_POS - 25), float(X2_HOME_POS + 25), _recalc_offsets);
|
||||
#else
|
||||
EDIT_ITEM_FAST(float42_52, MSG_HOTEND_OFFSET_X, &hotend_offset[1].x, -99.0, 99.0, _recalc_offsets);
|
||||
#endif
|
||||
EDIT_ITEM_FAST(float42_52, MSG_HOTEND_OFFSET_Y, &hotend_offset[1].y, -99.0, 99.0, _recalc_offsets);
|
||||
EDIT_ITEM_FAST(float42_52, MSG_HOTEND_OFFSET_Z, &hotend_offset[1].z, Z_PROBE_LOW_POINT, 10.0, _recalc_offsets);
|
||||
#if ENABLED(EEPROM_SETTINGS)
|
||||
ACTION_ITEM(MSG_STORE_EEPROM, lcd_store_settings);
|
||||
#endif
|
||||
END_MENU();
|
||||
}
|
||||
#endif
|
||||
|
||||
#if ENABLED(DUAL_X_CARRIAGE)
|
||||
|
||||
void menu_idex() {
|
||||
START_MENU();
|
||||
BACK_ITEM(MSG_CONFIGURATION);
|
||||
|
||||
GCODES_ITEM(MSG_IDEX_MODE_AUTOPARK, PSTR("M605 S1\nG28 X\nG1 X100"));
|
||||
const bool need_g28 = !(TEST(axis_known_position, Y_AXIS) && TEST(axis_known_position, Z_AXIS));
|
||||
GCODES_ITEM(MSG_IDEX_MODE_DUPLICATE, need_g28
|
||||
? PSTR("M605 S1\nT0\nG28\nM605 S2 X200\nG28 X\nG1 X100") // If Y or Z is not homed, do a full G28 first
|
||||
: PSTR("M605 S1\nT0\nM605 S2 X200\nG28 X\nG1 X100")
|
||||
);
|
||||
GCODES_ITEM(MSG_IDEX_MODE_MIRRORED_COPY, need_g28
|
||||
? PSTR("M605 S1\nT0\nG28\nM605 S2 X200\nG28 X\nG1 X100\nM605 S3 X200") // If Y or Z is not homed, do a full G28 first
|
||||
: PSTR("M605 S1\nT0\nM605 S2 X200\nG28 X\nG1 X100\nM605 S3 X200")
|
||||
);
|
||||
GCODES_ITEM(MSG_IDEX_MODE_FULL_CTRL, PSTR("M605 S0\nG28 X"));
|
||||
END_MENU();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if ENABLED(BLTOUCH)
|
||||
|
||||
#if ENABLED(BLTOUCH_LCD_VOLTAGE_MENU)
|
||||
void bltouch_report() {
|
||||
SERIAL_ECHOLNPAIR("EEPROM Last BLTouch Mode - ", (int)bltouch.last_written_mode);
|
||||
SERIAL_ECHOLNPGM("Configuration BLTouch Mode - "
|
||||
#if ENABLED(BLTOUCH_SET_5V_MODE)
|
||||
"5V"
|
||||
#else
|
||||
"OD"
|
||||
#endif
|
||||
);
|
||||
char mess[21];
|
||||
strcpy_P(mess, PSTR("BLTouch Mode - "));
|
||||
strcpy_P(&mess[15], bltouch.last_written_mode ? PSTR("5V") : PSTR("OD"));
|
||||
ui.set_status(mess);
|
||||
ui.return_to_status();
|
||||
}
|
||||
#endif
|
||||
|
||||
void menu_bltouch() {
|
||||
START_MENU();
|
||||
BACK_ITEM(MSG_CONFIGURATION);
|
||||
ACTION_ITEM(MSG_BLTOUCH_RESET, bltouch._reset);
|
||||
ACTION_ITEM(MSG_BLTOUCH_SELFTEST, bltouch._selftest);
|
||||
ACTION_ITEM(MSG_BLTOUCH_DEPLOY, bltouch._deploy);
|
||||
ACTION_ITEM(MSG_BLTOUCH_STOW, bltouch._stow);
|
||||
ACTION_ITEM(MSG_BLTOUCH_SW_MODE, bltouch._set_SW_mode);
|
||||
#if ENABLED(BLTOUCH_LCD_VOLTAGE_MENU)
|
||||
CONFIRM_ITEM(MSG_BLTOUCH_5V_MODE, MSG_BLTOUCH_5V_MODE, MSG_BUTTON_CANCEL, bltouch._set_5V_mode, ui.goto_previous_screen, GET_TEXT(MSG_BLTOUCH_MODE_CHANGE));
|
||||
CONFIRM_ITEM(MSG_BLTOUCH_OD_MODE, MSG_BLTOUCH_OD_MODE, MSG_BUTTON_CANCEL, bltouch._set_OD_mode, ui.goto_previous_screen, GET_TEXT(MSG_BLTOUCH_MODE_CHANGE));
|
||||
ACTION_ITEM(MSG_BLTOUCH_MODE_STORE, bltouch._mode_store);
|
||||
CONFIRM_ITEM(MSG_BLTOUCH_MODE_STORE_5V, MSG_BLTOUCH_MODE_STORE_5V, MSG_BUTTON_CANCEL, bltouch.mode_conv_5V, ui.goto_previous_screen, GET_TEXT(MSG_BLTOUCH_MODE_CHANGE));
|
||||
CONFIRM_ITEM(MSG_BLTOUCH_MODE_STORE_OD, MSG_BLTOUCH_MODE_STORE_OD, MSG_BUTTON_CANCEL, bltouch.mode_conv_OD, ui.goto_previous_screen, GET_TEXT(MSG_BLTOUCH_MODE_CHANGE));
|
||||
ACTION_ITEM(MSG_BLTOUCH_MODE_ECHO, bltouch_report);
|
||||
#endif
|
||||
END_MENU();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if ENABLED(TOUCH_MI_PROBE)
|
||||
void menu_touchmi() {
|
||||
START_MENU();
|
||||
ui.defer_status_screen();
|
||||
BACK_ITEM(MSG_CONFIGURATION);
|
||||
GCODES_ITEM(MSG_TOUCHMI_INIT, PSTR("M851 Z0\nG28\nG1 F200 Z0"));
|
||||
SUBMENU(MSG_ZPROBE_ZOFFSET, lcd_babystep_zoffset);
|
||||
GCODES_ITEM(MSG_TOUCHMI_SAVE, PSTR("M500\nG1 F200 Z10"));
|
||||
GCODES_ITEM(MSG_TOUCHMI_ZTEST, PSTR("G28\nG1 F200 Z0"));
|
||||
END_MENU();
|
||||
}
|
||||
#endif
|
||||
|
||||
#if ENABLED(CONTROLLER_FAN_MENU)
|
||||
|
||||
#include "../../feature/controllerfan.h"
|
||||
|
||||
void menu_controller_fan() {
|
||||
START_MENU();
|
||||
BACK_ITEM(MSG_CONFIGURATION);
|
||||
EDIT_ITEM_FAST(percent, MSG_CONTROLLER_FAN_IDLE_SPEED, &controllerFan.settings.idle_speed, _MAX(1, CONTROLLERFAN_SPEED_MIN) - 1, 255);
|
||||
EDIT_ITEM(bool, MSG_CONTROLLER_FAN_AUTO_ON, &controllerFan.settings.auto_mode);
|
||||
if (controllerFan.settings.auto_mode) {
|
||||
EDIT_ITEM_FAST(percent, MSG_CONTROLLER_FAN_SPEED, &controllerFan.settings.active_speed, _MAX(1, CONTROLLERFAN_SPEED_MIN) - 1, 255);
|
||||
EDIT_ITEM(uint16_4, MSG_CONTROLLER_FAN_DURATION, &controllerFan.settings.duration, 0, 4800);
|
||||
}
|
||||
END_MENU();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if ENABLED(CASE_LIGHT_MENU)
|
||||
|
||||
#include "../../feature/caselight.h"
|
||||
|
||||
#if DISABLED(CASE_LIGHT_NO_BRIGHTNESS)
|
||||
|
||||
void menu_case_light() {
|
||||
START_MENU();
|
||||
BACK_ITEM(MSG_CONFIGURATION);
|
||||
EDIT_ITEM(percent, MSG_CASE_LIGHT_BRIGHTNESS, &case_light_brightness, 0, 255, update_case_light, true);
|
||||
EDIT_ITEM(bool, MSG_CASE_LIGHT, (bool*)&case_light_on, update_case_light);
|
||||
END_MENU();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#if ENABLED(FWRETRACT)
|
||||
|
||||
#include "../../feature/fwretract.h"
|
||||
|
||||
void menu_config_retract() {
|
||||
START_MENU();
|
||||
BACK_ITEM(MSG_CONFIGURATION);
|
||||
#if ENABLED(FWRETRACT_AUTORETRACT)
|
||||
EDIT_ITEM(bool, MSG_AUTORETRACT, &fwretract.autoretract_enabled, fwretract.refresh_autoretract);
|
||||
#endif
|
||||
EDIT_ITEM(float52sign, MSG_CONTROL_RETRACT, &fwretract.settings.retract_length, 0, 100);
|
||||
#if EXTRUDERS > 1
|
||||
EDIT_ITEM(float52sign, MSG_CONTROL_RETRACT_SWAP, &fwretract.settings.swap_retract_length, 0, 100);
|
||||
#endif
|
||||
EDIT_ITEM(float3, MSG_CONTROL_RETRACTF, &fwretract.settings.retract_feedrate_mm_s, 1, 999);
|
||||
EDIT_ITEM(float52sign, MSG_CONTROL_RETRACT_ZHOP, &fwretract.settings.retract_zraise, 0, 999);
|
||||
EDIT_ITEM(float52sign, MSG_CONTROL_RETRACT_RECOVER, &fwretract.settings.retract_recover_extra, -100, 100);
|
||||
#if EXTRUDERS > 1
|
||||
EDIT_ITEM(float52sign, MSG_CONTROL_RETRACT_RECOVER_SWAP, &fwretract.settings.swap_retract_recover_extra, -100, 100);
|
||||
#endif
|
||||
EDIT_ITEM(float3, MSG_CONTROL_RETRACT_RECOVERF, &fwretract.settings.retract_recover_feedrate_mm_s, 1, 999);
|
||||
#if EXTRUDERS > 1
|
||||
EDIT_ITEM(float3, MSG_CONTROL_RETRACT_RECOVER_SWAPF, &fwretract.settings.swap_retract_recover_feedrate_mm_s, 1, 999);
|
||||
#endif
|
||||
END_MENU();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if DISABLED(SLIM_LCD_MENUS)
|
||||
|
||||
void _menu_configuration_preheat_settings(const uint8_t material) {
|
||||
#define _MINTEMP_ITEM(N) HEATER_##N##_MINTEMP,
|
||||
#define _MAXTEMP_ITEM(N) HEATER_##N##_MAXTEMP,
|
||||
#define MINTEMP_ALL _MIN(REPEAT(HOTENDS, _MINTEMP_ITEM) 999)
|
||||
#define MAXTEMP_ALL _MAX(REPEAT(HOTENDS, _MAXTEMP_ITEM) 0)
|
||||
START_MENU();
|
||||
BACK_ITEM(MSG_CONFIGURATION);
|
||||
EDIT_ITEM(percent, MSG_FAN_SPEED, &ui.preheat_fan_speed[material], 0, 255);
|
||||
#if HAS_TEMP_HOTEND
|
||||
EDIT_ITEM(int3, MSG_NOZZLE, &ui.preheat_hotend_temp[material], MINTEMP_ALL, MAXTEMP_ALL - 15);
|
||||
#endif
|
||||
#if HAS_HEATED_BED
|
||||
EDIT_ITEM(int3, MSG_BED, &ui.preheat_bed_temp[material], BED_MINTEMP, BED_MAXTEMP - 10);
|
||||
#endif
|
||||
#if ENABLED(EEPROM_SETTINGS)
|
||||
ACTION_ITEM(MSG_STORE_EEPROM, lcd_store_settings);
|
||||
#endif
|
||||
END_MENU();
|
||||
}
|
||||
|
||||
void menu_preheat_material1_settings() { _menu_configuration_preheat_settings(0); }
|
||||
void menu_preheat_material2_settings() { _menu_configuration_preheat_settings(1); }
|
||||
|
||||
#endif
|
||||
|
||||
void menu_configuration() {
|
||||
START_MENU();
|
||||
BACK_ITEM(MSG_MAIN);
|
||||
|
||||
//
|
||||
// Debug Menu when certain options are enabled
|
||||
//
|
||||
#if HAS_DEBUG_MENU
|
||||
SUBMENU(MSG_DEBUG_MENU, menu_debug);
|
||||
#endif
|
||||
|
||||
SUBMENU(MSG_ADVANCED_SETTINGS, menu_advanced_settings);
|
||||
|
||||
#if ENABLED(BABYSTEP_ZPROBE_OFFSET)
|
||||
SUBMENU(MSG_ZPROBE_ZOFFSET, lcd_babystep_zoffset);
|
||||
#elif HAS_BED_PROBE
|
||||
EDIT_ITEM(LCD_Z_OFFSET_TYPE, MSG_ZPROBE_ZOFFSET, &probe.offset.z, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX);
|
||||
#endif
|
||||
|
||||
//
|
||||
// Set Fan Controller speed
|
||||
//
|
||||
#if ENABLED(CONTROLLER_FAN_MENU)
|
||||
SUBMENU(MSG_CONTROLLER_FAN, menu_controller_fan);
|
||||
#endif
|
||||
|
||||
const bool busy = printer_busy();
|
||||
if (!busy) {
|
||||
#if EITHER(DELTA_CALIBRATION_MENU, DELTA_AUTO_CALIBRATION)
|
||||
SUBMENU(MSG_DELTA_CALIBRATE, menu_delta_calibrate);
|
||||
#endif
|
||||
|
||||
#if HAS_HOTEND_OFFSET
|
||||
SUBMENU(MSG_OFFSETS_MENU, menu_tool_offsets);
|
||||
#endif
|
||||
|
||||
#if ENABLED(DUAL_X_CARRIAGE)
|
||||
SUBMENU(MSG_IDEX_MENU, menu_idex);
|
||||
#endif
|
||||
|
||||
#if ENABLED(BLTOUCH)
|
||||
SUBMENU(MSG_BLTOUCH, menu_bltouch);
|
||||
#endif
|
||||
|
||||
#if ENABLED(TOUCH_MI_PROBE)
|
||||
SUBMENU(MSG_TOUCHMI_PROBE, menu_touchmi);
|
||||
#endif
|
||||
}
|
||||
|
||||
//
|
||||
// Set single nozzle filament retract and prime length
|
||||
//
|
||||
#if EXTRUDERS > 1
|
||||
SUBMENU(MSG_TOOL_CHANGE, menu_tool_change);
|
||||
#endif
|
||||
|
||||
//
|
||||
// Set Case light on/off/brightness
|
||||
//
|
||||
#if ENABLED(CASE_LIGHT_MENU)
|
||||
#if DISABLED(CASE_LIGHT_NO_BRIGHTNESS)
|
||||
if (true
|
||||
#if DISABLED(CASE_LIGHT_USE_NEOPIXEL)
|
||||
&& PWM_PIN(CASE_LIGHT_PIN)
|
||||
#endif
|
||||
)
|
||||
SUBMENU(MSG_CASE_LIGHT, menu_case_light);
|
||||
else
|
||||
#endif
|
||||
EDIT_ITEM(bool, MSG_CASE_LIGHT, (bool*)&case_light_on, update_case_light);
|
||||
#endif
|
||||
|
||||
#if HAS_LCD_CONTRAST
|
||||
EDIT_ITEM(int3, MSG_CONTRAST, &ui.contrast, LCD_CONTRAST_MIN, LCD_CONTRAST_MAX, ui.refresh_contrast, true);
|
||||
#endif
|
||||
#if ENABLED(FWRETRACT)
|
||||
SUBMENU(MSG_RETRACT, menu_config_retract);
|
||||
#endif
|
||||
|
||||
#if HAS_FILAMENT_SENSOR
|
||||
EDIT_ITEM(bool, MSG_RUNOUT_SENSOR, &runout.enabled, runout.reset);
|
||||
#endif
|
||||
|
||||
#if ENABLED(POWER_LOSS_RECOVERY)
|
||||
EDIT_ITEM(bool, MSG_OUTAGE_RECOVERY, &recovery.enabled, recovery.changed);
|
||||
#endif
|
||||
|
||||
#if DISABLED(SLIM_LCD_MENUS)
|
||||
// Preheat configurations
|
||||
SUBMENU(MSG_PREHEAT_1_SETTINGS, menu_preheat_material1_settings);
|
||||
SUBMENU(MSG_PREHEAT_2_SETTINGS, menu_preheat_material2_settings);
|
||||
#endif
|
||||
|
||||
#if ENABLED(EEPROM_SETTINGS)
|
||||
ACTION_ITEM(MSG_STORE_EEPROM, lcd_store_settings);
|
||||
if (!busy)
|
||||
ACTION_ITEM(MSG_LOAD_EEPROM, lcd_load_settings);
|
||||
#endif
|
||||
|
||||
if (!busy)
|
||||
ACTION_ITEM(MSG_RESTORE_DEFAULTS, []{
|
||||
settings.reset();
|
||||
#if HAS_BUZZER
|
||||
ui.completion_feedback();
|
||||
#endif
|
||||
});
|
||||
|
||||
END_MENU();
|
||||
}
|
||||
|
||||
#endif // HAS_LCD_MENU
|
133
Marlin/src/lcd/menu/menu_custom.cpp
Executable file
133
Marlin/src/lcd/menu/menu_custom.cpp
Executable file
@@ -0,0 +1,133 @@
|
||||
/**
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
//
|
||||
// Custom User Menu
|
||||
//
|
||||
|
||||
#include "../../inc/MarlinConfigPre.h"
|
||||
|
||||
#if HAS_LCD_MENU && ENABLED(CUSTOM_USER_MENUS)
|
||||
|
||||
#include "menu.h"
|
||||
#include "../../gcode/queue.h"
|
||||
|
||||
#ifdef USER_SCRIPT_DONE
|
||||
#define _DONE_SCRIPT "\n" USER_SCRIPT_DONE
|
||||
#else
|
||||
#define _DONE_SCRIPT ""
|
||||
#endif
|
||||
|
||||
void _lcd_user_gcode(PGM_P const cmd) {
|
||||
queue.inject_P(cmd);
|
||||
#if ENABLED(USER_SCRIPT_AUDIBLE_FEEDBACK) && HAS_BUZZER
|
||||
ui.completion_feedback();
|
||||
#endif
|
||||
#if ENABLED(USER_SCRIPT_RETURN)
|
||||
ui.return_to_status();
|
||||
#endif
|
||||
}
|
||||
|
||||
void menu_user() {
|
||||
START_MENU();
|
||||
BACK_ITEM(MSG_MAIN);
|
||||
#define HAS_USER_ITEM(N) (defined(USER_DESC_##N) && defined(USER_GCODE_##N))
|
||||
#define USER_ITEM(N) ACTION_ITEM_P(PSTR(USER_DESC_##N), []{ _lcd_user_gcode(PSTR(USER_GCODE_##N _DONE_SCRIPT)); });
|
||||
#if HAS_USER_ITEM(1)
|
||||
USER_ITEM(1);
|
||||
#endif
|
||||
#if HAS_USER_ITEM(2)
|
||||
USER_ITEM(2);
|
||||
#endif
|
||||
#if HAS_USER_ITEM(3)
|
||||
USER_ITEM(3);
|
||||
#endif
|
||||
#if HAS_USER_ITEM(4)
|
||||
USER_ITEM(4);
|
||||
#endif
|
||||
#if HAS_USER_ITEM(5)
|
||||
USER_ITEM(5);
|
||||
#endif
|
||||
#if HAS_USER_ITEM(6)
|
||||
USER_ITEM(6);
|
||||
#endif
|
||||
#if HAS_USER_ITEM(7)
|
||||
USER_ITEM(7);
|
||||
#endif
|
||||
#if HAS_USER_ITEM(8)
|
||||
USER_ITEM(8);
|
||||
#endif
|
||||
#if HAS_USER_ITEM(9)
|
||||
USER_ITEM(9);
|
||||
#endif
|
||||
#if HAS_USER_ITEM(10)
|
||||
USER_ITEM(10);
|
||||
#endif
|
||||
#if HAS_USER_ITEM(11)
|
||||
USER_ITEM(11);
|
||||
#endif
|
||||
#if HAS_USER_ITEM(12)
|
||||
USER_ITEM(12);
|
||||
#endif
|
||||
#if HAS_USER_ITEM(13)
|
||||
USER_ITEM(13);
|
||||
#endif
|
||||
#if HAS_USER_ITEM(14)
|
||||
USER_ITEM(14);
|
||||
#endif
|
||||
#if HAS_USER_ITEM(15)
|
||||
USER_ITEM(15);
|
||||
#endif
|
||||
#if HAS_USER_ITEM(16)
|
||||
USER_ITEM(16);
|
||||
#endif
|
||||
#if HAS_USER_ITEM(17)
|
||||
USER_ITEM(17);
|
||||
#endif
|
||||
#if HAS_USER_ITEM(18)
|
||||
USER_ITEM(18);
|
||||
#endif
|
||||
#if HAS_USER_ITEM(19)
|
||||
USER_ITEM(19);
|
||||
#endif
|
||||
#if HAS_USER_ITEM(20)
|
||||
USER_ITEM(20);
|
||||
#endif
|
||||
#if HAS_USER_ITEM(21)
|
||||
USER_ITEM(21);
|
||||
#endif
|
||||
#if HAS_USER_ITEM(22)
|
||||
USER_ITEM(22);
|
||||
#endif
|
||||
#if HAS_USER_ITEM(23)
|
||||
USER_ITEM(23);
|
||||
#endif
|
||||
#if HAS_USER_ITEM(24)
|
||||
USER_ITEM(24);
|
||||
#endif
|
||||
#if HAS_USER_ITEM(25)
|
||||
USER_ITEM(25);
|
||||
#endif
|
||||
END_MENU();
|
||||
}
|
||||
|
||||
#endif // HAS_LCD_MENU && CUSTOM_USER_MENUS
|
153
Marlin/src/lcd/menu/menu_delta_calibrate.cpp
Executable file
153
Marlin/src/lcd/menu/menu_delta_calibrate.cpp
Executable file
@@ -0,0 +1,153 @@
|
||||
/**
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
//
|
||||
// Delta Calibrate Menu
|
||||
//
|
||||
|
||||
#include "../../inc/MarlinConfigPre.h"
|
||||
|
||||
#if HAS_LCD_MENU && EITHER(DELTA_CALIBRATION_MENU, DELTA_AUTO_CALIBRATION)
|
||||
|
||||
#include "menu.h"
|
||||
#include "../../module/delta.h"
|
||||
#include "../../module/motion.h"
|
||||
|
||||
#if HAS_LEVELING
|
||||
#include "../../feature/bedlevel/bedlevel.h"
|
||||
#endif
|
||||
|
||||
#if ENABLED(EXTENSIBLE_UI)
|
||||
#include "../../lcd/extui/ui_api.h"
|
||||
#endif
|
||||
|
||||
void _man_probe_pt(const xy_pos_t &xy) {
|
||||
if (!ui.wait_for_move) {
|
||||
ui.wait_for_move = true;
|
||||
do_blocking_move_to_xy_z(xy, Z_CLEARANCE_BETWEEN_PROBES);
|
||||
ui.wait_for_move = false;
|
||||
ui.synchronize();
|
||||
move_menu_scale = _MAX(PROBE_MANUALLY_STEP, MIN_STEPS_PER_SEGMENT / float(DEFAULT_XYZ_STEPS_PER_UNIT));
|
||||
ui.goto_screen(lcd_move_z);
|
||||
}
|
||||
}
|
||||
|
||||
#if ENABLED(DELTA_AUTO_CALIBRATION)
|
||||
|
||||
#include "../../gcode/gcode.h"
|
||||
|
||||
#if ENABLED(HOST_PROMPT_SUPPORT)
|
||||
#include "../../feature/host_actions.h" // for host_prompt_do
|
||||
#endif
|
||||
|
||||
float lcd_probe_pt(const xy_pos_t &xy) {
|
||||
_man_probe_pt(xy);
|
||||
ui.defer_status_screen();
|
||||
#if ENABLED(HOST_PROMPT_SUPPORT)
|
||||
host_prompt_do(PROMPT_USER_CONTINUE, PSTR("Delta Calibration in progress"), CONTINUE_STR);
|
||||
#endif
|
||||
#if ENABLED(EXTENSIBLE_UI)
|
||||
ExtUI::onUserConfirmRequired_P(PSTR("Delta Calibration in progress"));
|
||||
#endif
|
||||
wait_for_user_response();
|
||||
ui.goto_previous_screen_no_defer();
|
||||
return current_position.z;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if ENABLED(DELTA_CALIBRATION_MENU)
|
||||
|
||||
#include "../../gcode/queue.h"
|
||||
|
||||
void _lcd_calibrate_homing() {
|
||||
_lcd_draw_homing();
|
||||
if (all_axes_homed()) ui.goto_previous_screen();
|
||||
}
|
||||
|
||||
void _lcd_delta_calibrate_home() {
|
||||
queue.inject_P(G28_STR);
|
||||
ui.goto_screen(_lcd_calibrate_homing);
|
||||
}
|
||||
|
||||
void _goto_tower_a(const float &a) {
|
||||
xy_pos_t tower_vec = { cos(RADIANS(a)), sin(RADIANS(a)) };
|
||||
_man_probe_pt(tower_vec * delta_calibration_radius());
|
||||
}
|
||||
void _goto_tower_x() { _goto_tower_a(210); }
|
||||
void _goto_tower_y() { _goto_tower_a(330); }
|
||||
void _goto_tower_z() { _goto_tower_a( 90); }
|
||||
void _goto_center() { xy_pos_t ctr{0}; _man_probe_pt(ctr); }
|
||||
|
||||
#endif
|
||||
|
||||
void lcd_delta_settings() {
|
||||
auto _recalc_delta_settings = []{
|
||||
#if HAS_LEVELING
|
||||
reset_bed_level(); // After changing kinematics bed-level data is no longer valid
|
||||
#endif
|
||||
recalc_delta_settings();
|
||||
};
|
||||
START_MENU();
|
||||
BACK_ITEM(MSG_DELTA_CALIBRATE);
|
||||
EDIT_ITEM(float52sign, MSG_DELTA_HEIGHT, &delta_height, delta_height - 10, delta_height + 10, _recalc_delta_settings);
|
||||
#define EDIT_ENDSTOP_ADJ(LABEL,N) EDIT_ITEM_P(float43, PSTR(LABEL), &delta_endstop_adj.N, -5, 5, _recalc_delta_settings)
|
||||
EDIT_ENDSTOP_ADJ("Ex", a);
|
||||
EDIT_ENDSTOP_ADJ("Ey", b);
|
||||
EDIT_ENDSTOP_ADJ("Ez", c);
|
||||
EDIT_ITEM(float52sign, MSG_DELTA_RADIUS, &delta_radius, delta_radius - 5, delta_radius + 5, _recalc_delta_settings);
|
||||
#define EDIT_ANGLE_TRIM(LABEL,N) EDIT_ITEM_P(float43, PSTR(LABEL), &delta_tower_angle_trim.N, -5, 5, _recalc_delta_settings)
|
||||
EDIT_ANGLE_TRIM("Tx", a);
|
||||
EDIT_ANGLE_TRIM("Ty", b);
|
||||
EDIT_ANGLE_TRIM("Tz", c);
|
||||
EDIT_ITEM(float52sign, MSG_DELTA_DIAG_ROD, &delta_diagonal_rod, delta_diagonal_rod - 5, delta_diagonal_rod + 5, _recalc_delta_settings);
|
||||
END_MENU();
|
||||
}
|
||||
|
||||
void menu_delta_calibrate() {
|
||||
START_MENU();
|
||||
BACK_ITEM(MSG_MAIN);
|
||||
|
||||
#if ENABLED(DELTA_AUTO_CALIBRATION)
|
||||
GCODES_ITEM(MSG_DELTA_AUTO_CALIBRATE, PSTR("G33"));
|
||||
#if ENABLED(EEPROM_SETTINGS)
|
||||
ACTION_ITEM(MSG_STORE_EEPROM, lcd_store_settings);
|
||||
ACTION_ITEM(MSG_LOAD_EEPROM, lcd_load_settings);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
SUBMENU(MSG_DELTA_SETTINGS, lcd_delta_settings);
|
||||
|
||||
#if ENABLED(DELTA_CALIBRATION_MENU)
|
||||
SUBMENU(MSG_AUTO_HOME, _lcd_delta_calibrate_home);
|
||||
if (all_axes_homed()) {
|
||||
SUBMENU(MSG_DELTA_CALIBRATE_X, _goto_tower_x);
|
||||
SUBMENU(MSG_DELTA_CALIBRATE_Y, _goto_tower_y);
|
||||
SUBMENU(MSG_DELTA_CALIBRATE_Z, _goto_tower_z);
|
||||
SUBMENU(MSG_DELTA_CALIBRATE_CENTER, _goto_center);
|
||||
}
|
||||
#endif
|
||||
|
||||
END_MENU();
|
||||
}
|
||||
|
||||
#endif // HAS_LCD_MENU && (DELTA_CALIBRATION_MENU || DELTA_AUTO_CALIBRATION)
|
318
Marlin/src/lcd/menu/menu_filament.cpp
Executable file
318
Marlin/src/lcd/menu/menu_filament.cpp
Executable file
@@ -0,0 +1,318 @@
|
||||
/**
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
//
|
||||
// Filament Change Menu
|
||||
//
|
||||
|
||||
#include "../../inc/MarlinConfigPre.h"
|
||||
|
||||
#if HAS_LCD_MENU && ENABLED(ADVANCED_PAUSE_FEATURE)
|
||||
|
||||
#include "menu.h"
|
||||
#include "../../module/temperature.h"
|
||||
#include "../../feature/pause.h"
|
||||
#if HAS_FILAMENT_SENSOR
|
||||
#include "../../feature/runout.h"
|
||||
#endif
|
||||
|
||||
//
|
||||
// Change Filament > Change/Unload/Load Filament
|
||||
//
|
||||
static PauseMode _change_filament_temp_mode; // =PAUSE_MODE_PAUSE_PRINT
|
||||
static int8_t _change_filament_temp_extruder; // =0
|
||||
|
||||
inline PGM_P _change_filament_temp_command() {
|
||||
switch (_change_filament_temp_mode) {
|
||||
case PAUSE_MODE_LOAD_FILAMENT:
|
||||
return PSTR("M701 T%d");
|
||||
case PAUSE_MODE_UNLOAD_FILAMENT:
|
||||
return _change_filament_temp_extruder >= 0 ? PSTR("M702 T%d") : PSTR("M702 ;%d");
|
||||
case PAUSE_MODE_CHANGE_FILAMENT:
|
||||
case PAUSE_MODE_PAUSE_PRINT:
|
||||
default:
|
||||
return PSTR("M600 B0 T%d");
|
||||
}
|
||||
return GET_TEXT(MSG_FILAMENTCHANGE);
|
||||
}
|
||||
|
||||
// Initiate Filament Load/Unload/Change at the specified temperature
|
||||
static void _change_filament_temp(const uint16_t temperature) {
|
||||
char cmd[11];
|
||||
sprintf_P(cmd, _change_filament_temp_command(), _change_filament_temp_extruder);
|
||||
thermalManager.setTargetHotend(temperature, _change_filament_temp_extruder);
|
||||
lcd_enqueue_one_now(cmd);
|
||||
}
|
||||
|
||||
//
|
||||
// Menu to choose the temperature and start Filament Change
|
||||
//
|
||||
|
||||
inline PGM_P change_filament_header(const PauseMode mode) {
|
||||
switch (mode) {
|
||||
case PAUSE_MODE_LOAD_FILAMENT:
|
||||
return GET_TEXT(MSG_FILAMENTLOAD);
|
||||
case PAUSE_MODE_UNLOAD_FILAMENT:
|
||||
return GET_TEXT(MSG_FILAMENTUNLOAD);
|
||||
default: break;
|
||||
}
|
||||
return GET_TEXT(MSG_FILAMENTCHANGE);
|
||||
}
|
||||
|
||||
void _menu_temp_filament_op(const PauseMode mode, const int8_t extruder) {
|
||||
_change_filament_temp_mode = mode;
|
||||
_change_filament_temp_extruder = extruder;
|
||||
START_MENU();
|
||||
if (LCD_HEIGHT >= 4) STATIC_ITEM_P(change_filament_header(mode), SS_CENTER|SS_INVERT);
|
||||
BACK_ITEM(MSG_BACK);
|
||||
ACTION_ITEM(MSG_PREHEAT_1, []{ _change_filament_temp(ui.preheat_hotend_temp[0]); });
|
||||
ACTION_ITEM(MSG_PREHEAT_2, []{ _change_filament_temp(ui.preheat_hotend_temp[1]); });
|
||||
EDIT_ITEM_FAST(int3, MSG_PREHEAT_CUSTOM, &thermalManager.temp_hotend[_change_filament_temp_extruder].target, EXTRUDE_MINTEMP, heater_maxtemp[extruder] - 15, []{
|
||||
_change_filament_temp(thermalManager.temp_hotend[_change_filament_temp_extruder].target);
|
||||
});
|
||||
END_MENU();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* "Change Filament" submenu
|
||||
*
|
||||
*/
|
||||
#if E_STEPPERS > 1 || ENABLED(FILAMENT_LOAD_UNLOAD_GCODES)
|
||||
void menu_change_filament() {
|
||||
START_MENU();
|
||||
BACK_ITEM(MSG_MAIN);
|
||||
|
||||
// Say "filament change" when no print is active
|
||||
editable.int8 = printingIsPaused() ? PAUSE_MODE_PAUSE_PRINT : PAUSE_MODE_CHANGE_FILAMENT;
|
||||
|
||||
// Change filament
|
||||
#if E_STEPPERS == 1
|
||||
PGM_P const msg = GET_TEXT(MSG_FILAMENTCHANGE);
|
||||
if (thermalManager.targetTooColdToExtrude(active_extruder))
|
||||
SUBMENU_P(msg, []{ _menu_temp_filament_op(PAUSE_MODE_CHANGE_FILAMENT, 0); });
|
||||
else
|
||||
GCODES_ITEM_P(msg, PSTR("M600 B0"));
|
||||
#else
|
||||
PGM_P const msg = GET_TEXT(MSG_FILAMENTCHANGE_E);
|
||||
LOOP_L_N(s, E_STEPPERS) {
|
||||
if (thermalManager.targetTooColdToExtrude(s))
|
||||
SUBMENU_N_P(s, msg, []{ _menu_temp_filament_op(PAUSE_MODE_CHANGE_FILAMENT, MenuItemBase::itemIndex); });
|
||||
else {
|
||||
ACTION_ITEM_N_P(s, msg, []{
|
||||
char cmd[13];
|
||||
sprintf_P(cmd, PSTR("M600 B0 T%i"), int(MenuItemBase::itemIndex));
|
||||
lcd_enqueue_one_now(cmd);
|
||||
});
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if ENABLED(FILAMENT_LOAD_UNLOAD_GCODES)
|
||||
if (!printer_busy()) {
|
||||
// Load filament
|
||||
#if E_STEPPERS == 1
|
||||
PGM_P const msg_load = GET_TEXT(MSG_FILAMENTLOAD);
|
||||
if (thermalManager.targetTooColdToExtrude(active_extruder))
|
||||
SUBMENU_P(msg_load, []{ _menu_temp_filament_op(PAUSE_MODE_LOAD_FILAMENT, 0); });
|
||||
else
|
||||
GCODES_ITEM_P(msg_load, PSTR("M701"));
|
||||
#else
|
||||
PGM_P const msg_load = GET_TEXT(MSG_FILAMENTLOAD_E);
|
||||
LOOP_L_N(s, E_STEPPERS) {
|
||||
if (thermalManager.targetTooColdToExtrude(s))
|
||||
SUBMENU_N_P(s, msg_load, []{ _menu_temp_filament_op(PAUSE_MODE_LOAD_FILAMENT, MenuItemBase::itemIndex); });
|
||||
else {
|
||||
ACTION_ITEM_N_P(s, msg_load, []{
|
||||
char cmd[12];
|
||||
sprintf_P(cmd, PSTR("M701 T%i"), int(MenuItemBase::itemIndex));
|
||||
lcd_enqueue_one_now(cmd);
|
||||
});
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// Unload filament
|
||||
#if E_STEPPERS == 1
|
||||
PGM_P const msg_unload = GET_TEXT(MSG_FILAMENTUNLOAD);
|
||||
if (thermalManager.targetTooColdToExtrude(active_extruder))
|
||||
SUBMENU_P(msg_unload, []{ _menu_temp_filament_op(PAUSE_MODE_UNLOAD_FILAMENT, 0); });
|
||||
else
|
||||
GCODES_ITEM_P(msg_unload, PSTR("M702"));
|
||||
#else
|
||||
#if ENABLED(FILAMENT_UNLOAD_ALL_EXTRUDERS)
|
||||
{
|
||||
bool too_cold = false;
|
||||
LOOP_L_N(s, E_STEPPERS) {
|
||||
if (thermalManager.targetTooColdToExtrude(s)) {
|
||||
too_cold = true; break;
|
||||
}
|
||||
}
|
||||
if (!too_cold)
|
||||
GCODES_ITEM(MSG_FILAMENTUNLOAD_ALL, PSTR("M702"));
|
||||
else
|
||||
SUBMENU(MSG_FILAMENTUNLOAD_ALL, []{ _menu_temp_filament_op(PAUSE_MODE_UNLOAD_FILAMENT, -1); });
|
||||
}
|
||||
#endif
|
||||
PGM_P const msg_unload = GET_TEXT(MSG_FILAMENTUNLOAD_E);
|
||||
LOOP_L_N(s, E_STEPPERS) {
|
||||
if (thermalManager.targetTooColdToExtrude(s))
|
||||
SUBMENU_N_P(s, msg_unload, []{ _menu_temp_filament_op(PAUSE_MODE_UNLOAD_FILAMENT, MenuItemBase::itemIndex); });
|
||||
else {
|
||||
ACTION_ITEM_N_P(s, msg_unload, []{
|
||||
char cmd[12];
|
||||
sprintf_P(cmd, PSTR("M702 T%i"), int(MenuItemBase::itemIndex));
|
||||
lcd_enqueue_one_now(cmd);
|
||||
});
|
||||
}
|
||||
}
|
||||
#endif
|
||||
} // !printer_busy
|
||||
#endif
|
||||
|
||||
END_MENU();
|
||||
}
|
||||
#endif
|
||||
|
||||
static uint8_t hotend_status_extruder = 0;
|
||||
|
||||
static PGM_P pause_header() {
|
||||
switch (pause_mode) {
|
||||
case PAUSE_MODE_CHANGE_FILAMENT:
|
||||
return GET_TEXT(MSG_FILAMENT_CHANGE_HEADER);
|
||||
case PAUSE_MODE_LOAD_FILAMENT:
|
||||
return GET_TEXT(MSG_FILAMENT_CHANGE_HEADER_LOAD);
|
||||
case PAUSE_MODE_UNLOAD_FILAMENT:
|
||||
return GET_TEXT(MSG_FILAMENT_CHANGE_HEADER_UNLOAD);
|
||||
default: break;
|
||||
}
|
||||
return GET_TEXT(MSG_FILAMENT_CHANGE_HEADER_PAUSE);
|
||||
}
|
||||
|
||||
// Portions from STATIC_ITEM...
|
||||
#define HOTEND_STATUS_ITEM() do { \
|
||||
if (_menuLineNr == _thisItemNr) { \
|
||||
if (ui.should_draw()) { \
|
||||
MenuItem_static::draw(_lcdLineNr, GET_TEXT(MSG_FILAMENT_CHANGE_NOZZLE), SS_INVERT); \
|
||||
ui.draw_hotend_status(_lcdLineNr, hotend_status_extruder); \
|
||||
} \
|
||||
if (_skipStatic && encoderLine <= _thisItemNr) { \
|
||||
ui.encoderPosition += ENCODER_STEPS_PER_MENU_ITEM; \
|
||||
++encoderLine; \
|
||||
} \
|
||||
ui.refresh(LCDVIEW_CALL_REDRAW_NEXT); \
|
||||
} \
|
||||
++_thisItemNr; \
|
||||
}while(0)
|
||||
|
||||
void menu_pause_option() {
|
||||
START_MENU();
|
||||
#if LCD_HEIGHT > 2
|
||||
STATIC_ITEM(MSG_FILAMENT_CHANGE_OPTION_HEADER);
|
||||
#endif
|
||||
ACTION_ITEM(MSG_FILAMENT_CHANGE_OPTION_PURGE, []{ pause_menu_response = PAUSE_RESPONSE_EXTRUDE_MORE; });
|
||||
#if HAS_FILAMENT_SENSOR
|
||||
if (runout.filament_ran_out)
|
||||
EDIT_ITEM(bool, MSG_RUNOUT_SENSOR, &runout.enabled, runout.reset);
|
||||
#endif
|
||||
ACTION_ITEM(MSG_FILAMENT_CHANGE_OPTION_RESUME, []{ pause_menu_response = PAUSE_RESPONSE_RESUME_PRINT; });
|
||||
END_MENU();
|
||||
}
|
||||
|
||||
//
|
||||
// ADVANCED_PAUSE_FEATURE message screens
|
||||
//
|
||||
// Warning: msg must have three null bytes to delimit lines!
|
||||
//
|
||||
void _lcd_pause_message(PGM_P const msg) {
|
||||
PGM_P const msg1 = msg;
|
||||
PGM_P const msg2 = msg1 + strlen_P(msg1) + 1;
|
||||
PGM_P const msg3 = msg2 + strlen_P(msg2) + 1;
|
||||
const bool has2 = msg2[0], has3 = msg3[0],
|
||||
skip1 = !has2 && (LCD_HEIGHT) >= 5;
|
||||
|
||||
START_SCREEN();
|
||||
STATIC_ITEM_P(pause_header(), SS_CENTER|SS_INVERT); // 1: Header
|
||||
if (skip1) SKIP_ITEM(); // Move a single-line message down
|
||||
STATIC_ITEM_P(msg1); // 2: Message Line 1
|
||||
if (has2) STATIC_ITEM_P(msg2); // 3: Message Line 2
|
||||
if (has3 && (LCD_HEIGHT) >= 5) STATIC_ITEM_P(msg3); // 4: Message Line 3 (if LCD has 5 lines)
|
||||
if (skip1 + 1 + has2 + has3 < (LCD_HEIGHT) - 2) SKIP_ITEM(); // Push Hotend Status down, if needed
|
||||
HOTEND_STATUS_ITEM(); // 5: Hotend Status
|
||||
END_SCREEN();
|
||||
}
|
||||
|
||||
void lcd_pause_pausing_message() { _lcd_pause_message(GET_TEXT(MSG_PAUSE_PRINT_INIT)); }
|
||||
void lcd_pause_changing_message() { _lcd_pause_message(GET_TEXT(MSG_FILAMENT_CHANGE_INIT)); }
|
||||
void lcd_pause_unload_message() { _lcd_pause_message(GET_TEXT(MSG_FILAMENT_CHANGE_UNLOAD)); }
|
||||
void lcd_pause_heating_message() { _lcd_pause_message(GET_TEXT(MSG_FILAMENT_CHANGE_HEATING)); }
|
||||
void lcd_pause_heat_message() { _lcd_pause_message(GET_TEXT(MSG_FILAMENT_CHANGE_HEAT)); }
|
||||
void lcd_pause_insert_message() { _lcd_pause_message(GET_TEXT(MSG_FILAMENT_CHANGE_INSERT)); }
|
||||
void lcd_pause_load_message() { _lcd_pause_message(GET_TEXT(MSG_FILAMENT_CHANGE_LOAD)); }
|
||||
void lcd_pause_waiting_message() { _lcd_pause_message(GET_TEXT(MSG_ADVANCED_PAUSE_WAITING)); }
|
||||
void lcd_pause_resume_message() { _lcd_pause_message(GET_TEXT(MSG_FILAMENT_CHANGE_RESUME)); }
|
||||
|
||||
void lcd_pause_purge_message() {
|
||||
#if ENABLED(ADVANCED_PAUSE_CONTINUOUS_PURGE)
|
||||
_lcd_pause_message(GET_TEXT(MSG_FILAMENT_CHANGE_CONT_PURGE));
|
||||
#else
|
||||
_lcd_pause_message(GET_TEXT(MSG_FILAMENT_CHANGE_PURGE));
|
||||
#endif
|
||||
}
|
||||
|
||||
FORCE_INLINE screenFunc_t ap_message_screen(const PauseMessage message) {
|
||||
switch (message) {
|
||||
case PAUSE_MESSAGE_PAUSING: return lcd_pause_pausing_message;
|
||||
case PAUSE_MESSAGE_CHANGING: return lcd_pause_changing_message;
|
||||
case PAUSE_MESSAGE_UNLOAD: return lcd_pause_unload_message;
|
||||
case PAUSE_MESSAGE_WAITING: return lcd_pause_waiting_message;
|
||||
case PAUSE_MESSAGE_INSERT: return lcd_pause_insert_message;
|
||||
case PAUSE_MESSAGE_LOAD: return lcd_pause_load_message;
|
||||
case PAUSE_MESSAGE_PURGE: return lcd_pause_purge_message;
|
||||
case PAUSE_MESSAGE_RESUME: return lcd_pause_resume_message;
|
||||
case PAUSE_MESSAGE_HEAT: return lcd_pause_heat_message;
|
||||
case PAUSE_MESSAGE_HEATING: return lcd_pause_heating_message;
|
||||
case PAUSE_MESSAGE_OPTION: pause_menu_response = PAUSE_RESPONSE_WAIT_FOR;
|
||||
return menu_pause_option;
|
||||
case PAUSE_MESSAGE_STATUS:
|
||||
default: break;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void lcd_pause_show_message(
|
||||
const PauseMessage message,
|
||||
const PauseMode mode/*=PAUSE_MODE_SAME*/,
|
||||
const uint8_t extruder/*=active_extruder*/
|
||||
) {
|
||||
if (mode != PAUSE_MODE_SAME) pause_mode = mode;
|
||||
hotend_status_extruder = extruder;
|
||||
const screenFunc_t next_screen = ap_message_screen(message);
|
||||
if (next_screen) {
|
||||
ui.defer_status_screen();
|
||||
ui.goto_screen(next_screen);
|
||||
}
|
||||
else
|
||||
ui.return_to_status();
|
||||
}
|
||||
|
||||
#endif // HAS_LCD_MENU && ADVANCED_PAUSE_FEATURE
|
54
Marlin/src/lcd/menu/menu_game.cpp
Executable file
54
Marlin/src/lcd/menu/menu_game.cpp
Executable file
@@ -0,0 +1,54 @@
|
||||
/**
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "../../inc/MarlinConfigPre.h"
|
||||
|
||||
#if HAS_GAME_MENU
|
||||
|
||||
#include "menu.h"
|
||||
#include "game/game.h"
|
||||
|
||||
void menu_game() {
|
||||
START_MENU();
|
||||
BACK_ITEM(
|
||||
#if ENABLED(LCD_INFO_MENU)
|
||||
MSG_INFO_MENU
|
||||
#else
|
||||
MSG_MAIN
|
||||
#endif
|
||||
);
|
||||
#if ENABLED(MARLIN_BRICKOUT)
|
||||
SUBMENU(MSG_BRICKOUT, brickout.enter_game);
|
||||
#endif
|
||||
#if ENABLED(MARLIN_INVADERS)
|
||||
SUBMENU(MSG_INVADERS, invaders.enter_game);
|
||||
#endif
|
||||
#if ENABLED(MARLIN_SNAKE)
|
||||
SUBMENU(MSG_SNAKE, snake.enter_game);
|
||||
#endif
|
||||
#if ENABLED(MARLIN_MAZE)
|
||||
SUBMENU(MSG_MAZE, maze.enter_game);
|
||||
#endif
|
||||
END_MENU();
|
||||
}
|
||||
|
||||
#endif // HAS_GAME_MENU
|
344
Marlin/src/lcd/menu/menu_info.cpp
Executable file
344
Marlin/src/lcd/menu/menu_info.cpp
Executable file
@@ -0,0 +1,344 @@
|
||||
/**
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
//
|
||||
// Info Menu
|
||||
//
|
||||
|
||||
#include "../../inc/MarlinConfigPre.h"
|
||||
|
||||
#if HAS_LCD_MENU && ENABLED(LCD_INFO_MENU)
|
||||
|
||||
#include "menu.h"
|
||||
|
||||
#if HAS_GAMES
|
||||
#include "game/game.h"
|
||||
#endif
|
||||
|
||||
#define VALUE_ITEM(MSG, VALUE, STYL) do{ strcpy_P(buffer, PSTR(": ")); strcpy(buffer + 2, VALUE); STATIC_ITEM(MSG, STYL, buffer); }while(0)
|
||||
#define VALUE_ITEM_P(MSG, PVALUE, STYL) do{ strcpy_P(buffer, PSTR(": ")); strcpy_P(buffer + 2, PSTR(PVALUE)); STATIC_ITEM(MSG, STYL, buffer); }while(0)
|
||||
|
||||
#if ENABLED(PRINTCOUNTER)
|
||||
|
||||
#include "../../module/printcounter.h"
|
||||
|
||||
//
|
||||
// About Printer > Printer Stats
|
||||
//
|
||||
void menu_info_stats() {
|
||||
if (ui.use_click()) return ui.go_back();
|
||||
|
||||
char buffer[21]; // For macro usage
|
||||
|
||||
printStatistics stats = print_job_timer.getStats();
|
||||
|
||||
START_SCREEN(); // 12345678901234567890
|
||||
VALUE_ITEM(MSG_INFO_PRINT_COUNT, i16tostr3left(stats.totalPrints), SS_LEFT); // Print Count: 999
|
||||
VALUE_ITEM(MSG_INFO_COMPLETED_PRINTS, i16tostr3left(stats.finishedPrints), SS_LEFT); // Completed : 666
|
||||
|
||||
STATIC_ITEM(MSG_INFO_PRINT_TIME, SS_LEFT); // Total print Time:
|
||||
STATIC_ITEM_P(PSTR("> "), SS_LEFT, duration_t(stats.printTime).toString(buffer)); // > 99y 364d 23h 59m 59s
|
||||
|
||||
STATIC_ITEM(MSG_INFO_PRINT_LONGEST, SS_LEFT); // Longest job time:
|
||||
STATIC_ITEM_P(PSTR("> "), SS_LEFT, duration_t(stats.longestPrint).toString(buffer)); // > 99y 364d 23h 59m 59s
|
||||
|
||||
STATIC_ITEM(MSG_INFO_PRINT_FILAMENT, SS_LEFT); // Extruded total:
|
||||
sprintf_P(buffer, PSTR("%ld.%im"), long(stats.filamentUsed / 1000), int16_t(stats.filamentUsed / 100) % 10);
|
||||
STATIC_ITEM_P(PSTR("> "), SS_LEFT, buffer); // > 125m
|
||||
|
||||
#if SERVICE_INTERVAL_1 > 0 || SERVICE_INTERVAL_2 > 0 || SERVICE_INTERVAL_3 > 0
|
||||
strcpy_P(buffer, GET_TEXT(MSG_SERVICE_IN));
|
||||
#endif
|
||||
|
||||
#if SERVICE_INTERVAL_1 > 0
|
||||
STATIC_ITEM_P(PSTR(SERVICE_NAME_1 " "), SS_LEFT, buffer); // Service X in:
|
||||
STATIC_ITEM_P(PSTR("> "), SS_LEFT, duration_t(stats.nextService1).toString(buffer)); // > 7d 12h 11m 10s
|
||||
#endif
|
||||
|
||||
#if SERVICE_INTERVAL_2 > 0
|
||||
STATIC_ITEM_P(PSTR(SERVICE_NAME_2 " "), SS_LEFT, buffer);
|
||||
STATIC_ITEM_P(PSTR("> "), SS_LEFT, duration_t(stats.nextService2).toString(buffer));
|
||||
#endif
|
||||
|
||||
#if SERVICE_INTERVAL_3 > 0
|
||||
STATIC_ITEM_P(PSTR(SERVICE_NAME_3 " "), SS_LEFT, buffer);
|
||||
STATIC_ITEM_P(PSTR("> "), SS_LEFT, duration_t(stats.nextService3).toString(buffer));
|
||||
#endif
|
||||
|
||||
END_SCREEN();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// About Printer > Thermistors
|
||||
//
|
||||
void menu_info_thermistors() {
|
||||
if (ui.use_click()) return ui.go_back();
|
||||
|
||||
char buffer[21]; // For macro usage
|
||||
|
||||
START_SCREEN();
|
||||
|
||||
#if EXTRUDERS
|
||||
#define THERMISTOR_ID TEMP_SENSOR_0
|
||||
#include "../thermistornames.h"
|
||||
STATIC_ITEM_P(PSTR(LCD_STR_E0 ": " THERMISTOR_NAME), SS_INVERT);
|
||||
VALUE_ITEM_P(MSG_INFO_MIN_TEMP, STRINGIFY(HEATER_0_MINTEMP), SS_LEFT);
|
||||
VALUE_ITEM_P(MSG_INFO_MAX_TEMP, STRINGIFY(HEATER_0_MAXTEMP), SS_LEFT);
|
||||
#endif
|
||||
|
||||
#if TEMP_SENSOR_1 != 0
|
||||
#undef THERMISTOR_ID
|
||||
#define THERMISTOR_ID TEMP_SENSOR_1
|
||||
#include "../thermistornames.h"
|
||||
STATIC_ITEM_P(PSTR(LCD_STR_E1 ": " THERMISTOR_NAME), SS_INVERT);
|
||||
VALUE_ITEM_P(MSG_INFO_MIN_TEMP, STRINGIFY(HEATER_1_MINTEMP), SS_LEFT);
|
||||
VALUE_ITEM_P(MSG_INFO_MAX_TEMP, STRINGIFY(HEATER_1_MAXTEMP), SS_LEFT);
|
||||
#endif
|
||||
|
||||
#if TEMP_SENSOR_2 != 0
|
||||
#undef THERMISTOR_ID
|
||||
#define THERMISTOR_ID TEMP_SENSOR_2
|
||||
#include "../thermistornames.h"
|
||||
STATIC_ITEM_P(PSTR(LCD_STR_E2 ": " THERMISTOR_NAME), SS_INVERT);
|
||||
VALUE_ITEM_P(MSG_INFO_MIN_TEMP, STRINGIFY(HEATER_2_MINTEMP), SS_LEFT);
|
||||
VALUE_ITEM_P(MSG_INFO_MAX_TEMP, STRINGIFY(HEATER_2_MAXTEMP), SS_LEFT);
|
||||
#endif
|
||||
|
||||
#if TEMP_SENSOR_3 != 0
|
||||
#undef THERMISTOR_ID
|
||||
#define THERMISTOR_ID TEMP_SENSOR_3
|
||||
#include "../thermistornames.h"
|
||||
STATIC_ITEM_P(PSTR(LCD_STR_E3 ": " THERMISTOR_NAME), SS_INVERT);
|
||||
VALUE_ITEM_P(MSG_INFO_MIN_TEMP, STRINGIFY(HEATER_3_MINTEMP), SS_LEFT);
|
||||
VALUE_ITEM_P(MSG_INFO_MAX_TEMP, STRINGIFY(HEATER_3_MAXTEMP), SS_LEFT);
|
||||
#endif
|
||||
|
||||
#if TEMP_SENSOR_4 != 0
|
||||
#undef THERMISTOR_ID
|
||||
#define THERMISTOR_ID TEMP_SENSOR_4
|
||||
#include "../thermistornames.h"
|
||||
STATIC_ITEM_P(PSTR(LCD_STR_E4 ": " THERMISTOR_NAME), SS_INVERT);
|
||||
VALUE_ITEM_P(MSG_INFO_MIN_TEMP, STRINGIFY(HEATER_4_MINTEMP), SS_LEFT);
|
||||
VALUE_ITEM_P(MSG_INFO_MAX_TEMP, STRINGIFY(HEATER_4_MAXTEMP), SS_LEFT);
|
||||
#endif
|
||||
|
||||
#if TEMP_SENSOR_5 != 0
|
||||
#undef THERMISTOR_ID
|
||||
#define THERMISTOR_ID TEMP_SENSOR_5
|
||||
#include "../thermistornames.h"
|
||||
STATIC_ITEM_P(PSTR(LCD_STR_E5 ": " THERMISTOR_NAME), SS_INVERT);
|
||||
VALUE_ITEM_P(MSG_INFO_MIN_TEMP, STRINGIFY(HEATER_5_MINTEMP), SS_LEFT);
|
||||
VALUE_ITEM_P(MSG_INFO_MAX_TEMP, STRINGIFY(HEATER_5_MAXTEMP), SS_LEFT);
|
||||
#endif
|
||||
|
||||
#if TEMP_SENSOR_6 != 0
|
||||
#undef THERMISTOR_ID
|
||||
#define THERMISTOR_ID TEMP_SENSOR_6
|
||||
#include "../thermistornames.h"
|
||||
STATIC_ITEM_P(PSTR(LCD_STR_E6 ": " THERMISTOR_NAME), SS_INVERT);
|
||||
VALUE_ITEM_P(MSG_INFO_MIN_TEMP, STRINGIFY(HEATER_6_MINTEMP), SS_LEFT);
|
||||
VALUE_ITEM_P(MSG_INFO_MAX_TEMP, STRINGIFY(HEATER_6_MAXTEMP), SS_LEFT);
|
||||
#endif
|
||||
|
||||
#if TEMP_SENSOR_7 != 0
|
||||
#undef THERMISTOR_ID
|
||||
#define THERMISTOR_ID TEMP_SENSOR_7
|
||||
#include "../thermistornames.h"
|
||||
STATIC_ITEM_P(PSTR(LCD_STR_E7 ": " THERMISTOR_NAME), SS_INVERT);
|
||||
VALUE_ITEM_P(MSG_INFO_MIN_TEMP, STRINGIFY(HEATER_7_MINTEMP), SS_LEFT);
|
||||
VALUE_ITEM_P(MSG_INFO_MAX_TEMP, STRINGIFY(HEATER_7_MAXTEMP), SS_LEFT);
|
||||
#endif
|
||||
|
||||
#if EXTRUDERS
|
||||
{
|
||||
STATIC_ITEM(
|
||||
#if WATCH_HOTENDS
|
||||
MSG_INFO_RUNAWAY_ON
|
||||
#else
|
||||
MSG_INFO_RUNAWAY_OFF
|
||||
#endif
|
||||
, SS_LEFT
|
||||
);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if HAS_HEATED_BED
|
||||
{
|
||||
#undef THERMISTOR_ID
|
||||
#define THERMISTOR_ID TEMP_SENSOR_BED
|
||||
#include "../thermistornames.h"
|
||||
STATIC_ITEM_P(PSTR("BED:" THERMISTOR_NAME), SS_INVERT);
|
||||
VALUE_ITEM_P(MSG_INFO_MIN_TEMP, STRINGIFY(BED_MINTEMP), SS_LEFT);
|
||||
VALUE_ITEM_P(MSG_INFO_MAX_TEMP, STRINGIFY(BED_MAXTEMP), SS_LEFT);
|
||||
STATIC_ITEM(
|
||||
#if WATCH_BED
|
||||
MSG_INFO_RUNAWAY_ON
|
||||
#else
|
||||
MSG_INFO_RUNAWAY_OFF
|
||||
#endif
|
||||
, SS_LEFT
|
||||
);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if HAS_HEATED_CHAMBER
|
||||
{
|
||||
#undef THERMISTOR_ID
|
||||
#define THERMISTOR_ID TEMP_SENSOR_CHAMBER
|
||||
#include "../thermistornames.h"
|
||||
STATIC_ITEM_P(PSTR("CHAM:" THERMISTOR_NAME), SS_INVERT);
|
||||
VALUE_ITEM_P(MSG_INFO_MIN_TEMP, STRINGIFY(CHAMBER_MINTEMP), SS_LEFT);
|
||||
VALUE_ITEM_P(MSG_INFO_MAX_TEMP, STRINGIFY(CHAMBER_MAXTEMP), SS_LEFT);
|
||||
STATIC_ITEM(
|
||||
#if WATCH_CHAMBER
|
||||
MSG_INFO_RUNAWAY_ON
|
||||
#else
|
||||
MSG_INFO_RUNAWAY_OFF
|
||||
#endif
|
||||
, SS_LEFT
|
||||
);
|
||||
}
|
||||
#endif
|
||||
|
||||
END_SCREEN();
|
||||
}
|
||||
|
||||
//
|
||||
// About Printer > Board Info
|
||||
//
|
||||
void menu_info_board() {
|
||||
if (ui.use_click()) return ui.go_back();
|
||||
|
||||
char buffer[21]; // For macro usage
|
||||
|
||||
START_SCREEN();
|
||||
STATIC_ITEM_P(PSTR(BOARD_INFO_NAME), SS_CENTER|SS_INVERT); // MyPrinterController
|
||||
#ifdef BOARD_WEBSITE_URL
|
||||
STATIC_ITEM_P(PSTR(BOARD_WEBSITE_URL), SS_LEFT); // www.my3dprinter.com
|
||||
#endif
|
||||
VALUE_ITEM_P(MSG_INFO_BAUDRATE, STRINGIFY(BAUDRATE), SS_CENTER); // Baud: 250000
|
||||
VALUE_ITEM_P(MSG_INFO_PROTOCOL, PROTOCOL_VERSION, SS_CENTER); // Protocol: 1.0
|
||||
VALUE_ITEM_P(MSG_INFO_PSU, PSU_NAME, SS_CENTER);
|
||||
END_SCREEN();
|
||||
}
|
||||
|
||||
//
|
||||
// About Printer > Printer Info
|
||||
//
|
||||
#if ENABLED(LCD_PRINTER_INFO_IS_BOOTSCREEN)
|
||||
|
||||
void menu_show_marlin_bootscreen() {
|
||||
if (ui.use_click()) { ui.goto_previous_screen_no_defer(); }
|
||||
ui.draw_marlin_bootscreen();
|
||||
}
|
||||
|
||||
#if ENABLED(SHOW_CUSTOM_BOOTSCREEN)
|
||||
void menu_show_custom_bootscreen() {
|
||||
if (ui.use_click()) { ui.goto_screen(menu_show_marlin_bootscreen); }
|
||||
ui.draw_custom_bootscreen();
|
||||
}
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
void menu_info_printer() {
|
||||
if (ui.use_click()) return ui.go_back();
|
||||
START_SCREEN();
|
||||
STATIC_ITEM(MSG_MARLIN, SS_CENTER|SS_INVERT); // Marlin
|
||||
STATIC_ITEM_P(PSTR(SHORT_BUILD_VERSION)); // x.x.x-Branch
|
||||
STATIC_ITEM_P(PSTR(STRING_DISTRIBUTION_DATE)); // YYYY-MM-DD HH:MM
|
||||
STATIC_ITEM_P(PSTR(MACHINE_NAME)); // My3DPrinter
|
||||
STATIC_ITEM_P(PSTR(WEBSITE_URL)); // www.my3dprinter.com
|
||||
char buffer[21];
|
||||
VALUE_ITEM_P(MSG_INFO_EXTRUDERS, STRINGIFY(EXTRUDERS), SS_CENTER); // Extruders: 2
|
||||
#if ENABLED(AUTO_BED_LEVELING_3POINT)
|
||||
STATIC_ITEM(MSG_3POINT_LEVELING); // 3-Point Leveling
|
||||
#elif ENABLED(AUTO_BED_LEVELING_LINEAR)
|
||||
STATIC_ITEM(MSG_LINEAR_LEVELING); // Linear Leveling
|
||||
#elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
|
||||
STATIC_ITEM(MSG_BILINEAR_LEVELING); // Bi-linear Leveling
|
||||
#elif ENABLED(AUTO_BED_LEVELING_UBL)
|
||||
STATIC_ITEM(MSG_UBL_LEVELING); // Unified Bed Leveling
|
||||
#elif ENABLED(MESH_BED_LEVELING)
|
||||
STATIC_ITEM(MSG_MESH_LEVELING); // Mesh Leveling
|
||||
#endif
|
||||
END_SCREEN();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// "About Printer" submenu
|
||||
//
|
||||
void menu_info() {
|
||||
START_MENU();
|
||||
BACK_ITEM(MSG_MAIN);
|
||||
#if ENABLED(LCD_PRINTER_INFO_IS_BOOTSCREEN)
|
||||
SUBMENU(MSG_INFO_PRINTER_MENU, (
|
||||
#if ENABLED(SHOW_CUSTOM_BOOTSCREEN)
|
||||
menu_show_custom_bootscreen
|
||||
#else
|
||||
menu_show_marlin_bootscreen
|
||||
#endif
|
||||
));
|
||||
#else
|
||||
SUBMENU(MSG_INFO_PRINTER_MENU, menu_info_printer); // Printer Info >
|
||||
SUBMENU(MSG_INFO_BOARD_MENU, menu_info_board); // Board Info >
|
||||
#if EXTRUDERS
|
||||
SUBMENU(MSG_INFO_THERMISTOR_MENU, menu_info_thermistors); // Thermistors >
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if ENABLED(PRINTCOUNTER)
|
||||
SUBMENU(MSG_INFO_STATS_MENU, menu_info_stats); // Printer Stats >
|
||||
#endif
|
||||
|
||||
#if HAS_GAMES
|
||||
#if ENABLED(GAMES_EASTER_EGG)
|
||||
SKIP_ITEM();
|
||||
SKIP_ITEM();
|
||||
SKIP_ITEM();
|
||||
#endif
|
||||
// Game sub-menu or the individual game
|
||||
{
|
||||
SUBMENU(
|
||||
#if HAS_GAME_MENU
|
||||
MSG_GAMES, menu_game
|
||||
#elif ENABLED(MARLIN_BRICKOUT)
|
||||
MSG_BRICKOUT, brickout.enter_game
|
||||
#elif ENABLED(MARLIN_INVADERS)
|
||||
MSG_INVADERS, invaders.enter_game
|
||||
#elif ENABLED(MARLIN_SNAKE)
|
||||
MSG_SNAKE, snake.enter_game
|
||||
#elif ENABLED(MARLIN_MAZE)
|
||||
MSG_MAZE, maze.enter_game
|
||||
#endif
|
||||
);
|
||||
}
|
||||
#endif
|
||||
|
||||
END_MENU();
|
||||
}
|
||||
|
||||
#endif // HAS_LCD_MENU && LCD_INFO_MENU
|
57
Marlin/src/lcd/menu/menu_job_recovery.cpp
Executable file
57
Marlin/src/lcd/menu/menu_job_recovery.cpp
Executable file
@@ -0,0 +1,57 @@
|
||||
/**
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
//
|
||||
// Job Recovery Menu
|
||||
//
|
||||
|
||||
#include "../../inc/MarlinConfigPre.h"
|
||||
|
||||
#if HAS_LCD_MENU && ENABLED(POWER_LOSS_RECOVERY)
|
||||
|
||||
#include "menu.h"
|
||||
#include "../../gcode/queue.h"
|
||||
#include "../../sd/cardreader.h"
|
||||
#include "../../feature/powerloss.h"
|
||||
|
||||
static void lcd_power_loss_recovery_resume() {
|
||||
ui.return_to_status();
|
||||
queue.inject_P(PSTR("M1000"));
|
||||
}
|
||||
|
||||
void lcd_power_loss_recovery_cancel() {
|
||||
recovery.cancel();
|
||||
ui.return_to_status();
|
||||
}
|
||||
|
||||
// TODO: Display long filename with Cancel/Resume buttons
|
||||
// Requires supporting methods in PLR class.
|
||||
void menu_job_recovery() {
|
||||
ui.defer_status_screen();
|
||||
START_MENU();
|
||||
STATIC_ITEM(MSG_OUTAGE_RECOVERY);
|
||||
ACTION_ITEM(MSG_RESUME_PRINT, lcd_power_loss_recovery_resume);
|
||||
ACTION_ITEM(MSG_STOP_PRINT, lcd_power_loss_recovery_cancel);
|
||||
END_MENU();
|
||||
}
|
||||
|
||||
#endif // HAS_LCD_MENU && POWER_LOSS_RECOVERY
|
83
Marlin/src/lcd/menu/menu_led.cpp
Executable file
83
Marlin/src/lcd/menu/menu_led.cpp
Executable file
@@ -0,0 +1,83 @@
|
||||
/**
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
//
|
||||
// LED Menu
|
||||
//
|
||||
|
||||
#include "../../inc/MarlinConfigPre.h"
|
||||
|
||||
#if HAS_LCD_MENU && ENABLED(LED_CONTROL_MENU)
|
||||
|
||||
#include "menu.h"
|
||||
#include "../../feature/leds/leds.h"
|
||||
|
||||
#if ENABLED(LED_COLOR_PRESETS)
|
||||
|
||||
void menu_led_presets() {
|
||||
START_MENU();
|
||||
#if LCD_HEIGHT > 2
|
||||
STATIC_ITEM(MSG_LED_PRESETS, SS_CENTER|SS_INVERT);
|
||||
#endif
|
||||
BACK_ITEM(MSG_LED_CONTROL);
|
||||
ACTION_ITEM(MSG_SET_LEDS_WHITE, leds.set_white);
|
||||
ACTION_ITEM(MSG_SET_LEDS_RED, leds.set_red);
|
||||
ACTION_ITEM(MSG_SET_LEDS_ORANGE, leds.set_orange);
|
||||
ACTION_ITEM(MSG_SET_LEDS_YELLOW,leds.set_yellow);
|
||||
ACTION_ITEM(MSG_SET_LEDS_GREEN, leds.set_green);
|
||||
ACTION_ITEM(MSG_SET_LEDS_BLUE, leds.set_blue);
|
||||
ACTION_ITEM(MSG_SET_LEDS_INDIGO, leds.set_indigo);
|
||||
ACTION_ITEM(MSG_SET_LEDS_VIOLET, leds.set_violet);
|
||||
END_MENU();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void menu_led_custom() {
|
||||
START_MENU();
|
||||
BACK_ITEM(MSG_LED_CONTROL);
|
||||
EDIT_ITEM(uint8, MSG_INTENSITY_R, &leds.color.r, 0, 255, leds.update, true);
|
||||
EDIT_ITEM(uint8, MSG_INTENSITY_G, &leds.color.g, 0, 255, leds.update, true);
|
||||
EDIT_ITEM(uint8, MSG_INTENSITY_B, &leds.color.b, 0, 255, leds.update, true);
|
||||
#if EITHER(RGBW_LED, NEOPIXEL_LED)
|
||||
EDIT_ITEM(uint8, MSG_INTENSITY_W, &leds.color.w, 0, 255, leds.update, true);
|
||||
#if ENABLED(NEOPIXEL_LED)
|
||||
EDIT_ITEM(uint8, MSG_LED_BRIGHTNESS, &leds.color.i, 0, 255, leds.update, true);
|
||||
#endif
|
||||
#endif
|
||||
END_MENU();
|
||||
}
|
||||
|
||||
void menu_led() {
|
||||
START_MENU();
|
||||
BACK_ITEM(MSG_MAIN);
|
||||
bool led_on = leds.lights_on;
|
||||
EDIT_ITEM(bool, MSG_LEDS, &led_on, leds.toggle);
|
||||
ACTION_ITEM(MSG_SET_LEDS_DEFAULT, leds.set_default);
|
||||
#if ENABLED(LED_COLOR_PRESETS)
|
||||
SUBMENU(MSG_LED_PRESETS, menu_led_presets);
|
||||
#endif
|
||||
SUBMENU(MSG_CUSTOM_LEDS, menu_led_custom);
|
||||
END_MENU();
|
||||
}
|
||||
|
||||
#endif // HAS_LCD_MENU && LED_CONTROL_MENU
|
297
Marlin/src/lcd/menu/menu_main.cpp
Executable file
297
Marlin/src/lcd/menu/menu_main.cpp
Executable file
@@ -0,0 +1,297 @@
|
||||
/**
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
//
|
||||
// Main Menu
|
||||
//
|
||||
|
||||
#include "../../inc/MarlinConfigPre.h"
|
||||
|
||||
#if HAS_LCD_MENU
|
||||
|
||||
#include "menu.h"
|
||||
#include "../../module/temperature.h"
|
||||
#include "../../gcode/queue.h"
|
||||
#include "../../module/printcounter.h"
|
||||
#include "../../module/stepper.h"
|
||||
#include "../../sd/cardreader.h"
|
||||
|
||||
#if HAS_GAMES && DISABLED(LCD_INFO_MENU)
|
||||
#include "game/game.h"
|
||||
#endif
|
||||
|
||||
#define MACHINE_CAN_STOP (EITHER(SDSUPPORT, HOST_PROMPT_SUPPORT) || defined(ACTION_ON_CANCEL))
|
||||
#define MACHINE_CAN_PAUSE (ANY(SDSUPPORT, HOST_PROMPT_SUPPORT, PARK_HEAD_ON_PAUSE) || defined(ACTION_ON_PAUSE))
|
||||
|
||||
#if ENABLED(PRUSA_MMU2)
|
||||
#include "../../lcd/menu/menu_mmu2.h"
|
||||
#endif
|
||||
|
||||
void menu_tune();
|
||||
void menu_motion();
|
||||
void menu_temperature();
|
||||
void menu_configuration();
|
||||
|
||||
#if ENABLED(CUSTOM_USER_MENUS)
|
||||
void menu_user();
|
||||
#endif
|
||||
|
||||
#if ENABLED(ADVANCED_PAUSE_FEATURE)
|
||||
void _menu_temp_filament_op(const PauseMode, const int8_t);
|
||||
void menu_change_filament();
|
||||
#endif
|
||||
|
||||
#if ENABLED(LCD_INFO_MENU)
|
||||
void menu_info();
|
||||
#endif
|
||||
|
||||
#if ENABLED(LED_CONTROL_MENU)
|
||||
void menu_led();
|
||||
#endif
|
||||
|
||||
#if HAS_CUTTER
|
||||
#include "../../feature/spindle_laser.h"
|
||||
void menu_spindle_laser();
|
||||
#endif
|
||||
|
||||
#if ENABLED(MIXING_EXTRUDER)
|
||||
void menu_mixer();
|
||||
#endif
|
||||
|
||||
extern const char M21_STR[];
|
||||
|
||||
void menu_main() {
|
||||
START_MENU();
|
||||
BACK_ITEM(MSG_INFO_SCREEN);
|
||||
|
||||
const bool busy = printingIsActive()
|
||||
#if ENABLED(SDSUPPORT)
|
||||
, card_detected = card.isMounted()
|
||||
, card_open = card_detected && card.isFileOpen()
|
||||
#endif
|
||||
;
|
||||
|
||||
if (busy) {
|
||||
#if MACHINE_CAN_PAUSE
|
||||
ACTION_ITEM(MSG_PAUSE_PRINT, ui.pause_print);
|
||||
#endif
|
||||
#if MACHINE_CAN_STOP
|
||||
SUBMENU(MSG_STOP_PRINT, []{
|
||||
MenuItem_confirm::select_screen(
|
||||
GET_TEXT(MSG_BUTTON_STOP), GET_TEXT(MSG_BACK),
|
||||
ui.abort_print, ui.goto_previous_screen,
|
||||
GET_TEXT(MSG_STOP_PRINT), (PGM_P)nullptr, PSTR("?")
|
||||
);
|
||||
});
|
||||
#endif
|
||||
SUBMENU(MSG_TUNE, menu_tune);
|
||||
}
|
||||
else {
|
||||
|
||||
#if !HAS_ENCODER_WHEEL && ENABLED(SDSUPPORT)
|
||||
|
||||
// *** IF THIS SECTION IS CHANGED, REPRODUCE BELOW ***
|
||||
|
||||
//
|
||||
// Autostart
|
||||
//
|
||||
#if ENABLED(MENU_ADDAUTOSTART)
|
||||
if (!busy) ACTION_ITEM(MSG_AUTOSTART, card.beginautostart);
|
||||
#endif
|
||||
|
||||
if (card_detected) {
|
||||
if (!card_open) {
|
||||
SUBMENU(MSG_MEDIA_MENU, menu_media);
|
||||
MENU_ITEM(gcode,
|
||||
#if PIN_EXISTS(SD_DETECT)
|
||||
MSG_CHANGE_MEDIA, M21_STR
|
||||
#else
|
||||
MSG_RELEASE_MEDIA, PSTR("M22")
|
||||
#endif
|
||||
);
|
||||
}
|
||||
}
|
||||
else {
|
||||
#if PIN_EXISTS(SD_DETECT)
|
||||
ACTION_ITEM(MSG_NO_MEDIA, nullptr);
|
||||
#else
|
||||
GCODES_ITEM(MSG_ATTACH_MEDIA, M21_STR);
|
||||
ACTION_ITEM(MSG_MEDIA_RELEASED, nullptr);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif // !HAS_ENCODER_WHEEL && SDSUPPORT
|
||||
|
||||
#if MACHINE_CAN_PAUSE
|
||||
if (printingIsPaused()) ACTION_ITEM(MSG_RESUME_PRINT, ui.resume_print);
|
||||
#endif
|
||||
|
||||
SUBMENU(MSG_MOTION, menu_motion);
|
||||
}
|
||||
|
||||
#if HAS_CUTTER
|
||||
SUBMENU(MSG_CUTTER(MENU), menu_spindle_laser);
|
||||
#endif
|
||||
|
||||
SUBMENU(MSG_TEMPERATURE, menu_temperature);
|
||||
|
||||
#if ENABLED(MIXING_EXTRUDER)
|
||||
SUBMENU(MSG_MIXER, menu_mixer);
|
||||
#endif
|
||||
|
||||
#if ENABLED(MMU2_MENUS)
|
||||
if (!busy) SUBMENU(MSG_MMU2_MENU, menu_mmu2);
|
||||
#endif
|
||||
|
||||
SUBMENU(MSG_CONFIGURATION, menu_configuration);
|
||||
|
||||
#if ENABLED(CUSTOM_USER_MENUS)
|
||||
#ifdef CUSTOM_USER_MENU_TITLE
|
||||
SUBMENU_P(PSTR(CUSTOM_USER_MENU_TITLE), menu_user);
|
||||
#else
|
||||
SUBMENU(MSG_USER_MENU, menu_user);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if ENABLED(ADVANCED_PAUSE_FEATURE)
|
||||
#if E_STEPPERS == 1 && DISABLED(FILAMENT_LOAD_UNLOAD_GCODES)
|
||||
if (thermalManager.targetHotEnoughToExtrude(active_extruder))
|
||||
GCODES_ITEM(MSG_FILAMENTCHANGE, PSTR("M600 B0"));
|
||||
else
|
||||
SUBMENU(MSG_FILAMENTCHANGE, []{ _menu_temp_filament_op(PAUSE_MODE_CHANGE_FILAMENT, 0); });
|
||||
#else
|
||||
SUBMENU(MSG_FILAMENTCHANGE, menu_change_filament);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if ENABLED(LCD_INFO_MENU)
|
||||
SUBMENU(MSG_INFO_MENU, menu_info);
|
||||
#endif
|
||||
|
||||
#if ENABLED(LED_CONTROL_MENU)
|
||||
SUBMENU(MSG_LED_CONTROL, menu_led);
|
||||
#endif
|
||||
|
||||
//
|
||||
// Switch power on/off
|
||||
//
|
||||
#if ENABLED(PSU_CONTROL)
|
||||
if (powersupply_on)
|
||||
GCODES_ITEM(MSG_SWITCH_PS_OFF, PSTR("M81"));
|
||||
else
|
||||
GCODES_ITEM(MSG_SWITCH_PS_ON, PSTR("M80"));
|
||||
#endif
|
||||
|
||||
#if HAS_ENCODER_WHEEL && ENABLED(SDSUPPORT)
|
||||
|
||||
// *** IF THIS SECTION IS CHANGED, REPRODUCE ABOVE ***
|
||||
|
||||
//
|
||||
// Autostart
|
||||
//
|
||||
#if ENABLED(MENU_ADDAUTOSTART)
|
||||
if (!busy) ACTION_ITEM(MSG_AUTOSTART, card.beginautostart);
|
||||
#endif
|
||||
|
||||
if (card_detected) {
|
||||
if (!card_open) {
|
||||
MENU_ITEM(gcode,
|
||||
#if PIN_EXISTS(SD_DETECT)
|
||||
MSG_CHANGE_MEDIA, M21_STR
|
||||
#else
|
||||
MSG_RELEASE_MEDIA, PSTR("M22")
|
||||
#endif
|
||||
);
|
||||
SUBMENU(MSG_MEDIA_MENU, menu_media);
|
||||
}
|
||||
}
|
||||
else {
|
||||
#if PIN_EXISTS(SD_DETECT)
|
||||
ACTION_ITEM(MSG_NO_MEDIA, nullptr);
|
||||
#else
|
||||
GCODES_ITEM(MSG_ATTACH_MEDIA, M21_STR);
|
||||
ACTION_ITEM(MSG_MEDIA_RELEASED, nullptr);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif // HAS_ENCODER_WHEEL && SDSUPPORT
|
||||
|
||||
#if HAS_SERVICE_INTERVALS
|
||||
static auto _service_reset = [](const int index) {
|
||||
print_job_timer.resetServiceInterval(index);
|
||||
#if HAS_BUZZER
|
||||
ui.completion_feedback();
|
||||
#endif
|
||||
ui.reset_status();
|
||||
ui.return_to_status();
|
||||
};
|
||||
#if SERVICE_INTERVAL_1 > 0
|
||||
CONFIRM_ITEM_P(PSTR(SERVICE_NAME_1),
|
||||
MSG_BUTTON_RESET, MSG_BUTTON_CANCEL,
|
||||
[]{ _service_reset(1); }, ui.goto_previous_screen,
|
||||
GET_TEXT(MSG_SERVICE_RESET), F(SERVICE_NAME_1), PSTR("?")
|
||||
);
|
||||
#endif
|
||||
#if SERVICE_INTERVAL_2 > 0
|
||||
CONFIRM_ITEM_P(PSTR(SERVICE_NAME_2),
|
||||
MSG_BUTTON_RESET, MSG_BUTTON_CANCEL,
|
||||
[]{ _service_reset(2); }, ui.goto_previous_screen,
|
||||
GET_TEXT(MSG_SERVICE_RESET), F(SERVICE_NAME_2), PSTR("?")
|
||||
);
|
||||
#endif
|
||||
#if SERVICE_INTERVAL_3 > 0
|
||||
CONFIRM_ITEM_P(PSTR(SERVICE_NAME_3),
|
||||
MSG_BUTTON_RESET, MSG_BUTTON_CANCEL,
|
||||
[]{ _service_reset(3); }, ui.goto_previous_screen,
|
||||
GET_TEXT(MSG_SERVICE_RESET), F(SERVICE_NAME_3), PSTR("?")
|
||||
);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if HAS_GAMES && DISABLED(LCD_INFO_MENU)
|
||||
#if ENABLED(GAMES_EASTER_EGG)
|
||||
SKIP_ITEM();
|
||||
SKIP_ITEM();
|
||||
SKIP_ITEM();
|
||||
#endif
|
||||
// Game sub-menu or the individual game
|
||||
{
|
||||
SUBMENU(
|
||||
#if HAS_GAME_MENU
|
||||
MSG_GAMES, menu_game
|
||||
#elif ENABLED(MARLIN_BRICKOUT)
|
||||
MSG_BRICKOUT, brickout.enter_game
|
||||
#elif ENABLED(MARLIN_INVADERS)
|
||||
MSG_INVADERS, invaders.enter_game
|
||||
#elif ENABLED(MARLIN_SNAKE)
|
||||
MSG_SNAKE, snake.enter_game
|
||||
#elif ENABLED(MARLIN_MAZE)
|
||||
MSG_MAZE, maze.enter_game
|
||||
#endif
|
||||
);
|
||||
}
|
||||
#endif
|
||||
|
||||
END_MENU();
|
||||
}
|
||||
|
||||
#endif // HAS_LCD_MENU
|
165
Marlin/src/lcd/menu/menu_media.cpp
Executable file
165
Marlin/src/lcd/menu/menu_media.cpp
Executable file
@@ -0,0 +1,165 @@
|
||||
/**
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
//
|
||||
// SD Card Menu
|
||||
//
|
||||
|
||||
#include "../../inc/MarlinConfigPre.h"
|
||||
|
||||
#if HAS_LCD_MENU && ENABLED(SDSUPPORT)
|
||||
|
||||
#include "menu.h"
|
||||
#include "../../sd/cardreader.h"
|
||||
|
||||
void lcd_sd_updir() {
|
||||
ui.encoderPosition = card.cdup() ? ENCODER_STEPS_PER_MENU_ITEM : 0;
|
||||
encoderTopLine = 0;
|
||||
ui.screen_changed = true;
|
||||
ui.refresh();
|
||||
}
|
||||
|
||||
#if ENABLED(SD_REPRINT_LAST_SELECTED_FILE)
|
||||
|
||||
uint16_t sd_encoder_position = 0xFFFF;
|
||||
int8_t sd_top_line, sd_items;
|
||||
|
||||
void MarlinUI::reselect_last_file() {
|
||||
if (sd_encoder_position == 0xFFFF) return;
|
||||
//#if HAS_GRAPHICAL_LCD
|
||||
// // This is a hack to force a screen update.
|
||||
// ui.refresh(LCDVIEW_CALL_REDRAW_NEXT);
|
||||
// ui.synchronize();
|
||||
// safe_delay(50);
|
||||
// ui.synchronize();
|
||||
// ui.refresh(LCDVIEW_CALL_REDRAW_NEXT);
|
||||
// ui.drawing_screen = ui.screen_changed = true;
|
||||
//#endif
|
||||
|
||||
goto_screen(menu_media, sd_encoder_position, sd_top_line, sd_items);
|
||||
sd_encoder_position = 0xFFFF;
|
||||
|
||||
defer_status_screen();
|
||||
|
||||
//#if HAS_GRAPHICAL_LCD
|
||||
// update();
|
||||
//#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
inline void sdcard_start_selected_file() {
|
||||
card.openAndPrintFile(card.filename);
|
||||
ui.return_to_status();
|
||||
ui.reset_status();
|
||||
}
|
||||
|
||||
class MenuItem_sdfile : public MenuItem_sdbase {
|
||||
public:
|
||||
static inline void draw(const bool sel, const uint8_t row, PGM_P const pstr, CardReader &theCard) {
|
||||
MenuItem_sdbase::draw(sel, row, pstr, theCard, false);
|
||||
}
|
||||
static void action(PGM_P const pstr, CardReader &) {
|
||||
#if ENABLED(SD_REPRINT_LAST_SELECTED_FILE)
|
||||
// Save menu state for the selected file
|
||||
sd_encoder_position = ui.encoderPosition;
|
||||
sd_top_line = encoderTopLine;
|
||||
sd_items = screen_items;
|
||||
#endif
|
||||
#if ENABLED(SD_MENU_CONFIRM_START)
|
||||
MenuItem_submenu::action(pstr, []{
|
||||
char * const longest = card.longest_filename();
|
||||
char buffer[strlen(longest) + 2];
|
||||
buffer[0] = ' ';
|
||||
strcpy(buffer + 1, longest);
|
||||
MenuItem_confirm::select_screen(
|
||||
GET_TEXT(MSG_BUTTON_PRINT), GET_TEXT(MSG_BUTTON_CANCEL),
|
||||
sdcard_start_selected_file, ui.goto_previous_screen,
|
||||
GET_TEXT(MSG_START_PRINT), buffer, PSTR("?")
|
||||
);
|
||||
});
|
||||
#else
|
||||
sdcard_start_selected_file();
|
||||
UNUSED(pstr);
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
class MenuItem_sdfolder : public MenuItem_sdbase {
|
||||
public:
|
||||
static inline void draw(const bool sel, const uint8_t row, PGM_P const pstr, CardReader &theCard) {
|
||||
MenuItem_sdbase::draw(sel, row, pstr, theCard, true);
|
||||
}
|
||||
static void action(PGM_P const, CardReader &theCard) {
|
||||
card.cd(theCard.filename);
|
||||
encoderTopLine = 0;
|
||||
ui.encoderPosition = 2 * (ENCODER_STEPS_PER_MENU_ITEM);
|
||||
ui.screen_changed = true;
|
||||
#if HAS_GRAPHICAL_LCD
|
||||
ui.drawing_screen = false;
|
||||
#endif
|
||||
ui.refresh();
|
||||
}
|
||||
};
|
||||
|
||||
void menu_media() {
|
||||
ui.encoder_direction_menus();
|
||||
|
||||
#if HAS_GRAPHICAL_LCD
|
||||
static uint16_t fileCnt;
|
||||
if (ui.first_page) fileCnt = card.get_num_Files();
|
||||
#else
|
||||
const uint16_t fileCnt = card.get_num_Files();
|
||||
#endif
|
||||
|
||||
START_MENU();
|
||||
BACK_ITEM(MSG_MAIN);
|
||||
if (card.flag.workDirIsRoot) {
|
||||
#if !PIN_EXISTS(SD_DETECT)
|
||||
ACTION_ITEM(MSG_REFRESH, []{ encoderTopLine = 0; card.mount(); });
|
||||
#endif
|
||||
}
|
||||
else if (card.isMounted())
|
||||
ACTION_ITEM_P(PSTR(LCD_STR_FOLDER ".."), lcd_sd_updir);
|
||||
|
||||
if (ui.should_draw()) for (uint16_t i = 0; i < fileCnt; i++) {
|
||||
if (_menuLineNr == _thisItemNr) {
|
||||
const uint16_t nr =
|
||||
#if ENABLED(SDCARD_RATHERRECENTFIRST) && DISABLED(SDCARD_SORT_ALPHA)
|
||||
fileCnt - 1 -
|
||||
#endif
|
||||
i;
|
||||
|
||||
card.getfilename_sorted(nr);
|
||||
|
||||
if (card.flag.filenameIsDir)
|
||||
MENU_ITEM(sdfolder, MSG_MEDIA_MENU, card);
|
||||
else
|
||||
MENU_ITEM(sdfile, MSG_MEDIA_MENU, card);
|
||||
}
|
||||
else {
|
||||
SKIP_ITEM();
|
||||
}
|
||||
}
|
||||
END_MENU();
|
||||
}
|
||||
|
||||
#endif // HAS_LCD_MENU && SDSUPPORT
|
292
Marlin/src/lcd/menu/menu_mixer.cpp
Executable file
292
Marlin/src/lcd/menu/menu_mixer.cpp
Executable file
@@ -0,0 +1,292 @@
|
||||
/**
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
//
|
||||
// Mixer Menu
|
||||
//
|
||||
|
||||
#include "../../inc/MarlinConfigPre.h"
|
||||
|
||||
#if HAS_LCD_MENU && ENABLED(MIXING_EXTRUDER)
|
||||
|
||||
#include "menu.h"
|
||||
#include "menu_addon.h"
|
||||
|
||||
#include "../../feature/mixing.h"
|
||||
|
||||
#define CHANNEL_MIX_EDITING !DUAL_MIXING_EXTRUDER
|
||||
|
||||
#if ENABLED(GRADIENT_MIX)
|
||||
|
||||
void lcd_mixer_gradient_z_start_edit() {
|
||||
ui.defer_status_screen();
|
||||
ENCODER_RATE_MULTIPLY(true);
|
||||
if (ui.encoderPosition != 0) {
|
||||
mixer.gradient.start_z += float(int32_t(ui.encoderPosition)) * 0.1;
|
||||
ui.encoderPosition = 0;
|
||||
NOLESS(mixer.gradient.start_z, 0);
|
||||
NOMORE(mixer.gradient.start_z, Z_MAX_POS);
|
||||
}
|
||||
if (ui.should_draw()) {
|
||||
char tmp[21];
|
||||
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);
|
||||
SETCURSOR(2, (LCD_HEIGHT - 1) / 2);
|
||||
lcd_put_u8str(tmp);
|
||||
}
|
||||
|
||||
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() {
|
||||
ui.defer_status_screen();
|
||||
ENCODER_RATE_MULTIPLY(true);
|
||||
if (ui.encoderPosition != 0) {
|
||||
mixer.gradient.end_z += float(int32_t(ui.encoderPosition)) * 0.1;
|
||||
ui.encoderPosition = 0;
|
||||
NOLESS(mixer.gradient.end_z, 0);
|
||||
NOMORE(mixer.gradient.end_z, Z_MAX_POS);
|
||||
}
|
||||
|
||||
if (ui.should_draw()) {
|
||||
char tmp[21];
|
||||
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);
|
||||
SETCURSOR(2, (LCD_HEIGHT - 1) / 2);
|
||||
lcd_put_u8str(tmp);
|
||||
}
|
||||
|
||||
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();
|
||||
BACK_ITEM(MSG_MIXER);
|
||||
|
||||
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);
|
||||
|
||||
#if ENABLED(GRADIENT_VTOOL)
|
||||
EDIT_ITEM(int8, MSG_GRADIENT_ALIAS, &mixer.gradient.vtool_index, 0, MIXING_VIRTUAL_TOOLS - 1, mixer.refresh_gradient);
|
||||
#endif
|
||||
|
||||
char tmp[18];
|
||||
|
||||
SUBMENU(MSG_START_Z, lcd_mixer_gradient_z_start_edit);
|
||||
MENU_ITEM_ADDON_START(9);
|
||||
sprintf_P(tmp, PSTR("%4d.%d mm"), int(mixer.gradient.start_z), int(mixer.gradient.start_z * 10) % 10);
|
||||
lcd_put_u8str(tmp);
|
||||
MENU_ITEM_ADDON_END();
|
||||
|
||||
SUBMENU(MSG_END_Z, lcd_mixer_gradient_z_end_edit);
|
||||
MENU_ITEM_ADDON_START(9);
|
||||
sprintf_P(tmp, PSTR("%4d.%d mm"), int(mixer.gradient.end_z), int(mixer.gradient.end_z * 10) % 10);
|
||||
lcd_put_u8str(tmp);
|
||||
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) {
|
||||
char tmp[20]; // "100%_100%"
|
||||
sprintf_P(tmp, PSTR("%3d%% %3d%%"), int(mixer.mix[0]), int(mixer.mix[1]));
|
||||
SETCURSOR(2, y); lcd_put_u8str_P(GET_TEXT(MSG_MIX));
|
||||
SETCURSOR_RJ(9, y); lcd_put_u8str(tmp);
|
||||
}
|
||||
#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() {
|
||||
|
||||
#if DUAL_MIXING_EXTRUDER && !CHANNEL_MIX_EDITING
|
||||
|
||||
// Adjust 2-channel mix from the encoder
|
||||
if (ui.encoderPosition != 0) {
|
||||
mixer.mix[0] += int32_t(ui.encoderPosition);
|
||||
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);
|
||||
|
||||
// Click to commit the change
|
||||
if (ui.lcd_clicked) {
|
||||
mixer.update_vtool_from_mix();
|
||||
ui.goto_previous_screen();
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
START_MENU();
|
||||
BACK_ITEM(MSG_MIXER);
|
||||
|
||||
#if CHANNEL_MIX_EDITING
|
||||
|
||||
LOOP_S_LE_N(n, 1, MIXING_STEPPERS)
|
||||
EDIT_ITEM_FAST_N(float42_52, n, MSG_MIX_COMPONENT_N, &mixer.collector[n-1], 0, 10);
|
||||
|
||||
ACTION_ITEM(MSG_CYCLE_MIX, _lcd_mixer_cycle_mix);
|
||||
ACTION_ITEM(MSG_COMMIT_VTOOL, _lcd_mixer_commit_vtool);
|
||||
|
||||
#endif
|
||||
|
||||
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();
|
||||
BACK_ITEM(MSG_MAIN);
|
||||
|
||||
v_index = mixer.get_current_vtool();
|
||||
EDIT_ITEM(uint8, MSG_ACTIVE_VTOOL, &v_index, 0, MIXING_VIRTUAL_TOOLS - 1, _lcd_mixer_select_vtool
|
||||
#if DUAL_MIXING_EXTRUDER
|
||||
, true
|
||||
#endif
|
||||
);
|
||||
|
||||
#if DUAL_MIXING_EXTRUDER
|
||||
{
|
||||
char tmp[10];
|
||||
SUBMENU(MSG_MIX, lcd_mixer_mix_edit);
|
||||
MENU_ITEM_ADDON_START(10);
|
||||
mixer.update_mix_from_vtool();
|
||||
sprintf_P(tmp, PSTR("%3d;%3d%%"), int(mixer.mix[0]), int(mixer.mix[1]));
|
||||
lcd_put_u8str(tmp);
|
||||
MENU_ITEM_ADDON_END();
|
||||
ACTION_ITEM(MSG_TOGGLE_MIX, _lcd_mixer_toggle_mix);
|
||||
}
|
||||
#else
|
||||
SUBMENU(MSG_MIX, _lcd_goto_mix_edit);
|
||||
#endif
|
||||
|
||||
//
|
||||
// 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("?")
|
||||
);
|
||||
|
||||
#if ENABLED(GRADIENT_MIX)
|
||||
{
|
||||
char tmp[13];
|
||||
SUBMENU(MSG_GRADIENT, lcd_mixer_edit_gradient_menu);
|
||||
MENU_ITEM_ADDON_START(10);
|
||||
sprintf_P(tmp, PSTR("T%i->T%i"), mixer.gradient.start_vtool, mixer.gradient.end_vtool);
|
||||
lcd_put_u8str(tmp);
|
||||
MENU_ITEM_ADDON_END();
|
||||
ACTION_ITEM(MSG_REVERSE_GRADIENT, _lcd_mixer_reverse_gradient);
|
||||
}
|
||||
#endif
|
||||
|
||||
END_MENU();
|
||||
}
|
||||
|
||||
#endif // HAS_LCD_MENU && MIXING_EXTRUDER
|
174
Marlin/src/lcd/menu/menu_mmu2.cpp
Executable file
174
Marlin/src/lcd/menu/menu_mmu2.cpp
Executable file
@@ -0,0 +1,174 @@
|
||||
/**
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
|
||||
#if HAS_LCD_MENU && ENABLED(MMU2_MENUS)
|
||||
|
||||
#include "../../feature/mmu2/mmu2.h"
|
||||
#include "menu_mmu2.h"
|
||||
#include "menu.h"
|
||||
|
||||
uint8_t currentTool;
|
||||
bool mmuMenuWait;
|
||||
|
||||
//
|
||||
// Load Filament
|
||||
//
|
||||
|
||||
void _mmu2_load_filamentToNozzle(uint8_t index) {
|
||||
ui.reset_status();
|
||||
ui.return_to_status();
|
||||
ui.status_printf_P(0, GET_TEXT(MSG_MMU2_LOADING_FILAMENT), int(index + 1));
|
||||
if (mmu2.load_filament_to_nozzle(index)) ui.reset_status();
|
||||
}
|
||||
|
||||
inline void action_mmu2_load_filament_to_nozzle(const uint8_t tool) {
|
||||
_mmu2_load_filamentToNozzle(tool);
|
||||
ui.return_to_status();
|
||||
}
|
||||
|
||||
void _mmu2_load_filament(uint8_t index) {
|
||||
ui.return_to_status();
|
||||
ui.status_printf_P(0, GET_TEXT(MSG_MMU2_LOADING_FILAMENT), int(index + 1));
|
||||
mmu2.load_filament(index);
|
||||
ui.reset_status();
|
||||
}
|
||||
void action_mmu2_load_all() {
|
||||
LOOP_L_N(i, EXTRUDERS)
|
||||
_mmu2_load_filament(i);
|
||||
ui.return_to_status();
|
||||
}
|
||||
|
||||
void menu_mmu2_load_filament() {
|
||||
START_MENU();
|
||||
BACK_ITEM(MSG_MMU2_MENU);
|
||||
ACTION_ITEM(MSG_MMU2_ALL, action_mmu2_load_all);
|
||||
LOOP_L_N(i, 5) ACTION_ITEM_N(i, MSG_MMU2_FILAMENT_N, []{ _mmu2_load_filament(MenuItemBase::itemIndex); });
|
||||
END_MENU();
|
||||
}
|
||||
|
||||
void menu_mmu2_load_to_nozzle() {
|
||||
START_MENU();
|
||||
BACK_ITEM(MSG_MMU2_MENU);
|
||||
LOOP_L_N(i, 5) ACTION_ITEM_N(i, MSG_MMU2_FILAMENT_N, []{ action_mmu2_load_filament_to_nozzle(MenuItemBase::itemIndex); });
|
||||
END_MENU();
|
||||
}
|
||||
|
||||
//
|
||||
// Eject Filament
|
||||
//
|
||||
|
||||
void _mmu2_eject_filament(uint8_t index) {
|
||||
ui.reset_status();
|
||||
ui.return_to_status();
|
||||
ui.status_printf_P(0, GET_TEXT(MSG_MMU2_EJECTING_FILAMENT), int(index + 1));
|
||||
if (mmu2.eject_filament(index, true)) ui.reset_status();
|
||||
}
|
||||
|
||||
void action_mmu2_unload_filament() {
|
||||
ui.reset_status();
|
||||
ui.return_to_status();
|
||||
LCD_MESSAGEPGM(MSG_MMU2_UNLOADING_FILAMENT);
|
||||
idle();
|
||||
if (mmu2.unload()) ui.reset_status();
|
||||
}
|
||||
|
||||
void menu_mmu2_eject_filament() {
|
||||
START_MENU();
|
||||
BACK_ITEM(MSG_MMU2_MENU);
|
||||
LOOP_L_N(i, 5) ACTION_ITEM_N(i, MSG_MMU2_FILAMENT_N, []{ _mmu2_eject_filament(MenuItemBase::itemIndex); });
|
||||
END_MENU();
|
||||
}
|
||||
|
||||
//
|
||||
// MMU2 Menu
|
||||
//
|
||||
|
||||
void action_mmu2_reset() {
|
||||
mmu2.init();
|
||||
ui.reset_status();
|
||||
}
|
||||
|
||||
void menu_mmu2() {
|
||||
START_MENU();
|
||||
BACK_ITEM(MSG_MAIN);
|
||||
SUBMENU(MSG_MMU2_LOAD_FILAMENT, menu_mmu2_load_filament);
|
||||
SUBMENU(MSG_MMU2_LOAD_TO_NOZZLE, menu_mmu2_load_to_nozzle);
|
||||
SUBMENU(MSG_MMU2_EJECT_FILAMENT, menu_mmu2_eject_filament);
|
||||
ACTION_ITEM(MSG_MMU2_UNLOAD_FILAMENT, action_mmu2_unload_filament);
|
||||
ACTION_ITEM(MSG_MMU2_RESET, action_mmu2_reset);
|
||||
END_MENU();
|
||||
}
|
||||
|
||||
//
|
||||
// T* Choose Filament
|
||||
//
|
||||
|
||||
inline void action_mmu2_choose(const uint8_t tool) {
|
||||
currentTool = tool;
|
||||
mmuMenuWait = false;
|
||||
}
|
||||
|
||||
void menu_mmu2_choose_filament() {
|
||||
START_MENU();
|
||||
#if LCD_HEIGHT > 2
|
||||
STATIC_ITEM(MSG_MMU2_CHOOSE_FILAMENT_HEADER, SS_CENTER|SS_INVERT);
|
||||
#endif
|
||||
LOOP_L_N(i, 5) ACTION_ITEM_N(i, MSG_MMU2_FILAMENT_N, []{ action_mmu2_choose(MenuItemBase::itemIndex); });
|
||||
END_MENU();
|
||||
}
|
||||
|
||||
//
|
||||
// MMU2 Filament Runout
|
||||
//
|
||||
|
||||
void menu_mmu2_pause() {
|
||||
currentTool = mmu2.get_current_tool();
|
||||
START_MENU();
|
||||
#if LCD_HEIGHT > 2
|
||||
STATIC_ITEM(MSG_FILAMENT_CHANGE_HEADER, SS_CENTER|SS_INVERT);
|
||||
#endif
|
||||
ACTION_ITEM(MSG_MMU2_RESUME, []{ mmuMenuWait = false; });
|
||||
ACTION_ITEM(MSG_MMU2_UNLOAD_FILAMENT, []{ mmu2.unload(); });
|
||||
ACTION_ITEM(MSG_MMU2_LOAD_FILAMENT, []{ mmu2.load_filament(currentTool); });
|
||||
ACTION_ITEM(MSG_MMU2_LOAD_TO_NOZZLE, []{ mmu2.load_filament_to_nozzle(currentTool); });
|
||||
END_MENU();
|
||||
}
|
||||
|
||||
void mmu2_M600() {
|
||||
ui.defer_status_screen();
|
||||
ui.goto_screen(menu_mmu2_pause);
|
||||
mmuMenuWait = true;
|
||||
while (mmuMenuWait) idle();
|
||||
}
|
||||
|
||||
uint8_t mmu2_choose_filament() {
|
||||
ui.defer_status_screen();
|
||||
ui.goto_screen(menu_mmu2_choose_filament);
|
||||
mmuMenuWait = true;
|
||||
while (mmuMenuWait) idle();
|
||||
ui.return_to_status();
|
||||
return currentTool;
|
||||
}
|
||||
|
||||
#endif // HAS_LCD_MENU && ENABLED(PRUSA_MMU2_MENUS)
|
28
Marlin/src/lcd/menu/menu_mmu2.h
Executable file
28
Marlin/src/lcd/menu/menu_mmu2.h
Executable file
@@ -0,0 +1,28 @@
|
||||
/**
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
void menu_mmu2();
|
||||
void mmu2_M600();
|
||||
uint8_t mmu2_choose_filament();
|
451
Marlin/src/lcd/menu/menu_motion.cpp
Executable file
451
Marlin/src/lcd/menu/menu_motion.cpp
Executable file
@@ -0,0 +1,451 @@
|
||||
/**
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
//
|
||||
// Motion Menu
|
||||
//
|
||||
|
||||
#include "../../inc/MarlinConfigPre.h"
|
||||
|
||||
#if HAS_LCD_MENU
|
||||
|
||||
#include "menu.h"
|
||||
#include "menu_addon.h"
|
||||
|
||||
#include "../../module/motion.h"
|
||||
|
||||
#if ENABLED(DELTA)
|
||||
#include "../../module/delta.h"
|
||||
#endif
|
||||
|
||||
#if ENABLED(PREVENT_COLD_EXTRUSION)
|
||||
#include "../../module/temperature.h"
|
||||
#endif
|
||||
|
||||
#if HAS_LEVELING
|
||||
#include "../../module/planner.h"
|
||||
#include "../../feature/bedlevel/bedlevel.h"
|
||||
#endif
|
||||
|
||||
extern millis_t manual_move_start_time;
|
||||
extern int8_t manual_move_axis;
|
||||
#if ENABLED(MANUAL_E_MOVES_RELATIVE)
|
||||
float manual_move_e_origin = 0;
|
||||
#endif
|
||||
#if IS_KINEMATIC
|
||||
extern float manual_move_offset;
|
||||
#endif
|
||||
|
||||
//
|
||||
// Tell ui.update() to start a move to current_position" after a short delay.
|
||||
//
|
||||
inline void manual_move_to_current(AxisEnum axis
|
||||
#if E_MANUAL > 1
|
||||
, const int8_t eindex=-1
|
||||
#endif
|
||||
) {
|
||||
#if E_MANUAL > 1
|
||||
if (axis == E_AXIS) ui.manual_move_e_index = eindex >= 0 ? eindex : active_extruder;
|
||||
#endif
|
||||
manual_move_start_time = millis() + (move_menu_scale < 0.99f ? 0UL : 250UL); // delay for bigger moves
|
||||
manual_move_axis = (int8_t)axis;
|
||||
}
|
||||
|
||||
//
|
||||
// "Motion" > "Move Axis" submenu
|
||||
//
|
||||
|
||||
static void _lcd_move_xyz(PGM_P const name, const AxisEnum axis) {
|
||||
if (ui.use_click()) return ui.goto_previous_screen_no_defer();
|
||||
if (ui.encoderPosition && !ui.processing_manual_move) {
|
||||
|
||||
// Start with no limits to movement
|
||||
float min = current_position[axis] - 1000,
|
||||
max = current_position[axis] + 1000;
|
||||
|
||||
// Limit to software endstops, if enabled
|
||||
#if HAS_SOFTWARE_ENDSTOPS
|
||||
if (soft_endstops_enabled) switch (axis) {
|
||||
case X_AXIS:
|
||||
#if ENABLED(MIN_SOFTWARE_ENDSTOP_X)
|
||||
min = soft_endstop.min.x;
|
||||
#endif
|
||||
#if ENABLED(MAX_SOFTWARE_ENDSTOP_X)
|
||||
max = soft_endstop.max.x;
|
||||
#endif
|
||||
break;
|
||||
case Y_AXIS:
|
||||
#if ENABLED(MIN_SOFTWARE_ENDSTOP_Y)
|
||||
min = soft_endstop.min.y;
|
||||
#endif
|
||||
#if ENABLED(MAX_SOFTWARE_ENDSTOP_Y)
|
||||
max = soft_endstop.max.y;
|
||||
#endif
|
||||
break;
|
||||
case Z_AXIS:
|
||||
#if ENABLED(MIN_SOFTWARE_ENDSTOP_Z)
|
||||
min = soft_endstop.min.z;
|
||||
#endif
|
||||
#if ENABLED(MAX_SOFTWARE_ENDSTOP_Z)
|
||||
max = soft_endstop.max.z;
|
||||
#endif
|
||||
default: break;
|
||||
}
|
||||
#endif // HAS_SOFTWARE_ENDSTOPS
|
||||
|
||||
// Delta limits XY based on the current offset from center
|
||||
// This assumes the center is 0,0
|
||||
#if ENABLED(DELTA)
|
||||
if (axis != Z_AXIS) {
|
||||
max = SQRT(sq((float)(DELTA_PRINTABLE_RADIUS)) - sq(current_position[Y_AXIS - axis])); // (Y_AXIS - axis) == the other axis
|
||||
min = -max;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Get the new position
|
||||
const float diff = float(int32_t(ui.encoderPosition)) * move_menu_scale;
|
||||
#if IS_KINEMATIC
|
||||
manual_move_offset += diff;
|
||||
if (int32_t(ui.encoderPosition) < 0)
|
||||
NOLESS(manual_move_offset, min - current_position[axis]);
|
||||
else
|
||||
NOMORE(manual_move_offset, max - current_position[axis]);
|
||||
#else
|
||||
current_position[axis] += diff;
|
||||
if (int32_t(ui.encoderPosition) < 0)
|
||||
NOLESS(current_position[axis], min);
|
||||
else
|
||||
NOMORE(current_position[axis], max);
|
||||
#endif
|
||||
|
||||
manual_move_to_current(axis);
|
||||
ui.refresh(LCDVIEW_REDRAW_NOW);
|
||||
}
|
||||
ui.encoderPosition = 0;
|
||||
if (ui.should_draw()) {
|
||||
const float pos = NATIVE_TO_LOGICAL(ui.processing_manual_move ? destination[axis] : current_position[axis]
|
||||
#if IS_KINEMATIC
|
||||
+ manual_move_offset
|
||||
#endif
|
||||
, axis);
|
||||
MenuEditItemBase::draw_edit_screen(name, move_menu_scale >= 0.1f ? ftostr41sign(pos) : ftostr43sign(pos));
|
||||
}
|
||||
}
|
||||
void lcd_move_x() { _lcd_move_xyz(GET_TEXT(MSG_MOVE_X), X_AXIS); }
|
||||
void lcd_move_y() { _lcd_move_xyz(GET_TEXT(MSG_MOVE_Y), Y_AXIS); }
|
||||
void lcd_move_z() { _lcd_move_xyz(GET_TEXT(MSG_MOVE_Z), Z_AXIS); }
|
||||
|
||||
#if E_MANUAL
|
||||
|
||||
static void lcd_move_e(
|
||||
#if E_MANUAL > 1
|
||||
const int8_t eindex=-1
|
||||
#endif
|
||||
) {
|
||||
if (ui.use_click()) return ui.goto_previous_screen_no_defer();
|
||||
if (ui.encoderPosition) {
|
||||
if (!ui.processing_manual_move) {
|
||||
const float diff = float(int32_t(ui.encoderPosition)) * move_menu_scale;
|
||||
#if IS_KINEMATIC
|
||||
manual_move_offset += diff;
|
||||
#else
|
||||
current_position.e += diff;
|
||||
#endif
|
||||
manual_move_to_current(E_AXIS
|
||||
#if E_MANUAL > 1
|
||||
, eindex
|
||||
#endif
|
||||
);
|
||||
ui.refresh(LCDVIEW_REDRAW_NOW);
|
||||
}
|
||||
ui.encoderPosition = 0;
|
||||
}
|
||||
if (ui.should_draw()) {
|
||||
#if E_MANUAL > 1
|
||||
MenuItemBase::init(eindex);
|
||||
#endif
|
||||
MenuEditItemBase::draw_edit_screen(
|
||||
GET_TEXT(
|
||||
#if E_MANUAL > 1
|
||||
MSG_MOVE_EN
|
||||
#else
|
||||
MSG_MOVE_E
|
||||
#endif
|
||||
),
|
||||
ftostr41sign(current_position.e
|
||||
#if IS_KINEMATIC
|
||||
+ manual_move_offset
|
||||
#endif
|
||||
#if ENABLED(MANUAL_E_MOVES_RELATIVE)
|
||||
- manual_move_e_origin
|
||||
#endif
|
||||
)
|
||||
);
|
||||
} // should_draw
|
||||
}
|
||||
|
||||
#endif // E_MANUAL
|
||||
|
||||
//
|
||||
// "Motion" > "Move Xmm" > "Move XYZ" submenu
|
||||
//
|
||||
|
||||
#ifndef SHORT_MANUAL_Z_MOVE
|
||||
#define SHORT_MANUAL_Z_MOVE 0.025
|
||||
#endif
|
||||
|
||||
screenFunc_t _manual_move_func_ptr;
|
||||
|
||||
void _goto_manual_move(const float scale) {
|
||||
ui.defer_status_screen();
|
||||
move_menu_scale = scale;
|
||||
ui.goto_screen(_manual_move_func_ptr);
|
||||
}
|
||||
|
||||
void _menu_move_distance(const AxisEnum axis, const screenFunc_t func, const int8_t eindex=-1) {
|
||||
_manual_move_func_ptr = func;
|
||||
START_MENU();
|
||||
if (LCD_HEIGHT >= 4) {
|
||||
switch (axis) {
|
||||
case X_AXIS: STATIC_ITEM(MSG_MOVE_X, SS_CENTER|SS_INVERT); break;
|
||||
case Y_AXIS: STATIC_ITEM(MSG_MOVE_Y, SS_CENTER|SS_INVERT); break;
|
||||
case Z_AXIS: STATIC_ITEM(MSG_MOVE_Z, SS_CENTER|SS_INVERT); break;
|
||||
default:
|
||||
#if ENABLED(MANUAL_E_MOVES_RELATIVE)
|
||||
manual_move_e_origin = current_position.e;
|
||||
#endif
|
||||
STATIC_ITEM(MSG_MOVE_E, SS_CENTER|SS_INVERT);
|
||||
break;
|
||||
}
|
||||
}
|
||||
#if ENABLED(PREVENT_COLD_EXTRUSION)
|
||||
if (axis == E_AXIS && thermalManager.tooColdToExtrude(eindex >= 0 ? eindex : active_extruder))
|
||||
BACK_ITEM(MSG_HOTEND_TOO_COLD);
|
||||
else
|
||||
#endif
|
||||
{
|
||||
BACK_ITEM(MSG_MOVE_AXIS);
|
||||
SUBMENU(MSG_MOVE_10MM, []{ _goto_manual_move(10); });
|
||||
SUBMENU(MSG_MOVE_1MM, []{ _goto_manual_move( 1); });
|
||||
SUBMENU(MSG_MOVE_01MM, []{ _goto_manual_move( 0.1f); });
|
||||
if (axis == Z_AXIS && (SHORT_MANUAL_Z_MOVE) > 0.0f && (SHORT_MANUAL_Z_MOVE) < 0.1f) {
|
||||
extern const char NUL_STR[];
|
||||
SUBMENU_P(NUL_STR, []{ _goto_manual_move(float(SHORT_MANUAL_Z_MOVE)); });
|
||||
MENU_ITEM_ADDON_START(0
|
||||
#if HAS_CHARACTER_LCD
|
||||
+ 1
|
||||
#endif
|
||||
);
|
||||
char tmp[20], numstr[10];
|
||||
// Determine digits needed right of decimal
|
||||
const uint8_t digs = !UNEAR_ZERO((SHORT_MANUAL_Z_MOVE) * 1000 - int((SHORT_MANUAL_Z_MOVE) * 1000)) ? 4 :
|
||||
!UNEAR_ZERO((SHORT_MANUAL_Z_MOVE) * 100 - int((SHORT_MANUAL_Z_MOVE) * 100)) ? 3 : 2;
|
||||
sprintf_P(tmp, GET_TEXT(MSG_MOVE_Z_DIST), dtostrf(SHORT_MANUAL_Z_MOVE, 1, digs, numstr));
|
||||
lcd_put_u8str(tmp);
|
||||
MENU_ITEM_ADDON_END();
|
||||
}
|
||||
}
|
||||
END_MENU();
|
||||
}
|
||||
|
||||
void menu_move() {
|
||||
START_MENU();
|
||||
BACK_ITEM(MSG_MOTION);
|
||||
|
||||
#if HAS_SOFTWARE_ENDSTOPS && ENABLED(SOFT_ENDSTOPS_MENU_ITEM)
|
||||
EDIT_ITEM(bool, MSG_LCD_SOFT_ENDSTOPS, &soft_endstops_enabled);
|
||||
#endif
|
||||
|
||||
if (
|
||||
#if IS_KINEMATIC || ENABLED(NO_MOTION_BEFORE_HOMING)
|
||||
all_axes_homed()
|
||||
#else
|
||||
true
|
||||
#endif
|
||||
) {
|
||||
if (
|
||||
#if ENABLED(DELTA)
|
||||
current_position.z <= delta_clip_start_height
|
||||
#else
|
||||
true
|
||||
#endif
|
||||
) {
|
||||
SUBMENU(MSG_MOVE_X, []{ _menu_move_distance(X_AXIS, lcd_move_x); });
|
||||
SUBMENU(MSG_MOVE_Y, []{ _menu_move_distance(Y_AXIS, lcd_move_y); });
|
||||
}
|
||||
#if ENABLED(DELTA)
|
||||
else
|
||||
ACTION_ITEM(MSG_FREE_XY, []{ line_to_z(delta_clip_start_height); ui.synchronize(); });
|
||||
#endif
|
||||
|
||||
SUBMENU(MSG_MOVE_Z, []{ _menu_move_distance(Z_AXIS, lcd_move_z); });
|
||||
}
|
||||
else
|
||||
GCODES_ITEM(MSG_AUTO_HOME, G28_STR);
|
||||
|
||||
#if ANY(SWITCHING_EXTRUDER, SWITCHING_NOZZLE, MAGNETIC_SWITCHING_TOOLHEAD)
|
||||
|
||||
#if EXTRUDERS >= 4
|
||||
switch (active_extruder) {
|
||||
case 0: GCODES_ITEM_N(1, MSG_SELECT_E, PSTR("T1")); break;
|
||||
case 1: GCODES_ITEM_N(0, MSG_SELECT_E, PSTR("T0")); break;
|
||||
case 2: GCODES_ITEM_N(3, MSG_SELECT_E, PSTR("T3")); break;
|
||||
case 3: GCODES_ITEM_N(2, MSG_SELECT_E, PSTR("T2")); break;
|
||||
#if EXTRUDERS == 6
|
||||
case 4: GCODES_ITEM_N(5, MSG_SELECT_E, PSTR("T5")); break;
|
||||
case 5: GCODES_ITEM_N(4, MSG_SELECT_E, PSTR("T4")); break;
|
||||
#endif
|
||||
}
|
||||
#elif EXTRUDERS == 3
|
||||
if (active_extruder < 2) {
|
||||
if (active_extruder)
|
||||
GCODES_ITEM_N(0, MSG_SELECT_E, PSTR("T0"));
|
||||
else
|
||||
GCODES_ITEM_N(1, MSG_SELECT_E, PSTR("T1"));
|
||||
}
|
||||
#else
|
||||
if (active_extruder)
|
||||
GCODES_ITEM_N(0, MSG_SELECT_E, PSTR("T0"));
|
||||
else
|
||||
GCODES_ITEM_N(1, MSG_SELECT_E, PSTR("T1"));
|
||||
#endif
|
||||
|
||||
#elif ENABLED(DUAL_X_CARRIAGE)
|
||||
|
||||
if (active_extruder)
|
||||
GCODES_ITEM_N(0, MSG_SELECT_E, PSTR("T0"));
|
||||
else
|
||||
GCODES_ITEM_N(1, MSG_SELECT_E, PSTR("T1"));
|
||||
|
||||
#endif
|
||||
|
||||
#if E_MANUAL
|
||||
|
||||
// The current extruder
|
||||
SUBMENU(MSG_MOVE_E, []{ _menu_move_distance(E_AXIS, []{ lcd_move_e(); }, -1); });
|
||||
|
||||
#define SUBMENU_MOVE_E(N) SUBMENU_N(N, MSG_MOVE_EN, []{ _menu_move_distance(E_AXIS, []{ lcd_move_e(MenuItemBase::itemIndex); }, MenuItemBase::itemIndex); });
|
||||
|
||||
#if EITHER(SWITCHING_EXTRUDER, SWITCHING_NOZZLE)
|
||||
|
||||
// ...and the non-switching
|
||||
#if E_MANUAL == 5
|
||||
SUBMENU_MOVE_E(4);
|
||||
#elif E_MANUAL == 3
|
||||
SUBMENU_MOVE_E(2);
|
||||
#endif
|
||||
|
||||
#elif E_MANUAL > 1
|
||||
|
||||
// Independent extruders with one E-stepper per hotend
|
||||
LOOP_L_N(n, E_MANUAL) SUBMENU_MOVE_E(n);
|
||||
|
||||
#endif
|
||||
|
||||
#endif // E_MANUAL
|
||||
|
||||
END_MENU();
|
||||
}
|
||||
|
||||
#if ENABLED(AUTO_BED_LEVELING_UBL)
|
||||
void _lcd_ubl_level_bed();
|
||||
#elif ENABLED(LCD_BED_LEVELING)
|
||||
void menu_bed_leveling();
|
||||
#endif
|
||||
|
||||
void menu_motion() {
|
||||
START_MENU();
|
||||
|
||||
//
|
||||
// ^ Main
|
||||
//
|
||||
BACK_ITEM(MSG_MAIN);
|
||||
|
||||
//
|
||||
// Move Axis
|
||||
//
|
||||
#if ENABLED(DELTA)
|
||||
if (all_axes_homed())
|
||||
#endif
|
||||
SUBMENU(MSG_MOVE_AXIS, menu_move);
|
||||
|
||||
//
|
||||
// Auto Home
|
||||
//
|
||||
GCODES_ITEM(MSG_AUTO_HOME, G28_STR);
|
||||
#if ENABLED(INDIVIDUAL_AXIS_HOMING_MENU)
|
||||
GCODES_ITEM(MSG_AUTO_HOME_X, PSTR("G28X"));
|
||||
GCODES_ITEM(MSG_AUTO_HOME_Y, PSTR("G28Y"));
|
||||
GCODES_ITEM(MSG_AUTO_HOME_Z, PSTR("G28Z"));
|
||||
#endif
|
||||
|
||||
//
|
||||
// Auto Z-Align
|
||||
//
|
||||
#if ENABLED(Z_STEPPER_AUTO_ALIGN)
|
||||
GCODES_ITEM(MSG_AUTO_Z_ALIGN, PSTR("G34"));
|
||||
#endif
|
||||
|
||||
//
|
||||
// Level Bed
|
||||
//
|
||||
#if ENABLED(AUTO_BED_LEVELING_UBL)
|
||||
|
||||
SUBMENU(MSG_UBL_LEVEL_BED, _lcd_ubl_level_bed);
|
||||
|
||||
#elif ENABLED(LCD_BED_LEVELING)
|
||||
|
||||
if (!g29_in_progress) SUBMENU(MSG_BED_LEVELING, menu_bed_leveling);
|
||||
|
||||
#elif HAS_LEVELING && DISABLED(SLIM_LCD_MENUS)
|
||||
|
||||
#if DISABLED(PROBE_MANUALLY)
|
||||
GCODES_ITEM(MSG_LEVEL_BED, PSTR("G28\nG29"));
|
||||
#endif
|
||||
if (all_axes_homed() && leveling_is_valid()) {
|
||||
bool show_state = planner.leveling_active;
|
||||
EDIT_ITEM(bool, MSG_BED_LEVELING, &show_state, _lcd_toggle_bed_leveling);
|
||||
}
|
||||
#if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
|
||||
editable.decimal = planner.z_fade_height;
|
||||
EDIT_ITEM_FAST(float3, MSG_Z_FADE_HEIGHT, &editable.decimal, 0, 100, []{ set_z_fade_height(editable.decimal); });
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#if ENABLED(LEVEL_BED_CORNERS) && DISABLED(LCD_BED_LEVELING)
|
||||
ACTION_ITEM(MSG_LEVEL_CORNERS, _lcd_level_bed_corners);
|
||||
#endif
|
||||
|
||||
#if ENABLED(Z_MIN_PROBE_REPEATABILITY_TEST)
|
||||
GCODES_ITEM(MSG_M48_TEST, PSTR("G28\nM48 P10"));
|
||||
#endif
|
||||
|
||||
//
|
||||
// Disable Steppers
|
||||
//
|
||||
GCODES_ITEM(MSG_DISABLE_STEPPERS, PSTR("M84"));
|
||||
|
||||
END_MENU();
|
||||
}
|
||||
|
||||
#endif // HAS_LCD_MENU
|
54
Marlin/src/lcd/menu/menu_spindle_laser.cpp
Executable file
54
Marlin/src/lcd/menu/menu_spindle_laser.cpp
Executable file
@@ -0,0 +1,54 @@
|
||||
/**
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
//
|
||||
// Spindle / Laser Menu
|
||||
//
|
||||
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
|
||||
#if HAS_LCD_MENU && HAS_CUTTER
|
||||
|
||||
#include "menu.h"
|
||||
|
||||
#include "../../feature/spindle_laser.h"
|
||||
|
||||
void menu_spindle_laser() {
|
||||
|
||||
START_MENU();
|
||||
BACK_ITEM(MSG_MAIN);
|
||||
if (cutter.enabled()) {
|
||||
#if ENABLED(SPINDLE_LASER_PWM)
|
||||
EDIT_ITEM(CUTTER_MENU_TYPE, MSG_CUTTER(POWER), &cutter.power, SPEED_POWER_MIN, SPEED_POWER_MAX);
|
||||
#endif
|
||||
ACTION_ITEM(MSG_CUTTER(OFF), cutter.disable);
|
||||
}
|
||||
else {
|
||||
ACTION_ITEM(MSG_CUTTER(ON), cutter.enable_forward);
|
||||
#if ENABLED(SPINDLE_CHANGE_DIR)
|
||||
ACTION_ITEM(MSG_SPINDLE_REVERSE, cutter.enable_reverse);
|
||||
#endif
|
||||
}
|
||||
END_MENU();
|
||||
}
|
||||
|
||||
#endif // HAS_LCD_MENU && HAS_CUTTER
|
297
Marlin/src/lcd/menu/menu_temperature.cpp
Executable file
297
Marlin/src/lcd/menu/menu_temperature.cpp
Executable file
@@ -0,0 +1,297 @@
|
||||
/**
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
//
|
||||
// Temperature Menu
|
||||
//
|
||||
|
||||
#include "../../inc/MarlinConfigPre.h"
|
||||
|
||||
#if HAS_LCD_MENU
|
||||
|
||||
#include "menu.h"
|
||||
#include "../../module/temperature.h"
|
||||
|
||||
#if FAN_COUNT > 1 || ENABLED(SINGLENOZZLE)
|
||||
#include "../../module/motion.h"
|
||||
#endif
|
||||
|
||||
#if ENABLED(SINGLENOZZLE)
|
||||
#include "../../module/tool_change.h"
|
||||
#endif
|
||||
|
||||
// Initialized by settings.load()
|
||||
int16_t MarlinUI::preheat_hotend_temp[2], MarlinUI::preheat_bed_temp[2];
|
||||
uint8_t MarlinUI::preheat_fan_speed[2];
|
||||
|
||||
//
|
||||
// "Temperature" submenu items
|
||||
//
|
||||
|
||||
void _lcd_preheat(const int16_t endnum, const int16_t temph, const int16_t tempb, const uint8_t fan) {
|
||||
#if HOTENDS
|
||||
if (temph > 0) thermalManager.setTargetHotend(_MIN(heater_maxtemp[endnum] - 15, temph), endnum);
|
||||
#endif
|
||||
#if HAS_HEATED_BED
|
||||
if (tempb >= 0) thermalManager.setTargetBed(tempb);
|
||||
#else
|
||||
UNUSED(tempb);
|
||||
#endif
|
||||
#if FAN_COUNT > 0
|
||||
#if FAN_COUNT > 1
|
||||
thermalManager.set_fan_speed(active_extruder < FAN_COUNT ? active_extruder : 0, fan);
|
||||
#else
|
||||
thermalManager.set_fan_speed(0, fan);
|
||||
#endif
|
||||
#else
|
||||
UNUSED(fan);
|
||||
#endif
|
||||
ui.return_to_status();
|
||||
}
|
||||
|
||||
#if HAS_TEMP_HOTEND
|
||||
inline void _preheat_end(const uint8_t m, const uint8_t e) {
|
||||
_lcd_preheat(e, ui.preheat_hotend_temp[m], -1, ui.preheat_fan_speed[m]);
|
||||
}
|
||||
#if HAS_HEATED_BED
|
||||
inline void _preheat_both(const uint8_t m, const uint8_t e) {
|
||||
_lcd_preheat(e, ui.preheat_hotend_temp[m], ui.preheat_bed_temp[m], ui.preheat_fan_speed[m]);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
#if HAS_HEATED_BED
|
||||
inline void _preheat_bed(const uint8_t m) {
|
||||
_lcd_preheat(0, 0, ui.preheat_bed_temp[m], ui.preheat_fan_speed[m]);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if HAS_TEMP_HOTEND || HAS_HEATED_BED
|
||||
|
||||
#define _PREHEAT_ITEMS(M,N) do{ \
|
||||
ACTION_ITEM_N(N, MSG_PREHEAT_##M##_H, []{ _preheat_both(M-1, MenuItemBase::itemIndex); }); \
|
||||
ACTION_ITEM_N(N, MSG_PREHEAT_##M##_END_E, []{ _preheat_end(M-1, MenuItemBase::itemIndex); }); \
|
||||
}while(0)
|
||||
#if HAS_HEATED_BED
|
||||
#define PREHEAT_ITEMS(M,N) _PREHEAT_ITEMS(M,N)
|
||||
#else
|
||||
#define PREHEAT_ITEMS(M,N) \
|
||||
ACTION_ITEM_N(N, MSG_PREHEAT_##M##_H, []{ _preheat_end(M-1, MenuItemBase::itemIndex); })
|
||||
#endif
|
||||
|
||||
void menu_preheat_m1() {
|
||||
START_MENU();
|
||||
BACK_ITEM(MSG_TEMPERATURE);
|
||||
#if HOTENDS == 1
|
||||
#if HAS_HEATED_BED
|
||||
ACTION_ITEM(MSG_PREHEAT_1, []{ _preheat_both(0, 0); });
|
||||
ACTION_ITEM(MSG_PREHEAT_1_END, []{ _preheat_end(0, 0); });
|
||||
#else
|
||||
ACTION_ITEM(MSG_PREHEAT_1, []{ _preheat_end(0, 0); });
|
||||
#endif
|
||||
#elif HOTENDS > 1
|
||||
#if HAS_HEATED_BED
|
||||
_PREHEAT_ITEMS(1,0);
|
||||
#endif
|
||||
LOOP_S_L_N(n, 1, HOTENDS) PREHEAT_ITEMS(1,n);
|
||||
ACTION_ITEM(MSG_PREHEAT_1_ALL, []() {
|
||||
#if HAS_HEATED_BED
|
||||
_preheat_bed(0);
|
||||
#endif
|
||||
HOTEND_LOOP() thermalManager.setTargetHotend(ui.preheat_hotend_temp[0], e);
|
||||
});
|
||||
#endif // HOTENDS > 1
|
||||
#if HAS_HEATED_BED
|
||||
ACTION_ITEM(MSG_PREHEAT_1_BEDONLY, []{ _preheat_bed(0); });
|
||||
#endif
|
||||
END_MENU();
|
||||
}
|
||||
|
||||
void menu_preheat_m2() {
|
||||
START_MENU();
|
||||
BACK_ITEM(MSG_TEMPERATURE);
|
||||
#if HOTENDS == 1
|
||||
#if HAS_HEATED_BED
|
||||
ACTION_ITEM(MSG_PREHEAT_2, []{ _preheat_both(1, 0); });
|
||||
ACTION_ITEM(MSG_PREHEAT_2_END, []{ _preheat_end(1, 0); });
|
||||
#else
|
||||
ACTION_ITEM(MSG_PREHEAT_2, []{ _preheat_end(1, 0); });
|
||||
#endif
|
||||
#elif HOTENDS > 1
|
||||
#if HAS_HEATED_BED
|
||||
_PREHEAT_ITEMS(2,0);
|
||||
#endif
|
||||
LOOP_S_L_N(n, 1, HOTENDS) PREHEAT_ITEMS(2,n);
|
||||
ACTION_ITEM(MSG_PREHEAT_2_ALL, []() {
|
||||
#if HAS_HEATED_BED
|
||||
_preheat_bed(1);
|
||||
#endif
|
||||
HOTEND_LOOP() thermalManager.setTargetHotend(ui.preheat_hotend_temp[1], e);
|
||||
});
|
||||
#endif // HOTENDS > 1
|
||||
#if HAS_HEATED_BED
|
||||
ACTION_ITEM(MSG_PREHEAT_2_BEDONLY, []{ _preheat_bed(1); });
|
||||
#endif
|
||||
END_MENU();
|
||||
}
|
||||
|
||||
void lcd_cooldown() {
|
||||
thermalManager.zero_fan_speeds();
|
||||
thermalManager.disable_all_heaters();
|
||||
ui.return_to_status();
|
||||
}
|
||||
|
||||
#endif // HAS_TEMP_HOTEND || HAS_HEATED_BED
|
||||
|
||||
void menu_temperature() {
|
||||
START_MENU();
|
||||
BACK_ITEM(MSG_MAIN);
|
||||
|
||||
//
|
||||
// Nozzle:
|
||||
// Nozzle [1-5]:
|
||||
//
|
||||
#if HOTENDS == 1
|
||||
EDIT_ITEM_FAST(int3, MSG_NOZZLE, &thermalManager.temp_hotend[0].target, 0, HEATER_0_MAXTEMP - 15, []{ thermalManager.start_watching_hotend(0); });
|
||||
#elif HOTENDS > 1
|
||||
HOTEND_LOOP()
|
||||
EDIT_ITEM_FAST_N(int3, e, MSG_NOZZLE_N, &thermalManager.temp_hotend[e].target, 0, heater_maxtemp[e] - 15, []{ thermalManager.start_watching_hotend(MenuItemBase::itemIndex); });
|
||||
#endif
|
||||
|
||||
#if ENABLED(SINGLENOZZLE)
|
||||
EDIT_ITEM_FAST(uint16_3, MSG_NOZZLE_STANDBY, &singlenozzle_temp[active_extruder ? 0 : 1], 0, HEATER_0_MAXTEMP - 15);
|
||||
#endif
|
||||
|
||||
//
|
||||
// Bed:
|
||||
//
|
||||
#if HAS_HEATED_BED
|
||||
EDIT_ITEM_FAST(int3, MSG_BED, &thermalManager.temp_bed.target, 0, BED_MAXTEMP - 10, thermalManager.start_watching_bed);
|
||||
#endif
|
||||
|
||||
//
|
||||
// Chamber:
|
||||
//
|
||||
#if HAS_HEATED_CHAMBER
|
||||
EDIT_ITEM_FAST(int3, MSG_CHAMBER, &thermalManager.temp_chamber.target, 0, CHAMBER_MAXTEMP - 10, thermalManager.start_watching_chamber);
|
||||
#endif
|
||||
|
||||
//
|
||||
// Fan Speed:
|
||||
//
|
||||
#if FAN_COUNT > 0
|
||||
|
||||
auto on_fan_update = []{
|
||||
thermalManager.set_fan_speed(MenuItemBase::itemIndex, editable.uint8);
|
||||
};
|
||||
|
||||
#if HAS_FAN1 || HAS_FAN2 || HAS_FAN3 || HAS_FAN4 || HAS_FAN5 || HAS_FAN6 || HAS_FAN7
|
||||
auto fan_edit_items = [&](const uint8_t f) {
|
||||
editable.uint8 = thermalManager.fan_speed[f];
|
||||
EDIT_ITEM_FAST_N(percent, f, MSG_FAN_SPEED_N, &editable.uint8, 0, 255, on_fan_update);
|
||||
#if ENABLED(EXTRA_FAN_SPEED)
|
||||
EDIT_ITEM_FAST_N(percent, f, MSG_EXTRA_FAN_SPEED_N, &thermalManager.new_fan_speed[f], 3, 255);
|
||||
#endif
|
||||
};
|
||||
#endif
|
||||
|
||||
#define SNFAN(N) (ENABLED(SINGLENOZZLE) && !HAS_FAN##N && EXTRUDERS > N)
|
||||
#if SNFAN(1) || SNFAN(2) || SNFAN(3) || SNFAN(4) || SNFAN(5) || SNFAN(6) || SNFAN(7)
|
||||
auto singlenozzle_item = [&](const uint8_t f) {
|
||||
editable.uint8 = thermalManager.fan_speed[f];
|
||||
EDIT_ITEM_FAST_N(percent, f, MSG_STORED_FAN_N, &editable.uint8, 0, 255, on_fan_update);
|
||||
};
|
||||
#endif
|
||||
|
||||
#if HAS_FAN0
|
||||
editable.uint8 = thermalManager.fan_speed[0];
|
||||
EDIT_ITEM_FAST_N(percent, 0, MSG_FIRST_FAN_SPEED, &editable.uint8, 0, 255, on_fan_update);
|
||||
#if ENABLED(EXTRA_FAN_SPEED)
|
||||
EDIT_ITEM_FAST_N(percent, 0, MSG_FIRST_EXTRA_FAN_SPEED, &thermalManager.new_fan_speed[0], 3, 255);
|
||||
#endif
|
||||
#endif
|
||||
#if HAS_FAN1
|
||||
fan_edit_items(1);
|
||||
#elif SNFAN(1)
|
||||
singlenozzle_item(1);
|
||||
#endif
|
||||
#if HAS_FAN2
|
||||
fan_edit_items(2);
|
||||
#elif SNFAN(2)
|
||||
singlenozzle_item(1);
|
||||
#endif
|
||||
#if HAS_FAN3
|
||||
fan_edit_items(3);
|
||||
#elif SNFAN(3)
|
||||
singlenozzle_item(1);
|
||||
#endif
|
||||
#if HAS_FAN4
|
||||
fan_edit_items(4);
|
||||
#elif SNFAN(4)
|
||||
singlenozzle_item(1);
|
||||
#endif
|
||||
#if HAS_FAN5
|
||||
fan_edit_items(5);
|
||||
#elif SNFAN(5)
|
||||
singlenozzle_item(1);
|
||||
#endif
|
||||
#if HAS_FAN6
|
||||
fan_edit_items(6);
|
||||
#elif SNFAN(6)
|
||||
singlenozzle_item(1);
|
||||
#endif
|
||||
#if HAS_FAN7
|
||||
fan_edit_items(7);
|
||||
#elif SNFAN(7)
|
||||
singlenozzle_item(1);
|
||||
#endif
|
||||
|
||||
#endif // FAN_COUNT > 0
|
||||
|
||||
#if HAS_TEMP_HOTEND
|
||||
|
||||
//
|
||||
// Preheat for Material 1 and 2
|
||||
//
|
||||
#if TEMP_SENSOR_1 != 0 || TEMP_SENSOR_2 != 0 || TEMP_SENSOR_3 != 0 || TEMP_SENSOR_4 != 0 || TEMP_SENSOR_5 != 0 || TEMP_SENSOR_6 != 0 || TEMP_SENSOR_7 != 0 || HAS_HEATED_BED
|
||||
SUBMENU(MSG_PREHEAT_1, menu_preheat_m1);
|
||||
SUBMENU(MSG_PREHEAT_2, menu_preheat_m2);
|
||||
#else
|
||||
ACTION_ITEM(MSG_PREHEAT_1, []{ _preheat_end(0, 0); });
|
||||
ACTION_ITEM(MSG_PREHEAT_2, []{ _preheat_end(1, 0); });
|
||||
#endif
|
||||
|
||||
//
|
||||
// Cooldown
|
||||
//
|
||||
bool has_heat = false;
|
||||
HOTEND_LOOP() if (thermalManager.temp_hotend[HOTEND_INDEX].target) { has_heat = true; break; }
|
||||
#if HAS_TEMP_BED
|
||||
if (thermalManager.temp_bed.target) has_heat = true;
|
||||
#endif
|
||||
if (has_heat) ACTION_ITEM(MSG_COOLDOWN, lcd_cooldown);
|
||||
|
||||
#endif // HAS_TEMP_HOTEND
|
||||
|
||||
END_MENU();
|
||||
}
|
||||
|
||||
#endif // HAS_LCD_MENU
|
252
Marlin/src/lcd/menu/menu_tmc.cpp
Executable file
252
Marlin/src/lcd/menu/menu_tmc.cpp
Executable file
@@ -0,0 +1,252 @@
|
||||
/**
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
//
|
||||
// TMC Menu
|
||||
//
|
||||
|
||||
#include "../../inc/MarlinConfigPre.h"
|
||||
|
||||
#if HAS_TRINAMIC_CONFIG && HAS_LCD_MENU
|
||||
|
||||
#include "menu.h"
|
||||
#include "../../module/stepper/indirection.h"
|
||||
#include "../../feature/tmc_util.h"
|
||||
|
||||
#define TMC_EDIT_STORED_I_RMS(ST,STR) EDIT_ITEM_P(uint16_4, PSTR(STR), &stepper##ST.val_mA, 100, 3000, []{ stepper##ST.refresh_stepper_current(); })
|
||||
|
||||
void menu_tmc_current() {
|
||||
START_MENU();
|
||||
BACK_ITEM(MSG_TMC_DRIVERS);
|
||||
#if AXIS_IS_TMC(X)
|
||||
TMC_EDIT_STORED_I_RMS(X, STR_X);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(Y)
|
||||
TMC_EDIT_STORED_I_RMS(Y, STR_Y);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(Z)
|
||||
TMC_EDIT_STORED_I_RMS(Z, STR_Z);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(X2)
|
||||
TMC_EDIT_STORED_I_RMS(X2, STR_X2);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(Y2)
|
||||
TMC_EDIT_STORED_I_RMS(Y2, STR_Y2);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(Z2)
|
||||
TMC_EDIT_STORED_I_RMS(Z2, STR_Z2);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(Z3)
|
||||
TMC_EDIT_STORED_I_RMS(Z3, STR_Z3);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(Z4)
|
||||
TMC_EDIT_STORED_I_RMS(Z4, STR_Z4);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(E0)
|
||||
TMC_EDIT_STORED_I_RMS(E0, LCD_STR_E0);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(E1)
|
||||
TMC_EDIT_STORED_I_RMS(E1, LCD_STR_E1);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(E2)
|
||||
TMC_EDIT_STORED_I_RMS(E2, LCD_STR_E2);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(E3)
|
||||
TMC_EDIT_STORED_I_RMS(E3, LCD_STR_E3);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(E4)
|
||||
TMC_EDIT_STORED_I_RMS(E4, LCD_STR_E4);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(E5)
|
||||
TMC_EDIT_STORED_I_RMS(E5, LCD_STR_E5);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(E6)
|
||||
TMC_EDIT_STORED_I_RMS(E6, LCD_STR_E6);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(E7)
|
||||
TMC_EDIT_STORED_I_RMS(E7, LCD_STR_E7);
|
||||
#endif
|
||||
END_MENU();
|
||||
}
|
||||
|
||||
#if ENABLED(HYBRID_THRESHOLD)
|
||||
|
||||
#define TMC_EDIT_STORED_HYBRID_THRS(ST, STR) EDIT_ITEM_P(uint8, PSTR(STR), &stepper##ST.stored.hybrid_thrs, 0, 255, []{ stepper##ST.refresh_hybrid_thrs(); });
|
||||
|
||||
void menu_tmc_hybrid_thrs() {
|
||||
START_MENU();
|
||||
BACK_ITEM(MSG_TMC_DRIVERS);
|
||||
#if AXIS_HAS_STEALTHCHOP(X)
|
||||
TMC_EDIT_STORED_HYBRID_THRS(X, STR_X);
|
||||
#endif
|
||||
#if AXIS_HAS_STEALTHCHOP(Y)
|
||||
TMC_EDIT_STORED_HYBRID_THRS(Y, STR_Y);
|
||||
#endif
|
||||
#if AXIS_HAS_STEALTHCHOP(Z)
|
||||
TMC_EDIT_STORED_HYBRID_THRS(Z, STR_Z);
|
||||
#endif
|
||||
#if AXIS_HAS_STEALTHCHOP(X2)
|
||||
TMC_EDIT_STORED_HYBRID_THRS(X2, STR_X2);
|
||||
#endif
|
||||
#if AXIS_HAS_STEALTHCHOP(Y2)
|
||||
TMC_EDIT_STORED_HYBRID_THRS(Y2, STR_Y2);
|
||||
#endif
|
||||
#if AXIS_HAS_STEALTHCHOP(Z2)
|
||||
TMC_EDIT_STORED_HYBRID_THRS(Z2, STR_Z2);
|
||||
#endif
|
||||
#if AXIS_HAS_STEALTHCHOP(Z3)
|
||||
TMC_EDIT_STORED_HYBRID_THRS(Z3, STR_Z3);
|
||||
#endif
|
||||
#if AXIS_HAS_STEALTHCHOP(Z4)
|
||||
TMC_EDIT_STORED_HYBRID_THRS(Z4, STR_Z4);
|
||||
#endif
|
||||
#if AXIS_HAS_STEALTHCHOP(E0)
|
||||
TMC_EDIT_STORED_HYBRID_THRS(E0, LCD_STR_E0);
|
||||
#endif
|
||||
#if AXIS_HAS_STEALTHCHOP(E1)
|
||||
TMC_EDIT_STORED_HYBRID_THRS(E1, LCD_STR_E1);
|
||||
#endif
|
||||
#if AXIS_HAS_STEALTHCHOP(E2)
|
||||
TMC_EDIT_STORED_HYBRID_THRS(E2, LCD_STR_E2);
|
||||
#endif
|
||||
#if AXIS_HAS_STEALTHCHOP(E3)
|
||||
TMC_EDIT_STORED_HYBRID_THRS(E3, LCD_STR_E3);
|
||||
#endif
|
||||
#if AXIS_HAS_STEALTHCHOP(E4)
|
||||
TMC_EDIT_STORED_HYBRID_THRS(E4, LCD_STR_E4);
|
||||
#endif
|
||||
#if AXIS_HAS_STEALTHCHOP(E5)
|
||||
TMC_EDIT_STORED_HYBRID_THRS(E5, LCD_STR_E5);
|
||||
#endif
|
||||
#if AXIS_HAS_STEALTHCHOP(E6)
|
||||
TMC_EDIT_STORED_HYBRID_THRS(E6, LCD_STR_E6);
|
||||
#endif
|
||||
#if AXIS_HAS_STEALTHCHOP(E7)
|
||||
TMC_EDIT_STORED_HYBRID_THRS(E7, LCD_STR_E7);
|
||||
#endif
|
||||
END_MENU();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if ENABLED(SENSORLESS_HOMING)
|
||||
|
||||
#define TMC_EDIT_STORED_SGT(ST) EDIT_ITEM_P(int4, PSTR(STR_##ST), &stepper##ST.stored.homing_thrs, stepper##ST.sgt_min, stepper##ST.sgt_max, []{ stepper##ST.refresh_homing_thrs(); });
|
||||
|
||||
void menu_tmc_homing_thrs() {
|
||||
START_MENU();
|
||||
BACK_ITEM(MSG_TMC_DRIVERS);
|
||||
#if X_SENSORLESS
|
||||
TMC_EDIT_STORED_SGT(X);
|
||||
#endif
|
||||
#if X2_SENSORLESS
|
||||
TMC_EDIT_STORED_SGT(X2);
|
||||
#endif
|
||||
#if Y_SENSORLESS
|
||||
TMC_EDIT_STORED_SGT(Y);
|
||||
#endif
|
||||
#if Z_SENSORLESS
|
||||
TMC_EDIT_STORED_SGT(Z);
|
||||
#endif
|
||||
END_MENU();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if HAS_STEALTHCHOP
|
||||
|
||||
#define TMC_EDIT_STEP_MODE(ST, STR) EDIT_ITEM_P(bool, PSTR(STR), &stepper##ST.stored.stealthChop_enabled, []{ stepper##ST.refresh_stepping_mode(); })
|
||||
|
||||
void menu_tmc_step_mode() {
|
||||
START_MENU();
|
||||
STATIC_ITEM(MSG_TMC_STEALTH_ENABLED);
|
||||
BACK_ITEM(MSG_TMC_DRIVERS);
|
||||
#if AXIS_HAS_STEALTHCHOP(X)
|
||||
TMC_EDIT_STEP_MODE(X, STR_X);
|
||||
#endif
|
||||
#if AXIS_HAS_STEALTHCHOP(Y)
|
||||
TMC_EDIT_STEP_MODE(Y, STR_Y);
|
||||
#endif
|
||||
#if AXIS_HAS_STEALTHCHOP(Z)
|
||||
TMC_EDIT_STEP_MODE(Z, STR_Z);
|
||||
#endif
|
||||
#if AXIS_HAS_STEALTHCHOP(X2)
|
||||
TMC_EDIT_STEP_MODE(X2, STR_X2);
|
||||
#endif
|
||||
#if AXIS_HAS_STEALTHCHOP(Y2)
|
||||
TMC_EDIT_STEP_MODE(Y2, STR_Y2);
|
||||
#endif
|
||||
#if AXIS_HAS_STEALTHCHOP(Z2)
|
||||
TMC_EDIT_STEP_MODE(Z2, STR_Z2);
|
||||
#endif
|
||||
#if AXIS_HAS_STEALTHCHOP(Z3)
|
||||
TMC_EDIT_STEP_MODE(Z3, STR_Z3);
|
||||
#endif
|
||||
#if AXIS_HAS_STEALTHCHOP(Z4)
|
||||
TMC_EDIT_STEP_MODE(Z4, STR_Z4);
|
||||
#endif
|
||||
#if AXIS_HAS_STEALTHCHOP(E0)
|
||||
TMC_EDIT_STEP_MODE(E0, LCD_STR_E0);
|
||||
#endif
|
||||
#if AXIS_HAS_STEALTHCHOP(E1)
|
||||
TMC_EDIT_STEP_MODE(E1, LCD_STR_E1);
|
||||
#endif
|
||||
#if AXIS_HAS_STEALTHCHOP(E2)
|
||||
TMC_EDIT_STEP_MODE(E2, LCD_STR_E2);
|
||||
#endif
|
||||
#if AXIS_HAS_STEALTHCHOP(E3)
|
||||
TMC_EDIT_STEP_MODE(E3, LCD_STR_E3);
|
||||
#endif
|
||||
#if AXIS_HAS_STEALTHCHOP(E4)
|
||||
TMC_EDIT_STEP_MODE(E4, LCD_STR_E4);
|
||||
#endif
|
||||
#if AXIS_HAS_STEALTHCHOP(E5)
|
||||
TMC_EDIT_STEP_MODE(E5, LCD_STR_E5);
|
||||
#endif
|
||||
#if AXIS_HAS_STEALTHCHOP(E6)
|
||||
TMC_EDIT_STEP_MODE(E6, LCD_STR_E6);
|
||||
#endif
|
||||
#if AXIS_HAS_STEALTHCHOP(E7)
|
||||
TMC_EDIT_STEP_MODE(E7, LCD_STR_E7);
|
||||
#endif
|
||||
END_MENU();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void menu_tmc() {
|
||||
START_MENU();
|
||||
BACK_ITEM(MSG_CONTROL);
|
||||
SUBMENU(MSG_TMC_CURRENT, menu_tmc_current);
|
||||
#if ENABLED(HYBRID_THRESHOLD)
|
||||
SUBMENU(MSG_TMC_HYBRID_THRS, menu_tmc_hybrid_thrs);
|
||||
#endif
|
||||
#if ENABLED(SENSORLESS_HOMING)
|
||||
SUBMENU(MSG_TMC_HOMING_THRS, menu_tmc_homing_thrs);
|
||||
#endif
|
||||
#if HAS_STEALTHCHOP
|
||||
SUBMENU(MSG_TMC_STEPPING_MODE, menu_tmc_step_mode);
|
||||
#endif
|
||||
END_MENU();
|
||||
}
|
||||
|
||||
#endif // HAS_TRINAMIC_CONFIG
|
262
Marlin/src/lcd/menu/menu_tune.cpp
Executable file
262
Marlin/src/lcd/menu/menu_tune.cpp
Executable file
@@ -0,0 +1,262 @@
|
||||
/**
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
//
|
||||
// Tune Menu
|
||||
//
|
||||
|
||||
#include "../../inc/MarlinConfigPre.h"
|
||||
|
||||
#if HAS_LCD_MENU
|
||||
|
||||
#include "menu.h"
|
||||
#include "../../module/motion.h"
|
||||
#include "../../module/planner.h"
|
||||
#include "../../module/temperature.h"
|
||||
#include "../../MarlinCore.h"
|
||||
|
||||
#if HAS_LEVELING
|
||||
#include "../../feature/bedlevel/bedlevel.h"
|
||||
#endif
|
||||
|
||||
#if ENABLED(SINGLENOZZLE)
|
||||
#include "../../module/tool_change.h"
|
||||
#endif
|
||||
|
||||
#if ENABLED(BABYSTEPPING)
|
||||
|
||||
#include "../../feature/babystep.h"
|
||||
#include "../lcdprint.h"
|
||||
#if HAS_GRAPHICAL_LCD
|
||||
#include "../dogm/ultralcd_DOGM.h"
|
||||
#endif
|
||||
|
||||
void _lcd_babystep(const AxisEnum axis, PGM_P const msg) {
|
||||
if (ui.use_click()) return ui.goto_previous_screen_no_defer();
|
||||
if (ui.encoderPosition) {
|
||||
const int16_t steps = int16_t(ui.encoderPosition) * (
|
||||
#if ENABLED(BABYSTEP_XY)
|
||||
axis != Z_AXIS ? BABYSTEP_MULTIPLICATOR_XY :
|
||||
#endif
|
||||
BABYSTEP_MULTIPLICATOR_Z
|
||||
);
|
||||
ui.encoderPosition = 0;
|
||||
ui.refresh(LCDVIEW_REDRAW_NOW);
|
||||
babystep.add_steps(axis, steps);
|
||||
}
|
||||
if (ui.should_draw()) {
|
||||
const float spm = planner.steps_to_mm[axis];
|
||||
MenuEditItemBase::draw_edit_screen(msg, BABYSTEP_TO_STR(spm * babystep.accum));
|
||||
#if ENABLED(BABYSTEP_DISPLAY_TOTAL)
|
||||
const bool in_view = (true
|
||||
#if HAS_GRAPHICAL_LCD
|
||||
&& PAGE_CONTAINS(LCD_PIXEL_HEIGHT - MENU_FONT_HEIGHT, LCD_PIXEL_HEIGHT - 1)
|
||||
#endif
|
||||
);
|
||||
if (in_view) {
|
||||
#if HAS_GRAPHICAL_LCD
|
||||
ui.set_font(FONT_MENU);
|
||||
lcd_moveto(0, LCD_PIXEL_HEIGHT - MENU_FONT_DESCENT);
|
||||
#else
|
||||
lcd_moveto(0, LCD_HEIGHT - 1);
|
||||
#endif
|
||||
lcd_put_u8str_P(GET_TEXT(MSG_BABYSTEP_TOTAL));
|
||||
lcd_put_wchar(':');
|
||||
lcd_put_u8str(BABYSTEP_TO_STR(spm * babystep.axis_total[BS_TOTAL_IND(axis)]));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
inline void _lcd_babystep_go(const screenFunc_t screen) {
|
||||
ui.goto_screen(screen);
|
||||
ui.defer_status_screen();
|
||||
babystep.accum = 0;
|
||||
}
|
||||
|
||||
#if ENABLED(BABYSTEP_XY)
|
||||
void _lcd_babystep_x() { _lcd_babystep(X_AXIS, GET_TEXT(MSG_BABYSTEP_X)); }
|
||||
void _lcd_babystep_y() { _lcd_babystep(Y_AXIS, GET_TEXT(MSG_BABYSTEP_Y)); }
|
||||
#endif
|
||||
|
||||
#if DISABLED(BABYSTEP_ZPROBE_OFFSET)
|
||||
void _lcd_babystep_z() { _lcd_babystep(Z_AXIS, GET_TEXT(MSG_BABYSTEP_Z)); }
|
||||
void lcd_babystep_z() { _lcd_babystep_go(_lcd_babystep_z); }
|
||||
#endif
|
||||
|
||||
#endif // BABYSTEPPING
|
||||
|
||||
void menu_tune() {
|
||||
START_MENU();
|
||||
BACK_ITEM(MSG_MAIN);
|
||||
|
||||
//
|
||||
// Speed:
|
||||
//
|
||||
EDIT_ITEM(int3, MSG_SPEED, &feedrate_percentage, 10, 999);
|
||||
|
||||
//
|
||||
// Manual bed leveling, Bed Z:
|
||||
//
|
||||
#if BOTH(MESH_BED_LEVELING, LCD_BED_LEVELING)
|
||||
EDIT_ITEM(float43, MSG_BED_Z, &mbl.z_offset, -1, 1);
|
||||
#endif
|
||||
|
||||
//
|
||||
// Nozzle:
|
||||
// Nozzle [1-4]:
|
||||
//
|
||||
#if HOTENDS == 1
|
||||
EDIT_ITEM_FAST(int3, MSG_NOZZLE, &thermalManager.temp_hotend[0].target, 0, HEATER_0_MAXTEMP - 15, []{ thermalManager.start_watching_hotend(0); });
|
||||
#elif HOTENDS > 1
|
||||
HOTEND_LOOP()
|
||||
EDIT_ITEM_FAST_N(int3, e, MSG_NOZZLE_N, &thermalManager.temp_hotend[e].target, 0, heater_maxtemp[e] - 15, []{ thermalManager.start_watching_hotend(MenuItemBase::itemIndex); });
|
||||
#endif
|
||||
|
||||
#if ENABLED(SINGLENOZZLE)
|
||||
EDIT_ITEM_FAST(uint16_3, MSG_NOZZLE_STANDBY, &singlenozzle_temp[active_extruder ? 0 : 1], 0, HEATER_0_MAXTEMP - 15);
|
||||
#endif
|
||||
|
||||
//
|
||||
// Bed:
|
||||
//
|
||||
#if HAS_HEATED_BED
|
||||
EDIT_ITEM_FAST(int3, MSG_BED, &thermalManager.temp_bed.target, 0, BED_MAXTEMP - 10, thermalManager.start_watching_bed);
|
||||
#endif
|
||||
|
||||
//
|
||||
// Fan Speed:
|
||||
//
|
||||
#if FAN_COUNT > 0
|
||||
|
||||
auto on_fan_update = []{
|
||||
thermalManager.set_fan_speed(MenuItemBase::itemIndex, editable.uint8);
|
||||
};
|
||||
|
||||
#if HAS_FAN1 || HAS_FAN2 || HAS_FAN3 || HAS_FAN4 || HAS_FAN5 || HAS_FAN6 || HAS_FAN7
|
||||
auto fan_edit_items = [&](const uint8_t f) {
|
||||
editable.uint8 = thermalManager.fan_speed[f];
|
||||
EDIT_ITEM_FAST_N(percent, f, MSG_FAN_SPEED_N, &editable.uint8, 0, 255, on_fan_update);
|
||||
#if ENABLED(EXTRA_FAN_SPEED)
|
||||
EDIT_ITEM_FAST_N(percent, f, MSG_EXTRA_FAN_SPEED_N, &thermalManager.new_fan_speed[f], 3, 255);
|
||||
#endif
|
||||
};
|
||||
#endif
|
||||
|
||||
#define SNFAN(N) (ENABLED(SINGLENOZZLE) && !HAS_FAN##N && EXTRUDERS > N)
|
||||
#if SNFAN(1) || SNFAN(2) || SNFAN(3) || SNFAN(4) || SNFAN(5) || SNFAN(6) || SNFAN(7)
|
||||
auto singlenozzle_item = [&](const uint8_t f) {
|
||||
editable.uint8 = thermalManager.fan_speed[f];
|
||||
EDIT_ITEM_FAST_N(percent, f, MSG_STORED_FAN_N, &editable.uint8, 0, 255, on_fan_update);
|
||||
};
|
||||
#endif
|
||||
|
||||
#if HAS_FAN0
|
||||
editable.uint8 = thermalManager.fan_speed[0];
|
||||
EDIT_ITEM_FAST_N(percent, 0, MSG_FIRST_FAN_SPEED, &editable.uint8, 0, 255, on_fan_update);
|
||||
#if ENABLED(EXTRA_FAN_SPEED)
|
||||
EDIT_ITEM_FAST_N(percent, 0, MSG_FIRST_EXTRA_FAN_SPEED, &thermalManager.new_fan_speed[0], 3, 255);
|
||||
#endif
|
||||
#endif
|
||||
#if HAS_FAN1
|
||||
fan_edit_items(1);
|
||||
#elif SNFAN(1)
|
||||
singlenozzle_item(1);
|
||||
#endif
|
||||
#if HAS_FAN2
|
||||
fan_edit_items(2);
|
||||
#elif SNFAN(2)
|
||||
singlenozzle_item(1);
|
||||
#endif
|
||||
#if HAS_FAN3
|
||||
fan_edit_items(3);
|
||||
#elif SNFAN(3)
|
||||
singlenozzle_item(1);
|
||||
#endif
|
||||
#if HAS_FAN4
|
||||
fan_edit_items(4);
|
||||
#elif SNFAN(4)
|
||||
singlenozzle_item(1);
|
||||
#endif
|
||||
#if HAS_FAN5
|
||||
fan_edit_items(5);
|
||||
#elif SNFAN(5)
|
||||
singlenozzle_item(1);
|
||||
#endif
|
||||
#if HAS_FAN6
|
||||
fan_edit_items(6);
|
||||
#elif SNFAN(6)
|
||||
singlenozzle_item(1);
|
||||
#endif
|
||||
#if HAS_FAN7
|
||||
fan_edit_items(7);
|
||||
#elif SNFAN(7)
|
||||
singlenozzle_item(1);
|
||||
#endif
|
||||
|
||||
#endif // FAN_COUNT > 0
|
||||
|
||||
//
|
||||
// Flow:
|
||||
//
|
||||
#if EXTRUDERS
|
||||
EDIT_ITEM(int3, MSG_FLOW, &planner.flow_percentage[active_extruder], 10, 999, []{ planner.refresh_e_factor(active_extruder); });
|
||||
// Flow En:
|
||||
#if EXTRUDERS > 1
|
||||
LOOP_L_N(n, EXTRUDERS)
|
||||
EDIT_ITEM_N(int3, n, MSG_FLOW_N, &planner.flow_percentage[n], 10, 999, []{ planner.refresh_e_factor(MenuItemBase::itemIndex); });
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//
|
||||
// Advance K:
|
||||
//
|
||||
#if ENABLED(LIN_ADVANCE) && DISABLED(SLIM_LCD_MENUS)
|
||||
#if EXTRUDERS == 1
|
||||
EDIT_ITEM(float42_52, MSG_ADVANCE_K, &planner.extruder_advance_K[0], 0, 999);
|
||||
#elif EXTRUDERS > 1
|
||||
LOOP_L_N(n, EXTRUDERS)
|
||||
EDIT_ITEM_N(float42_52, n, MSG_ADVANCE_K_E, &planner.extruder_advance_K[n], 0, 999);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//
|
||||
// Babystep X:
|
||||
// Babystep Y:
|
||||
// Babystep Z:
|
||||
//
|
||||
#if ENABLED(BABYSTEPPING)
|
||||
#if ENABLED(BABYSTEP_XY)
|
||||
SUBMENU(MSG_BABYSTEP_X, []{ _lcd_babystep_go(_lcd_babystep_x); });
|
||||
SUBMENU(MSG_BABYSTEP_Y, []{ _lcd_babystep_go(_lcd_babystep_y); });
|
||||
#endif
|
||||
#if ENABLED(BABYSTEP_ZPROBE_OFFSET)
|
||||
SUBMENU(MSG_ZPROBE_ZOFFSET, lcd_babystep_zoffset);
|
||||
#else
|
||||
SUBMENU(MSG_BABYSTEP_Z, lcd_babystep_z);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
END_MENU();
|
||||
}
|
||||
|
||||
#endif // HAS_LCD_MENU
|
623
Marlin/src/lcd/menu/menu_ubl.cpp
Executable file
623
Marlin/src/lcd/menu/menu_ubl.cpp
Executable file
@@ -0,0 +1,623 @@
|
||||
/**
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
//
|
||||
// Unified Bed Leveling Menus
|
||||
//
|
||||
|
||||
#include "../../inc/MarlinConfigPre.h"
|
||||
|
||||
#if HAS_LCD_MENU && ENABLED(AUTO_BED_LEVELING_UBL)
|
||||
|
||||
#include "menu.h"
|
||||
#include "../../module/planner.h"
|
||||
#include "../../module/configuration_store.h"
|
||||
#include "../../feature/bedlevel/bedlevel.h"
|
||||
|
||||
static int16_t ubl_storage_slot = 0,
|
||||
custom_hotend_temp = 190,
|
||||
side_points = 3,
|
||||
ubl_fillin_amount = 5,
|
||||
ubl_height_amount = 1;
|
||||
|
||||
static uint8_t n_edit_pts = 1, x_plot = 0, y_plot = 0;
|
||||
|
||||
#if HAS_HEATED_BED
|
||||
static int16_t custom_bed_temp = 50;
|
||||
#endif
|
||||
|
||||
float mesh_edit_value, mesh_edit_accumulator; // We round mesh_edit_value to 2.5 decimal places. So we keep a
|
||||
// separate value that doesn't lose precision.
|
||||
static int16_t ubl_encoderPosition = 0;
|
||||
|
||||
static void _lcd_mesh_fine_tune(PGM_P msg) {
|
||||
ui.defer_status_screen();
|
||||
if (ubl.encoder_diff) {
|
||||
ubl_encoderPosition = (ubl.encoder_diff > 0) ? 1 : -1;
|
||||
ubl.encoder_diff = 0;
|
||||
|
||||
mesh_edit_accumulator += float(ubl_encoderPosition) * 0.005f * 0.5f;
|
||||
mesh_edit_value = mesh_edit_accumulator;
|
||||
ui.encoderPosition = 0;
|
||||
ui.refresh(LCDVIEW_CALL_REDRAW_NEXT);
|
||||
|
||||
const int32_t rounded = (int32_t)(mesh_edit_value * 1000);
|
||||
mesh_edit_value = float(rounded - (rounded % 5L)) / 1000;
|
||||
}
|
||||
|
||||
if (ui.should_draw()) {
|
||||
MenuEditItemBase::draw_edit_screen(msg, ftostr43sign(mesh_edit_value));
|
||||
#if ENABLED(MESH_EDIT_GFX_OVERLAY)
|
||||
_lcd_zoffset_overlay_gfx(mesh_edit_value);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void _lcd_mesh_edit_NOP() {
|
||||
ui.defer_status_screen();
|
||||
}
|
||||
|
||||
float lcd_mesh_edit() {
|
||||
ui.goto_screen(_lcd_mesh_edit_NOP);
|
||||
ui.refresh(LCDVIEW_CALL_REDRAW_NEXT);
|
||||
_lcd_mesh_fine_tune(GET_TEXT(MSG_MESH_EDITOR));
|
||||
return mesh_edit_value;
|
||||
}
|
||||
|
||||
void lcd_mesh_edit_setup(const float &initial) {
|
||||
mesh_edit_value = mesh_edit_accumulator = initial;
|
||||
ui.goto_screen(_lcd_mesh_edit_NOP);
|
||||
}
|
||||
|
||||
void _lcd_z_offset_edit() {
|
||||
_lcd_mesh_fine_tune(GET_TEXT(MSG_UBL_Z_OFFSET));
|
||||
}
|
||||
|
||||
float lcd_z_offset_edit() {
|
||||
ui.goto_screen(_lcd_z_offset_edit);
|
||||
return mesh_edit_value;
|
||||
}
|
||||
|
||||
void lcd_z_offset_edit_setup(const float &initial) {
|
||||
mesh_edit_value = mesh_edit_accumulator = initial;
|
||||
ui.goto_screen(_lcd_z_offset_edit);
|
||||
}
|
||||
|
||||
/**
|
||||
* UBL Build Custom Mesh Command
|
||||
*/
|
||||
void _lcd_ubl_build_custom_mesh() {
|
||||
char ubl_lcd_gcode[20];
|
||||
queue.inject_P(G28_STR);
|
||||
#if HAS_HEATED_BED
|
||||
sprintf_P(ubl_lcd_gcode, PSTR("M190 S%i"), custom_bed_temp);
|
||||
lcd_enqueue_one_now(ubl_lcd_gcode);
|
||||
#endif
|
||||
sprintf_P(ubl_lcd_gcode, PSTR("M109 S%i"), custom_hotend_temp);
|
||||
lcd_enqueue_one_now(ubl_lcd_gcode);
|
||||
queue.inject_P(PSTR("G29 P1"));
|
||||
}
|
||||
|
||||
/**
|
||||
* UBL Custom Mesh submenu
|
||||
*
|
||||
* << Build Mesh
|
||||
* Hotend Temp: ---
|
||||
* Bed Temp: ---
|
||||
* Build Custom Mesh
|
||||
*/
|
||||
void _lcd_ubl_custom_mesh() {
|
||||
START_MENU();
|
||||
BACK_ITEM(MSG_UBL_BUILD_MESH_MENU);
|
||||
EDIT_ITEM(int3, MSG_UBL_HOTEND_TEMP_CUSTOM, &custom_hotend_temp, EXTRUDE_MINTEMP, (HEATER_0_MAXTEMP - 10));
|
||||
#if HAS_HEATED_BED
|
||||
EDIT_ITEM(int3, MSG_UBL_BED_TEMP_CUSTOM, &custom_bed_temp, BED_MINTEMP, (BED_MAXTEMP - 10));
|
||||
#endif
|
||||
ACTION_ITEM(MSG_UBL_BUILD_CUSTOM_MESH, _lcd_ubl_build_custom_mesh);
|
||||
END_MENU();
|
||||
}
|
||||
|
||||
/**
|
||||
* UBL Adjust Mesh Height Command
|
||||
*/
|
||||
void _lcd_ubl_adjust_height_cmd() {
|
||||
char ubl_lcd_gcode[16];
|
||||
const int ind = ubl_height_amount > 0 ? 9 : 10;
|
||||
strcpy_P(ubl_lcd_gcode, PSTR("G29 P6 C -"));
|
||||
sprintf_P(&ubl_lcd_gcode[ind], PSTR(".%i"), ABS(ubl_height_amount));
|
||||
lcd_enqueue_one_now(ubl_lcd_gcode);
|
||||
}
|
||||
|
||||
/**
|
||||
* UBL Adjust Mesh Height submenu
|
||||
*
|
||||
* << Edit Mesh
|
||||
* Height Amount: ---
|
||||
* Adjust Mesh Height
|
||||
* << Info Screen
|
||||
*/
|
||||
void _menu_ubl_height_adjust() {
|
||||
START_MENU();
|
||||
BACK_ITEM(MSG_EDIT_MESH);
|
||||
EDIT_ITEM(int3, MSG_UBL_MESH_HEIGHT_AMOUNT, &ubl_height_amount, -9, 9, _lcd_ubl_adjust_height_cmd);
|
||||
ACTION_ITEM(MSG_INFO_SCREEN, ui.return_to_status);
|
||||
END_MENU();
|
||||
}
|
||||
|
||||
/**
|
||||
* UBL Edit Mesh submenu
|
||||
*
|
||||
* << UBL Tools
|
||||
* Fine Tune All
|
||||
* Fine Tune Closest
|
||||
* - Adjust Mesh Height >>
|
||||
* << Info Screen
|
||||
*/
|
||||
void _lcd_ubl_edit_mesh() {
|
||||
START_MENU();
|
||||
BACK_ITEM(MSG_UBL_TOOLS);
|
||||
GCODES_ITEM(MSG_UBL_FINE_TUNE_ALL, PSTR("G29 P4 R999 T"));
|
||||
GCODES_ITEM(MSG_UBL_FINE_TUNE_CLOSEST, PSTR("G29 P4 T"));
|
||||
SUBMENU(MSG_UBL_MESH_HEIGHT_ADJUST, _menu_ubl_height_adjust);
|
||||
ACTION_ITEM(MSG_INFO_SCREEN, ui.return_to_status);
|
||||
END_MENU();
|
||||
}
|
||||
|
||||
/**
|
||||
* UBL Validate Custom Mesh Command
|
||||
*/
|
||||
void _lcd_ubl_validate_custom_mesh() {
|
||||
char ubl_lcd_gcode[24];
|
||||
const int temp =
|
||||
#if HAS_HEATED_BED
|
||||
custom_bed_temp
|
||||
#else
|
||||
0
|
||||
#endif
|
||||
;
|
||||
sprintf_P(ubl_lcd_gcode, PSTR("G26 C B%i H%i P"), temp, custom_hotend_temp);
|
||||
lcd_enqueue_one_now_P(G28_STR);
|
||||
lcd_enqueue_one_now(ubl_lcd_gcode);
|
||||
}
|
||||
|
||||
/**
|
||||
* UBL Validate Mesh submenu
|
||||
*
|
||||
* << UBL Tools
|
||||
* Mesh Validation with Material 1
|
||||
* Mesh Validation with Material 2
|
||||
* Validate Custom Mesh
|
||||
* << Info Screen
|
||||
*/
|
||||
void _lcd_ubl_validate_mesh() {
|
||||
START_MENU();
|
||||
BACK_ITEM(MSG_UBL_TOOLS);
|
||||
#if HAS_HEATED_BED
|
||||
GCODES_ITEM(MSG_UBL_VALIDATE_MESH_M1, PSTR("G28\nG26 C B" STRINGIFY(PREHEAT_1_TEMP_BED) " H" STRINGIFY(PREHEAT_1_TEMP_HOTEND) " P"));
|
||||
GCODES_ITEM(MSG_UBL_VALIDATE_MESH_M2, PSTR("G28\nG26 C B" STRINGIFY(PREHEAT_2_TEMP_BED) " H" STRINGIFY(PREHEAT_2_TEMP_HOTEND) " P"));
|
||||
#else
|
||||
GCODES_ITEM(MSG_UBL_VALIDATE_MESH_M1, PSTR("G28\nG26 C B0 H" STRINGIFY(PREHEAT_1_TEMP_HOTEND) " P"));
|
||||
GCODES_ITEM(MSG_UBL_VALIDATE_MESH_M2, PSTR("G28\nG26 C B0 H" STRINGIFY(PREHEAT_2_TEMP_HOTEND) " P"));
|
||||
#endif
|
||||
ACTION_ITEM(MSG_UBL_VALIDATE_CUSTOM_MESH, _lcd_ubl_validate_custom_mesh);
|
||||
ACTION_ITEM(MSG_INFO_SCREEN, ui.return_to_status);
|
||||
END_MENU();
|
||||
}
|
||||
|
||||
/**
|
||||
* UBL Grid Leveling submenu
|
||||
*
|
||||
* << UBL Tools
|
||||
* Side points: ---
|
||||
* Level Mesh
|
||||
*/
|
||||
void _lcd_ubl_grid_level() {
|
||||
START_MENU();
|
||||
BACK_ITEM(MSG_UBL_TOOLS);
|
||||
EDIT_ITEM(int3, MSG_UBL_SIDE_POINTS, &side_points, 2, 6);
|
||||
ACTION_ITEM(MSG_UBL_MESH_LEVEL, []{
|
||||
char ubl_lcd_gcode[12];
|
||||
sprintf_P(ubl_lcd_gcode, PSTR("G29 J%i"), side_points);
|
||||
lcd_enqueue_one_now(ubl_lcd_gcode);
|
||||
});
|
||||
END_MENU();
|
||||
}
|
||||
|
||||
/**
|
||||
* UBL Mesh Leveling submenu
|
||||
*
|
||||
* << UBL Tools
|
||||
* 3-Point Mesh Leveling
|
||||
* - Grid Mesh Leveling >>
|
||||
* << Info Screen
|
||||
*/
|
||||
void _lcd_ubl_mesh_leveling() {
|
||||
START_MENU();
|
||||
BACK_ITEM(MSG_UBL_TOOLS);
|
||||
GCODES_ITEM(MSG_UBL_3POINT_MESH_LEVELING, PSTR("G29 J0"));
|
||||
SUBMENU(MSG_UBL_GRID_MESH_LEVELING, _lcd_ubl_grid_level);
|
||||
ACTION_ITEM(MSG_INFO_SCREEN, ui.return_to_status);
|
||||
END_MENU();
|
||||
}
|
||||
|
||||
/**
|
||||
* UBL Fill-in Amount Mesh Command
|
||||
*/
|
||||
void _lcd_ubl_fillin_amount_cmd() {
|
||||
char ubl_lcd_gcode[18];
|
||||
sprintf_P(ubl_lcd_gcode, PSTR("G29 P3 R C.%i"), ubl_fillin_amount);
|
||||
lcd_enqueue_one_now(ubl_lcd_gcode);
|
||||
}
|
||||
|
||||
/**
|
||||
* UBL Fill-in Mesh submenu
|
||||
*
|
||||
* << Build Mesh
|
||||
* Fill-in Amount: ---
|
||||
* Fill-in Mesh
|
||||
* Smart Fill-in
|
||||
* Manual Fill-in
|
||||
* << Info Screen
|
||||
*/
|
||||
void _menu_ubl_fillin() {
|
||||
START_MENU();
|
||||
BACK_ITEM(MSG_UBL_BUILD_MESH_MENU);
|
||||
EDIT_ITEM(int3, MSG_UBL_FILLIN_AMOUNT, &ubl_fillin_amount, 0, 9, _lcd_ubl_fillin_amount_cmd);
|
||||
GCODES_ITEM(MSG_UBL_SMART_FILLIN, PSTR("G29 P3 T0"));
|
||||
GCODES_ITEM(MSG_UBL_MANUAL_FILLIN, PSTR("G29 P2 B T0"));
|
||||
ACTION_ITEM(MSG_INFO_SCREEN, ui.return_to_status);
|
||||
END_MENU();
|
||||
}
|
||||
|
||||
void _lcd_ubl_invalidate() {
|
||||
ubl.invalidate();
|
||||
SERIAL_ECHOLNPGM("Mesh invalidated.");
|
||||
}
|
||||
|
||||
/**
|
||||
* UBL Build Mesh submenu
|
||||
*
|
||||
* << UBL Tools
|
||||
* Build Mesh with Material 1
|
||||
* Build Mesh with Material 2
|
||||
* - Build Custom Mesh >>
|
||||
* Build Cold Mesh
|
||||
* - Fill-in Mesh >>
|
||||
* Continue Bed Mesh
|
||||
* Invalidate All
|
||||
* Invalidate Closest
|
||||
* << Info Screen
|
||||
*/
|
||||
void _lcd_ubl_build_mesh() {
|
||||
START_MENU();
|
||||
BACK_ITEM(MSG_UBL_TOOLS);
|
||||
#if HAS_HEATED_BED
|
||||
GCODES_ITEM(MSG_UBL_BUILD_MESH_M1, PSTR(
|
||||
"G28\n"
|
||||
"M190 S" STRINGIFY(PREHEAT_1_TEMP_BED) "\n"
|
||||
"M109 S" STRINGIFY(PREHEAT_1_TEMP_HOTEND) "\n"
|
||||
"G29 P1\n"
|
||||
"M104 S0\n"
|
||||
"M140 S0"
|
||||
));
|
||||
GCODES_ITEM(MSG_UBL_BUILD_MESH_M2, PSTR(
|
||||
"G28\n"
|
||||
"M190 S" STRINGIFY(PREHEAT_2_TEMP_BED) "\n"
|
||||
"M109 S" STRINGIFY(PREHEAT_2_TEMP_HOTEND) "\n"
|
||||
"G29 P1\n"
|
||||
"M104 S0\n"
|
||||
"M140 S0"
|
||||
));
|
||||
#else
|
||||
GCODES_ITEM(MSG_UBL_BUILD_MESH_M1, PSTR(
|
||||
"G28\n"
|
||||
"M109 S" STRINGIFY(PREHEAT_1_TEMP_HOTEND) "\n"
|
||||
"G29 P1\n"
|
||||
"M104 S0"
|
||||
));
|
||||
GCODES_ITEM(MSG_UBL_BUILD_MESH_M2, PSTR(
|
||||
"G28\n"
|
||||
"M109 S" STRINGIFY(PREHEAT_2_TEMP_HOTEND) "\n"
|
||||
"G29 P1\n"
|
||||
"M104 S0"
|
||||
));
|
||||
#endif
|
||||
SUBMENU(MSG_UBL_BUILD_CUSTOM_MESH, _lcd_ubl_custom_mesh);
|
||||
GCODES_ITEM(MSG_UBL_BUILD_COLD_MESH, PSTR("G28\nG29 P1"));
|
||||
SUBMENU(MSG_UBL_FILLIN_MESH, _menu_ubl_fillin);
|
||||
GCODES_ITEM(MSG_UBL_CONTINUE_MESH, PSTR("G29 P1 C"));
|
||||
ACTION_ITEM(MSG_UBL_INVALIDATE_ALL, _lcd_ubl_invalidate);
|
||||
GCODES_ITEM(MSG_UBL_INVALIDATE_CLOSEST, PSTR("G29 I"));
|
||||
ACTION_ITEM(MSG_INFO_SCREEN, ui.return_to_status);
|
||||
END_MENU();
|
||||
}
|
||||
|
||||
/**
|
||||
* UBL Load Mesh Command
|
||||
*/
|
||||
void _lcd_ubl_load_mesh_cmd() {
|
||||
char ubl_lcd_gcode[25];
|
||||
sprintf_P(ubl_lcd_gcode, PSTR("G29 L%i"), ubl_storage_slot);
|
||||
lcd_enqueue_one_now(ubl_lcd_gcode);
|
||||
sprintf_P(ubl_lcd_gcode, GET_TEXT(MSG_MESH_LOADED), ubl_storage_slot);
|
||||
lcd_enqueue_one_now(ubl_lcd_gcode);
|
||||
}
|
||||
|
||||
/**
|
||||
* UBL Save Mesh Command
|
||||
*/
|
||||
void _lcd_ubl_save_mesh_cmd() {
|
||||
char ubl_lcd_gcode[25];
|
||||
sprintf_P(ubl_lcd_gcode, PSTR("G29 S%i"), ubl_storage_slot);
|
||||
lcd_enqueue_one_now(ubl_lcd_gcode);
|
||||
sprintf_P(ubl_lcd_gcode, GET_TEXT(MSG_MESH_SAVED), ubl_storage_slot);
|
||||
lcd_enqueue_one_now(ubl_lcd_gcode);
|
||||
}
|
||||
|
||||
/**
|
||||
* UBL Mesh Storage submenu
|
||||
*
|
||||
* << Unified Bed Leveling
|
||||
* Memory Slot: ---
|
||||
* Load Bed Mesh
|
||||
* Save Bed Mesh
|
||||
*/
|
||||
void _lcd_ubl_storage_mesh() {
|
||||
int16_t a = settings.calc_num_meshes();
|
||||
START_MENU();
|
||||
BACK_ITEM(MSG_UBL_LEVEL_BED);
|
||||
if (!WITHIN(ubl_storage_slot, 0, a - 1)) {
|
||||
STATIC_ITEM(MSG_UBL_NO_STORAGE);
|
||||
}
|
||||
else {
|
||||
EDIT_ITEM(int3, MSG_UBL_STORAGE_SLOT, &ubl_storage_slot, 0, a - 1);
|
||||
ACTION_ITEM(MSG_UBL_LOAD_MESH, _lcd_ubl_load_mesh_cmd);
|
||||
ACTION_ITEM(MSG_UBL_SAVE_MESH, _lcd_ubl_save_mesh_cmd);
|
||||
}
|
||||
END_MENU();
|
||||
}
|
||||
|
||||
/**
|
||||
* UBL LCD "radar" map homing
|
||||
*/
|
||||
void _lcd_ubl_output_map_lcd();
|
||||
|
||||
void _lcd_ubl_map_homing() {
|
||||
ui.defer_status_screen();
|
||||
_lcd_draw_homing();
|
||||
if (all_axes_homed()) {
|
||||
ubl.lcd_map_control = true; // Return to the map screen
|
||||
ui.goto_screen(_lcd_ubl_output_map_lcd);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* UBL LCD "radar" map point editing
|
||||
*/
|
||||
void _lcd_ubl_map_lcd_edit_cmd() {
|
||||
char ubl_lcd_gcode[50], str[10], str2[10];
|
||||
dtostrf(ubl.mesh_index_to_xpos(x_plot), 0, 2, str);
|
||||
dtostrf(ubl.mesh_index_to_ypos(y_plot), 0, 2, str2);
|
||||
snprintf_P(ubl_lcd_gcode, sizeof(ubl_lcd_gcode), PSTR("G29 P4 X%s Y%s R%i"), str, str2, int(n_edit_pts));
|
||||
lcd_enqueue_one_now(ubl_lcd_gcode);
|
||||
}
|
||||
|
||||
/**
|
||||
* UBL LCD Map Movement
|
||||
*/
|
||||
void ubl_map_move_to_xy() {
|
||||
const feedRate_t fr_mm_s = MMM_TO_MMS(XY_PROBE_SPEED);
|
||||
|
||||
destination = current_position; // sync destination at the start
|
||||
|
||||
#if ENABLED(DELTA)
|
||||
if (current_position.z > delta_clip_start_height) {
|
||||
destination.z = delta_clip_start_height;
|
||||
prepare_internal_move_to_destination(fr_mm_s);
|
||||
}
|
||||
#endif
|
||||
|
||||
destination.set(ubl.mesh_index_to_xpos(x_plot), ubl.mesh_index_to_ypos(y_plot));
|
||||
prepare_internal_move_to_destination(fr_mm_s);
|
||||
}
|
||||
|
||||
/**
|
||||
* UBL LCD "radar" map
|
||||
*/
|
||||
void set_current_from_steppers_for_axis(const AxisEnum axis);
|
||||
void sync_plan_position();
|
||||
|
||||
void _lcd_do_nothing() {}
|
||||
void _lcd_hard_stop() {
|
||||
const screenFunc_t old_screen = ui.currentScreen;
|
||||
ui.currentScreen = _lcd_do_nothing;
|
||||
planner.quick_stop();
|
||||
ui.currentScreen = old_screen;
|
||||
set_current_from_steppers_for_axis(ALL_AXES);
|
||||
sync_plan_position();
|
||||
}
|
||||
|
||||
void _lcd_ubl_output_map_lcd() {
|
||||
static int16_t step_scaler = 0;
|
||||
|
||||
if (ui.use_click()) return _lcd_ubl_map_lcd_edit_cmd();
|
||||
|
||||
if (ui.encoderPosition) {
|
||||
step_scaler += int32_t(ui.encoderPosition);
|
||||
x_plot += step_scaler / (ENCODER_STEPS_PER_MENU_ITEM);
|
||||
ui.encoderPosition = 0;
|
||||
ui.refresh(LCDVIEW_REDRAW_NOW);
|
||||
}
|
||||
|
||||
#if IS_KINEMATIC
|
||||
#define KEEP_LOOPING true // Loop until a valid point is found
|
||||
#else
|
||||
#define KEEP_LOOPING false
|
||||
#endif
|
||||
|
||||
do {
|
||||
// Encoder to the right (++)
|
||||
if (x_plot >= GRID_MAX_POINTS_X) { x_plot = 0; y_plot++; }
|
||||
if (y_plot >= GRID_MAX_POINTS_Y) y_plot = 0;
|
||||
|
||||
// Encoder to the left (--)
|
||||
if (x_plot < 0) { x_plot = GRID_MAX_POINTS_X - 1; y_plot--; }
|
||||
if (y_plot < 0) y_plot = GRID_MAX_POINTS_Y - 1;
|
||||
|
||||
#if IS_KINEMATIC
|
||||
const xy_pos_t xy = { ubl.mesh_index_to_xpos(x_plot), ubl.mesh_index_to_ypos(y_plot) };
|
||||
if (position_is_reachable(xy)) break; // Found a valid point
|
||||
x_plot += (step_scaler < 0) ? -1 : 1;
|
||||
#endif
|
||||
|
||||
} while(KEEP_LOOPING);
|
||||
|
||||
// Determine number of points to edit
|
||||
#if IS_KINEMATIC
|
||||
n_edit_pts = 9; //TODO: Delta accessible edit points
|
||||
#else
|
||||
const bool xc = WITHIN(x_plot, 1, GRID_MAX_POINTS_X - 2),
|
||||
yc = WITHIN(y_plot, 1, GRID_MAX_POINTS_Y - 2);
|
||||
n_edit_pts = yc ? (xc ? 9 : 6) : (xc ? 6 : 4); // Corners
|
||||
#endif
|
||||
|
||||
// Cleanup
|
||||
if (ABS(step_scaler) >= ENCODER_STEPS_PER_MENU_ITEM) step_scaler = 0;
|
||||
|
||||
if (ui.should_draw()) {
|
||||
ui.ubl_plot(x_plot, y_plot);
|
||||
|
||||
if (planner.movesplanned()) // If the nozzle is already moving, cancel the move.
|
||||
_lcd_hard_stop();
|
||||
|
||||
ubl_map_move_to_xy(); // Move to new location
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* UBL Homing before LCD map
|
||||
*/
|
||||
void _lcd_ubl_output_map_lcd_cmd() {
|
||||
if (!all_axes_known()) {
|
||||
set_all_unhomed();
|
||||
queue.inject_P(G28_STR);
|
||||
}
|
||||
ui.goto_screen(_lcd_ubl_map_homing);
|
||||
}
|
||||
|
||||
/**
|
||||
* UBL Output map submenu
|
||||
*
|
||||
* << Unified Bed Leveling
|
||||
* Output for Host
|
||||
* Output for CSV
|
||||
* Off Printer Backup
|
||||
*/
|
||||
void _lcd_ubl_output_map() {
|
||||
START_MENU();
|
||||
BACK_ITEM(MSG_UBL_LEVEL_BED);
|
||||
GCODES_ITEM(MSG_UBL_OUTPUT_MAP_HOST, PSTR("G29 T0"));
|
||||
GCODES_ITEM(MSG_UBL_OUTPUT_MAP_CSV, PSTR("G29 T1"));
|
||||
GCODES_ITEM(MSG_UBL_OUTPUT_MAP_BACKUP, PSTR("G29 S-1"));
|
||||
END_MENU();
|
||||
}
|
||||
|
||||
/**
|
||||
* UBL Tools submenu
|
||||
*
|
||||
* << Unified Bed Leveling
|
||||
* - Build Mesh >>
|
||||
* - Validate Mesh >>
|
||||
* - Edit Mesh >>
|
||||
* - Mesh Leveling >>
|
||||
*/
|
||||
void _menu_ubl_tools() {
|
||||
START_MENU();
|
||||
BACK_ITEM(MSG_UBL_LEVEL_BED);
|
||||
SUBMENU(MSG_UBL_BUILD_MESH_MENU, _lcd_ubl_build_mesh);
|
||||
GCODES_ITEM(MSG_UBL_MANUAL_MESH, PSTR("G29 I999\nG29 P2 B T0"));
|
||||
SUBMENU(MSG_UBL_VALIDATE_MESH_MENU, _lcd_ubl_validate_mesh);
|
||||
SUBMENU(MSG_EDIT_MESH, _lcd_ubl_edit_mesh);
|
||||
SUBMENU(MSG_UBL_MESH_LEVELING, _lcd_ubl_mesh_leveling);
|
||||
END_MENU();
|
||||
}
|
||||
|
||||
/**
|
||||
* UBL Step-By-Step submenu
|
||||
*
|
||||
* << Unified Bed Leveling
|
||||
* 1 Build Cold Mesh
|
||||
* 2 Smart Fill-in
|
||||
* - 3 Validate Mesh >>
|
||||
* 4 Fine Tune All
|
||||
* - 5 Validate Mesh >>
|
||||
* 6 Fine Tune All
|
||||
* 7 Save Bed Mesh
|
||||
*/
|
||||
void _lcd_ubl_step_by_step() {
|
||||
START_MENU();
|
||||
BACK_ITEM(MSG_UBL_LEVEL_BED);
|
||||
GCODES_ITEM(MSG_UBL_1_BUILD_COLD_MESH, PSTR("G28\nG29 P1"));
|
||||
GCODES_ITEM(MSG_UBL_2_SMART_FILLIN, PSTR("G29 P3 T0"));
|
||||
SUBMENU(MSG_UBL_3_VALIDATE_MESH_MENU, _lcd_ubl_validate_mesh);
|
||||
GCODES_ITEM(MSG_UBL_4_FINE_TUNE_ALL, PSTR("G29 P4 R999 T"));
|
||||
SUBMENU(MSG_UBL_5_VALIDATE_MESH_MENU, _lcd_ubl_validate_mesh);
|
||||
GCODES_ITEM(MSG_UBL_6_FINE_TUNE_ALL, PSTR("G29 P4 R999 T"));
|
||||
ACTION_ITEM(MSG_UBL_7_SAVE_MESH, _lcd_ubl_save_mesh_cmd);
|
||||
END_MENU();
|
||||
}
|
||||
|
||||
/**
|
||||
* UBL System submenu
|
||||
*
|
||||
* << Motion
|
||||
* - Manually Build Mesh >>
|
||||
* - Activate UBL >>
|
||||
* - Deactivate UBL >>
|
||||
* - Step-By-Step UBL >>
|
||||
* - Mesh Storage >>
|
||||
* - Output Map >>
|
||||
* - UBL Tools >>
|
||||
* - Output UBL Info >>
|
||||
*/
|
||||
|
||||
void _lcd_ubl_level_bed() {
|
||||
START_MENU();
|
||||
BACK_ITEM(MSG_MOTION);
|
||||
if (planner.leveling_active)
|
||||
GCODES_ITEM(MSG_UBL_DEACTIVATE_MESH, PSTR("G29 D"));
|
||||
else
|
||||
GCODES_ITEM(MSG_UBL_ACTIVATE_MESH, PSTR("G29 A"));
|
||||
SUBMENU(MSG_UBL_STEP_BY_STEP_MENU, _lcd_ubl_step_by_step);
|
||||
ACTION_ITEM(MSG_UBL_MESH_EDIT, _lcd_ubl_output_map_lcd_cmd);
|
||||
SUBMENU(MSG_UBL_STORAGE_MESH_MENU, _lcd_ubl_storage_mesh);
|
||||
SUBMENU(MSG_UBL_OUTPUT_MAP, _lcd_ubl_output_map);
|
||||
SUBMENU(MSG_UBL_TOOLS, _menu_ubl_tools);
|
||||
GCODES_ITEM(MSG_UBL_INFO_UBL, PSTR("G29 W"));
|
||||
#if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
|
||||
editable.decimal = planner.z_fade_height;
|
||||
EDIT_ITEM_FAST(float3, MSG_Z_FADE_HEIGHT, &editable.decimal, 0, 100, []{ set_z_fade_height(editable.decimal); });
|
||||
#endif
|
||||
END_MENU();
|
||||
}
|
||||
|
||||
#endif // HAS_LCD_MENU && AUTO_BED_LEVELING_UBL
|
Reference in New Issue
Block a user