Pārlūkot izejas kodu

Unify naming convention (index->slot)

in all top level MMU-related functions
D.R.racer 2 gadi atpakaļ
vecāks
revīzija
ffbd95b482
2 mainītis faili ar 33 papildinājumiem un 33 dzēšanām
  1. 23 23
      Firmware/mmu2.cpp
  2. 10 10
      Firmware/mmu2.h

+ 23 - 23
Firmware/mmu2.cpp

@@ -311,11 +311,11 @@ void MMU2::update_tool_change_counter_eeprom() {
     reset_toolchange_counter();
 }
 
-void MMU2::MMU2::ToolChangeCommon(uint8_t index){
-    tool_change_extruder = index;
+void MMU2::MMU2::ToolChangeCommon(uint8_t slot){
+    tool_change_extruder = slot;
     do {
         for(;;) {
-            logic.ToolChange(index); // let the MMU pull the filament out and push a new one in
+            logic.ToolChange(slot); // let the MMU pull the filament out and push a new one in
             if( manage_response(true, true) )
                 break;
             // otherwise: failed to perform the command - unload first and then let it run again
@@ -325,8 +325,8 @@ void MMU2::MMU2::ToolChangeCommon(uint8_t index){
         plan_set_e_position(current_position[E_AXIS]);
     } while (0); // while not successfully fed into etruder's PTFE tube
 
-    extruder = index; //filament change is finished
-    SpoolJoin::spooljoin.setSlot(index);
+    extruder = slot; //filament change is finished
+    SpoolJoin::spooljoin.setSlot(slot);
 
     // @@TODO really report onto the serial? May be for the Octoprint? Not important now
     //        SERIAL_ECHO_START();
@@ -334,11 +334,11 @@ void MMU2::MMU2::ToolChangeCommon(uint8_t index){
     increment_tool_change_counter();
 }
 
-bool MMU2::tool_change(uint8_t index) {
+bool MMU2::tool_change(uint8_t slot) {
     if( ! WaitForMMUReady())
         return false;
 
-    if (index != extruder) {
+    if (slot != extruder) {
         if (!IS_SD_PRINTING && !usb_timer.running()) {
             // If Tcodes are used manually through the serial
             // we need to unload manually as well
@@ -348,7 +348,7 @@ bool MMU2::tool_change(uint8_t index) {
         ReportingRAII rep(CommandInProgress::ToolChange);
         FSensorBlockRunout blockRunout;
         st_synchronize();
-        ToolChangeCommon(index);
+        ToolChangeCommon(slot);
     }
     return true;
 }
@@ -406,12 +406,12 @@ uint8_t MMU2::get_tool_change_tool() const {
     return tool_change_extruder == MMU2_NO_TOOL ? (uint8_t)FILAMENT_UNKNOWN : tool_change_extruder;
 }
 
-bool MMU2::set_filament_type(uint8_t index, uint8_t type) {
+bool MMU2::set_filament_type(uint8_t slot, uint8_t type) {
     if( ! WaitForMMUReady())
         return false;
     
     // @@TODO - this is not supported in the new MMU yet
-    index = index; // @@TODO
+    slot = slot; // @@TODO
     type = type; // @@TODO
     // cmd_arg = filamentType;
     // command(MMU_CMD_F0 + index);
@@ -450,12 +450,12 @@ bool MMU2::unload() {
     return true;
 }
 
-bool MMU2::cut_filament(uint8_t index){
+bool MMU2::cut_filament(uint8_t slot){
     if( ! WaitForMMUReady())
         return false;
 
     ReportingRAII rep(CommandInProgress::CutFilament);
-    logic.CutFilament(index);
+    logic.CutFilament(slot);
     if( ! manage_response(false, true) ){
         // @@TODO failed to perform the command - retry
         ;
@@ -472,24 +472,24 @@ void FullScreenMsg(const char *pgmS, uint8_t slot){
     lcd_print(slot + 1);
 }
 
-bool MMU2::loading_test(uint8_t index){
-    FullScreenMsg(_T(MSG_TESTING_FILAMENT), index);
-    tool_change(index);
+bool MMU2::loading_test(uint8_t slot){
+    FullScreenMsg(_T(MSG_TESTING_FILAMENT), slot);
+    tool_change(slot);
     st_synchronize();
     unload();
     lcd_update_enable(true);
     return true;
 }
 
-bool MMU2::load_filament(uint8_t index) {
+bool MMU2::load_filament(uint8_t slot) {
     if( ! WaitForMMUReady())
         return false;
 
-    FullScreenMsg(_T(MSG_LOADING_FILAMENT), index);
+    FullScreenMsg(_T(MSG_LOADING_FILAMENT), slot);
 
     ReportingRAII rep(CommandInProgress::LoadFilament);
     do {
-        logic.LoadFilament(index);
+        logic.LoadFilament(slot);
     } while( ! manage_response(false, false) );
 
     Sound_MakeSound(e_SOUND_TYPE_StandardConfirm);
@@ -509,7 +509,7 @@ struct LoadingToNozzleRAII {
     }
 };
 
-bool MMU2::load_filament_to_nozzle(uint8_t index) {
+bool MMU2::load_filament_to_nozzle(uint8_t slot) {
     if( ! WaitForMMUReady())
         return false;
 
@@ -517,7 +517,7 @@ bool MMU2::load_filament_to_nozzle(uint8_t index) {
 
     WaitForHotendTargetTempBeep();
 
-    FullScreenMsg(_T(MSG_LOADING_FILAMENT), index);
+    FullScreenMsg(_T(MSG_LOADING_FILAMENT), slot);
     {
         // used for MMU-menu operation "Load to Nozzle"
         ReportingRAII rep(CommandInProgress::ToolChange);
@@ -527,7 +527,7 @@ bool MMU2::load_filament_to_nozzle(uint8_t index) {
             filament_ramming();
         }
 
-        ToolChangeCommon(index);
+        ToolChangeCommon(slot);
 
         // Finish loading to the nozzle with finely tuned steps.
         execute_extruder_sequence((const E_Step *)load_to_nozzle_sequence, sizeof(load_to_nozzle_sequence) / sizeof (load_to_nozzle_sequence[0]));
@@ -537,7 +537,7 @@ bool MMU2::load_filament_to_nozzle(uint8_t index) {
     return true;
 }
 
-bool MMU2::eject_filament(uint8_t index, bool recover) {
+bool MMU2::eject_filament(uint8_t slot, bool recover) {
     if( ! WaitForMMUReady())
         return false;
 
@@ -545,7 +545,7 @@ bool MMU2::eject_filament(uint8_t index, bool recover) {
     current_position[E_AXIS] -= MMU2_FILAMENTCHANGE_EJECT_FEED;
     plan_buffer_line_curposXYZE(2500.F / 60.F);
     st_synchronize();
-    logic.EjectFilament(index);
+    logic.EjectFilament(slot);
     if( ! manage_response(false, false) ){
         // @@TODO failed to perform the command - retry
         ;

+ 10 - 10
Firmware/mmu2.h

@@ -104,9 +104,9 @@ public:
     void mmu_loop();
 
     /// The main MMU command - select a different slot
-    /// @param index of the slot to be selected
+    /// @param slot of the slot to be selected
     /// @returns false if the operation cannot be performed (Stopped)
-    bool tool_change(uint8_t index);
+    bool tool_change(uint8_t slot);
     
     /// Handling of special Tx, Tc, T? commands
     bool tool_change(char code, uint8_t slot);
@@ -118,20 +118,20 @@ public:
 
     /// Load (insert) filament just into the MMU (not into printer's nozzle)
     /// @returns false if the operation cannot be performed (Stopped)
-    bool load_filament(uint8_t index);
+    bool load_filament(uint8_t slot);
     
     /// Load (push) filament from the MMU into the printer's nozzle
     /// @returns false if the operation cannot be performed (Stopped or cold extruder)
-    bool load_filament_to_nozzle(uint8_t index);
+    bool load_filament_to_nozzle(uint8_t slot);
 
     /// Move MMU's selector aside and push the selected filament forward.
     /// Usable for improving filament's tip or pulling the remaining piece of filament out completely.
-    bool eject_filament(uint8_t index, bool recover);
+    bool eject_filament(uint8_t slot, bool recover);
 
     /// Issue a Cut command into the MMU
     /// Requires unloaded filament from the printer (obviously)
     /// @returns false if the operation cannot be performed (Stopped)
-    bool cut_filament(uint8_t index);
+    bool cut_filament(uint8_t slot);
 
     /// Issue a planned request for statistics data from MMU
     void get_statistics();
@@ -140,9 +140,9 @@ public:
     /// It behaves very similarly like a ToolChange, but it doesn't load the filament
     /// all the way down to the nozzle. The sole purpose of this operation
     /// is to check, that the filament will be ready for printing.
-    /// @param index index of slot to be tested
+    /// @param slot index of slot to be tested
     /// @returns true
-    bool loading_test(uint8_t index);
+    bool loading_test(uint8_t slot);
 
     /// @returns the active filament slot index (0-4) or 0xff in case of no active tool
     uint8_t get_current_tool() const;
@@ -150,7 +150,7 @@ public:
     /// @returns The filament slot index (0 to 4) that will be loaded next, 0xff in case of no active tool change 
     uint8_t get_tool_change_tool() const;
 
-    bool set_filament_type(uint8_t index, uint8_t type);
+    bool set_filament_type(uint8_t slot, uint8_t type);
 
     /// Issue a "button" click into the MMU - to be used from Error screens of the MMU
     /// to select one of the 3 possible options to resolve the issue
@@ -285,7 +285,7 @@ private:
     bool WaitForMMUReady();
 
     /// Common processing of pushing filament into the extruder - shared by tool_change, load_to_nozzle and probably others
-    void ToolChangeCommon(uint8_t index);
+    void ToolChangeCommon(uint8_t slot);
 
     ProtocolLogic logic; ///< implementation of the protocol logic layer
     uint8_t extruder; ///< currently active slot in the MMU ... somewhat... not sure where to get it from yet