apply uncrust to anycubic_touchscreen

This commit is contained in:
Stefan Kalscheuer
2022-09-03 09:26:38 +02:00
parent 031c095019
commit afee7b10c2
2 changed files with 2338 additions and 2334 deletions

View File

@@ -124,15 +124,12 @@ char _conv[8];
constexpr float dpo[] = NOZZLE_TO_PROBE_OFFSET;
probe.offset.z = dpo[Z_AXIS];
for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++) {
for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++) {
z_values[x][y] = float(-1.0);
}
}
for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++)
for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++) z_values[x][y] = float(-1.0);
refresh_bed_level();
set_bed_leveling_enabled(true);
}
#endif
#endif // if ENABLED(KNUTWURST_TFT_LEVELING)
#if ENABLED(POWER_OUTAGE_TEST)
int PowerInt = 6;
@@ -142,16 +139,14 @@ char _conv[8];
unsigned char ResumingFlag = 0;
#endif
void setup_PowerOffPin()
{
void setup_PowerOffPin() {
#if ENABLED(KNUTWURST_4MAXP2)
SET_OUTPUT(POWER_OFF_PIN);
WRITE(POWER_OFF_PIN, HIGH);
#endif
}
void setup_OutageTestPin()
{
void setup_OutageTestPin() {
#ifdef POWER_OUTAGE_TEST
pinMode(OUTAGETEST_PIN, INPUT);
pinMode(OUTAGECON_PIN, OUTPUT);
@@ -256,9 +251,9 @@ void AnycubicTouchscreenClass::Setup() {
setup_PowerOffPin();
#ifdef STARTUP_CHIME
buzzer.tone(100, 554);
buzzer.tone(100, 740);
buzzer.tone(100, 831);
BUZZ(100, 554);
BUZZ(100, 740);
BUZZ(100, 831);
#endif
}
@@ -321,7 +316,7 @@ void AnycubicTouchscreenClass::Setup() {
HARDWARE_SERIAL_SPACE();
HARDWARE_SERIAL_ENTER();
}
#endif
#endif // if ENABLED(KNUTWURST_MEGA_P_LASER)
void AnycubicTouchscreenClass::KillTFT() {
HARDWARE_SERIAL_PROTOCOLPGM("J11"); // J11 Kill
@@ -462,7 +457,8 @@ void AnycubicTouchscreenClass::PausePrint() {
SERIAL_EOL();
SERIAL_ECHOLNPGM("DEBUG: Regular Pause");
#endif
} else { // pause caused by filament runout
}
else { // pause caused by filament runout
#ifdef ANYCUBIC_TFT_DEBUG
SERIAL_ECHOLNPGM("DEBUG: Filament Runout Pause");
#endif
@@ -470,11 +466,11 @@ void AnycubicTouchscreenClass::PausePrint() {
// queue.inject_P(PSTR("G91")); // relative mode
// queue.inject_P(PSTR("G1 E-3 F1800")); // retract 3mm
// queue.inject_P(PSTR("G90")); // absolute mode
buzzer.tone(200, 1567);
buzzer.tone(200, 1174);
buzzer.tone(200, 1567);
buzzer.tone(200, 1174);
buzzer.tone(2000, 1567);
BUZZ(200, 1567);
BUZZ(200, 1174);
BUZZ(200, 1567);
BUZZ(200, 1174);
BUZZ(2000, 1567);
#ifdef ANYCUBIC_TFT_DEBUG
SERIAL_ECHOLNPGM("DEBUG: Filament runout - Retract, beep and park.");
#endif
@@ -494,8 +490,7 @@ void AnycubicTouchscreenClass::PausePrint() {
TFTstate = ANYCUBIC_TFT_STATE_SDPAUSE_REQ;
}
inline void AnycubicTouchscreenClass::StopPrint()
{
inline void AnycubicTouchscreenClass::StopPrint() {
card.abortFilePrintSoon();
print_job_timer.stop();
@@ -617,11 +612,13 @@ void AnycubicTouchscreenClass::HandleSpecialMenu() {
SERIAL_EOL();
#endif
if ((strcasestr_P(currentTouchscreenSelection, PSTR(SM_SPECIAL_MENU_L)) != NULL)
|| (strcasestr_P(currentTouchscreenSelection, PSTR(SM_SPECIAL_MENU_S)) != NULL)) {
|| (strcasestr_P(currentTouchscreenSelection, PSTR(SM_SPECIAL_MENU_S)) != NULL)
) {
SpecialMenu = true;
}
else if ((strcasestr_P(currentTouchscreenSelection, PSTR(SM_PID_HOTEND_L)) != NULL)
|| (strcasestr_P(currentTouchscreenSelection, PSTR(SM_PID_HOTEND_S)) != NULL)) {
|| (strcasestr_P(currentTouchscreenSelection, PSTR(SM_PID_HOTEND_S)) != NULL)
) {
SERIAL_ECHOLNPGM("Special Menu: PID Tune Hotend");
#if ANY(KNUTWURST_MEGA, KNUTWURST_MEGA_S, KNUTWURST_MEGA_P)
@@ -640,157 +637,174 @@ void AnycubicTouchscreenClass::HandleSpecialMenu() {
queue.inject_P(PSTR("G28\nG90\nG1 Z20\nG1 X105 Y135 F4000\nG1 Z5\nM106 S172\nG4 P500\nM303 E0 S215 C15 U1\nG4 P500\nM107\nG28\nG1 Z10\nM84\nM500\nM300 S440 P200\nM300 S660 P250\nM300 S880 P300"));
#endif
buzzer.tone(200, 1108);
buzzer.tone(200, 1661);
buzzer.tone(200, 1108);
buzzer.tone(600, 1661);
BUZZ(200, 1108);
BUZZ(200, 1661);
BUZZ(200, 1108);
BUZZ(600, 1661);
}
else if ((strcasestr_P(currentTouchscreenSelection, PSTR(SM_PID_BED_L)) != NULL)
|| (strcasestr_P(currentTouchscreenSelection, PSTR(SM_PID_BED_S)) != NULL)) {
|| (strcasestr_P(currentTouchscreenSelection, PSTR(SM_PID_BED_S)) != NULL)
) {
SERIAL_ECHOLNPGM("Special Menu: PID Tune Ultrabase");
queue.inject_P(PSTR("M303 E-1 S60 C6 U1\nM500\nM300 S440 P200\nM300 S660 P250\nM300 S880 P300"));
buzzer.tone(200, 1108);
buzzer.tone(200, 1661);
buzzer.tone(200, 1108);
buzzer.tone(600, 1661);
BUZZ(200, 1108);
BUZZ(200, 1661);
BUZZ(200, 1108);
BUZZ(600, 1661);
}
else if ((strcasestr_P(currentTouchscreenSelection, PSTR(SM_SAVE_EEPROM_L)) != NULL)
|| (strcasestr_P(currentTouchscreenSelection, PSTR(SM_SAVE_EEPROM_S)) != NULL)) {
|| (strcasestr_P(currentTouchscreenSelection, PSTR(SM_SAVE_EEPROM_S)) != NULL)
) {
SERIAL_ECHOLNPGM("Special Menu: Save EEPROM");
settings.save(); // M500
buzzer.tone(105, 1108);
buzzer.tone(210, 1661);
BUZZ(105, 1108);
BUZZ(210, 1661);
}
else if ((strcasestr_P(currentTouchscreenSelection, PSTR(SM_LOAD_DEFAULTS_L)) != NULL)
|| (strcasestr_P(currentTouchscreenSelection, PSTR(SM_LOAD_DEFAULTS_S)) != NULL)) {
|| (strcasestr_P(currentTouchscreenSelection, PSTR(SM_LOAD_DEFAULTS_S)) != NULL)
) {
SERIAL_ECHOLNPGM("Special Menu: Load FW Defaults");
settings.reset(); // M502
#if ENABLED(KNUTWURST_TFT_LEVELING)
initializeGrid();
#endif
buzzer.tone(105, 1661);
buzzer.tone(210, 1108);
BUZZ(105, 1661);
BUZZ(210, 1108);
}
else if ((strcasestr_P(currentTouchscreenSelection, PSTR(SM_PREHEAT_BED_L)) != NULL)
|| (strcasestr_P(currentTouchscreenSelection, PSTR(SM_PREHEAT_BED_S)) != NULL)) {
|| (strcasestr_P(currentTouchscreenSelection, PSTR(SM_PREHEAT_BED_S)) != NULL)
) {
SERIAL_ECHOLNPGM("Special Menu: Preheat Ultrabase");
queue.inject_P(PSTR("M140 S60"));
}
#if NONE(KNUTWURST_BLTOUCH, KNUTWURST_TFT_LEVELING)
else if ((strcasestr_P(currentTouchscreenSelection, PSTR(SM_MESH_MENU_L)) != NULL)
|| (strcasestr_P(currentTouchscreenSelection, PSTR(SM_MESH_MENU_S)) != NULL)) {
|| (strcasestr_P(currentTouchscreenSelection, PSTR(SM_MESH_MENU_S)) != NULL)
) {
MMLMenu = true;
}
else if ((strcasestr_P(currentTouchscreenSelection, PSTR(SM_MESH_START_L)) != NULL)
|| (strcasestr_P(currentTouchscreenSelection, PSTR(SM_MESH_START_S)) != NULL)) {
|| (strcasestr_P(currentTouchscreenSelection, PSTR(SM_MESH_START_S)) != NULL)
) {
SERIAL_ECHOLNPGM("Special Menu: Start Mesh Leveling");
queue.inject_P(PSTR("G28\nG29 S1"));
}
else if ((strcasestr_P(currentTouchscreenSelection, PSTR(SM_MESH_NEXT_L)) != NULL)
|| (strcasestr_P(currentTouchscreenSelection, PSTR(SM_MESH_NEXT_S)) != NULL)) {
|| (strcasestr_P(currentTouchscreenSelection, PSTR(SM_MESH_NEXT_S)) != NULL)
) {
SERIAL_ECHOLNPGM("Special Menu: Next Mesh Point");
queue.inject_P(PSTR("G29 S2"));
}
else if ((strcasestr_P(currentTouchscreenSelection, PSTR(SM_Z_UP_01_L)) != NULL)
|| (strcasestr_P(currentTouchscreenSelection, PSTR(SM_Z_UP_01_S)) != NULL)) {
|| (strcasestr_P(currentTouchscreenSelection, PSTR(SM_Z_UP_01_S)) != NULL)
) {
SERIAL_ECHOLNPGM("Special Menu: Z Up 0.1");
queue.inject_P(PSTR("G91\nG1 Z+0.1\nG90"));
}
else if ((strcasestr_P(currentTouchscreenSelection, PSTR(SM_Z_DN_01_L)) != NULL)
|| (strcasestr_P(currentTouchscreenSelection, PSTR(SM_Z_DN_01_S)) != NULL)) {
|| (strcasestr_P(currentTouchscreenSelection, PSTR(SM_Z_DN_01_S)) != NULL)
) {
SERIAL_ECHOLNPGM("Special Menu: Z Down 0.1");
queue.inject_P(PSTR("G91\nG1 Z-0.1\nG90"));
}
else if ((strcasestr_P(currentTouchscreenSelection, PSTR(SM_Z_UP_002_L)) != NULL)
|| (strcasestr_P(currentTouchscreenSelection, PSTR(SM_Z_UP_002_S)) != NULL)) {
|| (strcasestr_P(currentTouchscreenSelection, PSTR(SM_Z_UP_002_S)) != NULL)
) {
SERIAL_ECHOLNPGM("Special Menu: Z Up 0.02");
queue.inject_P(PSTR("G91\nG1 Z+0.02\nG90"));
}
else if ((strcasestr_P(currentTouchscreenSelection, PSTR(SM_Z_DN_002_L)) != NULL)
|| (strcasestr_P(currentTouchscreenSelection, PSTR(SM_Z_DN_002_S)) != NULL)) {
|| (strcasestr_P(currentTouchscreenSelection, PSTR(SM_Z_DN_002_S)) != NULL)
) {
SERIAL_ECHOLNPGM("Special Menu: Z Down 0.02");
queue.inject_P(PSTR("G91\nG1 Z-0.02\nG90"));
}
else if ((strcasestr_P(currentTouchscreenSelection, PSTR(SM_Z_UP_001_L)) != NULL)
|| (strcasestr_P(currentTouchscreenSelection, PSTR(SM_Z_UP_001_S)) != NULL)) {
|| (strcasestr_P(currentTouchscreenSelection, PSTR(SM_Z_UP_001_S)) != NULL)
) {
SERIAL_ECHOLNPGM("Special Menu: Z Up 0.01");
queue.inject_P(PSTR("G91\nG1 Z+0.03\nG4 P250\nG1 Z-0.02\nG90"));
}
else if ((strcasestr_P(currentTouchscreenSelection, PSTR(SM_Z_DN_001_L)) != NULL)
|| (strcasestr_P(currentTouchscreenSelection, PSTR(SM_Z_DN_001_S)) != NULL)) {
|| (strcasestr_P(currentTouchscreenSelection, PSTR(SM_Z_DN_001_S)) != NULL)
) {
SERIAL_ECHOLNPGM("Special Menu: Z Down 0.01");
queue.inject_P(PSTR("G91\nG1 Z+0.02\nG4 P250\nG1 Z-0.03\nG90"));
}
#endif
#endif // if NONE(KNUTWURST_BLTOUCH, KNUTWURST_TFT_LEVELING)
#if ENABLED(KNUTWURST_BLTOUCH)
else if ((strcasestr_P(currentTouchscreenSelection, PSTR(SM_BLTOUCH_L)) != NULL)
|| (strcasestr_P(currentTouchscreenSelection, PSTR(SM_BLTOUCH_S)) != NULL)) {
|| (strcasestr_P(currentTouchscreenSelection, PSTR(SM_BLTOUCH_S)) != NULL)
) {
SERIAL_ECHOLNPGM("Special Menu: BLTouch Leveling");
queue.inject_P(PSTR("G28\nG29\nM500\nG90\nM300 S440 P200\nM300 S660 P250\nM300 S880 P300\nG1 Z30 F4000\nG1 X0 F4000\nG91\nM84\nM420 S1"));
buzzer.tone(105, 1108);
buzzer.tone(210, 1661);
BUZZ(105, 1108);
BUZZ(210, 1661);
}
#endif
#if ENABLED(KNUTWURST_TFT_LEVELING)
else if ((strcasestr_P(currentTouchscreenSelection, PSTR(SM_RESETLV_L)) != NULL)
|| (strcasestr_P(currentTouchscreenSelection, PSTR(SM_RESETLV_S)) != NULL)) {
|| (strcasestr_P(currentTouchscreenSelection, PSTR(SM_RESETLV_S)) != NULL)
) {
SERIAL_ECHOLNPGM("Special Menu: initializeGrid()");
initializeGrid();
settings.save();
buzzer.tone(105, 1108);
buzzer.tone(210, 1661);
BUZZ(105, 1108);
BUZZ(210, 1661);
}
#endif
else if ((strcasestr_P(currentTouchscreenSelection, PSTR(SM_PAUSE_L)) != NULL)
|| (strcasestr_P(currentTouchscreenSelection, PSTR(SM_PAUSE_L)) != NULL)) {
|| (strcasestr_P(currentTouchscreenSelection, PSTR(SM_PAUSE_L)) != NULL)
) {
SERIAL_ECHOLNPGM("Special Menu: Fil. Change Pause");
FilamentChangePause();
}
else if ((strcasestr_P(currentTouchscreenSelection, PSTR(SM_RESUME_L)) != NULL)
|| (strcasestr_P(currentTouchscreenSelection, PSTR(SM_RESUME_S)) != NULL))
{
|| (strcasestr_P(currentTouchscreenSelection, PSTR(SM_RESUME_S)) != NULL)
) {
SERIAL_ECHOLNPGM("Special Menu: Fil. Change Resume");
FilamentChangeResume();
}
else if ((strcasestr_P(currentTouchscreenSelection, PSTR(SM_DIS_FILSENS_L)) != NULL)
|| (strcasestr_P(currentTouchscreenSelection, PSTR(SM_DIS_FILSENS_S)) != NULL))
{
|| (strcasestr_P(currentTouchscreenSelection, PSTR(SM_DIS_FILSENS_S)) != NULL)
) {
SERIAL_ECHOLNPGM("Special Menu: Disable Filament Sensor");
FilamentSensorEnabled = false;
buzzer.tone(105, 1108);
buzzer.tone(105, 1108);
buzzer.tone(105, 1108);
BUZZ(105, 1108);
BUZZ(105, 1108);
BUZZ(105, 1108);
}
else if ((strcasestr_P(currentTouchscreenSelection, PSTR(SM_EN_FILSENS_L)) != NULL)
|| (strcasestr_P(currentTouchscreenSelection, PSTR(SM_EN_FILSENS_S)) != NULL))
{
|| (strcasestr_P(currentTouchscreenSelection, PSTR(SM_EN_FILSENS_S)) != NULL)
) {
SERIAL_ECHOLNPGM("Special Menu: Enable Filament Sensor");
FilamentSensorEnabled = true;
buzzer.tone(105, 1108);
buzzer.tone(105, 1108);
BUZZ(105, 1108);
BUZZ(105, 1108);
}
else if ((strcasestr_P(currentTouchscreenSelection, PSTR(SM_EXIT_L)) != NULL)
|| (strcasestr_P(currentTouchscreenSelection, PSTR(SM_EXIT_S)) != NULL))
{
|| (strcasestr_P(currentTouchscreenSelection, PSTR(SM_EXIT_S)) != NULL)
) {
SpecialMenu = false;
}
else if ((strcasestr_P(currentTouchscreenSelection, PSTR(SM_BACK_L)) != NULL)
|| (strcasestr_P(currentTouchscreenSelection, PSTR(SM_BACK_S)) != NULL))
{
|| (strcasestr_P(currentTouchscreenSelection, PSTR(SM_BACK_S)) != NULL)
) {
MMLMenu = false;
}
else if ((strcasestr_P(currentTouchscreenSelection, PSTR(SM_FLOWMENU_L)) != NULL)
|| (strcasestr_P(currentTouchscreenSelection, PSTR(SM_FLOWMENU_S)) != NULL))
{
|| (strcasestr_P(currentTouchscreenSelection, PSTR(SM_FLOWMENU_S)) != NULL)
) {
SERIAL_ECHOLNPGM("Special Menu: Enter Flow Menu");
FlowMenu = true;
}
else if ((strcasestr_P(currentTouchscreenSelection, PSTR(SM_FLOW_UP_L)) != NULL)
|| (strcasestr_P(currentTouchscreenSelection, PSTR(SM_FLOW_UP_S)) != NULL)) {
|| (strcasestr_P(currentTouchscreenSelection, PSTR(SM_FLOW_UP_S)) != NULL)
) {
SERIAL_ECHOLNPGM("Special Menu: Flow UP");
currentFlowRate = currentFlowRate + 1;
@@ -803,7 +817,8 @@ void AnycubicTouchscreenClass::HandleSpecialMenu() {
}
else if ((strcasestr_P(currentTouchscreenSelection, PSTR(SM_FLOW_DN_L)) != NULL)
|| (strcasestr_P(currentTouchscreenSelection, PSTR(SM_FLOW_DN_S)) != NULL)) {
|| (strcasestr_P(currentTouchscreenSelection, PSTR(SM_FLOW_DN_S)) != NULL)
) {
SERIAL_ECHOLNPGM("Special Menu: Flow Down");
currentFlowRate = currentFlowRate - 1;
@@ -815,49 +830,57 @@ void AnycubicTouchscreenClass::HandleSpecialMenu() {
queue.enqueue_one_now(value);
}
else if ((strcasestr_P(currentTouchscreenSelection, PSTR(SM_FLOW_EXIT_L)) != NULL)
|| (strcasestr_P(currentTouchscreenSelection, PSTR(SM_FLOW_EXIT_S)) != NULL)) {
|| (strcasestr_P(currentTouchscreenSelection, PSTR(SM_FLOW_EXIT_S)) != NULL)
) {
SERIAL_ECHOLNPGM("Special Menu: Exit Flow Menu");
FlowMenu = false;
}
#if ENABLED(KNUTWURST_BLTOUCH)
else if ((strcasestr_P(currentTouchscreenSelection, PSTR(SM_BLTZMENU_L)) != NULL)
|| (strcasestr_P(currentTouchscreenSelection, PSTR(SM_BLTZMENU_S)) != NULL)) {
|| (strcasestr_P(currentTouchscreenSelection, PSTR(SM_BLTZMENU_S)) != NULL)
) {
SERIAL_ECHOLNPGM("Special Menu: Enter BLTouch Menu");
BLTouchMenu = true;
}
else if ((strcasestr_P(currentTouchscreenSelection, PSTR(SM_BLTZ_UP_L)) != NULL)
|| (strcasestr_P(currentTouchscreenSelection, PSTR(SM_BLTZ_UP_S)) != NULL)) {
|| (strcasestr_P(currentTouchscreenSelection, PSTR(SM_BLTZ_UP_S)) != NULL)
) {
SERIAL_ECHOLNPGM("Special Menu: Offset UP");
probe.offset.z += 0.01F;
}
else if ((strcasestr_P(currentTouchscreenSelection, PSTR(SM_BLTZ_DN_L)) != NULL)
|| (strcasestr_P(currentTouchscreenSelection, PSTR(SM_BLTZ_DN_S)) != NULL)) {
|| (strcasestr_P(currentTouchscreenSelection, PSTR(SM_BLTZ_DN_S)) != NULL)
) {
SERIAL_ECHOLNPGM("Special Menu: Offset Down");
probe.offset.z -= 0.01F;
}
else if ((strcasestr_P(currentTouchscreenSelection, PSTR(SM_BLTZ_EXIT_L)) != NULL)
|| (strcasestr_P(currentTouchscreenSelection, PSTR(SM_BLTZ_EXIT_S)) != NULL)) {
|| (strcasestr_P(currentTouchscreenSelection, PSTR(SM_BLTZ_EXIT_S)) != NULL)
) {
SERIAL_ECHOLNPGM("Special Menu: Exit BLTouch Menu & Save EEPROM");
settings.save(); // M500
buzzer.tone(105, 1108);
buzzer.tone(210, 1661);
BUZZ(105, 1108);
BUZZ(210, 1661);
BLTouchMenu = false;
}
#endif
else if ((strcasestr_P(currentTouchscreenSelection, PSTR(SM_EZLVL_MENU_L)) != NULL)
|| (strcasestr_P(currentTouchscreenSelection, PSTR(SM_EZLVL_MENU_S)) != NULL)) {
|| (strcasestr_P(currentTouchscreenSelection, PSTR(SM_EZLVL_MENU_S)) != NULL)
) {
SERIAL_ECHOLNPGM("Special Menu: Enter Easy Level Menu");
LevelMenu = true;
queue.inject_P(PSTR("G28\nM420 S0\nG90\nG1 Z5\nG1 X15 Y15 F4000\nG1 Z0"));
}
else if ((strcasestr_P(currentTouchscreenSelection, PSTR(SM_EZLVL_P1_L)) != NULL)
|| (strcasestr_P(currentTouchscreenSelection, PSTR(SM_EZLVL_P1_S)) != NULL)) {
|| (strcasestr_P(currentTouchscreenSelection, PSTR(SM_EZLVL_P1_S)) != NULL)
) {
SERIAL_ECHOLNPGM("Special Menu: Easy Level POINT 1");
queue.inject_P(PSTR("G90\nG1 Z5\nG1 X15 Y15 F4000\nG1 Z0"));
}
else if ((strcasestr_P(currentTouchscreenSelection, PSTR(SM_EZLVL_P2_L)) != NULL)
|| (strcasestr_P(currentTouchscreenSelection, PSTR(SM_EZLVL_P2_S)) != NULL)) {
|| (strcasestr_P(currentTouchscreenSelection, PSTR(SM_EZLVL_P2_S)) != NULL)
) {
SERIAL_ECHOLNPGM("Special Menu: Easy Level POINT 2");
#if ANY(KNUTWURST_MEGA, KNUTWURST_MEGA_S, KNUTWURST_MEGA_P)
queue.inject_P(PSTR("G90\nG1 Z5\nG1 X205 Y15 F4000\nG1 Z0"));
@@ -876,7 +899,8 @@ void AnycubicTouchscreenClass::HandleSpecialMenu() {
#endif
}
else if ((strcasestr_P(currentTouchscreenSelection, PSTR(SM_EZLVL_P3_L)) != NULL)
|| (strcasestr_P(currentTouchscreenSelection, PSTR(SM_EZLVL_P3_S)) != NULL)) {
|| (strcasestr_P(currentTouchscreenSelection, PSTR(SM_EZLVL_P3_S)) != NULL)
) {
SERIAL_ECHOLNPGM("Special Menu: Easy Level POINT 3");
#if ANY(KNUTWURST_MEGA, KNUTWURST_MEGA_S, KNUTWURST_MEGA_P)
queue.inject_P(PSTR("G90\nG1 Z5\nG1 X205 Y200 F4000\nG1 Z0"));
@@ -895,7 +919,8 @@ void AnycubicTouchscreenClass::HandleSpecialMenu() {
#endif
}
else if ((strcasestr_P(currentTouchscreenSelection, PSTR(SM_EZLVL_P4_L)) != NULL)
|| (strcasestr_P(currentTouchscreenSelection, PSTR(SM_EZLVL_P4_S)) != NULL)) {
|| (strcasestr_P(currentTouchscreenSelection, PSTR(SM_EZLVL_P4_S)) != NULL)
) {
SERIAL_ECHOLNPGM("Special Menu: Easy Level POINT 4");
#if ANY(KNUTWURST_MEGA, KNUTWURST_MEGA_S, KNUTWURST_MEGA_P)
queue.inject_P(PSTR("G90\nG1 Z5\nG1 X15 Y200 F4000\nG1 Z0"));
@@ -914,12 +939,13 @@ void AnycubicTouchscreenClass::HandleSpecialMenu() {
#endif
}
else if ((strcasestr_P(currentTouchscreenSelection, PSTR(SM_EZLVL_EXIT_L)) != NULL)
|| (strcasestr_P(currentTouchscreenSelection, PSTR(SM_EZLVL_EXIT_S)) != NULL)) {
|| (strcasestr_P(currentTouchscreenSelection, PSTR(SM_EZLVL_EXIT_S)) != NULL)
) {
SERIAL_ECHOLNPGM("Special Menu: Exit Easy Level Menu");
LevelMenu = false;
queue.inject_P(PSTR("G90\nG1 Z10\nG1 X15 Y15 F4000\nM420 S1"));
}
#endif
#endif // if ENABLED(KNUTWURST_SPECIAL_MENU)
}
@@ -1105,7 +1131,7 @@ void AnycubicTouchscreenClass::PrintList() {
break;
}
}
#endif
#endif // if ENABLED(KNUTWURST_SPECIAL_MENU)
#ifdef SDSUPPORT
#if ENABLED(KNUTWURST_SPECIAL_MENU)
@@ -1186,11 +1212,10 @@ void AnycubicTouchscreenClass::PrintList() {
}
else {
outputString[i] = card.longFilename[i];
if (!isPrintable(outputString[i])) {
if (!isPrintable(outputString[i]))
outputString[i] = '_';
}
}
}
// I know, it's ugly, but it's faster than a string lib
if (fileNameWasCut) {
@@ -1222,7 +1247,8 @@ void AnycubicTouchscreenClass::PrintList() {
SERIAL_ECHO(count);
SERIAL_ECHOPGM(": /");
SERIAL_ECHOLN(outputString);
} else {
}
else {
HARDWARE_SERIAL_PROTOCOLLN(card.filename);
HARDWARE_SERIAL_PROTOCOLLN(outputString);
SERIAL_ECHO(count);
@@ -1232,7 +1258,7 @@ void AnycubicTouchscreenClass::PrintList() {
}
}
}
#endif
#endif // ifdef SDSUPPORT
else {
#if ENABLED(KNUTWURST_SPECIAL_MENU_WO_SD)
HARDWARE_SERIAL_PROTOCOLLNPGM(SM_SPECIAL_MENU_S);
@@ -1276,10 +1302,12 @@ void AnycubicTouchscreenClass::CheckHeaterError() {
#ifdef ANYCUBIC_TFT_DEBUG
SERIAL_ECHOLNPGM("TFT Serial Debug: Hotend temperature abnormal... J20");
#endif
} else {
}
else {
HeaterCheckCount++;
}
} else {
}
else {
HeaterCheckCount = 0;
}
}
@@ -1323,10 +1351,10 @@ void AnycubicTouchscreenClass::StateHandler() {
break;
case ANYCUBIC_TFT_STATE_SDPAUSE_OOF:
#ifdef ANYCUBIC_FILAMENT_RUNOUT_SENSOR
if (!FilamentTestStatus) {
if (!FilamentTestStatus)
// We got filament again
TFTstate = ANYCUBIC_TFT_STATE_SDPAUSE;
}
#endif
break;
case ANYCUBIC_TFT_STATE_SDPAUSE_REQ:
@@ -1349,12 +1377,12 @@ void AnycubicTouchscreenClass::StateHandler() {
}
}
#ifdef ANYCUBIC_FILAMENT_RUNOUT_SENSOR
if (FilamentTestStatus) {
if (FilamentTestStatus)
TFTstate = ANYCUBIC_TFT_STATE_SDPAUSE;
} else {
else
// Pause because of "out of filament"
TFTstate = ANYCUBIC_TFT_STATE_SDPAUSE_OOF;
}
#endif
#ifdef ANYCUBIC_TFT_DEBUG
SERIAL_ECHOLNPGM("TFT Serial Debug: SD print paused done... J18");
@@ -1461,7 +1489,7 @@ void AnycubicTouchscreenClass::FilamentRunout() {
SERIAL_ECHOLNPGM("TFT Serial Debug: Filament runout recovered");
#endif
}
#endif
#endif // if ENABLED(ANYCUBIC_FILAMENT_RUNOUT_SENSOR)
}
}
@@ -1578,13 +1606,11 @@ void AnycubicTouchscreenClass::GetCommandFromTFT() {
#ifdef SDSUPPORT
if (card.isPrinting()) {
HARDWARE_SERIAL_PROTOCOLPGM("A6V ");
if (card.isMounted()) {
if (card.isMounted())
HARDWARE_SERIAL_PROTOCOL(itostr3(card.percentDone()));
}
else {
else
HARDWARE_SERIAL_PROTOCOLPGM("J02"); // J02 SD Card initilized
}
}
else {
HARDWARE_SERIAL_PROTOCOLPGM("A6V ---");
}
@@ -1594,8 +1620,7 @@ void AnycubicTouchscreenClass::GetCommandFromTFT() {
case 7: // A7 GET PRINTING TIME
{
HARDWARE_SERIAL_PROTOCOLPGM("A7V ");
if (starttime != 0) // print time
{
if (starttime != 0) { // print time
uint16_t time = millis() / 60000 - starttime / 60000;
HARDWARE_SERIAL_PROTOCOL(itostr2(time / 60));
HARDWARE_SERIAL_SPACE();
@@ -1604,7 +1629,8 @@ void AnycubicTouchscreenClass::GetCommandFromTFT() {
HARDWARE_SERIAL_PROTOCOL(itostr2(time % 60));
HARDWARE_SERIAL_SPACE();
HARDWARE_SERIAL_PROTOCOLPGM("M");
} else {
}
else {
HARDWARE_SERIAL_SPACE();
HARDWARE_SERIAL_PROTOCOLPGM("999:999");
}
@@ -1613,12 +1639,11 @@ void AnycubicTouchscreenClass::GetCommandFromTFT() {
break;
case 8: // A8 GET SD LIST
#ifdef SDSUPPORT
if (SpecialMenu == false) {
if (SpecialMenu == false)
currentTouchscreenSelection[0] = 0;
}
#if DISABLED(KNUTWURST_SPECIAL_MENU_WO_SD)
if (!IS_SD_INSERTED())
{
if (!IS_SD_INSERTED()) {
HARDWARE_SERIAL_PROTOCOLPGM("J02");
HARDWARE_SERIAL_ENTER();
}
@@ -1655,12 +1680,11 @@ void AnycubicTouchscreenClass::GetCommandFromTFT() {
SERIAL_ECHOPGM("DEBUG: AI3M Pause State: ", ai3m_pause_state);
SERIAL_EOL();
#endif
if ((TFTstate == ANYCUBIC_TFT_STATE_SDPAUSE) || (TFTstate == ANYCUBIC_TFT_STATE_SDOUTAGE)) {
if ((TFTstate == ANYCUBIC_TFT_STATE_SDPAUSE) || (TFTstate == ANYCUBIC_TFT_STATE_SDOUTAGE))
StartPrint();
}
if (ai3m_pause_state > 3) {
if (ai3m_pause_state > 3)
ReheatNozzle(); // obsolete!
}
#endif
break;
case 11: // A11 STOP SD PRINT
@@ -1698,9 +1722,8 @@ void AnycubicTouchscreenClass::GetCommandFromTFT() {
strcpy(currentTouchscreenSelection, TFTstrchr_pointer + 4);
}
else {
if (SpecialMenu == false) {
if (SpecialMenu == false)
currentTouchscreenSelection[0] = 0;
}
#ifdef ANYCUBIC_TFT_DEBUG
SERIAL_ECHOLNPGM("TFT Serial Debug: Normal file open path");
@@ -1764,14 +1787,12 @@ void AnycubicTouchscreenClass::GetCommandFromTFT() {
unsigned int tempvalue;
if (CodeSeen('S')) {
tempvalue = constrain(CodeValue(), 0, 260);
if (thermalManager.degTargetHotend(0) <= 260) {
if (thermalManager.degTargetHotend(0) <= 260)
thermalManager.setTargetHotend(tempvalue, 0); // do not set Temp from TFT if it is set via gcode
}
}
else if ((CodeSeen('C')) && (!planner.movesplanned())) {
if ((current_position[Z_AXIS] < 10)) {
if ((current_position[Z_AXIS] < 10))
queue.inject_P(PSTR("G1 Z10")); // RASE Z AXIS
}
tempvalue = constrain(CodeValue(), 0, 260);
thermalManager.setTargetHotend(tempvalue, 0);
}
@@ -1783,11 +1804,10 @@ void AnycubicTouchscreenClass::GetCommandFromTFT() {
if (CodeSeen('S')) {
tempbed = constrain(CodeValue(), 0, 115);
thermalManager.setTargetBed(tempbed);
if (thermalManager.degTargetBed() <= 100) {
if (thermalManager.degTargetBed() <= 100)
thermalManager.setTargetBed(tempbed); // do not set Temp from TFT if it is set via gcode
}
}
}
break;
case 18: // A18 set fan speed
unsigned int temp;
@@ -1848,54 +1868,42 @@ void AnycubicTouchscreenClass::GetCommandFromTFT() {
if (CodeSeen('X')) { // Move in X direction
coorvalue = CodeValue();
if ((coorvalue <= 0.2) && coorvalue > 0) {
if ((coorvalue <= 0.2) && coorvalue > 0)
sprintf_P(value, PSTR("G1 X0.1F%i"), movespeed);
}
else if ((coorvalue <= -0.1) && coorvalue > -1) {
else if ((coorvalue <= -0.1) && coorvalue > -1)
sprintf_P(value, PSTR("G1 X-0.1F%i"), movespeed);
}
else {
else
sprintf_P(value, PSTR("G1 X%iF%i"), int(coorvalue), movespeed);
}
queue.enqueue_one_now(value);
}
else if (CodeSeen('Y')) { // Move in Y direction
coorvalue = CodeValue();
if ((coorvalue <= 0.2) && coorvalue > 0) {
if ((coorvalue <= 0.2) && coorvalue > 0)
sprintf_P(value, PSTR("G1 Y0.1F%i"), movespeed);
}
else if ((coorvalue <= -0.1) && coorvalue > -1) {
else if ((coorvalue <= -0.1) && coorvalue > -1)
sprintf_P(value, PSTR("G1 Y-0.1F%i"), movespeed);
}
else {
else
sprintf_P(value, PSTR("G1 Y%iF%i"), int(coorvalue), movespeed);
}
queue.enqueue_one_now(value);
}
else if (CodeSeen('Z')) { // Move in Z direction
coorvalue = CodeValue();
if ((coorvalue <= 0.2) && coorvalue > 0) {
if ((coorvalue <= 0.2) && coorvalue > 0)
sprintf_P(value, PSTR("G1 Z0.1F%i"), movespeed);
}
else if ((coorvalue <= -0.1) && coorvalue > -1) {
else if ((coorvalue <= -0.1) && coorvalue > -1)
sprintf_P(value, PSTR("G1 Z-0.1F%i"), movespeed);
}
else {
else
sprintf_P(value, PSTR("G1 Z%iF%i"), int(coorvalue), movespeed);
}
queue.enqueue_one_now(value);
}
else if (CodeSeen('E')) { // Extrude
coorvalue = CodeValue();
if ((coorvalue <= 0.2) && coorvalue > 0) {
if ((coorvalue <= 0.2) && coorvalue > 0)
sprintf_P(value, PSTR("G1 E0.1F%i"), movespeed);
}
else if ((coorvalue <= -0.1) && coorvalue > -1) {
else if ((coorvalue <= -0.1) && coorvalue > -1)
sprintf_P(value, PSTR("G1 E-0.1F%i"), movespeed);
}
else {
else
sprintf_P(value, PSTR("G1 E%iF500"), int(coorvalue));
}
queue.enqueue_one_now(value);
}
queue.enqueue_now_P(PSTR("G90")); // absolute coordinates
@@ -1904,9 +1912,8 @@ void AnycubicTouchscreenClass::GetCommandFromTFT() {
break;
case 23: // A23 preheat pla
if ((!planner.movesplanned()) && (TFTstate != ANYCUBIC_TFT_STATE_SDPAUSE) && (TFTstate != ANYCUBIC_TFT_STATE_SDOUTAGE)) {
if ((current_position[Z_AXIS] < 10)) {
if ((current_position[Z_AXIS] < 10))
queue.inject_P(PSTR("G1 Z10")); // RAISE Z AXIS
}
thermalManager.setTargetBed(KNUTWURST_PRHEAT_BED_PLA);
thermalManager.setTargetHotend(KNUTWURST_PRHEAT_NOZZLE_PLA, 0);
@@ -1916,9 +1923,8 @@ void AnycubicTouchscreenClass::GetCommandFromTFT() {
break;
case 24: // A24 preheat abs
if ((!planner.movesplanned()) && (TFTstate != ANYCUBIC_TFT_STATE_SDPAUSE) && (TFTstate != ANYCUBIC_TFT_STATE_SDOUTAGE)) {
if ((current_position[Z_AXIS] < 10)) {
if ((current_position[Z_AXIS] < 10))
queue.inject_P(PSTR("G1 Z10")); // RAISE Z AXIS
}
thermalManager.setTargetBed(KNUTWURST_PRHEAT_BED_ABS);
thermalManager.setTargetHotend(KNUTWURST_PRHEAT_NOZZLE_ABS, 0);
HARDWARE_SERIAL_SUCC_START;
@@ -1944,14 +1950,17 @@ void AnycubicTouchscreenClass::GetCommandFromTFT() {
#endif
if (currentTouchscreenSelection[0] == 0) {
card.mount();
} else {
}
else {
if ((strcasestr_P(currentTouchscreenSelection, PSTR(SM_DIR_UP_S)) != NULL)
|| (strcasestr_P(currentTouchscreenSelection, PSTR(SM_DIR_UP_L)) != NULL)) {
|| (strcasestr_P(currentTouchscreenSelection, PSTR(SM_DIR_UP_L)) != NULL)
) {
#ifdef ANYCUBIC_TFT_DEBUG
SERIAL_ECHOLNPGM("TFT Serial Debug: Directory UP (cd ..)");
#endif
card.cdup();
} else {
}
else {
if (currentTouchscreenSelection[0] == '<') {
#ifdef ANYCUBIC_TFT_DEBUG
SERIAL_ECHOLNPGM("TFT Serial Debug: Enter Special Menu");
@@ -1974,10 +1983,10 @@ void AnycubicTouchscreenClass::GetCommandFromTFT() {
}
}
}
if (SpecialMenu == false) {
if (SpecialMenu == false)
currentTouchscreenSelection[0] = 0;
}
#endif
#endif // ifdef SDSUPPORT
break;
#ifdef SERVO_ENDSTOPS
case 27: // A27 servos angles adjust
@@ -2008,8 +2017,8 @@ void AnycubicTouchscreenClass::GetCommandFromTFT() {
{
int mx, my;
if (CodeSeen('X')) { mx = CodeValueInt(); }
if (CodeSeen('Y')) { my = CodeValueInt(); }
if (CodeSeen('X')) mx = CodeValueInt();
if (CodeSeen('Y')) my = CodeValueInt();
float Zvalue = z_values[mx][my];
Zvalue = Zvalue * 100;
@@ -2055,20 +2064,16 @@ void AnycubicTouchscreenClass::GetCommandFromTFT() {
HARDWARE_SERIAL_PROTOCOLPGM("J26"); // start auto leveling
HARDWARE_SERIAL_ENTER();
}
if (CodeSeen('S') ) {
if (CodeSeen('S'))
queue.enqueue_now_P(PSTR("G28\nG29\nM500\nG90\nM300 S440 P200\nM300 S660 P250\nM300 S880 P300\nG1 Z30 F4000\nG1 X0 F4000\nG91\nM84"));
}
break;
case 31: // A31 z-offset
if (CodeSeen('S')) { // set
// soft_endstops_enabled = false; // disable endstops
float value = constrain(CodeValue(), -1.0, 1.0);
probe.offset.z += value;
for (x = 0; x < GRID_MAX_POINTS_X; x++) {
for (y = 0; y < GRID_MAX_POINTS_Y; y++) {
z_values[x][y] += value;
}
}
for (x = 0; x < GRID_MAX_POINTS_X; x++)
for (y = 0; y < GRID_MAX_POINTS_Y; y++) z_values[x][y] += value;
set_bed_leveling_enabled(true);
refresh_bed_level();
@@ -2104,8 +2109,8 @@ void AnycubicTouchscreenClass::GetCommandFromTFT() {
break;
case 34: // a34 bed grid write
{
if (CodeSeen('X')) { x = constrain(CodeValueInt(),0,GRID_MAX_POINTS_X); }
if (CodeSeen('Y')) { y = constrain(CodeValueInt(),0,GRID_MAX_POINTS_Y); }
if (CodeSeen('X')) x = constrain(CodeValueInt(), 0, GRID_MAX_POINTS_X);
if (CodeSeen('Y')) y = constrain(CodeValueInt(), 0, GRID_MAX_POINTS_Y);
if (CodeSeen('V')) {
float new_z_value = float(constrain(CodeValue() / 100, -10, 10));
@@ -2138,10 +2143,10 @@ void AnycubicTouchscreenClass::GetCommandFromTFT() {
HARDWARE_SERIAL_PROTOCOLPGM("J26"); // start auto leveling
HARDWARE_SERIAL_ENTER();
}
if (CodeSeen('S') ) {
if (CodeSeen('S'))
queue.enqueue_now_P(PSTR("G28\nG29\nM500\nG90\nM300 S440 P200\nM300 S660 P250\nM300 S880 P300\nG1 Z30 F4000\nG1 X0 F4000\nG91\nM84"));
}
#endif
#endif // if ENABLED(KNUTWURST_TFT_LEVELING)
#if ENABLED(KNUTWURST_4MAXP2)
case 40:
@@ -2153,7 +2158,8 @@ void AnycubicTouchscreenClass::GetCommandFromTFT() {
if (CodeSeen('O')) {
PrintdoneAndPowerOFF = true;
break;
} else if(CodeSeen('C')) {
}
else if (CodeSeen('C')) {
PrintdoneAndPowerOFF = false;
break;
}
@@ -2161,7 +2167,8 @@ void AnycubicTouchscreenClass::GetCommandFromTFT() {
if (PrintdoneAndPowerOFF) {
HARDWARE_SERIAL_PROTOCOLPGM("J35 ");
HARDWARE_SERIAL_ENTER();
} else {
}
else {
HARDWARE_SERIAL_PROTOCOLPGM("J34 ");
HARDWARE_SERIAL_ENTER();
}
@@ -2171,7 +2178,8 @@ void AnycubicTouchscreenClass::GetCommandFromTFT() {
SERIAL_ECHOLNPGM("Case Light OFF");
queue.inject_P(PSTR("M355 S1 P0"));
CaseLight = false;
} else {
}
else {
SERIAL_ECHOLNPGM("Case Light ON");
queue.inject_P(PSTR("M355 S1 P255"));
CaseLight = true;
@@ -2195,24 +2203,20 @@ void AnycubicTouchscreenClass::GetCommandFromTFT() {
if (CodeSeen('S')) {
int coorvalue;
coorvalue = CodeValueInt();
if (coorvalue!=0) {
if (coorvalue != 0)
Laser_printer_st.pic_vector = 1;
}
else {
else
Laser_printer_st.pic_vector = 0;
}
break;
case 37:
if (CodeSeen('S')) {
int coorvalue;
coorvalue = CodeValueInt();
if (coorvalue == 0) {
if (coorvalue == 0)
Laser_printer_st.pic_x_mirror = 0;
}
else if (coorvalue == 1) {
else if (coorvalue == 1)
Laser_printer_st.pic_x_mirror = 1; // x
}
}
break;
case 38:
if (CodeSeen('S')) {
@@ -2255,13 +2259,11 @@ void AnycubicTouchscreenClass::GetCommandFromTFT() {
if (CodeSeen('S')) { // y
int coorvalue;
coorvalue = CodeValueInt();
if (coorvalue == 0) {
if (coorvalue == 0)
Laser_printer_st.pic_y_mirror = 0;
}
else if (coorvalue == 1) {
else if (coorvalue == 1)
Laser_printer_st.pic_y_mirror = 1;
}
}
break;
case 44:
send_laser_param();
@@ -2273,12 +2275,13 @@ void AnycubicTouchscreenClass::GetCommandFromTFT() {
case 50: // A50
if (laser_on_off == 0) {
laser_on_off = 1;
} else {
}
else {
laser_on_off = 0;
WRITE(HEATER_0_PIN, 0);
}
break;
#endif
#endif // if ENABLED(KNUTWURST_MEGA_P_LASER)
#if ENABLED(KNUTWURST_MEGA_P)
case 51:
@@ -2316,7 +2319,8 @@ void AnycubicTouchscreenClass::GetCommandFromTFT() {
TFTbuflen += 1;
}
serial3_count = 0; // clear buffer
} else {
}
else {
if (serial3_char == ';') TFTcomment_mode = true;
if (!TFTcomment_mode) TFTcmdbuffer[TFTbufindw][serial3_count++] = serial3_char;
}
@@ -2381,9 +2385,8 @@ void AnycubicTouchscreenClass::CommandScan() {
}
#endif
if (TFTbuflen < (TFTBUFSIZE - 1)) {
if (TFTbuflen < (TFTBUFSIZE - 1))
GetCommandFromTFT();
}
if (TFTbuflen) {
TFTbuflen = (TFTbuflen - 1);
TFTbufindr = (TFTbufindr + 1) % TFTBUFSIZE;
@@ -2464,4 +2467,4 @@ void PowerKill() {
}
AnycubicTouchscreenClass AnycubicTouchscreen;
#endif
#endif // ifdef ANYCUBIC_TOUCHSCREEN

View File

@@ -300,7 +300,8 @@ class AnycubicTouchscreenClass {
float last_bed_temp;
float last_hotend_temp;
long lastSDposition;
} OutageData;
}
OutageData;
#endif
int CodeValueInt();
@@ -392,9 +393,9 @@ class AnycubicTouchscreenClass {
#define PIC_SPEDD 20000
#define MIN_GRAY_VLAUE 20
#define LASER_PRINT_SPEED 30 // 50*60
#endif
#endif // if ENABLED(KNUTWURST_MEGA_P_LASER)
};
extern AnycubicTouchscreenClass AnycubicTouchscreen;
#endif
#endif // ifndef anycubic_touchscreen_h