From 58cfcd42394664dcfce8508a1b814c8d7f768af6 Mon Sep 17 00:00:00 2001
From: Scott Lahteine <sourcetree@thinkyhead.com>
Date: Thu, 30 Jul 2015 22:21:18 -0700
Subject: [PATCH] Overridable Options - Part 5

Apply `ENABLED` / `DISABLED` macros to files needing only a small
number of changes.
---
 Marlin/MarlinSerial.cpp               |  2 +-
 Marlin/MarlinSerial.h                 |  2 +-
 Marlin/Sd2Card.cpp                    | 16 ++++++++--------
 Marlin/Sd2Card.h                      |  4 ++--
 Marlin/Sd2PinMap.h                    |  2 +-
 Marlin/SdBaseFile.cpp                 |  2 +-
 Marlin/SdBaseFile.h                   |  2 +-
 Marlin/SdFatConfig.h                  |  2 +-
 Marlin/SdFatStructs.h                 |  2 +-
 Marlin/SdFatUtil.cpp                  |  2 +-
 Marlin/SdFatUtil.h                    |  2 +-
 Marlin/SdFile.cpp                     |  2 +-
 Marlin/SdFile.h                       |  2 +-
 Marlin/SdInfo.h                       |  2 +-
 Marlin/SdVolume.cpp                   |  2 +-
 Marlin/SdVolume.h                     |  2 +-
 Marlin/blinkm.cpp                     |  3 ++-
 Marlin/buzzer.cpp                     |  4 ++--
 Marlin/cardreader.cpp                 |  6 +++---
 Marlin/cardreader.h                   |  6 +++---
 Marlin/configurator/config/language.h |  4 ++--
 Marlin/digipot_mcp4451.cpp            |  2 +-
 Marlin/dogm_bitmaps.h                 |  2 +-
 Marlin/mesh_bed_leveling.cpp          |  2 +-
 Marlin/mesh_bed_leveling.h            |  2 +-
 Marlin/qr_solve.cpp                   |  2 +-
 Marlin/qr_solve.h                     |  2 +-
 Marlin/servo.cpp                      | 24 ++++++++++++------------
 Marlin/ultralcd_st7920_u8glib_rrd.h   |  2 +-
 Marlin/vector_3.cpp                   |  2 +-
 Marlin/vector_3.h                     |  2 +-
 Marlin/watchdog.cpp                   | 10 +++++-----
 Marlin/watchdog.h                     |  2 +-
 33 files changed, 63 insertions(+), 62 deletions(-)

diff --git a/Marlin/MarlinSerial.cpp b/Marlin/MarlinSerial.cpp
index 0142ce99cc..49502ec3f4 100644
--- a/Marlin/MarlinSerial.cpp
+++ b/Marlin/MarlinSerial.cpp
@@ -287,6 +287,6 @@ MarlinSerial MSerial;
 #endif // !USBCON
 
 // For AT90USB targets use the UART for BT interfacing
-#if defined(USBCON) && defined(BTENABLED)
+#if defined(USBCON) && ENABLED(BTENABLED)
   HardwareSerial bt;
 #endif
diff --git a/Marlin/MarlinSerial.h b/Marlin/MarlinSerial.h
index 5ef63e67fc..e65317fb63 100644
--- a/Marlin/MarlinSerial.h
+++ b/Marlin/MarlinSerial.h
@@ -153,7 +153,7 @@ extern MarlinSerial MSerial;
 #endif // !USBCON
 
 // Use the UART for BT in AT90USB configurations
-#if defined(USBCON) && defined(BTENABLED)
+#if defined(USBCON) && ENABLED(BTENABLED)
   extern HardwareSerial bt;
 #endif
 
diff --git a/Marlin/Sd2Card.cpp b/Marlin/Sd2Card.cpp
index 1182c99628..d7faa1f954 100644
--- a/Marlin/Sd2Card.cpp
+++ b/Marlin/Sd2Card.cpp
@@ -19,10 +19,10 @@
  */
 #include "Marlin.h"
 
-#ifdef SDSUPPORT
+#if ENABLED(SDSUPPORT)
 #include "Sd2Card.h"
 //------------------------------------------------------------------------------
-#ifndef SOFTWARE_SPI
+#if DISABLED(SOFTWARE_SPI)
 // functions for hardware SPI
 //------------------------------------------------------------------------------
 // make sure SPCR rate is in expected bits
@@ -209,7 +209,7 @@ void Sd2Card::chipSelectHigh() {
 }
 //------------------------------------------------------------------------------
 void Sd2Card::chipSelectLow() {
-#ifndef SOFTWARE_SPI
+#if DISABLED(SOFTWARE_SPI)
   spiInit(spiRate_);
 #endif  // SOFTWARE_SPI
   digitalWrite(chipSelectPin_, LOW);
@@ -297,7 +297,7 @@ bool Sd2Card::init(uint8_t sckRateID, uint8_t chipSelectPin) {
   pinMode(SPI_MOSI_PIN, OUTPUT);
   pinMode(SPI_SCK_PIN, OUTPUT);
 
-#ifndef SOFTWARE_SPI
+#if DISABLED(SOFTWARE_SPI)
   // SS must be in output mode even it is not chip select
   pinMode(SS_PIN, OUTPUT);
   // set SS high - may be chip select for another SPI device
@@ -353,7 +353,7 @@ bool Sd2Card::init(uint8_t sckRateID, uint8_t chipSelectPin) {
   }
   chipSelectHigh();
 
-#ifndef SOFTWARE_SPI
+#if DISABLED(SOFTWARE_SPI)
   return setSckRate(sckRateID);
 #else  // SOFTWARE_SPI
   return true;
@@ -373,7 +373,7 @@ bool Sd2Card::init(uint8_t sckRateID, uint8_t chipSelectPin) {
  * the value zero, false, is returned for failure.
  */
 bool Sd2Card::readBlock(uint32_t blockNumber, uint8_t* dst) {
-#ifdef SD_CHECK_AND_RETRY
+#if ENABLED(SD_CHECK_AND_RETRY)
   uint8_t retryCnt = 3;
   // use address if not SDHC card
   if (type()!= SD_CARD_TYPE_SDHC) blockNumber <<= 9;
@@ -422,7 +422,7 @@ bool Sd2Card::readData(uint8_t *dst) {
   return readData(dst, 512);
 }
 
-#ifdef SD_CHECK_AND_RETRY
+#if ENABLED(SD_CHECK_AND_RETRY)
 static const uint16_t crctab[] PROGMEM = {
   0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50A5, 0x60C6, 0x70E7,
   0x8108, 0x9129, 0xA14A, 0xB16B, 0xC18C, 0xD1AD, 0xE1CE, 0xF1EF,
@@ -483,7 +483,7 @@ bool Sd2Card::readData(uint8_t* dst, uint16_t count) {
   // transfer data
   spiRead(dst, count);
 
-#ifdef SD_CHECK_AND_RETRY
+#if ENABLED(SD_CHECK_AND_RETRY)
   {
     uint16_t calcCrc = CRC_CCITT(dst, count);
     uint16_t recvCrc = spiRec() << 8;
diff --git a/Marlin/Sd2Card.h b/Marlin/Sd2Card.h
index d6b302bfed..658f0dff2e 100644
--- a/Marlin/Sd2Card.h
+++ b/Marlin/Sd2Card.h
@@ -19,7 +19,7 @@
  */
 
 #include "Marlin.h"
-#ifdef SDSUPPORT
+#if ENABLED(SDSUPPORT)
 
 #ifndef Sd2Card_h
 #define Sd2Card_h
@@ -125,7 +125,7 @@ uint8_t const SD_CARD_TYPE_SDHC = 3;
 //------------------------------------------------------------------------------
 // SPI pin definitions - do not edit here - change in SdFatConfig.h
 //
-#ifndef SOFTWARE_SPI
+#if DISABLED(SOFTWARE_SPI)
 // hardware pin defs
 /** The default chip select pin for the SD card is SS. */
 uint8_t const  SD_CHIP_SELECT_PIN = SS_PIN;
diff --git a/Marlin/Sd2PinMap.h b/Marlin/Sd2PinMap.h
index 80f5185f5c..f7838827cb 100644
--- a/Marlin/Sd2PinMap.h
+++ b/Marlin/Sd2PinMap.h
@@ -21,7 +21,7 @@
 #include "Marlin.h"
 #include "macros.h"
 
-#ifdef SDSUPPORT
+#if ENABLED(SDSUPPORT)
 
 #ifndef Sd2PinMap_h
 #define Sd2PinMap_h
diff --git a/Marlin/SdBaseFile.cpp b/Marlin/SdBaseFile.cpp
index f92f48e148..06bf5468d4 100644
--- a/Marlin/SdBaseFile.cpp
+++ b/Marlin/SdBaseFile.cpp
@@ -19,7 +19,7 @@
  */
 
 #include "Marlin.h"
-#ifdef SDSUPPORT
+#if ENABLED(SDSUPPORT)
 
 #include "SdBaseFile.h"
 //------------------------------------------------------------------------------
diff --git a/Marlin/SdBaseFile.h b/Marlin/SdBaseFile.h
index dea299a646..4a49ecfd1c 100644
--- a/Marlin/SdBaseFile.h
+++ b/Marlin/SdBaseFile.h
@@ -18,7 +18,7 @@
  * <http://www.gnu.org/licenses/>.
  */
 #include "Marlin.h"
-#ifdef SDSUPPORT
+#if ENABLED(SDSUPPORT)
 
 #ifndef SdBaseFile_h
 #define SdBaseFile_h
diff --git a/Marlin/SdFatConfig.h b/Marlin/SdFatConfig.h
index a549835f70..2c795451ca 100644
--- a/Marlin/SdFatConfig.h
+++ b/Marlin/SdFatConfig.h
@@ -22,7 +22,7 @@
  * \brief configuration definitions
  */
 #include "Marlin.h"
-#ifdef SDSUPPORT
+#if ENABLED(SDSUPPORT)
 
 #ifndef SdFatConfig_h
 #define SdFatConfig_h
diff --git a/Marlin/SdFatStructs.h b/Marlin/SdFatStructs.h
index 3867216160..c97090a054 100644
--- a/Marlin/SdFatStructs.h
+++ b/Marlin/SdFatStructs.h
@@ -18,7 +18,7 @@
  * <http://www.gnu.org/licenses/>.
  */
 #include "Marlin.h"
-#ifdef SDSUPPORT
+#if ENABLED(SDSUPPORT)
 
 #ifndef SdFatStructs_h
 #define SdFatStructs_h
diff --git a/Marlin/SdFatUtil.cpp b/Marlin/SdFatUtil.cpp
index 32cd198b66..e32ae1d1f7 100644
--- a/Marlin/SdFatUtil.cpp
+++ b/Marlin/SdFatUtil.cpp
@@ -19,7 +19,7 @@
  */
 #include "Marlin.h"
 
-#ifdef SDSUPPORT
+#if ENABLED(SDSUPPORT)
 #include "SdFatUtil.h"
 
 //------------------------------------------------------------------------------
diff --git a/Marlin/SdFatUtil.h b/Marlin/SdFatUtil.h
index 7f1809422b..ac004cf7d0 100644
--- a/Marlin/SdFatUtil.h
+++ b/Marlin/SdFatUtil.h
@@ -18,7 +18,7 @@
  * <http://www.gnu.org/licenses/>.
  */
 #include "Marlin.h"
-#ifdef SDSUPPORT
+#if ENABLED(SDSUPPORT)
 
 #ifndef SdFatUtil_h
 #define SdFatUtil_h
diff --git a/Marlin/SdFile.cpp b/Marlin/SdFile.cpp
index 29f5efadc1..66652a7f6b 100644
--- a/Marlin/SdFile.cpp
+++ b/Marlin/SdFile.cpp
@@ -19,7 +19,7 @@
  */
 #include "Marlin.h"
 
-#ifdef SDSUPPORT
+#if ENABLED(SDSUPPORT)
 #include "SdFile.h"
 /**  Create a file object and open it in the current working directory.
  *
diff --git a/Marlin/SdFile.h b/Marlin/SdFile.h
index cbf1bbdbd9..0e1a6ad2b3 100644
--- a/Marlin/SdFile.h
+++ b/Marlin/SdFile.h
@@ -23,7 +23,7 @@
  */
 #include "Marlin.h"
 
-#ifdef SDSUPPORT
+#if ENABLED(SDSUPPORT)
 #include "SdBaseFile.h"
 #include <Print.h>
 #ifndef SdFile_h
diff --git a/Marlin/SdInfo.h b/Marlin/SdInfo.h
index 03ece10224..da7b0643ec 100644
--- a/Marlin/SdInfo.h
+++ b/Marlin/SdInfo.h
@@ -18,7 +18,7 @@
  * <http://www.gnu.org/licenses/>.
  */
 #include "Marlin.h"
-#ifdef SDSUPPORT
+#if ENABLED(SDSUPPORT)
 
 #ifndef SdInfo_h
 #define SdInfo_h
diff --git a/Marlin/SdVolume.cpp b/Marlin/SdVolume.cpp
index 6297e2a7bd..4a6d1a402b 100644
--- a/Marlin/SdVolume.cpp
+++ b/Marlin/SdVolume.cpp
@@ -18,7 +18,7 @@
  * <http://www.gnu.org/licenses/>.
  */
 #include "Marlin.h"
-#ifdef SDSUPPORT
+#if ENABLED(SDSUPPORT)
 
 #include "SdVolume.h"
 //------------------------------------------------------------------------------
diff --git a/Marlin/SdVolume.h b/Marlin/SdVolume.h
index 2ff2b6eb96..5cf83110e6 100644
--- a/Marlin/SdVolume.h
+++ b/Marlin/SdVolume.h
@@ -18,7 +18,7 @@
  * <http://www.gnu.org/licenses/>.
  */
 #include "Marlin.h"
-#ifdef SDSUPPORT
+#if ENABLED(SDSUPPORT)
 #ifndef SdVolume_h
 #define SdVolume_h
 /**
diff --git a/Marlin/blinkm.cpp b/Marlin/blinkm.cpp
index 1ec5b656cc..fec88dca40 100644
--- a/Marlin/blinkm.cpp
+++ b/Marlin/blinkm.cpp
@@ -3,7 +3,8 @@
   Created by Tim Koster, August 21 2013.
 */
 #include "Marlin.h"
-#ifdef BLINKM
+
+#if ENABLED(BLINKM)
 
 #include "blinkm.h"
 
diff --git a/Marlin/buzzer.cpp b/Marlin/buzzer.cpp
index fcbca2a8bd..fd3d161ab5 100644
--- a/Marlin/buzzer.cpp
+++ b/Marlin/buzzer.cpp
@@ -5,9 +5,9 @@
 #if HAS_BUZZER
   void buzz(long duration, uint16_t freq) {
     if (freq > 0) {
-      #ifdef LCD_USE_I2C_BUZZER
+      #if ENABLED(LCD_USE_I2C_BUZZER)
         lcd_buzz(duration, freq);
-      #elif defined(BEEPER) && BEEPER >= 0 // on-board buzzers have no further condition
+      #elif HAS_BUZZER // on-board buzzers have no further condition
         SET_OUTPUT(BEEPER);
         #ifdef SPEAKER // a speaker needs a AC ore a pulsed DC
           //tone(BEEPER, freq, duration); // needs a PWMable pin
diff --git a/Marlin/cardreader.cpp b/Marlin/cardreader.cpp
index 12d2a5da3b..8bb22c8a2f 100644
--- a/Marlin/cardreader.cpp
+++ b/Marlin/cardreader.cpp
@@ -5,7 +5,7 @@
 #include "temperature.h"
 #include "language.h"
 
-#ifdef SDSUPPORT
+#if ENABLED(SDSUPPORT)
 
 CardReader::CardReader() {
   filesize = 0;
@@ -128,7 +128,7 @@ void CardReader::ls()  {
   lsDive("", root);
 }
 
-#ifdef LONG_FILENAME_HOST_SUPPORT
+#if ENABLED(LONG_FILENAME_HOST_SUPPORT)
 
   /**
    * Get a long pretty path based on a DOS 8.3 path
@@ -195,7 +195,7 @@ void CardReader::initsd() {
   cardOK = false;
   if (root.isOpen()) root.close();
 
-  #ifdef SDSLOW
+  #if ENABLED(SDSLOW)
     #define SPI_SPEED SPI_HALF_SPEED
   #else
     #define SPI_SPEED SPI_FULL_SPEED
diff --git a/Marlin/cardreader.h b/Marlin/cardreader.h
index 4b0b6e44cc..2d4029e47c 100644
--- a/Marlin/cardreader.h
+++ b/Marlin/cardreader.h
@@ -1,7 +1,7 @@
 #ifndef CARDREADER_H
 #define CARDREADER_H
 
-#ifdef SDSUPPORT
+#if ENABLED(SDSUPPORT)
 
 #define MAX_DIR_DEPTH 10          // Maximum folder depth
 
@@ -28,7 +28,7 @@ public:
   void getStatus();
   void printingHasFinished();
 
-  #ifdef LONG_FILENAME_HOST_SUPPORT
+  #if ENABLED(LONG_FILENAME_HOST_SUPPORT)
     void printLongPath(char *path);
   #endif
 
@@ -82,7 +82,7 @@ extern CardReader card;
 #define IS_SD_PRINTING (card.sdprinting)
 
 #if (SDCARDDETECT > -1)
-  #ifdef SDCARDDETECTINVERTED
+  #if ENABLED(SDCARDDETECTINVERTED)
     #define IS_SD_INSERTED (READ(SDCARDDETECT) != 0)
   #else
     #define IS_SD_INSERTED (READ(SDCARDDETECT) == 0)
diff --git a/Marlin/configurator/config/language.h b/Marlin/configurator/config/language.h
index 2c3f9d240d..a13b69e3df 100644
--- a/Marlin/configurator/config/language.h
+++ b/Marlin/configurator/config/language.h
@@ -37,7 +37,7 @@
   #define LANGUAGE_INCLUDE GENERATE_LANGUAGE_INCLUDE(en)
 #endif
 
-#ifdef HAS_AUTOMATIC_VERSIONING
+#if ENABLED(HAS_AUTOMATIC_VERSIONING)
   #include "_Version.h"
 #endif
 
@@ -216,7 +216,7 @@
 
 // LCD Menu Messages
 
-#if !(defined( DISPLAY_CHARSET_HD44780_JAPAN ) || defined( DISPLAY_CHARSET_HD44780_WESTERN ) || defined( DISPLAY_CHARSET_HD44780_CYRILLIC ))
+#if DISABLED(DISPLAY_CHARSET_HD44780_JAPAN) && DISABLED(DISPLAY_CHARSET_HD44780_WESTERN) && DISABLED(DISPLAY_CHARSET_HD44780_CYRILLIC)
   #define DISPLAY_CHARSET_HD44780_JAPAN
 #endif
 
diff --git a/Marlin/digipot_mcp4451.cpp b/Marlin/digipot_mcp4451.cpp
index f9d6013d29..60ba699178 100644
--- a/Marlin/digipot_mcp4451.cpp
+++ b/Marlin/digipot_mcp4451.cpp
@@ -1,6 +1,6 @@
 #include "Configuration.h"
 
-#ifdef DIGIPOT_I2C
+#if ENABLED(DIGIPOT_I2C)
 
 #include "Stream.h"
 #include "utility/twi.h"
diff --git a/Marlin/dogm_bitmaps.h b/Marlin/dogm_bitmaps.h
index 8c8356785a..2f5985baed 100644
--- a/Marlin/dogm_bitmaps.h
+++ b/Marlin/dogm_bitmaps.h
@@ -3,7 +3,7 @@
 // Please note that using the high-res version takes 402Bytes of PROGMEM. 
 //#define START_BMPHIGH
 
-#ifdef START_BMPHIGH
+#if ENABLED(START_BMPHIGH)
   #define START_BMPWIDTH      112
   #define START_BMPHEIGHT      38
   #define START_BMPBYTEWIDTH   14
diff --git a/Marlin/mesh_bed_leveling.cpp b/Marlin/mesh_bed_leveling.cpp
index a48a6e6195..0946e7a3f1 100644
--- a/Marlin/mesh_bed_leveling.cpp
+++ b/Marlin/mesh_bed_leveling.cpp
@@ -1,6 +1,6 @@
 #include "mesh_bed_leveling.h"
 
-#ifdef MESH_BED_LEVELING
+#if ENABLED(MESH_BED_LEVELING)
 
   mesh_bed_leveling mbl;
 
diff --git a/Marlin/mesh_bed_leveling.h b/Marlin/mesh_bed_leveling.h
index bf7275e5c3..86a1ecd7bd 100644
--- a/Marlin/mesh_bed_leveling.h
+++ b/Marlin/mesh_bed_leveling.h
@@ -1,6 +1,6 @@
 #include "Marlin.h"
 
-#ifdef MESH_BED_LEVELING
+#if ENABLED(MESH_BED_LEVELING)
 
   #define MESH_X_DIST ((MESH_MAX_X - MESH_MIN_X)/(MESH_NUM_X_POINTS - 1))
   #define MESH_Y_DIST ((MESH_MAX_Y - MESH_MIN_Y)/(MESH_NUM_Y_POINTS - 1))
diff --git a/Marlin/qr_solve.cpp b/Marlin/qr_solve.cpp
index 45f0541824..ea22b56b7c 100644
--- a/Marlin/qr_solve.cpp
+++ b/Marlin/qr_solve.cpp
@@ -1,6 +1,6 @@
 #include "qr_solve.h"
 
-#ifdef AUTO_BED_LEVELING_GRID
+#if ENABLED(AUTO_BED_LEVELING_GRID)
 
 #include <stdlib.h>
 #include <math.h>
diff --git a/Marlin/qr_solve.h b/Marlin/qr_solve.h
index 2ec8a8ea9e..31673b7b20 100644
--- a/Marlin/qr_solve.h
+++ b/Marlin/qr_solve.h
@@ -1,6 +1,6 @@
 #include "Configuration.h"
 
-#ifdef AUTO_BED_LEVELING_GRID
+#if ENABLED(AUTO_BED_LEVELING_GRID)
 
 void daxpy ( int n, double da, double dx[], int incx, double dy[], int incy );
 double ddot ( int n, double dx[], int incx, double dy[], int incy );
diff --git a/Marlin/servo.cpp b/Marlin/servo.cpp
index 718ae388ff..f259891d2d 100644
--- a/Marlin/servo.cpp
+++ b/Marlin/servo.cpp
@@ -42,10 +42,10 @@
  attached()  - Returns true if there is a servo attached.
  detach()    - Stops an attached servos from pulsing its i/o pin.
 
- */
+*/
 #include "Configuration.h" 
 
-#ifdef NUM_SERVOS
+#if HAS_SERVOS
 
 #include <avr/interrupt.h>
 #include <Arduino.h>
@@ -103,29 +103,29 @@ static inline void handle_interrupts(timer16_Sequence_t timer, volatile uint16_t
 #ifndef WIRING // Wiring pre-defines signal handlers so don't define any if compiling for the Wiring platform
 
   // Interrupt handlers for Arduino
-  #ifdef _useTimer1
+  #if ENABLED(_useTimer1)
     SIGNAL (TIMER1_COMPA_vect) { handle_interrupts(_timer1, &TCNT1, &OCR1A); }
   #endif
 
-  #ifdef _useTimer3
+  #if ENABLED(_useTimer3)
     SIGNAL (TIMER3_COMPA_vect) { handle_interrupts(_timer3, &TCNT3, &OCR3A); }
   #endif
 
-  #ifdef _useTimer4
+  #if ENABLED(_useTimer4)
     SIGNAL (TIMER4_COMPA_vect) { handle_interrupts(_timer4, &TCNT4, &OCR4A); }
   #endif
 
-  #ifdef _useTimer5
+  #if ENABLED(_useTimer5)
     SIGNAL (TIMER5_COMPA_vect) { handle_interrupts(_timer5, &TCNT5, &OCR5A); }
   #endif
 
 #else //!WIRING
 
   // Interrupt handlers for Wiring
-  #ifdef _useTimer1
+  #if ENABLED(_useTimer1)
     void Timer1Service() { handle_interrupts(_timer1, &TCNT1, &OCR1A); }
   #endif
-  #ifdef _useTimer3
+  #if ENABLED(_useTimer3)
     void Timer3Service() { handle_interrupts(_timer3, &TCNT3, &OCR3A); }
   #endif
 
@@ -133,7 +133,7 @@ static inline void handle_interrupts(timer16_Sequence_t timer, volatile uint16_t
 
 
 static void initISR(timer16_Sequence_t timer) {
-  #ifdef _useTimer1
+  #if ENABLED(_useTimer1)
     if (timer == _timer1) {
       TCCR1A = 0;             // normal counting mode
       TCCR1B = _BV(CS11);     // set prescaler of 8
@@ -152,7 +152,7 @@ static void initISR(timer16_Sequence_t timer) {
     }
   #endif
 
-  #ifdef _useTimer3
+  #if ENABLED(_useTimer3)
     if (timer == _timer3) {
       TCCR3A = 0;             // normal counting mode
       TCCR3B = _BV(CS31);     // set prescaler of 8
@@ -170,7 +170,7 @@ static void initISR(timer16_Sequence_t timer) {
     }
   #endif
 
-  #ifdef _useTimer4
+  #if ENABLED(_useTimer4)
     if (timer == _timer4) {
       TCCR4A = 0;             // normal counting mode
       TCCR4B = _BV(CS41);     // set prescaler of 8
@@ -180,7 +180,7 @@ static void initISR(timer16_Sequence_t timer) {
     }
   #endif
 
-  #ifdef _useTimer5
+  #if ENABLED(_useTimer5)
     if (timer == _timer5) {
       TCCR5A = 0;             // normal counting mode
       TCCR5B = _BV(CS51);     // set prescaler of 8
diff --git a/Marlin/ultralcd_st7920_u8glib_rrd.h b/Marlin/ultralcd_st7920_u8glib_rrd.h
index 3181ea2657..66fb9b2ca7 100644
--- a/Marlin/ultralcd_st7920_u8glib_rrd.h
+++ b/Marlin/ultralcd_st7920_u8glib_rrd.h
@@ -3,7 +3,7 @@
 
 #include "Marlin.h"
 
-#ifdef U8GLIB_ST7920
+#if ENABLED(U8GLIB_ST7920)
 
 //set optimization so ARDUINO optimizes this file
 #pragma GCC optimize (3)
diff --git a/Marlin/vector_3.cpp b/Marlin/vector_3.cpp
index 9eb3465fbf..525480be33 100644
--- a/Marlin/vector_3.cpp
+++ b/Marlin/vector_3.cpp
@@ -19,7 +19,7 @@
 #include <math.h>
 #include "Marlin.h"
 
-#ifdef ENABLE_AUTO_BED_LEVELING
+#if ENABLED(ENABLE_AUTO_BED_LEVELING)
 #include "vector_3.h"
 
 vector_3::vector_3() : x(0), y(0), z(0) { }
diff --git a/Marlin/vector_3.h b/Marlin/vector_3.h
index 0c5938bac9..1c91e8b347 100644
--- a/Marlin/vector_3.h
+++ b/Marlin/vector_3.h
@@ -19,7 +19,7 @@
 #ifndef VECTOR_3_H
 #define VECTOR_3_H
 
-#ifdef ENABLE_AUTO_BED_LEVELING
+#if ENABLED(ENABLE_AUTO_BED_LEVELING)
 class matrix_3x3;
 
 struct vector_3
diff --git a/Marlin/watchdog.cpp b/Marlin/watchdog.cpp
index d9127c54f8..961a6d1169 100644
--- a/Marlin/watchdog.cpp
+++ b/Marlin/watchdog.cpp
@@ -1,6 +1,6 @@
 #include "Marlin.h"
 
-#ifdef USE_WATCHDOG
+#if ENABLED(USE_WATCHDOG)
 #include <avr/wdt.h>
 
 #include "watchdog.h"
@@ -18,15 +18,15 @@
 /// intialise watch dog with a 4 sec interrupt time
 void watchdog_init()
 {
-#ifdef WATCHDOG_RESET_MANUAL
+  #if ENABLED(WATCHDOG_RESET_MANUAL)
     //We enable the watchdog timer, but only for the interrupt.
     //Take care, as this requires the correct order of operation, with interrupts disabled. See the datasheet of any AVR chip for details.
     wdt_reset();
     _WD_CONTROL_REG = _BV(_WD_CHANGE_BIT) | _BV(WDE);
     _WD_CONTROL_REG = _BV(WDIE) | WDTO_4S;
-#else
+  #else
     wdt_enable(WDTO_4S);
-#endif
+  #endif
 }
 
 /// reset watchdog. MUST be called every 1s after init or avr will reset.
@@ -40,7 +40,7 @@ void watchdog_reset()
 //===========================================================================
 
 //Watchdog timer interrupt, called if main program blocks >1sec and manual reset is enabled.
-#ifdef WATCHDOG_RESET_MANUAL
+#if ENABLED(WATCHDOG_RESET_MANUAL)
 ISR(WDT_vect)
 { 
     SERIAL_ERROR_START;
diff --git a/Marlin/watchdog.h b/Marlin/watchdog.h
index a73f3a8463..6416f13dec 100644
--- a/Marlin/watchdog.h
+++ b/Marlin/watchdog.h
@@ -3,7 +3,7 @@
 
 #include "Marlin.h"
 
-#ifdef USE_WATCHDOG
+#if ENABLED(USE_WATCHDOG)
   // initialize watch dog with a 1 sec interrupt time
   void watchdog_init();
   // pad the dog/reset watchdog. MUST be called at least every second after the first watchdog_init or AVR will go into emergency procedures..
-- 
GitLab