Simple rename of hex_print

This commit is contained in:
Scott Lahteine 2020-08-05 23:21:41 -05:00
parent a9912681b4
commit d69c2a90b7
10 changed files with 101 additions and 96 deletions

View file

@ -40,7 +40,7 @@
#include "../../../module/stepper/indirection.h" #include "../../../module/stepper/indirection.h"
#include "../../../module/printcounter.h" #include "../../../module/printcounter.h"
#include "../../../libs/duration_t.h" #include "../../../libs/duration_t.h"
#include "../../../libs/hex_print_routines.h" #include "../../../libs/hex_print.h"
//some default values used in initialization //some default values used in initialization
#define DEFAULT_MICROSTEPPING_VALUE 32 #define DEFAULT_MICROSTEPPING_VALUE 32

View file

@ -28,7 +28,7 @@
#include "../../../MarlinCore.h" #include "../../../MarlinCore.h"
#include "../../../HAL/shared/eeprom_api.h" #include "../../../HAL/shared/eeprom_api.h"
#include "../../../libs/hex_print_routines.h" #include "../../../libs/hex_print.h"
#include "../../../module/configuration_store.h" #include "../../../module/configuration_store.h"
#include "../../../lcd/ultralcd.h" #include "../../../lcd/ultralcd.h"
#include "../../../module/stepper.h" #include "../../../module/stepper.h"

View file

@ -34,7 +34,7 @@
#if ENABLED(TMC_DEBUG) #if ENABLED(TMC_DEBUG)
#include "../module/planner.h" #include "../module/planner.h"
#include "../libs/hex_print_routines.h" #include "../libs/hex_print.h"
#if ENABLED(MONITOR_DRIVER_STATUS) #if ENABLED(MONITOR_DRIVER_STATUS)
static uint16_t report_tmc_status_interval; // = 0 static uint16_t report_tmc_status_interval; // = 0
#endif #endif

View file

@ -26,7 +26,7 @@
#include "../gcode.h" #include "../gcode.h"
#include "../queue.h" #include "../queue.h"
#include "../../libs/hex_print_routines.h" #include "../../libs/hex_print.h"
#include "../../MarlinCore.h" // for idle() #include "../../MarlinCore.h" // for idle()

View file

@ -60,7 +60,7 @@ void GcodeSuite::M502() {
#if ENABLED(EEPROM_SETTINGS) #if ENABLED(EEPROM_SETTINGS)
#if ENABLED(MARLIN_DEV_MODE) #if ENABLED(MARLIN_DEV_MODE)
#include "../../libs/hex_print_routines.h" #include "../../libs/hex_print.h"
#endif #endif
/** /**

View file

@ -31,7 +31,7 @@
//#define DEBUG_GCODE_PARSER //#define DEBUG_GCODE_PARSER
#if ENABLED(DEBUG_GCODE_PARSER) #if ENABLED(DEBUG_GCODE_PARSER)
#include "../libs/hex_print_routines.h" #include "../libs/hex_print.h"
#endif #endif
#if ENABLED(TEMPERATURE_UNITS_SUPPORT) #if ENABLED(TEMPERATURE_UNITS_SUPPORT)

View file

@ -378,3 +378,8 @@
#if ENABLED(EEPROM_SETTINGS) && NONE(I2C_EEPROM, SPI_EEPROM, QSPI_EEPROM, FLASH_EEPROM_EMULATION, SRAM_EEPROM_EMULATION, SDCARD_EEPROM_EMULATION) #if ENABLED(EEPROM_SETTINGS) && NONE(I2C_EEPROM, SPI_EEPROM, QSPI_EEPROM, FLASH_EEPROM_EMULATION, SRAM_EEPROM_EMULATION, SDCARD_EEPROM_EMULATION)
#define NO_EEPROM_SELECTED 1 #define NO_EEPROM_SELECTED 1
#endif #endif
// Flag whether hex_print.cpp is used
#if ANY(AUTO_BED_LEVELING_UBL, M100_FREE_MEMORY_WATCHER, DEBUG_GCODE_PARSER, TMC_DEBUG, MARLIN_DEV_MODE)
#define NEED_HEX_PRINT 1
#endif

View file

@ -0,0 +1,90 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* 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 <https://www.gnu.org/licenses/>.
*
*/
#include "../inc/MarlinConfig.h"
#include "../gcode/parser.h"
#if NEED_HEX_PRINT
#include "hex_print.h"
#ifdef CPU_32_BIT
constexpr int byte_start = 4;
static char _hex[] = "0x00000000";
#else
constexpr int byte_start = 0;
static char _hex[] = "0x0000";
#endif
char* hex_byte(const uint8_t b) {
_hex[byte_start + 4] = hex_nybble(b >> 4);
_hex[byte_start + 5] = hex_nybble(b);
return &_hex[byte_start + 4];
}
inline void _hex_word(const uint16_t w) {
_hex[byte_start + 2] = hex_nybble(w >> 12);
_hex[byte_start + 3] = hex_nybble(w >> 8);
_hex[byte_start + 4] = hex_nybble(w >> 4);
_hex[byte_start + 5] = hex_nybble(w);
}
char* hex_word(const uint16_t w) {
_hex_word(w);
return &_hex[byte_start + 2];
}
#ifdef CPU_32_BIT
char* hex_long(const uint32_t l) {
_hex[2] = hex_nybble(l >> 28);
_hex[3] = hex_nybble(l >> 24);
_hex[4] = hex_nybble(l >> 20);
_hex[5] = hex_nybble(l >> 16);
_hex_word((uint16_t)(l & 0xFFFF));
return &_hex[2];
}
#endif
char* hex_address(const void * const w) {
#ifdef CPU_32_BIT
(void)hex_long((ptr_int_t)w);
#else
(void)hex_word((ptr_int_t)w);
#endif
return _hex;
}
void print_hex_nybble(const uint8_t n) { SERIAL_CHAR(hex_nybble(n)); }
void print_hex_byte(const uint8_t b) { SERIAL_ECHO(hex_byte(b)); }
void print_hex_word(const uint16_t w) { SERIAL_ECHO(hex_word(w)); }
void print_hex_address(const void * const w) { SERIAL_ECHO(hex_address(w)); }
void print_hex_long(const uint32_t w, const char delimiter) {
SERIAL_ECHOPGM("0x");
for (int B = 24; B >= 8; B -= 8){
print_hex_byte(w >> B);
SERIAL_CHAR(delimiter);
}
print_hex_byte(w);
}
#endif // NEED_HEX_PRINT

View file

@ -1,90 +0,0 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* 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 <https://www.gnu.org/licenses/>.
*
*/
#include "../inc/MarlinConfig.h"
#include "../gcode/parser.h"
#if ANY(AUTO_BED_LEVELING_UBL, M100_FREE_MEMORY_WATCHER, DEBUG_GCODE_PARSER, TMC_DEBUG, MARLIN_DEV_MODE)
#include "hex_print_routines.h"
#ifdef CPU_32_BIT
constexpr int byte_start = 4;
static char _hex[] = "0x00000000";
#else
constexpr int byte_start = 0;
static char _hex[] = "0x0000";
#endif
char* hex_byte(const uint8_t b) {
_hex[byte_start + 4] = hex_nybble(b >> 4);
_hex[byte_start + 5] = hex_nybble(b);
return &_hex[byte_start + 4];
}
inline void _hex_word(const uint16_t w) {
_hex[byte_start + 2] = hex_nybble(w >> 12);
_hex[byte_start + 3] = hex_nybble(w >> 8);
_hex[byte_start + 4] = hex_nybble(w >> 4);
_hex[byte_start + 5] = hex_nybble(w);
}
char* hex_word(const uint16_t w) {
_hex_word(w);
return &_hex[byte_start + 2];
}
#ifdef CPU_32_BIT
char* hex_long(const uint32_t l) {
_hex[2] = hex_nybble(l >> 28);
_hex[3] = hex_nybble(l >> 24);
_hex[4] = hex_nybble(l >> 20);
_hex[5] = hex_nybble(l >> 16);
_hex_word((uint16_t)(l & 0xFFFF));
return &_hex[2];
}
#endif
char* hex_address(const void * const w) {
#ifdef CPU_32_BIT
(void)hex_long((ptr_int_t)w);
#else
(void)hex_word((ptr_int_t)w);
#endif
return _hex;
}
void print_hex_nybble(const uint8_t n) { SERIAL_CHAR(hex_nybble(n)); }
void print_hex_byte(const uint8_t b) { SERIAL_ECHO(hex_byte(b)); }
void print_hex_word(const uint16_t w) { SERIAL_ECHO(hex_word(w)); }
void print_hex_address(const void * const w) { SERIAL_ECHO(hex_address(w)); }
void print_hex_long(const uint32_t w, const char delimiter) {
SERIAL_ECHOPGM("0x");
for (int B = 24; B >= 8; B -= 8){
print_hex_byte(w >> B);
SERIAL_CHAR(delimiter);
}
print_hex_byte(w);
}
#endif // AUTO_BED_LEVELING_UBL || M100_FREE_MEMORY_WATCHER || DEBUG_GCODE_PARSER