From d6d2cdea929905e11c8655e3bba4d863dff11333 Mon Sep 17 00:00:00 2001 From: cyberman54 Date: Tue, 22 Feb 2022 13:11:46 +0100 Subject: [PATCH] cleanup #ifdefs in .h files --- include/bmesensor.h | 4 ++++ include/dcf77.h | 4 ++++ include/gpsread.h | 4 ++++ include/if482.h | 4 ++++ include/ledmatrixdisplay.h | 4 ++++ include/mqttclient.h | 4 ++++ include/power.h | 3 --- include/rtctime.h | 4 ++++ include/sdcard.h | 6 ++++-- include/sds011read.h | 7 ++++++- include/spislave.h | 4 ++++ src/rtctime.cpp | 4 ++-- 12 files changed, 44 insertions(+), 8 deletions(-) diff --git a/include/bmesensor.h b/include/bmesensor.h index 5724db84..a038994e 100644 --- a/include/bmesensor.h +++ b/include/bmesensor.h @@ -1,6 +1,8 @@ #ifndef _BMESENSOR_H #define _BMESENSOR_H +#if (HAS_BME) + #include #include "globals.h" @@ -53,4 +55,6 @@ int checkIaqSensorStatus(void); void loadState(void); void updateState(void); +#endif + #endif \ No newline at end of file diff --git a/include/dcf77.h b/include/dcf77.h index df9400e9..6844c1b7 100644 --- a/include/dcf77.h +++ b/include/dcf77.h @@ -1,6 +1,8 @@ #ifndef _DCF77_H #define _DCF77_H +#ifdef HAS_DCF77 + #include "globals.h" #include "timekeeper.h" @@ -15,4 +17,6 @@ enum dcf_pinstate { dcf_low, dcf_high }; void DCF77_Pulse(uint8_t bit); uint64_t DCF77_Frame(const struct tm t); +#endif + #endif \ No newline at end of file diff --git a/include/gpsread.h b/include/gpsread.h index 95cd1afa..6eae7bb7 100644 --- a/include/gpsread.h +++ b/include/gpsread.h @@ -1,6 +1,8 @@ #ifndef _GPSREAD_H #define _GPSREAD_H +#if (HAS_GPS) + #include // library for parsing NMEA data #include #include "timekeeper.h" @@ -19,4 +21,6 @@ void gps_storelocation(gpsStatus_t *gps_store); void gps_loop(void *pvParameters); time_t get_gpstime(uint16_t *msec); +#endif + #endif \ No newline at end of file diff --git a/include/if482.h b/include/if482.h index 9a3fe92f..4efdbd3f 100644 --- a/include/if482.h +++ b/include/if482.h @@ -1,6 +1,8 @@ #ifndef _IF482_H #define _IF482_H +#ifdef HAS_IF482 + #include "globals.h" #include "timekeeper.h" #include "esp_sntp.h" @@ -10,4 +12,6 @@ String IF482_Frame(time_t t); +#endif + #endif \ No newline at end of file diff --git a/include/ledmatrixdisplay.h b/include/ledmatrixdisplay.h index b27914c1..57b323c0 100644 --- a/include/ledmatrixdisplay.h +++ b/include/ledmatrixdisplay.h @@ -1,6 +1,8 @@ #ifndef _MATRIX_DISPLAY_H #define _MATRIX_DISPLAY_H +#ifdef HAS_MATRIX_DISPLAY + #include "LEDMatrix.h" #include "ledmatrixfonts.h" #include "ledmatrixdisplay.h" @@ -16,4 +18,6 @@ uint8_t GetCharFromFont(char cChar); uint8_t GetCharWidth(char cChar); void ScrollMatrixLeft(uint8_t *buf, const uint16_t cols, const uint16_t rows); +#endif + #endif \ No newline at end of file diff --git a/include/mqttclient.h b/include/mqttclient.h index 6151dd52..cfdad89f 100644 --- a/include/mqttclient.h +++ b/include/mqttclient.h @@ -1,6 +1,8 @@ #ifndef _MQTTCLIENT_H #define _MQTTCLIENT_H +#ifdef HAS_MQTT + #include "globals.h" #include "rcommand.h" #include "hash.h" @@ -24,4 +26,6 @@ void NetworkEvent(WiFiEvent_t event); esp_err_t mqtt_init(void); void mqtt_deinit(void); +#endif + #endif // _MQTTCLIENT_H \ No newline at end of file diff --git a/include/power.h b/include/power.h index 0e123c98..24f6fb67 100644 --- a/include/power.h +++ b/include/power.h @@ -3,7 +3,6 @@ #include #include -//include #include #include "i2c.h" @@ -56,7 +55,6 @@ void calibrate_voltage(void); bool batt_sufficient(void); #ifdef HAS_PMU - #include extern AXP20X_Class pmu; enum pmu_power_t { pmu_power_on, pmu_power_off, pmu_power_sleep }; @@ -64,7 +62,6 @@ void AXP192_powerevent_IRQ(void); void AXP192_power(pmu_power_t powerlevel); void AXP192_init(void); void AXP192_showstatus(void); - #endif // HAS_PMU #ifdef HAS_IP5306 diff --git a/include/rtctime.h b/include/rtctime.h index 3f75eb37..802b06ee 100644 --- a/include/rtctime.h +++ b/include/rtctime.h @@ -1,6 +1,8 @@ #ifndef _RTCTIME_H #define _RTCTIME_H +#ifdef HAS_RTC + #include // must be included here so that Arduino library object file references work #include @@ -15,4 +17,6 @@ void sync_rtctime(void); time_t get_rtctime(uint16_t *msec); float get_rtctemp(void); +#endif + #endif // _RTCTIME_H \ No newline at end of file diff --git a/include/sdcard.h b/include/sdcard.h index 25fcf2c4..1c9eb3d7 100644 --- a/include/sdcard.h +++ b/include/sdcard.h @@ -1,11 +1,12 @@ #ifndef _SDCARD_H #define _SDCARD_H +#if (HAS_SDCARD) + #include "globals.h" #include #include -#if (HAS_SDCARD) #if HAS_SDCARD == 1 #include #elif HAS_SDCARD == 2 @@ -13,7 +14,6 @@ #else #error HAS_SDCARD unknown card reader value, must be either 1 or 2 #endif -#endif #ifdef HAS_SDS011 #include "sds011read.h" @@ -65,4 +65,6 @@ bool sdcard_init(bool create = true); void sdcard_close(void); void sdcardWriteData(uint16_t, uint16_t, uint16_t = 0); +#endif + #endif // _SDCARD_H diff --git a/include/sds011read.h b/include/sds011read.h index f1b874d3..6345a267 100644 --- a/include/sds011read.h +++ b/include/sds011read.h @@ -1,10 +1,12 @@ #ifndef _SDS011READ_H #define _SDS011READ_H +#if (HAS_SDS011) + #include #include "globals.h" -#define SDCARD_FILE_HEADER_SDS011 ", PM10,PM25" +#define SDCARD_FILE_HEADER_SDS011 ", PM10,PM25" // use original pins from HardwareSerial if none defined #ifndef SDS_TX @@ -21,4 +23,7 @@ void sds011_loop(); void sds011_sleep(void); void sds011_wakeup(void); void sds011_store(sdsStatus_t *sds_store); + +#endif + #endif // _SDS011READ_H diff --git a/include/spislave.h b/include/spislave.h index 78b7a737..389aa573 100644 --- a/include/spislave.h +++ b/include/spislave.h @@ -24,6 +24,8 @@ licenses. Refer to LICENSE.txt file in repository for more details. #ifndef _SPISLAVE_H #define _SPISLAVE_H +#ifdef HAS_SPI + #include "globals.h" #include "rcommand.h" @@ -35,4 +37,6 @@ void spi_enqueuedata(MessageBuffer_t *message); uint32_t spi_queuewaiting(void); void spi_queuereset(void); +#endif + #endif // _SPISLAVE_H diff --git a/src/rtctime.cpp b/src/rtctime.cpp index eb25698d..9b12cd94 100644 --- a/src/rtctime.cpp +++ b/src/rtctime.cpp @@ -1,10 +1,10 @@ +#ifdef HAS_RTC // we have hardware RTC + #include "rtctime.h" // Local logging tag static const char TAG[] = __FILE__; -#ifdef HAS_RTC // we have hardware RTC - RtcDS3231 Rtc(Wire); // RTC hardware i2c interface // initialize RTC