From c6a5c7420895bbb32ac3c70f0382ed5622c3746e Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 19 Oct 2018 13:52:44 -0500 Subject: [PATCH] Add parentheses to SD macros --- Marlin/src/HAL/HAL_DUE/usb/sd_mmc_spi_mem.cpp | 10 +++++----- Marlin/src/HAL/HAL_LPC1768/main.cpp | 4 ++-- Marlin/src/Marlin.cpp | 2 +- Marlin/src/feature/runout.h | 2 +- Marlin/src/gcode/lcd/M73.cpp | 2 +- Marlin/src/gcode/queue.cpp | 2 +- Marlin/src/lcd/dogm/status_screen_lite_ST7920.h | 2 +- Marlin/src/lcd/extensible_ui/ui_api.cpp | 6 +++--- Marlin/src/lcd/ultralcd.cpp | 6 +++--- Marlin/src/lcd/ultralcd_impl_HD44780.h | 2 +- Marlin/src/sd/cardreader.h | 16 ++++++++-------- 11 files changed, 27 insertions(+), 27 deletions(-) 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 df79fe6a7..1054f5ab3 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 @@ -19,7 +19,7 @@ void sd_mmc_spi_mem_init(void) { } Ctrl_status sd_mmc_spi_test_unit_ready(void) { - if (!IS_SD_INSERTED || IS_SD_PRINTING || IS_SD_FILE_OPEN || !card.cardOK) + if (!IS_SD_INSERTED() || IS_SD_PRINTING() || IS_SD_FILE_OPEN() || !card.cardOK) return CTRL_NO_PRESENT; return CTRL_GOOD; } @@ -27,7 +27,7 @@ Ctrl_status sd_mmc_spi_test_unit_ready(void) { // NOTE: This function is defined as returning the address of the last block // in the card, which is cardSize() - 1 Ctrl_status sd_mmc_spi_read_capacity(uint32_t *nb_sector) { - if (!IS_SD_INSERTED || IS_SD_PRINTING || IS_SD_FILE_OPEN || !card.cardOK) + if (!IS_SD_INSERTED() || IS_SD_PRINTING() || IS_SD_FILE_OPEN() || !card.cardOK) return CTRL_NO_PRESENT; *nb_sector = card.getSd2Card().cardSize() - 1; return CTRL_GOOD; @@ -42,7 +42,7 @@ bool sd_mmc_spi_wr_protect(void) { } bool sd_mmc_spi_removal(void) { - if (!IS_SD_INSERTED || IS_SD_PRINTING || IS_SD_FILE_OPEN || !card.cardOK) + if (!IS_SD_INSERTED() || IS_SD_PRINTING() || IS_SD_FILE_OPEN() || !card.cardOK) return true; return false; } @@ -61,7 +61,7 @@ uint8_t sector_buf[SD_MMC_BLOCK_SIZE]; // #define DEBUG_MMC Ctrl_status sd_mmc_spi_usb_read_10(uint32_t addr, uint16_t nb_sector) { - if (!IS_SD_INSERTED || IS_SD_PRINTING || IS_SD_FILE_OPEN || !card.cardOK) + if (!IS_SD_INSERTED() || IS_SD_PRINTING() || IS_SD_FILE_OPEN() || !card.cardOK) return CTRL_NO_PRESENT; #ifdef DEBUG_MMC @@ -95,7 +95,7 @@ Ctrl_status sd_mmc_spi_usb_read_10(uint32_t addr, uint16_t nb_sector) { } Ctrl_status sd_mmc_spi_usb_write_10(uint32_t addr, uint16_t nb_sector) { - if (!IS_SD_INSERTED || IS_SD_PRINTING || IS_SD_FILE_OPEN || !card.cardOK) + if (!IS_SD_INSERTED() || IS_SD_PRINTING() || IS_SD_FILE_OPEN() || !card.cardOK) return CTRL_NO_PRESENT; #ifdef DEBUG_MMC diff --git a/Marlin/src/HAL/HAL_LPC1768/main.cpp b/Marlin/src/HAL/HAL_LPC1768/main.cpp index 49dcdf6b5..9fe2a0404 100644 --- a/Marlin/src/HAL/HAL_LPC1768/main.cpp +++ b/Marlin/src/HAL/HAL_LPC1768/main.cpp @@ -97,11 +97,11 @@ void HAL_idletask(void) { #if ENABLED(SDSUPPORT) && defined(SHARED_SD_CARD) // If Marlin is using the SD card we need to lock it to prevent access from // a PC via USB. - // Other HALs use IS_SD_PRINTING and IS_SD_FILE_OPEN to check for access but + // Other HALs use IS_SD_PRINTING() and IS_SD_FILE_OPEN() to check for access but // this will not reliably detect delete operations. To be safe we will lock // the disk if Marlin has it mounted. Unfortuately there is currently no way // to unmount the disk from the LCD menu. - // if (IS_SD_PRINTING || IS_SD_FILE_OPEN) + // if (IS_SD_PRINTING() || IS_SD_FILE_OPEN()) if (card.cardOK) MSC_Aquire_Lock(); else diff --git a/Marlin/src/Marlin.cpp b/Marlin/src/Marlin.cpp index 656085340..cc755d4cf 100644 --- a/Marlin/src/Marlin.cpp +++ b/Marlin/src/Marlin.cpp @@ -417,7 +417,7 @@ void manage_inactivity(const bool ignore_stepper_queue/*=false*/) { // --------------------------------------------------------- static int homeDebounceCount = 0; // poor man's debouncing count const int HOME_DEBOUNCE_DELAY = 2500; - if (!IS_SD_PRINTING && !READ(HOME_PIN)) { + if (!IS_SD_PRINTING() && !READ(HOME_PIN)) { if (!homeDebounceCount) { enqueue_and_echo_commands_P(PSTR("G28")); LCD_MESSAGEPGM(MSG_AUTO_HOME); diff --git a/Marlin/src/feature/runout.h b/Marlin/src/feature/runout.h index 415dd4bad..3f35536a7 100644 --- a/Marlin/src/feature/runout.h +++ b/Marlin/src/feature/runout.h @@ -75,7 +75,7 @@ class TFilamentSensor : public FilamentSensorBase { } static void run() { - if (enabled && !filament_ran_out && (IS_SD_PRINTING || print_job_timer.isRunning())) { + if (enabled && !filament_ran_out && (IS_SD_PRINTING() || print_job_timer.isRunning())) { response.run(); sensor.run(); if (response.has_runout()) { diff --git a/Marlin/src/gcode/lcd/M73.cpp b/Marlin/src/gcode/lcd/M73.cpp index 1c1deee9f..c721d5b36 100644 --- a/Marlin/src/gcode/lcd/M73.cpp +++ b/Marlin/src/gcode/lcd/M73.cpp @@ -38,7 +38,7 @@ * This has no effect during an SD print job */ void GcodeSuite::M73() { - if (!IS_SD_PRINTING && parser.seen('P')) { + if (!IS_SD_PRINTING() && parser.seen('P')) { progress_bar_percent = parser.value_byte(); NOMORE(progress_bar_percent, 100); } diff --git a/Marlin/src/gcode/queue.cpp b/Marlin/src/gcode/queue.cpp index f911c946a..7de38442d 100644 --- a/Marlin/src/gcode/queue.cpp +++ b/Marlin/src/gcode/queue.cpp @@ -450,7 +450,7 @@ inline void get_serial_commands() { #endif ; - if (!IS_SD_PRINTING) return; + if (!IS_SD_PRINTING()) return; /** * '#' stops reading from SD to the buffer prematurely, so procedural diff --git a/Marlin/src/lcd/dogm/status_screen_lite_ST7920.h b/Marlin/src/lcd/dogm/status_screen_lite_ST7920.h index 237642113..df1d6cb1c 100644 --- a/Marlin/src/lcd/dogm/status_screen_lite_ST7920.h +++ b/Marlin/src/lcd/dogm/status_screen_lite_ST7920.h @@ -885,7 +885,7 @@ void ST7920_Lite_Status_Screen::update_progress(const bool forceUpdate) { #if ENABLED(SDSUPPORT) // Progress bar % comes from SD when actively printing - if (IS_SD_PRINTING) progress_bar_percent = card.percentDone(); + if (IS_SD_PRINTING()) progress_bar_percent = card.percentDone(); #endif // Since the progress bar involves writing diff --git a/Marlin/src/lcd/extensible_ui/ui_api.cpp b/Marlin/src/lcd/extensible_ui/ui_api.cpp index 26b38b1f2..e13ca0875 100644 --- a/Marlin/src/lcd/extensible_ui/ui_api.cpp +++ b/Marlin/src/lcd/extensible_ui/ui_api.cpp @@ -433,7 +433,7 @@ namespace UI { } bool isPrinting() { - return (planner.movesplanned() || IS_SD_PRINTING || + return (planner.movesplanned() || IS_SD_PRINTING() || #if ENABLED(SDSUPPORT) (card.cardOK && card.isFileOpen()) #else @@ -444,7 +444,7 @@ namespace UI { bool isMediaInserted() { #if ENABLED(SDSUPPORT) - return IS_SD_INSERTED && card.cardOK; + return IS_SD_INSERTED() && card.cardOK; #else return false; #endif @@ -583,7 +583,7 @@ void lcd_init() { void lcd_update() { #if ENABLED(SDSUPPORT) static bool last_sd_status; - const bool sd_status = IS_SD_INSERTED; + const bool sd_status = IS_SD_INSERTED(); if (sd_status != last_sd_status) { last_sd_status = sd_status; if (sd_status) { diff --git a/Marlin/src/lcd/ultralcd.cpp b/Marlin/src/lcd/ultralcd.cpp index 7d9b58797..85a2180bb 100644 --- a/Marlin/src/lcd/ultralcd.cpp +++ b/Marlin/src/lcd/ultralcd.cpp @@ -509,7 +509,7 @@ millis_t next_lcd_update_ms; return click; } - inline bool printer_busy() { return planner.movesplanned() || IS_SD_PRINTING; } + inline bool printer_busy() { return planner.movesplanned() || IS_SD_PRINTING(); } void lcd_move_z(); float move_menu_scale; @@ -689,7 +689,7 @@ void lcd_status_screen() { #if ENABLED(LCD_SET_PROGRESS_MANUALLY) && ENABLED(SDSUPPORT) && (ENABLED(LCD_PROGRESS_BAR) || ENABLED(DOGLCD)) // Progress bar % comes from SD when actively printing - if (IS_SD_PRINTING) + if (IS_SD_PRINTING()) progress_bar_percent = card.percentDone(); #endif @@ -5462,7 +5462,7 @@ void lcd_update() { #if ENABLED(SDSUPPORT) && PIN_EXISTS(SD_DETECT) - const uint8_t sd_status = (uint8_t)IS_SD_INSERTED; + const uint8_t sd_status = (uint8_t)IS_SD_INSERTED(); if (sd_status != lcd_sd_status && lcd_detected()) { uint8_t old_sd_status = lcd_sd_status; // prevent re-entry to this block! diff --git a/Marlin/src/lcd/ultralcd_impl_HD44780.h b/Marlin/src/lcd/ultralcd_impl_HD44780.h index bb0d0cd91..5f37de5e5 100644 --- a/Marlin/src/lcd/ultralcd_impl_HD44780.h +++ b/Marlin/src/lcd/ultralcd_impl_HD44780.h @@ -571,7 +571,7 @@ FORCE_INLINE void _draw_bed_status(const bool blink) { FORCE_INLINE void _draw_print_progress() { const uint8_t percent = ( #if ENABLED(SDSUPPORT) - IS_SD_PRINTING ? card.percentDone() : 0 + IS_SD_PRINTING() ? card.percentDone() : 0 #else progress_bar_percent #endif diff --git a/Marlin/src/sd/cardreader.h b/Marlin/src/sd/cardreader.h index b975d053f..675c3adf4 100644 --- a/Marlin/src/sd/cardreader.h +++ b/Marlin/src/sd/cardreader.h @@ -244,16 +244,16 @@ private: }; #if ENABLED(USB_FLASH_DRIVE_SUPPORT) - #define IS_SD_INSERTED Sd2Card::isInserted() + #define IS_SD_INSERTED() Sd2Card::isInserted() #elif PIN_EXISTS(SD_DETECT) #if ENABLED(SD_DETECT_INVERTED) - #define IS_SD_INSERTED (READ(SD_DETECT_PIN) == HIGH) + #define IS_SD_INSERTED() (READ(SD_DETECT_PIN) == HIGH) #else - #define IS_SD_INSERTED (READ(SD_DETECT_PIN) == LOW) + #define IS_SD_INSERTED() (READ(SD_DETECT_PIN) == LOW) #endif #else // No card detect line? Assume the card is inserted. - #define IS_SD_INSERTED true + #define IS_SD_INSERTED() true #endif extern CardReader card; @@ -261,11 +261,11 @@ extern CardReader card; #endif // SDSUPPORT #if ENABLED(SDSUPPORT) - #define IS_SD_PRINTING (card.sdprinting) - #define IS_SD_FILE_OPEN (card.isFileOpen()) + #define IS_SD_PRINTING() card.sdprinting + #define IS_SD_FILE_OPEN() card.isFileOpen() #else - #define IS_SD_PRINTING (false) - #define IS_SD_FILE_OPEN (false) + #define IS_SD_PRINTING() false + #define IS_SD_FILE_OPEN() false #endif #endif // _CARDREADER_H_