Browse Source

Convert mmu_last_finda_response to ShortTimer

Saves 48 bytes of Flash, 1 byte of SRAM
Guðni Már Gilbert 3 years ago
parent
commit
802b8860c8
3 changed files with 6 additions and 5 deletions
  1. 3 3
      Firmware/mmu.cpp
  2. 2 1
      Firmware/mmu.h
  3. 1 1
      Firmware/ultralcd.cpp

+ 3 - 3
Firmware/mmu.cpp

@@ -70,7 +70,6 @@ uint8_t mmu_extruder = MMU_FILAMENT_UNKNOWN;
 uint8_t tmp_extruder = MMU_FILAMENT_UNKNOWN;
 
 int8_t mmu_finda = -1;
-uint32_t mmu_last_finda_response = 0;
 
 int16_t mmu_version = -1;
 
@@ -78,6 +77,7 @@ int16_t mmu_buildnr = -1;
 
 ShortTimer mmu_last_request;
 ShortTimer mmu_last_response;
+ShortTimer mmu_last_finda_response;
 
 MmuCmd mmu_last_cmd = MmuCmd::None;
 uint16_t mmu_power_failures = 0;
@@ -265,7 +265,7 @@ void mmu_loop(void)
 		if (mmu_rx_ok() > 0)
 		{
 			fscanf_P(uart2io, PSTR("%hhu"), &mmu_finda); //scan finda from buffer
-			mmu_last_finda_response = _millis();
+			mmu_last_finda_response.start();
 			FDEBUG_PRINTF_P(PSTR("MMU => '%dok'\n"), mmu_finda);
 			puts_P(PSTR("MMU - ENABLED"));
 			mmu_enabled = true;
@@ -378,7 +378,7 @@ void mmu_loop(void)
 		if (mmu_rx_ok() > 0)
 		{
 			fscanf_P(uart2io, PSTR("%hhu"), &mmu_finda); //scan finda from buffer
-			mmu_last_finda_response = _millis();
+			mmu_last_finda_response.start();
 			FDEBUG_PRINTF_P(PSTR("MMU => '%dok'\n"), mmu_finda);
 			//printf_P(PSTR("Eact: %d\n"), int(e_active()));
 			if (!mmu_finda && CHECK_FSENSOR && fsensor_enabled) {

+ 2 - 1
Firmware/mmu.h

@@ -4,6 +4,7 @@
 #define MMU_H
 
 #include <inttypes.h>
+#include "Timer.h"
 
 
 extern bool mmu_enabled;
@@ -14,7 +15,7 @@ extern uint8_t mmu_extruder;
 extern uint8_t tmp_extruder;
 
 extern int8_t mmu_finda;
-extern uint32_t mmu_last_finda_response;
+extern ShortTimer mmu_last_finda_response;
 extern bool ir_sensor_detected;
 
 extern int16_t mmu_version;

+ 1 - 1
Firmware/ultralcd.cpp

@@ -3839,7 +3839,7 @@ static void lcd_show_sensors_state()
 	uint8_t idler_state = STATE_NA;
 
 	pinda_state = READ(Z_MIN_PIN);
-	if (mmu_enabled && ((_millis() - mmu_last_finda_response) < 1000ul) )
+	if (mmu_enabled && mmu_last_finda_response.expired(1000))
 	{
 		finda_state = mmu_finda;
 	}