Working Implementation of Anycubic Touchscreen. Also with UTF8 workaround when using invalid characters on SD.

This commit is contained in:
Knutwurst
2020-06-02 19:20:48 +02:00
parent 612108066d
commit 06bd56f54d
6 changed files with 222 additions and 159 deletions

View File

@@ -126,7 +126,8 @@
#define STR_INVALID_E_STEPPER "Invalid E stepper"
#define STR_E_STEPPER_NOT_SPECIFIED "E stepper not specified"
#define STR_INVALID_SOLENOID "Invalid solenoid"
#define STR_M115_REPORT "FIRMWARE_NAME:Marlin " DETAILED_BUILD_VERSION " SOURCE_CODE_URL:" SOURCE_CODE_URL " PROTOCOL_VERSION:" PROTOCOL_VERSION " MACHINE_TYPE:" MACHINE_NAME " EXTRUDER_COUNT:" STRINGIFY(EXTRUDERS) " UUID:" MACHINE_UUID
#define STR_M115_REPORT "FIRMWARE_NAME:Marlin " DETAILED_BUILD_VERSION " MARLIN-AI3M_VERSION:" CUSTOM_BUILD_VERSION " SOURCE_CODE_URL:" SOURCE_CODE_URL " PROTOCOL_VERSION:" PROTOCOL_VERSION " MACHINE_TYPE:" MACHINE_NAME " EXTRUDER_COUNT:" STRINGIFY(EXTRUDERS) " UUID:" MACHINE_UUID
#define STR_MARLIN_AI3M "Marlin-AI3M"
#define STR_COUNT_X " Count X:"
#define STR_COUNT_A " Count A:"
#define STR_WATCHDOG_FIRED "Watchdog timeout. Reset required."

View File

@@ -28,19 +28,18 @@
#define SHORT_BUILD_VERSION "2.0.5.3"
#endif
/**
* Verbose version identifier containing a unique identifier, such as the
* vendor name, download location, GitHub account, etc.
*/
#ifndef DETAILED_BUILD_VERSION
#define DETAILED_BUILD_VERSION SHORT_BUILD_VERSION " (GitHub)"
#endif
/**
* Verbose version identifier which should contain a reference to the location
* from where the binary was downloaded or the source code was compiled.
*/
#define DETAILED_BUILD_VERSION SHORT_BUILD_VERSION " (knutwurst, Github)"
/**
* The STRING_DISTRIBUTION_DATE represents when the binary file was built,
* here we define this default string as the date where the latest release
* version was tagged.
* Defines the version of the Marlin build. Not to be confused with
* Marlin's own build number, e.g. 2.0.x.
*/
#define CUSTOM_BUILD_VERSION "1.0.0"
#ifndef STRING_DISTRIBUTION_DATE
#define STRING_DISTRIBUTION_DATE "2020-03-31"
#endif
@@ -69,27 +68,24 @@
#define PROTOCOL_VERSION "1.0"
#endif
/**
* Define a generic printer name to be output to the LCD after booting Marlin.
*/
#ifndef MACHINE_NAME
#define MACHINE_NAME "3D Printer"
#endif
/**
* Defines a generic printer name to be output to the LCD after booting Marlin.
*/
#define MACHINE_NAME "Anycubic i3 MEGA S"
/**
* Website where users can find Marlin source code for the binary installed on the
* device. Override this if you provide public source code download. (GPLv3 requires
* providing the source code to your customers.)
*/
#ifndef SOURCE_CODE_URL
#define SOURCE_CODE_URL "https://github.com/MarlinFirmware/Marlin"
#endif
/**
* The SOURCE_CODE_URL is the location where users will find the Marlin Source
* Code which is installed on the device. In most cases —unless the manufacturer
* has a distinct Github fork— the Source Code URL should just be the main
* Marlin repository.
*/
#define SOURCE_CODE_URL "https://github.com/knutwurst/Marlin-2-0-x-Anycubic-i3-MEGA-S"
/**
* Default generic printer UUID.
*/
#ifndef DEFAULT_MACHINE_UUID
#define DEFAULT_MACHINE_UUID "cede2a2f-41a2-4748-9b12-c55c62f367ff"
#define DEFAULT_MACHINE_UUID "b6153152-86fb-4cd8-bda7-91c6a04c467d"
#endif
/**

View File

@@ -131,7 +131,6 @@ const char newSucc[] PROGMEM = "OK";
#define ANYCUBIC_SERIAL_ERRORLN(x) ANYCUBIC_SERIAL_PROTOCOLLN(x)
#define ANYCUBIC_SERIAL_ERRORLNPGM(x) ANYCUBIC_SERIAL_PROTOCOLLNPGM(x)
//##define ANYCUBIC_SERIAL_ECHO_START (AnycubicSerialprintPGM(newSucc))
#define ANYCUBIC_SERIAL_ECHOLN(x) ANYCUBIC_SERIAL_PROTOCOLLN(x)
#define ANYCUBIC_SERIAL_SUCC_START (AnycubicSerialprintPGM(newSucc))
#define ANYCUBIC_SERIAL_ECHOPAIR(name, value) (serial_echopair_P(PSTR(name), (value)))

View File

@@ -509,44 +509,49 @@ void AnycubicTouchscreenClass::Ls()
switch (filenumber)
{
case 0: // First Page
ANYCUBIC_SERIAL_PROTOCOLLNPGM("<Z Up 0.1>");
ANYCUBIC_SERIAL_PROTOCOLLNPGM("<Z Up 0.1>");
ANYCUBIC_SERIAL_PROTOCOLLNPGM("<Z Up 0.02>");
ANYCUBIC_SERIAL_PROTOCOLLNPGM("<Z Up 0.02>");
ANYCUBIC_SERIAL_PROTOCOLLNPGM("<Z Down 0.02>");
ANYCUBIC_SERIAL_PROTOCOLLNPGM("<Z Down 0.02>");
ANYCUBIC_SERIAL_PROTOCOLLNPGM("<Z Down 0.1>");
ANYCUBIC_SERIAL_PROTOCOLLNPGM("<Z Down 0.1>");
ANYCUBIC_SERIAL_PROTOCOLLNPGM("<Exit>");
ANYCUBIC_SERIAL_PROTOCOLLNPGM("<Exit>");
ANYCUBIC_SERIAL_PROTOCOLLNPGM("<Preheat Ultrabase>");
ANYCUBIC_SERIAL_PROTOCOLLNPGM("<Preheat Ultrabase>");
ANYCUBIC_SERIAL_PROTOCOLLNPGM("<FilamentChange Pause>");
ANYCUBIC_SERIAL_PROTOCOLLNPGM("<FilamentChange Pause>");
ANYCUBIC_SERIAL_PROTOCOLLNPGM("<FilamentChange Resume>");
ANYCUBIC_SERIAL_PROTOCOLLNPGM("<FilamentChange Resume>");
break;
case 4: // Second Page
ANYCUBIC_SERIAL_PROTOCOLLNPGM("<Preheat bed>");
ANYCUBIC_SERIAL_PROTOCOLLNPGM("<Preheat bed>");
ANYCUBIC_SERIAL_PROTOCOLLNPGM("<Start Mesh Leveling>");
ANYCUBIC_SERIAL_PROTOCOLLNPGM("<Start Mesh Leveling>");
ANYCUBIC_SERIAL_PROTOCOLLNPGM("<Next Mesh Point>");
ANYCUBIC_SERIAL_PROTOCOLLNPGM("<Next Mesh Point>");
ANYCUBIC_SERIAL_PROTOCOLLNPGM("<Save EEPROM>");
ANYCUBIC_SERIAL_PROTOCOLLNPGM("<Save EEPROM>");
ANYCUBIC_SERIAL_PROTOCOLLNPGM("<Z Up 0.1>");
ANYCUBIC_SERIAL_PROTOCOLLNPGM("<Z Up 0.1>");
ANYCUBIC_SERIAL_PROTOCOLLNPGM("<Z Down 0.1>");
ANYCUBIC_SERIAL_PROTOCOLLNPGM("<Z Down 0.1>");
break;
case 8: // Third Page
ANYCUBIC_SERIAL_PROTOCOLLNPGM("<Exit>");
ANYCUBIC_SERIAL_PROTOCOLLNPGM("<Exit>");
ANYCUBIC_SERIAL_PROTOCOLLNPGM("<Auto Tune Hotend PID>");
ANYCUBIC_SERIAL_PROTOCOLLNPGM("<Auto Tune Hotend PID>");
ANYCUBIC_SERIAL_PROTOCOLLNPGM("<Auto Tune Hotbed PID>");
ANYCUBIC_SERIAL_PROTOCOLLNPGM("<Auto Tune Hotbed PID>");
ANYCUBIC_SERIAL_PROTOCOLLNPGM("<PID Tune Hotend>");
ANYCUBIC_SERIAL_PROTOCOLLNPGM("<PID Tune Hotend>");
ANYCUBIC_SERIAL_PROTOCOLLNPGM("<PID Tune Ultrabase>");
ANYCUBIC_SERIAL_PROTOCOLLNPGM("<PID Tune Ultrabase>");
ANYCUBIC_SERIAL_PROTOCOLLNPGM("<Save EEPROM>");
ANYCUBIC_SERIAL_PROTOCOLLNPGM("<Save EEPROM>");
ANYCUBIC_SERIAL_PROTOCOLLNPGM("<Load FW Defaults>");
ANYCUBIC_SERIAL_PROTOCOLLNPGM("<Load FW Defaults>");
break;
/*
case 12: // Fourth Page
ANYCUBIC_SERIAL_PROTOCOLLNPGM("<FilamentChange Pause>");
ANYCUBIC_SERIAL_PROTOCOLLNPGM("<FilamentChange Pause>");
ANYCUBIC_SERIAL_PROTOCOLLNPGM("<FilamentChange Resume>");
ANYCUBIC_SERIAL_PROTOCOLLNPGM("<FilamentChange Resume>");
ANYCUBIC_SERIAL_PROTOCOLLNPGM("<Z Up 0.1>");
ANYCUBIC_SERIAL_PROTOCOLLNPGM("<Z Up 0.1>");
ANYCUBIC_SERIAL_PROTOCOLLNPGM("<Z Down 0.1>");
ANYCUBIC_SERIAL_PROTOCOLLNPGM("<Z Down 0.1>");
ANYCUBIC_SERIAL_PROTOCOLLNPGM("<Z Up 0.02>");
ANYCUBIC_SERIAL_PROTOCOLLNPGM("<Z Up 0.02>");
ANYCUBIC_SERIAL_PROTOCOLLNPGM("<Z Down 0.02>");
ANYCUBIC_SERIAL_PROTOCOLLNPGM("<Z Down 0.02>");
break;
*/
default:
break;
@@ -590,24 +595,54 @@ void AnycubicTouchscreenClass::Ls()
else
{
card.selectFileByIndex(cnt - 1);
// card.selectFileByIndex(cnt);
bool hasInvalidCharacter = false;
for (unsigned char currentChar = 0; currentChar < strlen(card.longFilename); currentChar++)
if (!isAscii(card.longFilename[currentChar]))
{
hasInvalidCharacter = true;
break;
}
if (card.flag.filenameIsDir)
{
ANYCUBIC_SERIAL_PROTOCOLPGM("/");
ANYCUBIC_SERIAL_PROTOCOLLN(card.filename);
ANYCUBIC_SERIAL_PROTOCOLPGM("/");
ANYCUBIC_SERIAL_PROTOCOLLN(card.longFilename);
SERIAL_ECHO(cnt);
SERIAL_ECHOPGM("/");
SERIAL_ECHOLN(card.longFilename);
if(hasInvalidCharacter)
{
ANYCUBIC_SERIAL_PROTOCOLPGM("/");
ANYCUBIC_SERIAL_PROTOCOLLN(card.filename);
ANYCUBIC_SERIAL_PROTOCOLPGM("/");
ANYCUBIC_SERIAL_PROTOCOLLN(card.filename);
SERIAL_ECHO(cnt);
SERIAL_ECHOPGM("/");
SERIAL_ECHOLN(card.filename);
}
else
{
ANYCUBIC_SERIAL_PROTOCOLPGM("/");
ANYCUBIC_SERIAL_PROTOCOLLN(card.longFilename);
ANYCUBIC_SERIAL_PROTOCOLPGM("/");
ANYCUBIC_SERIAL_PROTOCOLLN(card.longFilename);
SERIAL_ECHO(cnt);
SERIAL_ECHOPGM("/");
SERIAL_ECHOLN(card.longFilename);
}
}
else
{
ANYCUBIC_SERIAL_PROTOCOLLN(card.filename);
ANYCUBIC_SERIAL_PROTOCOLLN(card.longFilename);
SERIAL_ECHO(cnt);
SERIAL_ECHOLN(card.longFilename);
if(hasInvalidCharacter)
{
ANYCUBIC_SERIAL_PROTOCOLLN(card.filename);
ANYCUBIC_SERIAL_PROTOCOLLN(card.filename);
SERIAL_ECHO(cnt);
SERIAL_ECHOLN(card.filename);
}
else
{
ANYCUBIC_SERIAL_PROTOCOLLN(card.longFilename);
ANYCUBIC_SERIAL_PROTOCOLLN(card.longFilename);
SERIAL_ECHO(cnt);
SERIAL_ECHOLN(card.longFilename);
}
}
}
}
@@ -1152,7 +1187,7 @@ void AnycubicTouchscreenClass::GetCommandFromTFT()
thermalManager.setTargetHotend(tempvalue, 0);
}
}
// ANYCUBIC_SERIAL_ENTER();
// ANYCUBIC_SERIAL_ENTER();
break;
case 17: // A17 set heated bed temp
{