From 55beced1f80eed9bc3470b2c60d695ab92923d46 Mon Sep 17 00:00:00 2001 From: Mathieu Maret Date: Sat, 26 Mar 2016 15:27:23 +0100 Subject: [PATCH] Make BMP180 optionnal Save 1.5ko of ROM --- WifiControlSensor/BMP180.h | 20 ++++++++++++++++++++ WifiControlSensor/BMP180.ino | 9 +++------ WifiControlSensor/WifiControlSensor.ino | 12 ++---------- 3 files changed, 25 insertions(+), 16 deletions(-) create mode 100644 WifiControlSensor/BMP180.h diff --git a/WifiControlSensor/BMP180.h b/WifiControlSensor/BMP180.h new file mode 100644 index 0000000..4dd0561 --- /dev/null +++ b/WifiControlSensor/BMP180.h @@ -0,0 +1,20 @@ +#pragma once +#ifdef ENABLE_BMP180 +#include + +// Get Current altitude with http://fr.mygeoposition.com/ +#define ALTITUDE 130 +SFE_BMP180 bmp180; +int bmp180Connected = 0; + +int BMP180GetTemperature(double &t); +int BMP180GetTempAndPressure(double &t, double &p); +int BMP180Setup(); +bool BMP180IsConnected(); + +#else //ENABLE_BMP80 +int BMP180GetTemperature(double &t){return 0;}; +int BMP180GetTempAndPressure(double &t, double &p){return 0;}; +int BMP180Setup(){return 0;}; +bool BMP180IsConnected(){return 0;}; +#endif diff --git a/WifiControlSensor/BMP180.ino b/WifiControlSensor/BMP180.ino index cc7c008..7c68804 100644 --- a/WifiControlSensor/BMP180.ino +++ b/WifiControlSensor/BMP180.ino @@ -1,9 +1,5 @@ -// Get Current altitude with http://fr.mygeoposition.com/ -#define ALTITUDE 130 - -SFE_BMP180 bmp180; -int bmp180Connected = 0; - +#ifdef ENABLE_BMP180 +#include "BMP180.h" int BMP180Setup() { bmp180Connected = bmp180.begin(SDA, SCL); return bmp180Connected; @@ -43,3 +39,4 @@ int BMP180GetTempAndPressure(double &t, double &p) { } return -1; } +#endif diff --git a/WifiControlSensor/WifiControlSensor.ino b/WifiControlSensor/WifiControlSensor.ino index 223e9da..99d5e98 100644 --- a/WifiControlSensor/WifiControlSensor.ino +++ b/WifiControlSensor/WifiControlSensor.ino @@ -20,10 +20,9 @@ #include #include -#include -#include - +#define ENABLE_BMP180 #include "debug_sketch.h" +#include "BMP180.h" #include "Adafruit_MQTT.h" #include "Adafruit_MQTT_Client.h" @@ -67,13 +66,6 @@ int EepromSaveConfig(uint8_t bootMode, String ssid, String password, String host int EepromSaveBootMode(uint8_t bootMode); void EepromReadConfig(uint8_t &bootMode, char **ssid, char **password, char **host, char **mqttServer, char **mqttUser, char **mqttPasswd, int &mqttPort); -/* BMP180 decl */ -int BMP180GetTemperature(double &t); -int BMP180GetTempAndPressure(double &t, double &p); -int BMP180Setup(); -bool BMP180IsConnected(); - - /* MQTT decl */ int MqttConnect(); int MqttIsConnected();