From ce563d7c2e1f61dfb76f3f14e125b4f74f6d41fe Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 19 Jan 2019 16:56:12 -0600 Subject: [PATCH] Various general cleanups Mostly from the L6470-oriented PR --- Marlin/src/HAL/HAL_DUE/EepromEmulation_Due.cpp | 6 +++--- Marlin/src/HAL/HAL_DUE/pinsDebug.h | 2 +- Marlin/src/HAL/HAL_DUE/usb/sd_mmc_spi_mem.cpp | 4 ++-- Marlin/src/HAL/HAL_TEENSY35_36/pinsDebug.h | 10 +++++----- .../examples/3DFabXYZ/Migbot/Configuration_adv.h | 6 ++---- Marlin/src/core/macros.h | 4 +--- Marlin/src/gcode/config/M302.cpp | 3 ++- Marlin/src/sd/usb_flashdrive/Sd2Card_FlashDrive.cpp | 2 +- Marlin/src/sd/usb_flashdrive/usb_host.cpp | 2 +- buildroot/share/atom/auto_build.py | 3 +++ 10 files changed, 21 insertions(+), 21 deletions(-) diff --git a/Marlin/src/HAL/HAL_DUE/EepromEmulation_Due.cpp b/Marlin/src/HAL/HAL_DUE/EepromEmulation_Due.cpp index 54d08d69b..e56057014 100644 --- a/Marlin/src/HAL/HAL_DUE/EepromEmulation_Due.cpp +++ b/Marlin/src/HAL/HAL_DUE/EepromEmulation_Due.cpp @@ -120,14 +120,14 @@ static uint8_t buffer[256] = {0}, // The RAM buffer to accumulate writes const uint8_t* c = (const uint8_t*) data; char buffer[80]; - sprintf(buffer, "Page: %d (0x%04x)\n", page, page); + sprintf_P(buffer, PSTR("Page: %d (0x%04x)\n"), page, page); SERIAL_ECHO(buffer); char* p = &buffer[0]; for (int i = 0; i< PageSize; ++i) { - if ((i & 0xF) == 0) p += sprintf(p,"%04x] ", i); + if ((i & 0xF) == 0) p += sprintf_P(p, PSTR("%04x] "), i); - p += sprintf(p," %02x", c[i]); + p += sprintf_P(p, PSTR(" %02x"), c[i]); if ((i & 0xF) == 0xF) { *p++ = '\n'; *p = 0; diff --git a/Marlin/src/HAL/HAL_DUE/pinsDebug.h b/Marlin/src/HAL/HAL_DUE/pinsDebug.h index f4e223898..09dc24e0e 100644 --- a/Marlin/src/HAL/HAL_DUE/pinsDebug.h +++ b/Marlin/src/HAL/HAL_DUE/pinsDebug.h @@ -71,7 +71,7 @@ #define GET_ARRAY_PIN(p) pin_array[p].pin #define VALID_PIN(pin) (pin >= 0 && pin < (int8_t)NUMBER_PINS_TOTAL ? 1 : 0) #define DIGITAL_PIN_TO_ANALOG_PIN(p) int(p - analogInputToDigitalPin(0)) -#define IS_ANALOG(P) (((P) >= analogInputToDigitalPin(0)) && ((P) <= analogInputToDigitalPin(NUM_ANALOG_INPUTS - 1))) +#define IS_ANALOG(P) WITHIN(P, char(analogInputToDigitalPin(0)), char(analogInputToDigitalPin(NUM_ANALOG_INPUTS - 1))) #define pwm_status(pin) (((g_pinStatus[pin] & 0xF) == PIN_STATUS_PWM) && \ ((g_APinDescription[pin].ulPinAttribute & PIN_ATTR_PWM) == PIN_ATTR_PWM)) #define MULTI_NAME_PAD 14 // space needed to be pretty if not first name assigned to a pin diff --git a/Marlin/src/HAL/HAL_DUE/usb/sd_mmc_spi_mem.cpp b/Marlin/src/HAL/HAL_DUE/usb/sd_mmc_spi_mem.cpp index cfaa057a2..52edc9711 100644 --- a/Marlin/src/HAL/HAL_DUE/usb/sd_mmc_spi_mem.cpp +++ b/Marlin/src/HAL/HAL_DUE/usb/sd_mmc_spi_mem.cpp @@ -66,7 +66,7 @@ Ctrl_status sd_mmc_spi_usb_read_10(uint32_t addr, uint16_t nb_sector) { #ifdef DEBUG_MMC char buffer[80]; - sprintf(buffer, "SDRD: %d @ 0x%08x\n", nb_sector, addr); + sprintf_P(buffer, PSTR("SDRD: %d @ 0x%08x\n"), nb_sector, addr); SERIAL_ECHO_P(0, buffer); #endif @@ -100,7 +100,7 @@ Ctrl_status sd_mmc_spi_usb_write_10(uint32_t addr, uint16_t nb_sector) { #ifdef DEBUG_MMC char buffer[80]; - sprintf(buffer, "SDWR: %d @ 0x%08x\n", nb_sector, addr); + sprintf_P(buffer, PSTR("SDWR: %d @ 0x%08x\n"), nb_sector, addr); SERIAL_ECHO_P(0, buffer); #endif diff --git a/Marlin/src/HAL/HAL_TEENSY35_36/pinsDebug.h b/Marlin/src/HAL/HAL_TEENSY35_36/pinsDebug.h index 6ba5eebab..015382376 100644 --- a/Marlin/src/HAL/HAL_TEENSY35_36/pinsDebug.h +++ b/Marlin/src/HAL/HAL_TEENSY35_36/pinsDebug.h @@ -53,16 +53,16 @@ #define IS_ANALOG(P) ((P) >= analogInputToDigitalPin(0) && (P) <= analogInputToDigitalPin(9)) || ((P) >= analogInputToDigitalPin(12) && (P) <= analogInputToDigitalPin(20)) void HAL_print_analog_pin(char buffer[], int8_t pin) { - if (pin <= 23) sprintf(buffer, "(A%2d) ", int(pin - 14)); - else if (pin <= 39) sprintf(buffer, "(A%2d) ", int(pin - 19)); + if (pin <= 23) sprintf_P(buffer, PSTR("(A%2d) "), int(pin - 14)); + else if (pin <= 39) sprintf_P(buffer, PSTR("(A%2d) "), int(pin - 19)); } void HAL_analog_pin_state(char buffer[], int8_t pin) { - if (pin <= 23) sprintf(buffer, "Analog in =% 5d", analogRead(pin - 14)); - else if (pin <= 39) sprintf(buffer, "Analog in =% 5d", analogRead(pin - 19)); + if (pin <= 23) sprintf_P(buffer, PSTR("Analog in =% 5d"), analogRead(pin - 14)); + else if (pin <= 39) sprintf_P(buffer, PSTR("Analog in =% 5d"), analogRead(pin - 19)); } -#define PWM_PRINT(V) do{ sprintf(buffer, "PWM: %4d", 22); SERIAL_ECHO(buffer); }while(0) +#define PWM_PRINT(V) do{ sprintf_P(buffer, PSTR("PWM: %4d"), 22); SERIAL_ECHO(buffer); }while(0) #define FTM_CASE(N,Z) \ case FTM##N##_CH##Z##_PIN: \ if (FTM##N##_C##Z##V) { \ diff --git a/Marlin/src/config/examples/3DFabXYZ/Migbot/Configuration_adv.h b/Marlin/src/config/examples/3DFabXYZ/Migbot/Configuration_adv.h index 356e71e9a..547ae220a 100644 --- a/Marlin/src/config/examples/3DFabXYZ/Migbot/Configuration_adv.h +++ b/Marlin/src/config/examples/3DFabXYZ/Migbot/Configuration_adv.h @@ -1788,10 +1788,8 @@ #define USER_DESC_1 "Test Print" #define USER_GCODE_1 "G28\nG29\nG26" -/* - #define USER_DESC_1 "Home & UBL Info" - #define USER_GCODE_1 "G28\nG29 W" + /* #define USER_DESC_2 "Preheat for " PREHEAT_1_LABEL #define USER_GCODE_2 "M140 S" STRINGIFY(PREHEAT_1_TEMP_BED) "\nM104 S" STRINGIFY(PREHEAT_1_TEMP_HOTEND) @@ -1803,7 +1801,7 @@ #define USER_DESC_5 "Home & Info" #define USER_GCODE_5 "G28\nM503" -*/ + */ #endif /** diff --git a/Marlin/src/core/macros.h b/Marlin/src/core/macros.h index bfdbdd552..1c57d88c8 100644 --- a/Marlin/src/core/macros.h +++ b/Marlin/src/core/macros.h @@ -56,9 +56,7 @@ #define NANOSECONDS_PER_CYCLE (1000000000.0 / F_CPU) // Remove compiler warning on an unused variable -#if !defined(ARDUINO_ARCH_STM32) || defined(STM32GENERIC) - #define UNUSED(x) ((void)(x)) -#endif +#define UNUSED(x) ((void)(x)) // Macros to make a string from a macro #define STRINGIFY_(M) #M diff --git a/Marlin/src/gcode/config/M302.cpp b/Marlin/src/gcode/config/M302.cpp index 5097c5493..6ddb738e2 100644 --- a/Marlin/src/gcode/config/M302.cpp +++ b/Marlin/src/gcode/config/M302.cpp @@ -54,7 +54,8 @@ void GcodeSuite::M302() { else if (!seen_S) { // Report current state SERIAL_ECHO_START(); - SERIAL_ECHOPAIR("Cold extrudes are ", (thermalManager.allow_cold_extrude ? "en" : "dis")); + SERIAL_ECHOPGM("Cold extrudes are "); + serialprintPGM(thermalManager.allow_cold_extrude ? PSTR("en") : PSTR("dis")); SERIAL_ECHOPAIR("abled (min temp ", thermalManager.extrude_min_temp); SERIAL_ECHOLNPGM("C)"); } diff --git a/Marlin/src/sd/usb_flashdrive/Sd2Card_FlashDrive.cpp b/Marlin/src/sd/usb_flashdrive/Sd2Card_FlashDrive.cpp index 6cf6dd8c3..38762b644 100644 --- a/Marlin/src/sd/usb_flashdrive/Sd2Card_FlashDrive.cpp +++ b/Marlin/src/sd/usb_flashdrive/Sd2Card_FlashDrive.cpp @@ -110,7 +110,7 @@ bool Sd2Card::init(const uint8_t sckRateID/*=0*/, const pin_t chipSelectPin/*=SD const uint32_t sectorSize = bulk.GetSectorSize(0); if (sectorSize != 512) { - SERIAL_ECHOLNPAIR("Expecting sector size of 512, got:", sectorSize); + SERIAL_ECHOLNPAIR("Expecting sector size of 512. Got: ", sectorSize); return false; } diff --git a/Marlin/src/sd/usb_flashdrive/usb_host.cpp b/Marlin/src/sd/usb_flashdrive/usb_host.cpp index 71155b82a..41895e86d 100644 --- a/Marlin/src/sd/usb_flashdrive/usb_host.cpp +++ b/Marlin/src/sd/usb_flashdrive/usb_host.cpp @@ -127,7 +127,7 @@ bool MAX3421e::start() { const uint8_t revision = regRd(rREVISION); if (revision == 0x00 || revision == 0xFF) { - SERIAL_ECHOLNPAIR("Revision register appears incorrect on MAX3421e initialization, got ", revision); + SERIAL_ECHOLNPAIR("Revision register appears incorrect on MAX3421e initialization. Got ", revision); return false; } diff --git a/buildroot/share/atom/auto_build.py b/buildroot/share/atom/auto_build.py index 494d63f8e..223723ffd 100644 --- a/buildroot/share/atom/auto_build.py +++ b/buildroot/share/atom/auto_build.py @@ -105,6 +105,7 @@ current_OS = platform.system() target_env = '' board_name = '' +from datetime import datetime, date, time ######### # Python 2 error messages: @@ -892,6 +893,8 @@ def run_PIO(dummy): write_to_screen_queue('\nBoard name: ' + board_name + '\n') # put build info at the bottom of the screen write_to_screen_queue('Build type: ' + build_type + '\n') write_to_screen_queue('Environment used: ' + target_env + '\n') + write_to_screen_queue(str(datetime.now()) + '\n') + # end - run_PIO