From f52a31a27517eaf5773f6ab443596e29c573f6e7 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 6 Sep 2017 06:28:32 -0500 Subject: [PATCH] Core updates --- Marlin/src/core/enum.h | 2 +- Marlin/src/core/language.h | 8 +-- Marlin/src/core/macros.h | 3 + Marlin/src/core/serial.cpp | 9 +++ Marlin/src/core/serial.h | 10 +-- Marlin/src/core/types.h | 5 +- Marlin/src/core/utility.cpp | 128 +++++++++++++++++++++++++++++++++++- Marlin/src/core/utility.h | 6 ++ 8 files changed, 156 insertions(+), 15 deletions(-) diff --git a/Marlin/src/core/enum.h b/Marlin/src/core/enum.h index c3e9ad0121..c02e597f8b 100644 --- a/Marlin/src/core/enum.h +++ b/Marlin/src/core/enum.h @@ -23,7 +23,7 @@ #ifndef __ENUM_H__ #define __ENUM_H__ -#include "MarlinConfig.h" +#include "../inc/MarlinConfig.h" /** * Axis indices as enumerated constants diff --git a/Marlin/src/core/language.h b/Marlin/src/core/language.h index a357acc25f..a50c80d721 100644 --- a/Marlin/src/core/language.h +++ b/Marlin/src/core/language.h @@ -23,7 +23,7 @@ #ifndef LANGUAGE_H #define LANGUAGE_H -#include "MarlinConfig.h" +#include "../inc/MarlinConfig.h" #define _UxGT(a) a @@ -44,7 +44,7 @@ // // ==> ALWAYS TRY TO COMPILE MARLIN WITH/WITHOUT "ULTIPANEL" / "ULTRALCD" / "SDSUPPORT" #define IN "Configuration.h" // ==> ALSO TRY ALL AVAILABLE LANGUAGE OPTIONS -// See also https://github.com/MarlinFirmware/Marlin/wiki/LCD-Language +// See also http://marlinfw.org/docs/development/lcd_language.html // Languages // an Aragonese @@ -260,7 +260,7 @@ // LCD Menu Messages -#define LANGUAGE_INCL_(M) STRINGIFY_(language_##M.h) +#define LANGUAGE_INCL_(M) STRINGIFY_(../lcd/language/language_##M.h) #define LANGUAGE_INCL(M) LANGUAGE_INCL_(M) #define INCLUDE_LANGUAGE LANGUAGE_INCL(LCD_LANGUAGE) @@ -310,6 +310,6 @@ #define DISPLAY_CHARSET_ISO10646_1 // use the better font on full graphic displays. #endif -#include "language_en.h" +#include "../lcd/language/language_en.h" #endif // __LANGUAGE_H diff --git a/Marlin/src/core/macros.h b/Marlin/src/core/macros.h index dd5ca4f474..95154bc8c5 100644 --- a/Marlin/src/core/macros.h +++ b/Marlin/src/core/macros.h @@ -102,6 +102,9 @@ #define DEGREES(r) ((r)*180.0/M_PI) #define HYPOT2(x,y) (sq(x)+sq(y)) +#define CIRCLE_AREA(R) (M_PI * sq(R)) +#define CIRCLE_CIRC(R) (2.0 * M_PI * (R)) + #define SIGN(a) ((a>0)-(a<0)) // Macros to contrain values diff --git a/Marlin/src/core/serial.cpp b/Marlin/src/core/serial.cpp index 232a85c308..15528c4506 100644 --- a/Marlin/src/core/serial.cpp +++ b/Marlin/src/core/serial.cpp @@ -25,6 +25,15 @@ const char errormagic[] PROGMEM = "Error:"; const char echomagic[] PROGMEM = "echo:"; + +void serialprintPGM(const char * str) { + #ifdef TARGET_LPC1768 + MYSERIAL.print(str); + #else + while (char ch = pgm_read_byte(str++)) MYSERIAL.write(ch); + #endif +} + void serial_echopair_P(const char* s_P, const char *v) { serialprintPGM(s_P); SERIAL_ECHO(v); } void serial_echopair_P(const char* s_P, char v) { serialprintPGM(s_P); SERIAL_CHAR(v); } void serial_echopair_P(const char* s_P, int v) { serialprintPGM(s_P); SERIAL_ECHO(v); } diff --git a/Marlin/src/core/serial.h b/Marlin/src/core/serial.h index f23d9f7a1a..e860c9c05f 100644 --- a/Marlin/src/core/serial.h +++ b/Marlin/src/core/serial.h @@ -23,7 +23,7 @@ #ifndef __SERIAL_H__ #define __SERIAL_H__ -#include "src/HAL/HAL.h" +#include "../inc/MarlinConfig.h" //todo: HAL: breaks encapsulation // For AVR only, define a serial interface based on configuration @@ -36,13 +36,11 @@ #define MYSERIAL Serial #endif // BLUETOOTH #else - #include "src/HAL/HAL_AVR/MarlinSerial.h" + #include "../HAL/HAL_AVR/MarlinSerial.h" #define MYSERIAL customizedSerial #endif #endif -#include "MarlinConfig.h" - extern const char echomagic[] PROGMEM; extern const char errormagic[] PROGMEM; @@ -100,8 +98,6 @@ void serial_spaces(uint8_t count); // // Functions for serial printing from PROGMEM. (Saves loads of SRAM.) // -FORCE_INLINE void serialprintPGM(const char* str) { - while (char ch = pgm_read_byte(str++)) MYSERIAL.write(ch); -} +void serialprintPGM(const char* str); #endif // __SERIAL_H__ diff --git a/Marlin/src/core/types.h b/Marlin/src/core/types.h index 8ab7beebea..db6587a08c 100644 --- a/Marlin/src/core/types.h +++ b/Marlin/src/core/types.h @@ -23,6 +23,9 @@ #ifndef __TYPES_H__ #define __TYPES_H__ -typedef unsigned long millis_t; +#include +#include + +typedef uint32_t millis_t; #endif diff --git a/Marlin/src/core/utility.cpp b/Marlin/src/core/utility.cpp index 0f59193553..f970c46a67 100644 --- a/Marlin/src/core/utility.cpp +++ b/Marlin/src/core/utility.cpp @@ -20,9 +20,10 @@ * */ -#include "Marlin.h" #include "utility.h" -#include "temperature.h" + +#include "../Marlin.h" +#include "../module/temperature.h" void safe_delay(millis_t ms) { while (ms > 50) { @@ -255,3 +256,126 @@ void safe_delay(millis_t ms) { } #endif // ULTRA_LCD + +#if ENABLED(DEBUG_LEVELING_FEATURE) + + #include "../module/probe.h" + #include "../module/motion.h" + #include "../module/stepper.h" + #include "../feature/bedlevel/bedlevel.h" + + void log_machine_info() { + SERIAL_ECHOPGM("Machine Type: "); + #if ENABLED(DELTA) + SERIAL_ECHOLNPGM("Delta"); + #elif IS_SCARA + SERIAL_ECHOLNPGM("SCARA"); + #elif IS_CORE + SERIAL_ECHOLNPGM("Core"); + #else + SERIAL_ECHOLNPGM("Cartesian"); + #endif + + SERIAL_ECHOPGM("Probe: "); + #if ENABLED(PROBE_MANUALLY) + SERIAL_ECHOLNPGM("PROBE_MANUALLY"); + #elif ENABLED(FIX_MOUNTED_PROBE) + SERIAL_ECHOLNPGM("FIX_MOUNTED_PROBE"); + #elif ENABLED(BLTOUCH) + SERIAL_ECHOLNPGM("BLTOUCH"); + #elif HAS_Z_SERVO_ENDSTOP + SERIAL_ECHOLNPGM("SERVO PROBE"); + #elif ENABLED(Z_PROBE_SLED) + SERIAL_ECHOLNPGM("Z_PROBE_SLED"); + #elif ENABLED(Z_PROBE_ALLEN_KEY) + SERIAL_ECHOLNPGM("Z_PROBE_ALLEN_KEY"); + #else + SERIAL_ECHOLNPGM("NONE"); + #endif + + #if HAS_BED_PROBE + SERIAL_ECHOPAIR("Probe Offset X:", X_PROBE_OFFSET_FROM_EXTRUDER); + SERIAL_ECHOPAIR(" Y:", Y_PROBE_OFFSET_FROM_EXTRUDER); + SERIAL_ECHOPAIR(" Z:", zprobe_zoffset); + #if X_PROBE_OFFSET_FROM_EXTRUDER > 0 + SERIAL_ECHOPGM(" (Right"); + #elif X_PROBE_OFFSET_FROM_EXTRUDER < 0 + SERIAL_ECHOPGM(" (Left"); + #elif Y_PROBE_OFFSET_FROM_EXTRUDER != 0 + SERIAL_ECHOPGM(" (Middle"); + #else + SERIAL_ECHOPGM(" (Aligned With"); + #endif + #if Y_PROBE_OFFSET_FROM_EXTRUDER > 0 + SERIAL_ECHOPGM("-Back"); + #elif Y_PROBE_OFFSET_FROM_EXTRUDER < 0 + SERIAL_ECHOPGM("-Front"); + #elif X_PROBE_OFFSET_FROM_EXTRUDER != 0 + SERIAL_ECHOPGM("-Center"); + #endif + if (zprobe_zoffset < 0) + SERIAL_ECHOPGM(" & Below"); + else if (zprobe_zoffset > 0) + SERIAL_ECHOPGM(" & Above"); + else + SERIAL_ECHOPGM(" & Same Z as"); + SERIAL_ECHOLNPGM(" Nozzle)"); + #endif + + #if HAS_ABL + SERIAL_ECHOPGM("Auto Bed Leveling: "); + #if ENABLED(AUTO_BED_LEVELING_LINEAR) + SERIAL_ECHOPGM("LINEAR"); + #elif ENABLED(AUTO_BED_LEVELING_BILINEAR) + SERIAL_ECHOPGM("BILINEAR"); + #elif ENABLED(AUTO_BED_LEVELING_3POINT) + SERIAL_ECHOPGM("3POINT"); + #elif ENABLED(AUTO_BED_LEVELING_UBL) + SERIAL_ECHOPGM("UBL"); + #endif + if (leveling_is_active()) { + SERIAL_ECHOLNPGM(" (enabled)"); + #if ABL_PLANAR + const float diff[XYZ] = { + stepper.get_axis_position_mm(X_AXIS) - current_position[X_AXIS], + stepper.get_axis_position_mm(Y_AXIS) - current_position[Y_AXIS], + stepper.get_axis_position_mm(Z_AXIS) - current_position[Z_AXIS] + }; + SERIAL_ECHOPGM("ABL Adjustment X"); + if (diff[X_AXIS] > 0) SERIAL_CHAR('+'); + SERIAL_ECHO(diff[X_AXIS]); + SERIAL_ECHOPGM(" Y"); + if (diff[Y_AXIS] > 0) SERIAL_CHAR('+'); + SERIAL_ECHO(diff[Y_AXIS]); + SERIAL_ECHOPGM(" Z"); + if (diff[Z_AXIS] > 0) SERIAL_CHAR('+'); + SERIAL_ECHO(diff[Z_AXIS]); + #elif ENABLED(AUTO_BED_LEVELING_UBL) + SERIAL_ECHOPAIR("UBL Adjustment Z", stepper.get_axis_position_mm(Z_AXIS) - current_position[Z_AXIS]); + #elif ENABLED(AUTO_BED_LEVELING_BILINEAR) + SERIAL_ECHOPAIR("ABL Adjustment Z", bilinear_z_offset(current_position)); + #endif + } + else + SERIAL_ECHOLNPGM(" (disabled)"); + + SERIAL_EOL(); + + #elif ENABLED(MESH_BED_LEVELING) + + SERIAL_ECHOPGM("Mesh Bed Leveling"); + if (leveling_is_active()) { + float lz = current_position[Z_AXIS]; + planner.apply_leveling(current_position[X_AXIS], current_position[Y_AXIS], lz); + SERIAL_ECHOLNPGM(" (enabled)"); + SERIAL_ECHOPAIR("MBL Adjustment Z", lz); + } + else + SERIAL_ECHOPGM(" (disabled)"); + + SERIAL_EOL(); + + #endif // MESH_BED_LEVELING + } + +#endif // DEBUG_LEVELING_FEATURE diff --git a/Marlin/src/core/utility.h b/Marlin/src/core/utility.h index 426c5837cd..45679d2cab 100644 --- a/Marlin/src/core/utility.h +++ b/Marlin/src/core/utility.h @@ -23,6 +23,8 @@ #ifndef __UTILITY_H__ #define __UTILITY_H__ +#include "../inc/MarlinConfig.h" + void safe_delay(millis_t ms); #if ENABLED(EEPROM_SETTINGS) @@ -83,4 +85,8 @@ void safe_delay(millis_t ms); #endif // ULTRA_LCD +#if ENABLED(DEBUG_LEVELING_FEATURE) + void log_machine_info(); +#endif + #endif // __UTILITY_H__