Browse Source

🧑‍💻 Anycubic shared code (#25690)

Scott Lahteine 1 year ago
parent
commit
6e3b58d76a

+ 11 - 16
Marlin/src/lcd/extui/anycubic_vyper/Tunes.cpp → Marlin/src/lcd/extui/anycubic/Tunes.cpp

@@ -21,7 +21,7 @@
  */
 
 /**
- * lcd/extui/anycubic_vyper/Tunes.cpp
+ * lcd/extui/anycubic/Tunes.cpp
  */
 
 /***********************************************************************
@@ -31,28 +31,23 @@
 
 #include "../../../inc/MarlinConfigPre.h"
 
-#if ENABLED(ANYCUBIC_LCD_VYPER)
+#if EITHER(ANYCUBIC_LCD_CHIRON, ANYCUBIC_LCD_VYPER)
 
 #include "Tunes.h"
+#include "../../../libs/buzzer.h"
 #include "../ui_api.h"
 
 namespace Anycubic {
 
-  void PlayTune(const uint8_t beeperPin, const uint16_t *tune, const uint8_t speed=1) {
-    uint8_t pos = 1;
-    uint16_t wholenotelen = tune[0] / speed;
-    do {
-      uint16_t freq = tune[pos];
-      uint16_t notelen = wholenotelen / tune[pos + 1];
-
-      ::tone(beeperPin, freq, notelen);
-      ExtUI::delay_ms(notelen);
-      pos += 2;
-
-      if (pos >= MAX_TUNE_LENGTH) break;
-    } while (tune[pos] != n_END);
+  void PlayTune(const uint16_t *tune, const uint8_t speed=1) {
+    const uint16_t wholenotelen = tune[0] / speed;
+    for (uint8_t pos = 1; pos < MAX_TUNE_LENGTH; pos += 2) {
+      const uint16_t freq = tune[pos];
+      if (freq == n_END) break;
+      BUZZ(freq, wholenotelen / tune[pos + 1]);
+    }
   }
 
 }
 
-#endif // ANYCUBIC_LCD_VYPER
+#endif // ANYCUBIC_LCD_CHIRON || ANYCUBIC_LCD_VYPER

+ 16 - 121
Marlin/src/lcd/extui/anycubic_vyper/Tunes.h → Marlin/src/lcd/extui/anycubic/Tunes.h

@@ -22,7 +22,7 @@
 #pragma once
 
 /**
- * lcd/extui/anycubic_vyper/Tunes.h
+ * lcd/extui/anycubic/Tunes.h
  */
 
 /**************************************************************************
@@ -41,127 +41,23 @@
 
 #define MAX_TUNE_LENGTH 128
 
-// Special notes!
-#define n_P    0       // silence or pause
-#define n_END  10000   // end of tune marker
-
 // Note duration divisors
-#define l_T1   1
-#define l_T2   2
-#define l_T3   3
-#define l_T4   4
-#define l_T8   8
-#define l_T16 16
+enum { l_T1=1, l_T2 =2, l_T3=3, l_T4 =4, l_T8=8, l_T16=16 };
 
 // Note Frequency
-#define n_C0     16
-#define n_CS0    17
-#define n_D0     18
-#define n_DS0    19
-#define n_E0     21
-#define n_F0     22
-#define n_FS0    23
-#define n_G0     25
-#define n_GS0    26
-#define n_A0     28
-#define n_AS0    29
-#define n_B0     31
-#define n_C1     33
-#define n_CS1    35
-#define n_D1     37
-#define n_DS1    39
-#define n_E1     41
-#define n_F1     44
-#define n_FS1    46
-#define n_G1     49
-#define n_GS1    52
-#define n_A1     55
-#define n_AS1    58
-#define n_B1     62
-#define n_C2     65
-#define n_CS2    69
-#define n_D2     73
-#define n_DS2    78
-#define n_E2     82
-#define n_F2     87
-#define n_FS2    93
-#define n_G2     98
-#define n_GS2   104
-#define n_A2    110
-#define n_AS2   117
-#define n_B2    123
-#define n_C3    131
-#define n_CS3   139
-#define n_D3    147
-#define n_DS3   156
-#define n_E3    165
-#define n_F3    175
-#define n_FS3   185
-#define n_G3    196
-#define n_GS3   208
-#define n_A3    220
-#define n_AS3   233
-#define n_B3    247
-#define n_C4    262
-#define n_CS4   277
-#define n_D4    294
-#define n_DS4   311
-#define n_E4    330
-#define n_F4    349
-#define n_FS4   370
-#define n_G4    392
-#define n_GS4   415
-#define n_A4    440
-#define n_AS4   466
-#define n_B4    494
-#define n_C5    523
-#define n_CS5   554
-#define n_D5    587
-#define n_DS5   622
-#define n_E5    659
-#define n_F5    698
-#define n_FS5   740
-#define n_G5    784
-#define n_GS5   831
-#define n_A5    880
-#define n_AS5   932
-#define n_B5    988
-#define n_C6   1047
-#define n_CS6  1109
-#define n_D6   1175
-#define n_DS6  1245
-#define n_E6   1319
-#define n_F6   1397
-#define n_FS6  1480
-#define n_G6   1568
-#define n_GS6  1661
-#define n_A6   1760
-#define n_AS6  1865
-#define n_B6   1976
-#define n_C7   2093
-#define n_CS7  2217
-#define n_D7   2349
-#define n_DS7  2489
-#define n_E7   2637
-#define n_F7   2794
-#define n_FS7  2960
-#define n_G7   3136
-#define n_GS7  3322
-#define n_A7   3520
-#define n_AS7  3729
-#define n_B7   3951
-#define n_C8   4186
-#define n_CS8  4435
-#define n_D8   4699
-#define n_DS8  4978
-#define n_E8   5274
-#define n_F8   5587
-#define n_FS8  5920
-#define n_G8   6272
-#define n_GS8  6645
-#define n_A8   7040
-#define n_AS8  7459
-#define n_B8   7902
+enum {
+n_P =   0,  // silence or pause
+n_C0=  16, n_CS0=  17, n_D0=  18, n_DS0=  19, n_E0=  21, n_F0=  22, n_FS0=  23, n_G0=  25, n_GS0=  26, n_A0=  28, n_AS0=  29, n_B0=  31,
+n_C1=  33, n_CS1=  35, n_D1=  37, n_DS1=  39, n_E1=  41, n_F1=  44, n_FS1=  46, n_G1=  49, n_GS1=  52, n_A1=  55, n_AS1=  58, n_B1=  62,
+n_C2=  65, n_CS2=  69, n_D2=  73, n_DS2=  78, n_E2=  82, n_F2=  87, n_FS2=  93, n_G2=  98, n_GS2= 104, n_A2= 110, n_AS2= 117, n_B2= 123,
+n_C3= 131, n_CS3= 139, n_D3= 147, n_DS3= 156, n_E3= 165, n_F3= 175, n_FS3= 185, n_G3= 196, n_GS3= 208, n_A3= 220, n_AS3= 233, n_B3= 247,
+n_C4= 262, n_CS4= 277, n_D4= 294, n_DS4= 311, n_E4= 330, n_F4= 349, n_FS4= 370, n_G4= 392, n_GS4= 415, n_A4= 440, n_AS4= 466, n_B4= 494,
+n_C5= 523, n_CS5= 554, n_D5= 587, n_DS5= 622, n_E5= 659, n_F5= 698, n_FS5= 740, n_G5= 784, n_GS5= 831, n_A5= 880, n_AS5= 932, n_B5= 988,
+n_C6=1047, n_CS6=1109, n_D6=1175, n_DS6=1245, n_E6=1319, n_F6=1397, n_FS6=1480, n_G6=1568, n_GS6=1661, n_A6=1760, n_AS6=1865, n_B6=1976,
+n_C7=2093, n_CS7=2217, n_D7=2349, n_DS7=2489, n_E7=2637, n_F7=2794, n_FS7=2960, n_G7=3136, n_GS7=3322, n_A7=3520, n_AS7=3729, n_B7=3951,
+n_C8=4186, n_CS8=4435, n_D8=4699, n_DS8=4978, n_E8=5274, n_F8=5587, n_FS8=5920, n_G8=6272, n_GS8=6645, n_A8=7040, n_AS8=7459, n_B8=7902,
+n_END=10000 // end of tune marker
+};
 
 namespace Anycubic {
 
@@ -194,8 +90,7 @@ namespace Anycubic {
   const uint16_t Anycubic_PowerOn[] = {
     1000,
     n_F7,l_T8, n_P,l_T8, n_C7,l_T8, n_P,l_T8, n_D7,l_T8, n_P,l_T8,
-    n_E7,l_T8, n_P,l_T8, n_D7,l_T4, n_P,l_T4, n_G7,l_T4, n_P,l_T4,
-    n_A7,l_T2, n_P,l_T1,
+    n_E7,l_T8, n_P,l_T8, n_D7,l_T4, n_P,l_T4,
     n_END
   };
 

+ 138 - 0
Marlin/src/lcd/extui/anycubic/common_defs.h

@@ -0,0 +1,138 @@
+/**
+ * Marlin 3D Printer Firmware
+ * Copyright (c) 2023 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 <https://www.gnu.org/licenses/>.
+ *
+ */
+#pragma once
+
+/**
+ * lcd/extui/anycubic/common_defs.h
+ */
+
+#include "../../../inc/MarlinConfigPre.h"
+
+#define ACDEBUGLEVEL 0  //  0: off, 255: all levels enabled
+
+#if ACDEBUGLEVEL
+  // Bit-masks for selective debug:
+  enum ACDebugMask : uint8_t {
+    AC_INFO   =  1,
+    AC_ACTION =  2,
+    AC_FILE   =  4,
+    AC_PANEL  =  8,
+    AC_MARLIN = 16,
+    AC_SOME   = 32,
+    AC_ALL    = 64
+  };
+  #define ACDEBUG(mask) ( ((mask) & ACDEBUGLEVEL) == mask )  // Debug flag macro
+#else
+  #define ACDEBUG(mask) false
+#endif
+
+#define TFTSer LCD_SERIAL                    // Serial interface for TFT panel now uses marlinserial
+#define MAX_FOLDER_DEPTH                4    // Limit folder depth TFT has a limit for the file path
+#define MAX_CMND_LEN                   16 * MAX_FOLDER_DEPTH // Maximum Length for a Panel command
+#define MAX_PATH_LEN                   16 * MAX_FOLDER_DEPTH // Maximum number of characters in a SD file path
+
+#define AC_HEATER_FAULT_VALIDATION_TIME 5    // number of 1/2 second loops before signalling a heater fault
+#define AC_LOWEST_MESHPOINT_VAL        Z_PROBE_LOW_POINT // The lowest value you can set for a single mesh point offset
+
+// TFT panel commands
+#define AC_msg_sd_card_inserted         F("J00")
+#define AC_msg_sd_card_removed          F("J01")
+#define AC_msg_no_sd_card               F("J02")
+#define AC_msg_usb_connected            F("J03")
+#define AC_msg_print_from_sd_card       F("J04")
+#define AC_msg_pause                    F("J05")
+#define AC_msg_nozzle_heating           F("J06")
+#define AC_msg_nozzle_heating_done      F("J07")
+#define AC_msg_bed_heating              F("J08")
+#define AC_msg_bed_heating_done         F("J09")
+#define AC_msg_nozzle_temp_abnormal     F("J10")
+#define AC_msg_kill_lcd                 F("J11")
+#define AC_msg_ready                    F("J12")
+#define AC_msg_low_nozzle_temp          F("J13")
+#define AC_msg_print_complete           F("J14")
+#define AC_msg_filament_out_alert       F("J15")
+#define AC_msg_stop                     F("J16")
+#define AC_msg_main_board_has_reset     F("J17")
+#define AC_msg_paused                   F("J18")
+#define AC_msg_j19_unknown              F("J19")
+#define AC_msg_sd_file_open_success     F("J20")
+#define AC_msg_sd_file_open_failed      F("J21")
+#define AC_msg_level_monitor_finished   F("J22")
+#define AC_msg_filament_out_block       F("J23")
+#define AC_msg_probing_not_allowed      F("J24")
+#define AC_msg_probing_complete         F("J25")
+#define AC_msg_start_probing            F("J26")
+#define AC_msg_version                  F("J27")
+
+// TFT panel messages
+#define MARLIN_msg_start_probing        PSTR("Probing Point 1/25")
+#define MARLIN_msg_probing_failed       PSTR("Probing Failed")
+#define MARLIN_msg_ready                PSTR(" Ready.")
+#define MARLIN_msg_print_paused         PSTR("Print Paused")
+#define MARLIN_msg_print_aborted        PSTR("Print Aborted")
+#define MARLIN_msg_extruder_heating     PSTR("E Heating...")
+#define MARLIN_msg_bed_heating          PSTR("Bed Heating...")
+
+#define MARLIN_msg_nozzle_parked        PSTR("Nozzle Parked")
+#define MARLIN_msg_heater_timeout       PSTR("Heater Timeout")
+#define MARLIN_msg_reheating            PSTR("Reheating...")
+#define MARLIN_msg_reheat_done          PSTR("Reheat finished.")
+#define MARLIN_msg_filament_purging     PSTR("Filament Purging...")
+
+#define MARLIN_msg_special_pause        PSTR("PB")                   // AnyCubic
+
+#define AC_cmnd_auto_unload_filament    F("M701")                    // Marlin unload routine
+#define AC_cmnd_auto_load_filament      F("M702 M0 PB")              // AnyCubic: Marlin load routine, pause for user to clean nozzle
+
+#define AC_cmnd_manual_load_filament    F("M83\nG1 E50 F700\nM82")   // replace the manual panel commands with something a little faster
+#define AC_cmnd_manual_unload_filament  F("M83\nG1 E-50 F1200\nM82")
+#define AC_cmnd_enable_leveling         F("M420SV")
+#define AC_cmnd_power_loss_recovery     F("G28XYR5\nG28Z")           // Lift, home X and Y then home Z when in 'safe' position
+
+namespace Anycubic {
+
+  enum heater_state_t : uint8_t {
+    AC_heater_off,
+    AC_heater_temp_set,
+    AC_heater_temp_reached
+  };
+
+  enum timer_event_t : uint8_t {
+    AC_timer_started,
+    AC_timer_paused,
+    AC_timer_stopped
+  };
+
+  enum media_event_t : uint8_t {
+    AC_media_inserted,
+    AC_media_removed,
+    AC_media_error
+  };
+
+  enum file_menu_t : uint8_t {
+    AC_menu_file,
+    AC_menu_command,
+    AC_menu_change_to_file,
+    AC_menu_change_to_command
+  };
+
+} // Anycubic

+ 14 - 14
Marlin/src/lcd/extui/anycubic_chiron/FileNavigator.cpp

@@ -63,7 +63,7 @@ FileNavigator filenavigator;
 FileList  FileNavigator::filelist;                          // Instance of the Marlin file API
 uint16_t  FileNavigator::lastpanelindex;
 uint16_t  FileNavigator::currentindex;                      // override the panel request
-uint8_t   FileNavigator::currentfolderdepth;
+uint8_t   FileNavigator::folderdepth;
 uint16_t  FileNavigator::currentfolderindex[MAX_FOLDER_DEPTH];   // track folder pos for iteration
 char      FileNavigator::currentfoldername[MAX_PATH_LEN + 1];   // Current folder path
 
@@ -71,7 +71,7 @@ FileNavigator::FileNavigator() { reset(); }
 
 void FileNavigator::reset() {
   currentfoldername[0] = '\0';
-  currentfolderdepth = 0;
+  folderdepth = 0;
   currentindex = 0;
   lastpanelindex = 0;
   ZERO(currentfolderindex);
@@ -84,25 +84,25 @@ void FileNavigator::reset() {
 void FileNavigator::refresh() { filelist.refresh(); }
 
 void FileNavigator::changeDIR(const char *folder) {
-  if (currentfolderdepth >= MAX_FOLDER_DEPTH) return; // limit the folder depth
-  currentfolderindex[currentfolderdepth] = currentindex;
+  if (folderdepth >= MAX_FOLDER_DEPTH) return; // limit the folder depth
+  currentfolderindex[folderdepth] = currentindex;
   strcat(currentfoldername, folder);
   strcat(currentfoldername, "/");
   filelist.changeDir(folder);
-  currentfolderdepth++;
+  folderdepth++;
   currentindex = 0;
 }
 
 void FileNavigator::upDIR() {
   if (!filelist.isAtRootDir()) {
     filelist.upDir();
-    currentfolderdepth--;
-    currentindex = currentfolderindex[currentfolderdepth]; // restore last position in the folder
+    folderdepth--;
+    currentindex = currentfolderindex[folderdepth]; // restore last position in the folder
     filelist.seek(currentindex); // restore file information
   }
 
   // Remove the child folder from the stored path
-  if (currentfolderdepth == 0)
+  if (folderdepth == 0)
     currentfoldername[0] = '\0';
   else {
     char * const pos = strchr(currentfoldername, '/');
@@ -122,7 +122,7 @@ void FileNavigator::skiptofileindex(uint16_t skip) {
         changeDIR(filelist.shortFilename());
     } // valid file
     if (currentindex == filelist.count()) {
-      if (currentfolderdepth > 0) {
+      if (folderdepth > 0) {
         upDIR();
         currentindex++;
       }
@@ -147,7 +147,7 @@ void FileNavigator::skiptofileindex(uint16_t skip) {
     }
     lastpanelindex = index;
 
-    if (currentindex == 0 && currentfolderdepth > 0) { // Add a link to go up a folder
+    if (currentindex == 0 && folderdepth > 0) { // Add a link to go up a folder
       // The new panel ignores entries that don't end in .GCO or .gcode so add and pad them.
       if (paneltype <= AC_panel_new) {
         TFTSer.println("<<.GCO");
@@ -186,7 +186,7 @@ void FileNavigator::skiptofileindex(uint16_t skip) {
     }
     else { // Not DIR
       TFTSer.write('/');
-      if (currentfolderdepth > 0) TFTSer.print(currentfoldername);
+      if (folderdepth > 0) TFTSer.print(currentfoldername);
       TFTSer.println(filelist.shortFilename());
       TFTSer.print(filelist.longFilename());
 
@@ -221,7 +221,7 @@ void FileNavigator::skiptofileindex(uint16_t skip) {
       } // valid file
 
       if (currentindex == filelist.count()) {
-        if (currentfolderdepth > 0) {
+        if (folderdepth > 0) {
           upDIR();
           currentindex++;
         }
@@ -233,9 +233,9 @@ void FileNavigator::skiptofileindex(uint16_t skip) {
 
   void FileNavigator::sendFile(panel_type_t paneltype) {
     TFTSer.write('/');
-    if (currentfolderdepth > 0) TFTSer.print(currentfoldername);
+    if (folderdepth > 0) TFTSer.print(currentfoldername);
     TFTSer.println(filelist.shortFilename());
-    if (currentfolderdepth > 0) TFTSer.print(currentfoldername);
+    if (folderdepth > 0) TFTSer.print(currentfoldername);
     TFTSer.println(filelist.longFilename());
   }
 

+ 21 - 21
Marlin/src/lcd/extui/anycubic_chiron/FileNavigator.h

@@ -36,26 +36,26 @@ using namespace ExtUI;
 
 namespace Anycubic {
 
-class FileNavigator {
-  public:
-    FileNavigator();
-    static void reset();
-    static void getFiles(uint16_t, panel_type_t, uint8_t filesneeded=4);
-    static void upDIR();
-    static void changeDIR(const char *);
-    static void sendFile(panel_type_t);
-    static void refresh();
-    static void skiptofileindex(uint16_t);
-
-    static FileList filelist;
-  private:
-    static uint16_t lastpanelindex;
-    static uint16_t currentindex;
-    static uint8_t  currentfolderdepth;
-    static uint16_t currentfolderindex[MAX_FOLDER_DEPTH];
-    static char     currentfoldername[MAX_PATH_LEN + 1];
-};
-
-extern FileNavigator filenavigator;
+  class FileNavigator {
+    public:
+      static FileList filelist;
+
+      FileNavigator();
+      static void reset();
+      static void getFiles(uint16_t, panel_type_t, uint8_t filesneeded=4);
+      static void upDIR();
+      static void changeDIR(const char *);
+      static void sendFile(panel_type_t);
+      static void refresh();
+      static void skiptofileindex(uint16_t);
+    private:
+      static uint16_t lastpanelindex;
+      static uint16_t currentindex;
+      static uint8_t  folderdepth;
+      static uint16_t currentfolderindex[MAX_FOLDER_DEPTH];
+      static char     currentfoldername[MAX_PATH_LEN + 1];
+  };
+
+  extern FileNavigator filenavigator;
 
 }

+ 0 - 61
Marlin/src/lcd/extui/anycubic_chiron/Tunes.cpp

@@ -1,61 +0,0 @@
-/**
- * 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 <https://www.gnu.org/licenses/>.
- *
- */
-
-/**
- * lcd/extui/anycubic_chiron/Tunes.cpp
- *
- * Extensible_UI implementation for Anycubic Chiron
- * Written By Nick Wells, 2020 [https://github.com/SwiftNick]
- *  (not affiliated with Anycubic, Ltd.)
- */
-
-/***********************************************************************
- * A Utility to play tunes using the buzzer in the printer controller. *
- * See Tunes.h for note and tune definitions.                          *
- ***********************************************************************/
-
-#include "../../../inc/MarlinConfigPre.h"
-
-// TODO: Use Marlin's built-in tone player instead.
-
-#if ENABLED(ANYCUBIC_LCD_CHIRON)
-
-#include "Tunes.h"
-#include "../ui_api.h"
-
-namespace Anycubic {
-
-  void PlayTune(uint8_t beeperPin, const uint16_t *tune, uint8_t speed=1) {
-    uint8_t pos = 1;
-    const uint16_t wholenotelen = tune[0] / speed;
-    do {
-      const uint16_t freq = tune[pos], notelen = wholenotelen / tune[pos + 1];
-      ::tone(beeperPin, freq, notelen);
-      ExtUI::delay_ms(notelen);
-      pos += 2;
-      if (pos >= MAX_TUNE_LENGTH) break;
-    } while (tune[pos] != n_END);
-  }
-
-}
-
-#endif // ANYCUBIC_LCD_CHIRON

+ 0 - 224
Marlin/src/lcd/extui/anycubic_chiron/Tunes.h

@@ -1,224 +0,0 @@
-/**
- * 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 <https://www.gnu.org/licenses/>.
- *
- */
-#pragma once
-
-/**
- * lcd/extui/anycubic_chiron/Tunes.h
- *
- * Extensible_UI implementation for Anycubic Chiron
- * Written By Nick Wells, 2020 [https://github.com/SwiftNick]
- *  (not affiliated with Anycubic, Ltd.)
- */
-
-/**************************************************************************
- * Notes definition from https://pages.mtu.edu/~suits/NoteFreqCalcs.html  *
- *                                                                        *
- * The format of a tune is:                                               *
- * {<whole note time>,<note1>,<length1>, <note2>,<length2>, ... <END>}    *
- *                                                                        *
- * 1) The first value is the length of a whole note in milliseconds       *
- * 2) Then a sequence of pitch and duration pairs                         *
- * 3) Finally the END marker so your tunes can be any length up to        *
- *    MAX_TUNE_LEN                                                        *
- *************************************************************************/
-
-#include <stdint.h>
-
-#define MAX_TUNE_LENGTH 128
-
-// Special notes!
-#define n_P    0       // silence or pause
-#define n_END  10000   // end of tune marker
-
-// Note duration divisors
-#define l_T1   1
-#define l_T2   2
-#define l_T3   3
-#define l_T4   4
-#define l_T8   8
-#define l_T16 16
-
-// Note Frequency
-#define n_C0     16
-#define n_CS0    17
-#define n_D0     18
-#define n_DS0    19
-#define n_E0     21
-#define n_F0     22
-#define n_FS0    23
-#define n_G0     25
-#define n_GS0    26
-#define n_A0     28
-#define n_AS0    29
-#define n_B0     31
-#define n_C1     33
-#define n_CS1    35
-#define n_D1     37
-#define n_DS1    39
-#define n_E1     41
-#define n_F1     44
-#define n_FS1    46
-#define n_G1     49
-#define n_GS1    52
-#define n_A1     55
-#define n_AS1    58
-#define n_B1     62
-#define n_C2     65
-#define n_CS2    69
-#define n_D2     73
-#define n_DS2    78
-#define n_E2     82
-#define n_F2     87
-#define n_FS2    93
-#define n_G2     98
-#define n_GS2   104
-#define n_A2    110
-#define n_AS2   117
-#define n_B2    123
-#define n_C3    131
-#define n_CS3   139
-#define n_D3    147
-#define n_DS3   156
-#define n_E3    165
-#define n_F3    175
-#define n_FS3   185
-#define n_G3    196
-#define n_GS3   208
-#define n_A3    220
-#define n_AS3   233
-#define n_B3    247
-#define n_C4    262
-#define n_CS4   277
-#define n_D4    294
-#define n_DS4   311
-#define n_E4    330
-#define n_F4    349
-#define n_FS4   370
-#define n_G4    392
-#define n_GS4   415
-#define n_A4    440
-#define n_AS4   466
-#define n_B4    494
-#define n_C5    523
-#define n_CS5   554
-#define n_D5    587
-#define n_DS5   622
-#define n_E5    659
-#define n_F5    698
-#define n_FS5   740
-#define n_G5    784
-#define n_GS5   831
-#define n_A5    880
-#define n_AS5   932
-#define n_B5    988
-#define n_C6   1047
-#define n_CS6  1109
-#define n_D6   1175
-#define n_DS6  1245
-#define n_E6   1319
-#define n_F6   1397
-#define n_FS6  1480
-#define n_G6   1568
-#define n_GS6  1661
-#define n_A6   1760
-#define n_AS6  1865
-#define n_B6   1976
-#define n_C7   2093
-#define n_CS7  2217
-#define n_D7   2349
-#define n_DS7  2489
-#define n_E7   2637
-#define n_F7   2794
-#define n_FS7  2960
-#define n_G7   3136
-#define n_GS7  3322
-#define n_A7   3520
-#define n_AS7  3729
-#define n_B7   3951
-#define n_C8   4186
-#define n_CS8  4435
-#define n_D8   4699
-#define n_DS8  4978
-#define n_E8   5274
-#define n_F8   5587
-#define n_FS8  5920
-#define n_G8   6272
-#define n_GS8  6645
-#define n_A8   7040
-#define n_AS8  7459
-#define n_B8   7902
-
-namespace Anycubic {
-
-  void PlayTune(uint8_t beeperPin, const uint16_t *tune, uint8_t speed);
-
-  // Only uncomment the tunes you are using to save memory
-  // This will help you write tunes!
-  // https://www.apronus.com/music/flashpiano.htm
-
-  const uint16_t SOS[] = {
-    250,
-    n_G6,l_T3, n_P,l_T3, n_G6,l_T3, n_P,l_T3, n_G6,l_T3, n_P,l_T1,
-    n_G6,l_T1, n_P,l_T3, n_G6,l_T1, n_P,l_T3, n_G6,l_T1, n_P,l_T1,
-    n_G6,l_T3, n_P,l_T3, n_G6,l_T3, n_P,l_T3, n_G6,l_T3, n_P,l_T1,
-    n_END
-  };
-
-  const uint16_t BeepBeep[] = {
-    500,
-    n_C7,l_T8, n_P,l_T16, n_C7,l_T8, n_P,l_T8,
-    n_END
-  };
-
-  const uint16_t BeepBeepBeeep[] = {
-    1000,
-    n_G7,l_T4, n_P,l_T16, n_G7,l_T4, n_P,l_T8, n_G7,l_T2,
-    n_END
-  };
-
-  const uint16_t Anycubic_PowerOn[] = {
-    1000,
-    n_F7,l_T8, n_P,l_T8, n_C7,l_T8, n_P,l_T8, n_D7,l_T8, n_P,l_T8,
-    n_E7,l_T8, n_P,l_T8, n_D7,l_T4, n_P,l_T4, n_G7,l_T4, n_P,l_T4,
-    n_A7,l_T2, n_P,l_T1,
-    n_END
-  };
-
-  const uint16_t GB_PowerOn[] = {
-    500,
-    n_C6,l_T4, n_P,l_T16, n_C7,l_T2, n_P,l_T8,
-    n_END
-  };
-
-  const uint16_t Heater_Timedout[] = {
-    1000,
-    n_C6,l_T1,
-    n_END
-  };
-
-  const uint16_t FilamentOut[] = {
-    1000,
-    n_AS7,l_T4, n_P,l_T16, n_FS7,l_T2,
-    n_END
-  };
-
-}

+ 5 - 5
Marlin/src/lcd/extui/anycubic_chiron/chiron_tft.cpp

@@ -33,7 +33,7 @@
 #if ENABLED(ANYCUBIC_LCD_CHIRON)
 
 #include "chiron_tft.h"
-#include "Tunes.h"
+#include "../anycubic/Tunes.h"
 #include "FileNavigator.h"
 
 #include "../../../gcode/queue.h"
@@ -104,7 +104,7 @@ void ChironTFT::Startup() {
   injectCommands(AC_cmnd_enable_leveling);
 
   // Startup tunes are defined in Tunes.h
-  PlayTune(BEEPER_PIN, TERN(AC_DEFAULT_STARTUP_TUNE, Anycubic_PowerOn, GB_PowerOn), 1);
+  PlayTune(TERN(AC_DEFAULT_STARTUP_TUNE, Anycubic_PowerOn, GB_PowerOn), 1);
 
   #if ACDEBUGLEVEL
     SERIAL_ECHOLNPGM("AC Debug Level ", ACDEBUGLEVEL);
@@ -192,7 +192,7 @@ void ChironTFT::FilamentRunout()  {
   // 1 Signal filament out
   last_error = AC_error_filament_runout;
   SendtoTFTLN(isPrintingFromMedia() ? AC_msg_filament_out_alert : AC_msg_filament_out_block);
-  PlayTune(BEEPER_PIN, FilamentOut, 1);
+  PlayTune(FilamentOut, 1);
 }
 
 void ChironTFT::ConfirmationRequest(const char * const msg)  {
@@ -253,7 +253,7 @@ void ChironTFT::StatusChange(const char * const msg)  {
       }
       // If probing fails don't save the mesh raise the probe above the bad point
       if (strcmp_P(msg, MARLIN_msg_probing_failed) == 0) {
-        PlayTune(BEEPER_PIN, BeepBeepBeeep, 1);
+        PlayTune(BeepBeepBeeep, 1);
         injectCommands(F("G1 Z50 F500"));
         SendtoTFTLN(AC_msg_probing_complete);
         printer_state = AC_printer_idle;
@@ -307,7 +307,7 @@ void ChironTFT::StatusChange(const char * const msg)  {
 void ChironTFT::PowerLossRecovery()  {
   printer_state = AC_printer_resuming_from_power_outage; // Play tune to notify user we can recover.
   last_error = AC_error_powerloss;
-  PlayTune(BEEPER_PIN, SOS, 1);
+  PlayTune(SOS, 1);
   SERIAL_ECHOLNF(AC_msg_powerloss_recovery);
 }
 

+ 25 - 115
Marlin/src/lcd/extui/anycubic_chiron/chiron_tft_defs.h

@@ -29,116 +29,39 @@
  *  (not affiliated with Anycubic, Ltd.)
  */
 
-#include "../../../inc/MarlinConfigPre.h"
-//#define ACDEBUGLEVEL 4
+#include "../anycubic/common_defs.h"
 
-#if ACDEBUGLEVEL
-  // Bit-masks for selective debug:
-  enum ACDebugMask : uint8_t {
-    AC_INFO   =  1,
-    AC_ACTION =  2,
-    AC_FILE   =  4,
-    AC_PANEL  =  8,
-    AC_MARLIN = 16,
-    AC_SOME   = 32,
-    AC_ALL    = 64
-  };
-  #define ACDEBUG(mask) ( ((mask) & ACDEBUGLEVEL) == mask )  // Debug flag macro
-#else
-  #define ACDEBUG(mask) false
-#endif
-
-#define TFTSer LCD_SERIAL                    // Serial interface for TFT panel now uses marlinserial
-#define MAX_FOLDER_DEPTH                4    // Limit folder depth TFT has a limit for the file path
-#define MAX_CMND_LEN                   16 * MAX_FOLDER_DEPTH // Maximum Length for a Panel command
-#define MAX_PATH_LEN                   16 * MAX_FOLDER_DEPTH // Maximum number of characters in a SD file path
-
-#define AC_HEATER_FAULT_VALIDATION_TIME 5    // number of 1/2 second loops before signalling a heater fault
-#define AC_LOWEST_MESHPOINT_VAL         -10  // The lowest value you can set for a single mesh point offset
-
- // TFT panel commands
-#define AC_msg_sd_card_inserted        F("J00")
-#define AC_msg_sd_card_removed         F("J01")
-#define AC_msg_no_sd_card              F("J02")
-#define AC_msg_usb_connected           F("J03")
-#define AC_msg_print_from_sd_card      F("J04")
-#define AC_msg_pause                   F("J05")
-#define AC_msg_nozzle_heating          F("J06")
-#define AC_msg_nozzle_heating_done     F("J07")
-#define AC_msg_bed_heating             F("J08")
-#define AC_msg_bed_heating_done        F("J09")
-#define AC_msg_nozzle_temp_abnormal    F("J10")
-#define AC_msg_kill_lcd                F("J11")
-#define AC_msg_ready                   F("J12")
-#define AC_msg_low_nozzle_temp         F("J13")
-#define AC_msg_print_complete          F("J14")
-#define AC_msg_filament_out_alert      F("J15")
-#define AC_msg_stop                    F("J16")
-#define AC_msg_main_board_has_reset    F("J17")
-#define AC_msg_paused                  F("J18")
-#define AC_msg_j19_unknown             F("J19")
-#define AC_msg_sd_file_open_success    F("J20")
-#define AC_msg_sd_file_open_failed     F("J21")
-#define AC_msg_level_monitor_finished  F("J22")
-#define AC_msg_filament_out_block      F("J23")
-#define AC_msg_probing_not_allowed     F("J24")
-#define AC_msg_probing_complete        F("J25")
-#define AC_msg_start_probing           F("J26")
-#define AC_msg_version                 F("J27")
-#define AC_msg_mesh_changes_abandoned  F("Mesh changes abandoned, previous mesh restored.")
-#define AC_msg_mesh_changes_saved      F("Mesh changes saved.")
-#define AC_msg_old_panel_detected      F("Standard TFT panel detected!")
-#define AC_msg_new_panel_detected      F("New TFT panel detected!")
-#define AC_msg_auto_panel_detection    F("Auto detect panel type (assuming new panel)")
-#define AC_msg_old_panel_set           F("Set for standard TFT panel.")
-#define AC_msg_new_panel_set           F("Set for new TFT panel.")
+// TFT panel messages
+#define AC_msg_mesh_changes_abandoned F("Mesh changes abandoned, previous mesh restored.")
+#define AC_msg_mesh_changes_saved     F("Mesh changes saved.")
+#define AC_msg_old_panel_detected     F("Standard TFT panel detected!")
+#define AC_msg_new_panel_detected     F("New TFT panel detected!")
+#define AC_msg_auto_panel_detection   F("Auto detect panel type (assuming new panel)")
+#define AC_msg_old_panel_set          F("Set for standard TFT panel.")
+#define AC_msg_new_panel_set          F("Set for new TFT panel.")
 
-#define AC_msg_powerloss_recovery      F("Resuming from power outage! select the same SD file then press resume")
+#define AC_msg_powerloss_recovery     F("Resuming from power outage! select the same SD file then press resume")
 // Error messages must not contain spaces
-#define AC_msg_error_bed_temp          F("Abnormal_bed_temp")
-#define AC_msg_error_hotend_temp       F("Abnormal_hotend_temp")
-#define AC_msg_error_sd_card           F("SD_card_error")
-#define AC_msg_filament_out            F("Filament_runout")
-#define AC_msg_power_loss              F("Power_failure")
-#define AC_msg_eeprom_version          F("EEPROM_ver_wrong")
+#define AC_msg_error_bed_temp         F("Abnormal_bed_temp")
+#define AC_msg_error_hotend_temp      F("Abnormal_hotend_temp")
+#define AC_msg_error_sd_card          F("SD_card_error")
+#define AC_msg_filament_out           F("Filament_runout")
+#define AC_msg_power_loss             F("Power_failure")
+#define AC_msg_eeprom_version         F("EEPROM_ver_wrong")
 
-#define MARLIN_msg_start_probing       PSTR("Probing Point 1/25")
-#define MARLIN_msg_probing_failed      PSTR("Probing Failed")
-#define MARLIN_msg_ready               PSTR(" Ready.")
-#define MARLIN_msg_print_paused        PSTR("Print Paused")
-#define MARLIN_msg_print_aborted       PSTR("Print Aborted")
-#define MARLIN_msg_extruder_heating    PSTR("E Heating...")
-#define MARLIN_msg_bed_heating         PSTR("Bed Heating...")
-#define MARLIN_msg_EEPROM_version      PSTR("EEPROM Version Error")
-#define MARLIN_msg_nozzle_parked       PSTR("Nozzle Parked")
-#define MARLIN_msg_heater_timeout      PSTR("Heater Timeout")
-#define MARLIN_msg_reheating           PSTR("Reheating...")
-#define MARLIN_msg_reheat_done         PSTR("Reheat finished.")
-#define MARLIN_msg_filament_purging    PSTR("Filament Purging...")
-#define MARLIN_msg_special_pause       PSTR("PB")
+#define MARLIN_msg_EEPROM_version     PSTR("EEPROM Version Error")
 
-#define AC_cmnd_auto_unload_filament   F("M701")                    // Use Marlin unload routine
-#define AC_cmnd_auto_load_filament     F("M702 M0 PB")              // Use Marlin load routing then pause for user to clean nozzle
-
-#define AC_cmnd_manual_load_filament   F("M83\nG1 E50 F700\nM82")   // replace the manual panel commands with something a little faster
-#define AC_cmnd_manual_unload_filament F("M83\nG1 E-50 F1200\nM82")
-#define AC_cmnd_enable_leveling        F("M420SV")
-#define AC_cmnd_power_loss_recovery    F("G28XYR5\nG28Z")           // Lift, home X and Y then home Z when in 'safe' position
-
-#define AC_Test_for_OldPanel           F("SIZE")                    // An old panel will respond with 'SXY 480 320' a new panel wont respond.
-#define AC_Test_for_NewPanel           F("J200")                    // A new panel will respond with '[0]=0   [1]=0' to '[19]=0   '  an old panel wont respond
+#define AC_Test_for_OldPanel          F("SIZE")                    // An old panel will respond with 'SXY 480 320' a new panel wont respond.
+#define AC_Test_for_NewPanel          F("J200")                    // A new panel will respond with '[0]=0   [1]=0' to '[19]=0   '  an old panel wont respond
 
 namespace Anycubic {
-  enum heater_state_t : uint8_t {
-    AC_heater_off,
-    AC_heater_temp_set,
-    AC_heater_temp_reached
-  };
+
   enum paused_state_t : uint8_t {
     AC_paused_heater_timed_out,
     AC_paused_purging_filament,
     AC_paused_idle
   };
+
   enum printer_state_t : uint8_t {
     AC_printer_booting,
     AC_printer_idle,
@@ -149,27 +72,13 @@ namespace Anycubic {
     AC_printer_stopping,
     AC_printer_resuming_from_power_outage
   };
-  enum timer_event_t : uint8_t {
-    AC_timer_started,
-    AC_timer_paused,
-    AC_timer_stopped
-  };
-  enum media_event_t : uint8_t {
-    AC_media_inserted,
-    AC_media_removed,
-    AC_media_error
-  };
-  enum file_menu_t : uint8_t {
-    AC_menu_file,
-    AC_menu_command,
-    AC_menu_change_to_file,
-    AC_menu_change_to_command
-  };
+
   enum panel_type_t : uint8_t { // order is important here as we assume new panel if type is unknown
     AC_panel_unknown,
     AC_panel_new,
     AC_panel_standard
   };
+
   enum last_error_t : uint8_t {
     AC_error_none,
     AC_error_abnormal_temp_t0,
@@ -179,4 +88,5 @@ namespace Anycubic {
     AC_error_filament_runout,
     AC_error_EEPROM
   };
-}  // Anycubic namespace
+
+} // Anycubic

+ 16 - 17
Marlin/src/lcd/extui/anycubic_vyper/FileNavigator.h

@@ -31,27 +31,26 @@
 using namespace ExtUI;
 
 namespace Anycubic {
+
   class FileNavigator {
     public:
-      FileNavigator();
-
-      static FileList  filelist;
-
-      void   reset();
-      void   getFiles(uint16_t);
-      void   upDIR();
-      void   changeDIR(char *);
-      void   sendFile();
-      void   refresh();
-      char * getCurrentFolderName();
-      uint16_t getFileNum();
+      static FileList filelist;
 
+      FileNavigator();
+      static void reset();
+      static void getFiles(uint16_t);
+      static void upDIR();
+      static void changeDIR(char *);
+      static void sendFile();
+      static void refresh();
+      static char* getCurrentFolderName();
+      static uint16_t getFileNum();
     private:
-
-      static char      currentfoldername[MAX_PATH_LEN];
-      static uint16_t  lastindex;
-      static uint8_t   folderdepth;
-      static uint16_t  currentindex;
+      static uint16_t lastindex;
+      static uint16_t currentindex;
+      static uint8_t  folderdepth;
+      static char     currentfoldername[MAX_PATH_LEN + 1];
   };
+
   extern FileNavigator filenavigator;
 }

Some files were not shown because too many files changed in this diff