2017-04-02 06:04:54 +00:00
|
|
|
/**
|
|
|
|
* Marlin 3D Printer Firmware
|
2019-02-12 21:06:53 +00:00
|
|
|
* Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
2017-04-02 06:04:54 +00:00
|
|
|
*
|
|
|
|
* Based on Sprinter and grbl.
|
|
|
|
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
2018-11-04 08:25:55 +00:00
|
|
|
#pragma once
|
2017-04-02 06:04:54 +00:00
|
|
|
|
2018-06-28 03:39:59 +00:00
|
|
|
#include "../inc/MarlinConfigPre.h"
|
|
|
|
#include HAL_PATH(../HAL, HAL.h)
|
2017-05-17 10:07:35 +00:00
|
|
|
|
2017-09-08 03:08:13 +00:00
|
|
|
/**
|
|
|
|
* Define debug bit-masks
|
|
|
|
*/
|
2018-11-06 04:48:28 +00:00
|
|
|
enum MarlinDebugFlags : uint8_t {
|
|
|
|
MARLIN_DEBUG_NONE = 0,
|
|
|
|
MARLIN_DEBUG_ECHO = _BV(0), ///< Echo commands in order as they are processed
|
|
|
|
MARLIN_DEBUG_INFO = _BV(1), ///< Print messages for code that has debug output
|
|
|
|
MARLIN_DEBUG_ERRORS = _BV(2), ///< Not implemented
|
|
|
|
MARLIN_DEBUG_DRYRUN = _BV(3), ///< Ignore temperature setting and E movement commands
|
|
|
|
MARLIN_DEBUG_COMMUNICATION = _BV(4), ///< Not implemented
|
|
|
|
MARLIN_DEBUG_LEVELING = _BV(5), ///< Print detailed output for homing and leveling
|
|
|
|
MARLIN_DEBUG_MESH_ADJUST = _BV(6), ///< UBL bed leveling
|
|
|
|
MARLIN_DEBUG_ALL = 0xFF
|
2017-09-08 03:08:13 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
extern uint8_t marlin_debug_flags;
|
2018-11-06 04:48:28 +00:00
|
|
|
#define DEBUGGING(F) (marlin_debug_flags & (MARLIN_DEBUG_## F))
|
2017-09-08 03:08:13 +00:00
|
|
|
|
2017-11-05 14:49:38 +00:00
|
|
|
#if NUM_SERIAL > 1
|
2019-02-24 04:53:01 +00:00
|
|
|
extern int8_t serial_port_index;
|
|
|
|
#define _PORT_REDIRECT(n,p) REMEMBER(n,serial_port_index,p)
|
|
|
|
#define _PORT_RESTORE(n) RESTORE(n)
|
|
|
|
#define SERIAL_BOTH 0x7F
|
|
|
|
#define SERIAL_OUT(WHAT, ...) do{ \
|
2019-02-24 21:04:29 +00:00
|
|
|
if (!serial_port_index || serial_port_index == SERIAL_BOTH) MYSERIAL0.WHAT(__VA_ARGS__); \
|
|
|
|
if ( serial_port_index) MYSERIAL1.WHAT(__VA_ARGS__); \
|
2019-02-24 04:53:01 +00:00
|
|
|
}while(0)
|
|
|
|
#else
|
|
|
|
#define _PORT_REDIRECT(n,p) NOOP
|
|
|
|
#define _PORT_RESTORE(n) NOOP
|
|
|
|
#define SERIAL_OUT(WHAT, ...) MYSERIAL0.WHAT(__VA_ARGS__)
|
|
|
|
#endif
|
2018-11-29 22:58:58 +00:00
|
|
|
|
2019-02-24 04:53:01 +00:00
|
|
|
#define PORT_REDIRECT(p) _PORT_REDIRECT(1,p)
|
|
|
|
#define PORT_RESTORE() _PORT_RESTORE(1)
|
|
|
|
|
|
|
|
#define SERIAL_CHAR(x) SERIAL_OUT(write, x)
|
|
|
|
#define SERIAL_ECHO(x) SERIAL_OUT(print, x)
|
|
|
|
#define SERIAL_ECHO_F(x,y) SERIAL_OUT(print, x, y)
|
|
|
|
#define SERIAL_ECHOLN(x) SERIAL_OUT(println, x)
|
|
|
|
#define SERIAL_PRINT(x,b) SERIAL_OUT(print, x, b)
|
|
|
|
#define SERIAL_PRINTLN(x,b) SERIAL_OUT(println, x, b)
|
|
|
|
#define SERIAL_PRINTF(args...) SERIAL_OUT(printf, args)
|
|
|
|
#define SERIAL_FLUSH() SERIAL_OUT(flush)
|
2019-02-24 21:04:29 +00:00
|
|
|
|
2019-02-24 04:53:01 +00:00
|
|
|
#if TX_BUFFER_SIZE > 0
|
|
|
|
#define SERIAL_FLUSHTX() SERIAL_OUT(flushTX)
|
2019-02-24 21:04:29 +00:00
|
|
|
#else
|
|
|
|
#define SERIAL_FLUSHTX()
|
2019-02-24 04:53:01 +00:00
|
|
|
#endif
|
2017-11-05 14:49:38 +00:00
|
|
|
|
2018-11-29 22:58:58 +00:00
|
|
|
#define SERIAL_ECHOPGM(x) (serialprintPGM(PSTR(x)))
|
|
|
|
#define SERIAL_ECHOLNPGM(x) (serialprintPGM(PSTR(x "\n")))
|
|
|
|
#define SERIAL_ECHOPAIR(pre, value) (serial_echopair_PGM(PSTR(pre), value))
|
2019-02-24 04:53:01 +00:00
|
|
|
#define SERIAL_ECHOLNPAIR(pre, value) do{ SERIAL_ECHOPAIR(pre, value); SERIAL_EOL(); }while(0)
|
2018-11-29 22:58:58 +00:00
|
|
|
|
|
|
|
#define SERIAL_ECHOPAIR_F(pre, value, y) do{ SERIAL_ECHO(pre); SERIAL_ECHO_F(value, y); }while(0)
|
|
|
|
#define SERIAL_ECHOLNPAIR_F(pre, value, y) do{ SERIAL_ECHOPAIR_F(pre, value, y); SERIAL_EOL(); }while(0)
|
|
|
|
|
|
|
|
#define SERIAL_ECHO_START() serial_echo_start()
|
|
|
|
#define SERIAL_ERROR_START() serial_error_start()
|
|
|
|
#define SERIAL_EOL() SERIAL_CHAR('\n')
|
|
|
|
|
|
|
|
#define SERIAL_ECHO_MSG(STR) do{ SERIAL_ECHO_START(); SERIAL_ECHOLNPGM(STR); }while(0)
|
|
|
|
#define SERIAL_ERROR_MSG(STR) do{ SERIAL_ERROR_START(); SERIAL_ECHOLNPGM(STR); }while(0)
|
2017-04-02 06:04:54 +00:00
|
|
|
|
2018-11-29 22:58:58 +00:00
|
|
|
#define SERIAL_ECHO_SP(C) serial_spaces(C)
|
2017-04-28 22:15:39 +00:00
|
|
|
|
2017-04-02 06:04:54 +00:00
|
|
|
//
|
|
|
|
// Functions for serial printing from PROGMEM. (Saves loads of SRAM.)
|
|
|
|
//
|
2018-11-29 22:58:58 +00:00
|
|
|
void serial_echopair_PGM(PGM_P const s_P, const char *v);
|
|
|
|
void serial_echopair_PGM(PGM_P const s_P, char v);
|
|
|
|
void serial_echopair_PGM(PGM_P const s_P, int v);
|
|
|
|
void serial_echopair_PGM(PGM_P const s_P, long v);
|
|
|
|
void serial_echopair_PGM(PGM_P const s_P, float v);
|
|
|
|
void serial_echopair_PGM(PGM_P const s_P, double v);
|
|
|
|
void serial_echopair_PGM(PGM_P const s_P, unsigned int v);
|
|
|
|
void serial_echopair_PGM(PGM_P const s_P, unsigned long v);
|
|
|
|
inline void serial_echopair_PGM(PGM_P const s_P, uint8_t v) { serial_echopair_PGM(s_P, (int)v); }
|
|
|
|
inline void serial_echopair_PGM(PGM_P const s_P, bool v) { serial_echopair_PGM(s_P, (int)v); }
|
|
|
|
inline void serial_echopair_PGM(PGM_P const s_P, void *v) { serial_echopair_PGM(s_P, (unsigned long)v); }
|
|
|
|
|
2018-10-01 04:44:33 +00:00
|
|
|
void serialprintPGM(PGM_P str);
|
2018-10-07 20:32:15 +00:00
|
|
|
void serial_echo_start();
|
|
|
|
void serial_error_start();
|
2018-11-12 23:04:00 +00:00
|
|
|
void serialprint_onoff(const bool onoff);
|
|
|
|
void serialprintln_onoff(const bool onoff);
|
2019-02-24 04:53:01 +00:00
|
|
|
void serial_spaces(uint8_t count);
|
2017-04-02 06:04:54 +00:00
|
|
|
|
2017-09-08 03:08:13 +00:00
|
|
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
2018-11-29 22:58:58 +00:00
|
|
|
void print_xyz(PGM_P const prefix, PGM_P const suffix, const float x, const float y, const float z);
|
|
|
|
void print_xyz(PGM_P const prefix, PGM_P const suffix, const float xyz[]);
|
2017-11-05 14:49:38 +00:00
|
|
|
#define DEBUG_POS(SUFFIX,VAR) do { print_xyz(PSTR(" " STRINGIFY(VAR) "="), PSTR(" : " SUFFIX "\n"), VAR); } while(0)
|
2017-09-08 03:08:13 +00:00
|
|
|
#endif
|