-
Notifications
You must be signed in to change notification settings - Fork 214
/
M863.cpp
61 lines (52 loc) · 1.6 KB
/
M863.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include "core/serial.h"
#include "gcode/parser.h"
#include "inc/MarlinConfig.h"
#include "PrusaGcodeSuite.hpp"
#include "module/prusa/tool_mapper.hpp"
#if ENABLED(PRUSA_TOOL_MAPPING)
/** \addtogroup G-Codes
* @{
*/
/**
* @brief Tool remapping gcode
*
* ## Example
*
* - `M863 M P0 L1` - Instead of tool 0, use tool 1
* - `M863 E1/0` - Enable/disable tool remapping
* - `M863 R` - Reset tool remapping
* - `M863` - Print current tool mapping
*/
void PrusaGcodeSuite::M863() {
if (parser.seen('M') && parser.seen("P") && parser.seen("L")) {
// map logical tool to physical
const uint8_t logical = parser.byteval('L');
const uint8_t physical = parser.byteval('P');
bool res = tool_mapper.set_mapping(logical, physical);
if (!res) {
SERIAL_ERROR_MSG("Invalid mapping");
}
} else if (parser.seen('E')) {
// enable/disable tool mapping
tool_mapper.set_enable(parser.boolval('E'));
} else if (parser.seen('R')) {
// reset tool mapping to default
tool_mapper.reset();
} else {
// print current tool mapping settings
SERIAL_ECHOLN("Tool mapping: ");
for (size_t i = 0; i < EXTRUDERS; i++) {
SERIAL_ECHOPAIR(" Tool ", i, " -> ");
const uint8_t to = tool_mapper.to_physical(i, true);
if (to == tool_mapper.NO_TOOL_MAPPED) {
SERIAL_ECHO("<none>");
} else {
SERIAL_ECHO(to);
}
SERIAL_EOL();
}
SERIAL_ECHOLNPAIR("Enabled: ", tool_mapper.is_enabled());
}
}
/** @}*/
#endif