cleanup #ifdefs in .h files

This commit is contained in:
cyberman54 2022-02-22 13:11:46 +01:00
parent 33ee8a4b50
commit d6d2cdea92
12 changed files with 44 additions and 8 deletions

View File

@ -1,6 +1,8 @@
#ifndef _BMESENSOR_H #ifndef _BMESENSOR_H
#define _BMESENSOR_H #define _BMESENSOR_H
#if (HAS_BME)
#include <Wire.h> #include <Wire.h>
#include "globals.h" #include "globals.h"
@ -53,4 +55,6 @@ int checkIaqSensorStatus(void);
void loadState(void); void loadState(void);
void updateState(void); void updateState(void);
#endif
#endif #endif

View File

@ -1,6 +1,8 @@
#ifndef _DCF77_H #ifndef _DCF77_H
#define _DCF77_H #define _DCF77_H
#ifdef HAS_DCF77
#include "globals.h" #include "globals.h"
#include "timekeeper.h" #include "timekeeper.h"
@ -15,4 +17,6 @@ enum dcf_pinstate { dcf_low, dcf_high };
void DCF77_Pulse(uint8_t bit); void DCF77_Pulse(uint8_t bit);
uint64_t DCF77_Frame(const struct tm t); uint64_t DCF77_Frame(const struct tm t);
#endif
#endif #endif

View File

@ -1,6 +1,8 @@
#ifndef _GPSREAD_H #ifndef _GPSREAD_H
#define _GPSREAD_H #define _GPSREAD_H
#if (HAS_GPS)
#include <TinyGPS++.h> // library for parsing NMEA data #include <TinyGPS++.h> // library for parsing NMEA data
#include <RtcDateTime.h> #include <RtcDateTime.h>
#include "timekeeper.h" #include "timekeeper.h"
@ -19,4 +21,6 @@ void gps_storelocation(gpsStatus_t *gps_store);
void gps_loop(void *pvParameters); void gps_loop(void *pvParameters);
time_t get_gpstime(uint16_t *msec); time_t get_gpstime(uint16_t *msec);
#endif
#endif #endif

View File

@ -1,6 +1,8 @@
#ifndef _IF482_H #ifndef _IF482_H
#define _IF482_H #define _IF482_H
#ifdef HAS_IF482
#include "globals.h" #include "globals.h"
#include "timekeeper.h" #include "timekeeper.h"
#include "esp_sntp.h" #include "esp_sntp.h"
@ -10,4 +12,6 @@
String IF482_Frame(time_t t); String IF482_Frame(time_t t);
#endif
#endif #endif

View File

@ -1,6 +1,8 @@
#ifndef _MATRIX_DISPLAY_H #ifndef _MATRIX_DISPLAY_H
#define _MATRIX_DISPLAY_H #define _MATRIX_DISPLAY_H
#ifdef HAS_MATRIX_DISPLAY
#include "LEDMatrix.h" #include "LEDMatrix.h"
#include "ledmatrixfonts.h" #include "ledmatrixfonts.h"
#include "ledmatrixdisplay.h" #include "ledmatrixdisplay.h"
@ -16,4 +18,6 @@ uint8_t GetCharFromFont(char cChar);
uint8_t GetCharWidth(char cChar); uint8_t GetCharWidth(char cChar);
void ScrollMatrixLeft(uint8_t *buf, const uint16_t cols, const uint16_t rows); void ScrollMatrixLeft(uint8_t *buf, const uint16_t cols, const uint16_t rows);
#endif
#endif #endif

View File

@ -1,6 +1,8 @@
#ifndef _MQTTCLIENT_H #ifndef _MQTTCLIENT_H
#define _MQTTCLIENT_H #define _MQTTCLIENT_H
#ifdef HAS_MQTT
#include "globals.h" #include "globals.h"
#include "rcommand.h" #include "rcommand.h"
#include "hash.h" #include "hash.h"
@ -24,4 +26,6 @@ void NetworkEvent(WiFiEvent_t event);
esp_err_t mqtt_init(void); esp_err_t mqtt_init(void);
void mqtt_deinit(void); void mqtt_deinit(void);
#endif
#endif // _MQTTCLIENT_H #endif // _MQTTCLIENT_H

View File

@ -3,7 +3,6 @@
#include <Arduino.h> #include <Arduino.h>
#include <esp_adc_cal.h> #include <esp_adc_cal.h>
//include <esp32-hal-adc.h>
#include <soc/adc_channel.h> #include <soc/adc_channel.h>
#include "i2c.h" #include "i2c.h"
@ -56,7 +55,6 @@ void calibrate_voltage(void);
bool batt_sufficient(void); bool batt_sufficient(void);
#ifdef HAS_PMU #ifdef HAS_PMU
#include <axp20x.h> #include <axp20x.h>
extern AXP20X_Class pmu; extern AXP20X_Class pmu;
enum pmu_power_t { pmu_power_on, pmu_power_off, pmu_power_sleep }; 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_power(pmu_power_t powerlevel);
void AXP192_init(void); void AXP192_init(void);
void AXP192_showstatus(void); void AXP192_showstatus(void);
#endif // HAS_PMU #endif // HAS_PMU
#ifdef HAS_IP5306 #ifdef HAS_IP5306

View File

@ -1,6 +1,8 @@
#ifndef _RTCTIME_H #ifndef _RTCTIME_H
#define _RTCTIME_H #define _RTCTIME_H
#ifdef HAS_RTC
#include <Wire.h> // must be included here so that Arduino library object file references work #include <Wire.h> // must be included here so that Arduino library object file references work
#include <RtcDS3231.h> #include <RtcDS3231.h>
@ -15,4 +17,6 @@ void sync_rtctime(void);
time_t get_rtctime(uint16_t *msec); time_t get_rtctime(uint16_t *msec);
float get_rtctemp(void); float get_rtctemp(void);
#endif
#endif // _RTCTIME_H #endif // _RTCTIME_H

View File

@ -1,11 +1,12 @@
#ifndef _SDCARD_H #ifndef _SDCARD_H
#define _SDCARD_H #define _SDCARD_H
#if (HAS_SDCARD)
#include "globals.h" #include "globals.h"
#include <stdio.h> #include <stdio.h>
#include <SPI.h> #include <SPI.h>
#if (HAS_SDCARD)
#if HAS_SDCARD == 1 #if HAS_SDCARD == 1
#include <SD.h> #include <SD.h>
#elif HAS_SDCARD == 2 #elif HAS_SDCARD == 2
@ -13,7 +14,6 @@
#else #else
#error HAS_SDCARD unknown card reader value, must be either 1 or 2 #error HAS_SDCARD unknown card reader value, must be either 1 or 2
#endif #endif
#endif
#ifdef HAS_SDS011 #ifdef HAS_SDS011
#include "sds011read.h" #include "sds011read.h"
@ -65,4 +65,6 @@ bool sdcard_init(bool create = true);
void sdcard_close(void); void sdcard_close(void);
void sdcardWriteData(uint16_t, uint16_t, uint16_t = 0); void sdcardWriteData(uint16_t, uint16_t, uint16_t = 0);
#endif
#endif // _SDCARD_H #endif // _SDCARD_H

View File

@ -1,10 +1,12 @@
#ifndef _SDS011READ_H #ifndef _SDS011READ_H
#define _SDS011READ_H #define _SDS011READ_H
#if (HAS_SDS011)
#include <SdsDustSensor.h> #include <SdsDustSensor.h>
#include "globals.h" #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 // use original pins from HardwareSerial if none defined
#ifndef SDS_TX #ifndef SDS_TX
@ -21,4 +23,7 @@ void sds011_loop();
void sds011_sleep(void); void sds011_sleep(void);
void sds011_wakeup(void); void sds011_wakeup(void);
void sds011_store(sdsStatus_t *sds_store); void sds011_store(sdsStatus_t *sds_store);
#endif
#endif // _SDS011READ_H #endif // _SDS011READ_H

View File

@ -24,6 +24,8 @@ licenses. Refer to LICENSE.txt file in repository for more details.
#ifndef _SPISLAVE_H #ifndef _SPISLAVE_H
#define _SPISLAVE_H #define _SPISLAVE_H
#ifdef HAS_SPI
#include "globals.h" #include "globals.h"
#include "rcommand.h" #include "rcommand.h"
@ -35,4 +37,6 @@ void spi_enqueuedata(MessageBuffer_t *message);
uint32_t spi_queuewaiting(void); uint32_t spi_queuewaiting(void);
void spi_queuereset(void); void spi_queuereset(void);
#endif
#endif // _SPISLAVE_H #endif // _SPISLAVE_H

View File

@ -1,10 +1,10 @@
#ifdef HAS_RTC // we have hardware RTC
#include "rtctime.h" #include "rtctime.h"
// Local logging tag // Local logging tag
static const char TAG[] = __FILE__; static const char TAG[] = __FILE__;
#ifdef HAS_RTC // we have hardware RTC
RtcDS3231<TwoWire> Rtc(Wire); // RTC hardware i2c interface RtcDS3231<TwoWire> Rtc(Wire); // RTC hardware i2c interface
// initialize RTC // initialize RTC