Simplify processing T? Tcode
tool_change calls load_filament_to_nozzle if it sees T?, we should utilise this. Change in memory: Flash: -60 bytes SRAM: 0 bytes
This commit is contained in:
parent
5295bfa040
commit
64c7202986
|
|
@ -20,18 +20,7 @@ inline void TCodeInvalid() {
|
||||||
SERIAL_ECHOLNPGM("Invalid T code.");
|
SERIAL_ECHOLNPGM("Invalid T code.");
|
||||||
}
|
}
|
||||||
|
|
||||||
struct SChooseFromMenu {
|
void TCodes(char *const strchr_pointer, const uint8_t codeValue) {
|
||||||
uint8_t slot:7;
|
|
||||||
uint8_t loadToNozzle:1;
|
|
||||||
inline constexpr SChooseFromMenu(uint8_t slot, bool loadToNozzle):slot(slot), loadToNozzle(loadToNozzle){}
|
|
||||||
inline constexpr SChooseFromMenu():slot(0), loadToNozzle(false) { }
|
|
||||||
};
|
|
||||||
|
|
||||||
SChooseFromMenu TCodeChooseFromMenu() {
|
|
||||||
return SChooseFromMenu( choose_menu_P(_T(MSG_SELECT_FILAMENT), _T(MSG_FILAMENT)), MMU2::mmu2.Enabled() );
|
|
||||||
}
|
|
||||||
|
|
||||||
void TCodes(char *const strchr_pointer, uint8_t codeValue) {
|
|
||||||
uint8_t index = 1;
|
uint8_t index = 1;
|
||||||
for ( /*nothing*/ ; strchr_pointer[index] == ' ' || strchr_pointer[index] == '\t'; index++)
|
for ( /*nothing*/ ; strchr_pointer[index] == ' ' || strchr_pointer[index] == '\t'; index++)
|
||||||
;
|
;
|
||||||
|
|
@ -40,7 +29,7 @@ void TCodes(char *const strchr_pointer, uint8_t codeValue) {
|
||||||
|
|
||||||
if (IsInvalidTCode(strchr_pointer, index)){
|
if (IsInvalidTCode(strchr_pointer, index)){
|
||||||
TCodeInvalid();
|
TCodeInvalid();
|
||||||
} else if (strchr_pointer[index] == 'x'){
|
} else if (strchr_pointer[index] == 'x' || strchr_pointer[index] == '?'){
|
||||||
// load to extruder gears; if mmu is not present do nothing
|
// load to extruder gears; if mmu is not present do nothing
|
||||||
if (MMU2::mmu2.Enabled()) {
|
if (MMU2::mmu2.Enabled()) {
|
||||||
MMU2::mmu2.tool_change(strchr_pointer[index], choose_menu_P(_T(MSG_SELECT_FILAMENT), _T(MSG_FILAMENT)));
|
MMU2::mmu2.tool_change(strchr_pointer[index], choose_menu_P(_T(MSG_SELECT_FILAMENT), _T(MSG_FILAMENT)));
|
||||||
|
|
@ -50,39 +39,25 @@ void TCodes(char *const strchr_pointer, uint8_t codeValue) {
|
||||||
if (MMU2::mmu2.Enabled()) {
|
if (MMU2::mmu2.Enabled()) {
|
||||||
MMU2::mmu2.tool_change(strchr_pointer[index], MMU2::mmu2.get_current_tool());
|
MMU2::mmu2.tool_change(strchr_pointer[index], MMU2::mmu2.get_current_tool());
|
||||||
}
|
}
|
||||||
} else {
|
} else { // Process T0 ... T4
|
||||||
SChooseFromMenu selectedSlot;
|
|
||||||
if (strchr_pointer[index] == '?') {
|
|
||||||
selectedSlot = TCodeChooseFromMenu();
|
|
||||||
/*} else if (MMU2::mmu2.Enabled() && SpoolJoin::spooljoin.isSpoolJoinEnabled()) {
|
|
||||||
// TODO: What if the next slot has no filament?
|
|
||||||
selectedSlot.slot = SpoolJoin::spooljoin.nextSlot();*/
|
|
||||||
} else {
|
|
||||||
selectedSlot.slot = codeValue;
|
|
||||||
}
|
|
||||||
st_synchronize();
|
st_synchronize();
|
||||||
|
|
||||||
if (MMU2::mmu2.Enabled()) {
|
if (MMU2::mmu2.Enabled()) {
|
||||||
if (selectedSlot.slot == MMU2::mmu2.get_current_tool()){
|
if (codeValue == MMU2::mmu2.get_current_tool()){
|
||||||
// don't execute the same T-code twice in a row
|
// don't execute the same T-code twice in a row
|
||||||
puts_P(duplicate_Tcode_ignored);
|
puts_P(duplicate_Tcode_ignored);
|
||||||
} else {
|
} else {
|
||||||
#if defined(MMU_HAS_CUTTER) && defined(MMU_ALWAYS_CUT)
|
#if defined(MMU_HAS_CUTTER) && defined(MMU_ALWAYS_CUT)
|
||||||
if (EEPROM_MMU_CUTTER_ENABLED_always == eeprom_read_byte((uint8_t *)EEPROM_MMU_CUTTER_ENABLED)) {
|
if (EEPROM_MMU_CUTTER_ENABLED_always == eeprom_read_byte((uint8_t *)EEPROM_MMU_CUTTER_ENABLED)) {
|
||||||
MMU2::mmu2.cut_filament(selectedSlot.slot);
|
MMU2::mmu2.cut_filament(codeValue);
|
||||||
}
|
}
|
||||||
#endif // defined(MMU_HAS_CUTTER) && defined(MMU_ALWAYS_CUT)
|
#endif // defined(MMU_HAS_CUTTER) && defined(MMU_ALWAYS_CUT)
|
||||||
if (selectedSlot.loadToNozzle){ // for single material usage with mmu
|
MMU2::mmu2.tool_change(codeValue);
|
||||||
MMU2::mmu2.load_filament_to_nozzle(selectedSlot.slot);
|
|
||||||
} else {
|
|
||||||
MMU2::mmu2.tool_change(selectedSlot.slot);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
SERIAL_ECHO_START;
|
SERIAL_ECHO_START;
|
||||||
if (selectedSlot.slot >= EXTRUDERS) {
|
if (codeValue >= EXTRUDERS) {
|
||||||
SERIAL_ECHO('T');
|
SERIAL_ECHO('T');
|
||||||
SERIAL_ECHOLN(selectedSlot.slot + '0');
|
SERIAL_ECHOLN(codeValue + '0');
|
||||||
SERIAL_ECHOLNRPGM(_n("Invalid extruder")); ////MSG_INVALID_EXTRUDER
|
SERIAL_ECHOLNRPGM(_n("Invalid extruder")); ////MSG_INVALID_EXTRUDER
|
||||||
} else {
|
} else {
|
||||||
// @@TODO if (code_seen('F')) {
|
// @@TODO if (code_seen('F')) {
|
||||||
|
|
|
||||||
|
|
@ -2,4 +2,4 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
void TCodes(char * const strchr_pointer, uint8_t codeValue);
|
void TCodes(char * const strchr_pointer, const uint8_t codeValue);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue