Browse Source

Use loop to enquecommand_P() in first layer calibration.

Marek Bel 4 years ago
parent
commit
4be8fa701e
3 changed files with 51 additions and 9 deletions
  1. 30 0
      Firmware/first_lay_cal.cpp
  2. 16 0
      Firmware/first_lay_cal.h
  3. 5 9
      Firmware/ultralcd.cpp

+ 30 - 0
Firmware/first_lay_cal.cpp

@@ -0,0 +1,30 @@
+/*
+ * first_lay_cal.cpp
+ *
+ *  Created on: Jun 10, 2019
+ *      Author: marek
+ */
+#include "first_lay_cal.h"
+#include "Configuration_prusa.h"
+#include "language.h"
+
+static const char cmd_0[] PROGMEM = "M107";
+static const char cmd_1[] PROGMEM = "M104 S" STRINGIFY(PLA_PREHEAT_HOTEND_TEMP);
+static const char cmd_2[] PROGMEM = "M140 S" STRINGIFY(PLA_PREHEAT_HPB_TEMP);
+static const char cmd_3[] PROGMEM = "M190 S" STRINGIFY(PLA_PREHEAT_HPB_TEMP);
+static const char cmd_4[] PROGMEM = "M109 S" STRINGIFY(PLA_PREHEAT_HOTEND_TEMP);
+static const char cmd_6[] PROGMEM = "G28";
+static const char cmd_7[] PROGMEM = "G92 E0.0";
+
+
+const char * const layer1_cal[8] PROGMEM =
+{
+    cmd_0,
+    cmd_1,
+    cmd_2,
+    cmd_3,
+    cmd_4,
+    MSG_M117_V2_CALIBRATION, //TODO missing internationalization
+    cmd_6,
+    cmd_7,
+};

+ 16 - 0
Firmware/first_lay_cal.h

@@ -0,0 +1,16 @@
+/*
+ * first_lay_cal.h
+ *
+ *  Created on: Jun 10, 2019
+ *      Author: marek
+ */
+
+#ifndef FIRMWARE_FIRST_LAY_CAL_H_
+#define FIRMWARE_FIRST_LAY_CAL_H_
+#include <avr/pgmspace.h>
+
+
+extern const char * const layer1_cal[8] PROGMEM;
+
+
+#endif /* FIRMWARE_FIRST_LAY_CAL_H_ */

+ 5 - 9
Firmware/ultralcd.cpp

@@ -40,6 +40,7 @@
 
 #include "static_assert.h"
 #include "io_atmega2560.h"
+#include "first_lay_cal.h"
 
 
 int scrollstuff = 0;
@@ -1386,15 +1387,10 @@ void lcd_commands()
 
 		if (lcd_commands_step == 10)
 		{
-			enquecommand_P(PSTR("M107"));
-			enquecommand_P(PSTR("M104 S" STRINGIFY(PLA_PREHEAT_HOTEND_TEMP)));
-			enquecommand_P(PSTR("M140 S" STRINGIFY(PLA_PREHEAT_HPB_TEMP)));
-			enquecommand_P(PSTR("M190 S" STRINGIFY(PLA_PREHEAT_HPB_TEMP)));
-            enquecommand_P(PSTR("M109 S" STRINGIFY(PLA_PREHEAT_HOTEND_TEMP)));
-			enquecommand_P(_T(MSG_M117_V2_CALIBRATION));
-			enquecommand_P(PSTR("G28"));
-			enquecommand_P(PSTR("G92 E0.0"));
-
+		    for (uint8_t i = 0; i < (sizeof(layer1_cal)/sizeof(layer1_cal[0])); ++i)
+		    {
+		        enquecommand_P(static_cast<char*>(pgm_read_ptr(&layer1_cal[i])));
+		    }
             lcd_commands_step = 9;
 		}
         if (lcd_commands_step == 9 && !blocks_queued() && cmd_buffer_empty())