Browse Source

Report detected MMU version in the Support menu

It was just subtly broken, all the functionality had already been implemented.
D.R.racer 2 years ago
parent
commit
dab26fe50b
4 changed files with 26 additions and 9 deletions
  1. 1 1
      Firmware/mmu2.h
  2. 6 3
      Firmware/mmu2_protocol_logic.cpp
  3. 18 4
      Firmware/mmu2_protocol_logic.h
  4. 1 1
      Firmware/ultralcd.cpp

+ 1 - 1
Firmware/mmu2.h

@@ -146,7 +146,7 @@ public:
     /// In the future we'll return the trully detected FW version
     Version GetMMUFWVersion()const {
         if( State() == xState::Active ){
-            return { 2, 0, 0 };
+            return { logic.MmuFwVersionMajor(), logic.MmuFwVersionMinor(), logic.MmuFwVersionBuild() };
         } else {
             return { 0, 0, 0}; 
         }

+ 6 - 3
Firmware/mmu2_protocol_logic.cpp

@@ -145,7 +145,8 @@ StepStatus StartSeq::Step() {
     // solve initial handshake
     switch (state) {
     case State::S0Sent: // received response to S0 - major
-        if (logic->rsp.paramValue != 2) {
+        logic->mmuFwVersionMajor = logic->rsp.paramValue;
+        if (logic->mmuFwVersionMajor != 2) {
             return VersionMismatch;
         }
         logic->dataTO.Reset(); // got meaningful response from the MMU, stop data layer timeout tracking
@@ -153,14 +154,16 @@ StepStatus StartSeq::Step() {
         state = State::S1Sent;
         break;
     case State::S1Sent: // received response to S1 - minor
-        if (logic->rsp.paramValue != 0) {
+        logic->mmuFwVersionMinor = logic->rsp.paramValue;
+        if (logic->mmuFwVersionMinor != 0) {
             return VersionMismatch;
         }
         logic->SendMsg(RequestMsg(RequestMsgCodes::Version, 2));
         state = State::S2Sent;
         break;
     case State::S2Sent: // received response to S2 - revision
-        if (logic->rsp.paramValue != 0) {
+        logic->mmuFwVersionBuild = logic->rsp.paramValue;
+        if (logic->mmuFwVersionBuild != 0) {
             return VersionMismatch;
         }
         // Start General Interrogation after line up.

+ 18 - 4
Firmware/mmu2_protocol_logic.h

@@ -227,15 +227,26 @@ public:
     Buttons Button() const { return buttonCode; }
 
     uint8_t CommandInProgress()const;
-    
+
     inline bool Running()const {
         return state == State::Running;
     }
-    
+
     inline bool FindaPressed() const {
         return findaPressed;
     }
 
+    inline uint8_t MmuFwVersionMajor() const {
+        return mmuFwVersionMajor;
+    }
+
+    inline uint8_t MmuFwVersionMinor() const {
+        return mmuFwVersionMinor;
+    }
+
+    inline uint16_t MmuFwVersionBuild() const {
+        return mmuFwVersionBuild;
+    }
 #ifndef UNITTEST
 private:
 #endif
@@ -305,9 +316,12 @@ private:
     Buttons buttonCode;        ///< Last received button from the MMU.
 
     uint8_t lastFSensor; ///< last state of filament sensor
-    
+
     bool findaPressed;
-    
+
+    uint8_t mmuFwVersionMajor, mmuFwVersionMinor;
+    uint16_t mmuFwVersionBuild;
+
     friend class ProtocolLogicPartBase;
     friend class Stopped;
     friend class Command;

+ 1 - 1
Firmware/ultralcd.cpp

@@ -1706,7 +1706,7 @@ static void lcd_support_menu()
 		{
 			lcd_set_cursor(6, menu_row);
 			MMU2::Version mmu_version = MMU2::mmu2.GetMMUFWVersion();
-			if ((mmu_version.major > 0) && (mmu_version.build > 0))
+			if (mmu_version.major > 0)
 				lcd_printf_P(PSTR("%d.%d.%d"), mmu_version.major, mmu_version.minor, mmu_version.build);
 			else
 				lcd_puts_P(_i("unknown"));  ////MSG_UNKNOWN c=13