Skip to content

Commit 1829745

Browse files
everslickigrr
authored andcommitted
allows global object instances be switch off with defines (#2344)
1 parent bd01e44 commit 1829745

File tree

26 files changed

+72
-11
lines changed

26 files changed

+72
-11
lines changed

cores/esp8266/FS.h

+2
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,8 @@ using fs::SeekEnd;
139139
using fs::FSInfo;
140140
#endif //FS_NO_GLOBALS
141141

142+
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_SPIFFS)
142143
extern fs::FS SPIFFS;
144+
#endif
143145

144146
#endif //FS_H

cores/esp8266/spiffs_api.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,13 @@ extern "C" uint32_t _SPIFFS_block;
124124
#define SPIFFS_MAX_OPEN_FILES 5
125125
#endif
126126

127+
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_SPIFFS)
127128
FS SPIFFS = FS(FSImplPtr(new SPIFFSImpl(
128129
SPIFFS_PHYS_ADDR,
129130
SPIFFS_PHYS_SIZE,
130131
SPIFFS_PHYS_PAGE,
131132
SPIFFS_PHYS_BLOCK,
132133
SPIFFS_MAX_OPEN_FILES)));
134+
#endif
133135

134136
#endif

libraries/ArduinoOTA/ArduinoOTA.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -334,4 +334,6 @@ int ArduinoOTAClass::getCommand() {
334334
return _cmd;
335335
}
336336

337+
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_ARDUINOOTA)
337338
ArduinoOTAClass ArduinoOTA;
339+
#endif

libraries/ArduinoOTA/ArduinoOTA.h

+2
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ class ArduinoOTAClass
6868
String readStringUntil(char end);
6969
};
7070

71+
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_ARDUINOOTA)
7172
extern ArduinoOTAClass ArduinoOTA;
73+
#endif
7274

7375
#endif /* __ARDUINO_OTA_H */

libraries/EEPROM/EEPROM.cpp

+14-3
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,16 @@
2222
#include "Arduino.h"
2323
#include "EEPROM.h"
2424

25-
extern "C" {
25+
extern "C" {
2626
#include "c_types.h"
2727
#include "ets_sys.h"
2828
#include "os_type.h"
2929
#include "osapi.h"
3030
#include "spi_flash.h"
3131
}
3232

33+
extern "C" uint32_t _SPIFFS_end;
34+
3335
EEPROMClass::EEPROMClass(uint32_t sector)
3436
: _sector(sector)
3537
, _data(0)
@@ -38,6 +40,14 @@ EEPROMClass::EEPROMClass(uint32_t sector)
3840
{
3941
}
4042

43+
EEPROMClass::EEPROMClass(void)
44+
: _sector((((uint32_t)&_SPIFFS_end - 0x40200000) / SPI_FLASH_SEC_SIZE))
45+
, _data(0)
46+
, _size(0)
47+
, _dirty(false)
48+
{
49+
}
50+
4151
void EEPROMClass::begin(size_t size) {
4252
if (size <= 0)
4353
return;
@@ -121,5 +131,6 @@ uint8_t * EEPROMClass::getDataPtr() {
121131
return &_data[0];
122132
}
123133

124-
extern "C" uint32_t _SPIFFS_end;
125-
EEPROMClass EEPROM((((uint32_t)&_SPIFFS_end - 0x40200000) / SPI_FLASH_SEC_SIZE));
134+
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_EEPROM)
135+
EEPROMClass EEPROM;
136+
#endif

libraries/EEPROM/EEPROM.h

+3
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
class EEPROMClass {
3030
public:
3131
EEPROMClass(uint32_t sector);
32+
EEPROMClass(void);
3233

3334
void begin(size_t size);
3435
uint8_t read(int address);
@@ -64,7 +65,9 @@ class EEPROMClass {
6465
bool _dirty;
6566
};
6667

68+
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_EEPROM)
6769
extern EEPROMClass EEPROM;
70+
#endif
6871

6972
#endif
7073

libraries/ESP8266NetBIOS/ESP8266NetBIOS.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -261,5 +261,8 @@ void ESP8266NetBIOS::_s_recv(void *arg, udp_pcb *upcb, pbuf *p, struct ip_addr *
261261
reinterpret_cast<ESP8266NetBIOS*>(arg)->_recv(upcb, p, addr, port);
262262
}
263263

264+
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_NETBIOS)
264265
ESP8266NetBIOS NBNS;
266+
#endif
267+
265268
// EOF

libraries/ESP8266NetBIOS/ESP8266NetBIOS.h

+2
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ class ESP8266NetBIOS
3333
void end();
3434
};
3535

36+
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_NETBIOS)
3637
extern ESP8266NetBIOS NBNS;
38+
#endif
3739

3840
#endif

libraries/ESP8266SSDP/ESP8266SSDP.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -431,4 +431,6 @@ void SSDPClass::_startTimer() {
431431
os_timer_arm(tm, interval, 1 /* repeat */);
432432
}
433433

434+
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_SSDP)
434435
SSDPClass SSDP;
436+
#endif

libraries/ESP8266SSDP/ESP8266SSDP.h

+2
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ class SSDPClass{
121121
char _modelNumber[SSDP_MODEL_VERSION_SIZE];
122122
};
123123

124+
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_SSDP)
124125
extern SSDPClass SSDP;
126+
#endif
125127

126128
#endif

libraries/ESP8266httpUpdate/src/ESP8266httpUpdate.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,6 @@ bool ESP8266HTTPUpdate::runUpdate(Stream& in, uint32_t size, String md5, int com
383383
return true;
384384
}
385385

386-
387-
386+
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_HTTPUPDATE)
388387
ESP8266HTTPUpdate ESPhttpUpdate;
388+
#endif

libraries/ESP8266httpUpdate/src/ESP8266httpUpdate.h

+2
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ class ESP8266HTTPUpdate
105105
bool _rebootOnUpdate = true;
106106
};
107107

108+
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_HTTPUPDATE)
108109
extern ESP8266HTTPUpdate ESPhttpUpdate;
110+
#endif
109111

110112
#endif /* ESP8266HTTPUPDATE_H_ */

libraries/ESP8266mDNS/ESP8266mDNS.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -1046,4 +1046,6 @@ void MDNSResponder::_reply(uint8_t replyMask, char * service, char *proto, uint1
10461046
_conn->send();
10471047
}
10481048

1049-
MDNSResponder MDNS = MDNSResponder();
1049+
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_MDNS)
1050+
MDNSResponder MDNS;
1051+
#endif

libraries/ESP8266mDNS/ESP8266mDNS.h

+2
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,8 @@ class MDNSResponder {
131131
void _restart();
132132
};
133133

134+
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_MDNS)
134135
extern MDNSResponder MDNS;
136+
#endif
135137

136138
#endif //ESP8266MDNS_H

libraries/Ethernet/src/Ethernet.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -139,4 +139,6 @@ IPAddress EthernetClass::dnsServerIP()
139139
return _dnsServerAddress;
140140
}
141141

142-
EthernetClass Ethernet;
142+
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_ETHERNET)
143+
EthernetClass Ethernet;
144+
#endif

libraries/Ethernet/src/Ethernet.h

+2
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ class EthernetClass {
3636
friend class EthernetServer;
3737
};
3838

39+
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_ETHERNET)
3940
extern EthernetClass Ethernet;
41+
#endif
4042

4143
#endif

libraries/SD/src/SD.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -611,4 +611,6 @@ void File::rewindDirectory(void) {
611611
_file->rewind();
612612
}
613613

614+
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_SD)
614615
SDClass SD;
616+
#endif

libraries/SD/src/SD.h

+2
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,8 @@ class SDClass {
132132
friend boolean callback_openPath(SdFile&, char *, boolean, void *);
133133
};
134134

135+
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_SD)
135136
extern SDClass SD;
137+
#endif
136138

137139
#endif

libraries/SPI/SPI.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ typedef union {
3333
};
3434
} spiClk_t;
3535

36-
SPIClass SPI;
37-
3836
SPIClass::SPIClass() {
3937
useHwCs = false;
4038
}
@@ -486,3 +484,6 @@ void SPIClass::transferBytes_(uint8_t * out, uint8_t * in, uint8_t size) {
486484
}
487485
}
488486

487+
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_SPI)
488+
SPIClass SPI;
489+
#endif

libraries/SPI/SPI.h

+2
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ class SPIClass {
7979
inline void setDataBits(uint16_t bits);
8080
};
8181

82+
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_SPI)
8283
extern SPIClass SPI;
84+
#endif
8385

8486
#endif

libraries/SPISlave/src/SPISlave.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -100,4 +100,6 @@ void SPISlaveClass::onStatusSent(SpiSlaveSentHandler cb)
100100
_status_sent_cb = cb;
101101
}
102102

103+
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_SPISLAVE)
103104
SPISlaveClass SPISlave;
105+
#endif

libraries/SPISlave/src/SPISlave.h

+2
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ class SPISlaveClass
6464
void onStatusSent(SpiSlaveSentHandler cb);
6565
};
6666

67+
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_SPISLAVE)
6768
extern SPISlaveClass SPISlave;
69+
#endif
6870

6971
#endif

libraries/TFT_Touch_Shield_V2/TFTv2.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,10 @@ INT8U TFT::drawFloat(float floatNumber,INT16U poX, INT16U poY,INT16U size,INT16U
567567
return f;
568568
}
569569

570-
TFT Tft=TFT();
570+
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_TFT)
571+
TFT Tft;
572+
#endif
573+
571574
/*********************************************************************************************************
572575
END FILE
573576
*********************************************************************************************************/

libraries/TFT_Touch_Shield_V2/TFTv2.h

+2
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,9 @@ class TFT
213213

214214
};
215215

216+
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_TFT)
216217
extern TFT Tft;
218+
#endif
217219

218220
#endif
219221

libraries/Wire/Wire.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -251,4 +251,6 @@ void TwoWire::onRequest( void (*function)(void) ){
251251

252252
// Preinstantiate Objects //////////////////////////////////////////////////////
253253

254-
TwoWire Wire = TwoWire();
254+
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_TWOWIRE)
255+
TwoWire Wire;
256+
#endif

libraries/Wire/Wire.h

+2
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,9 @@ class TwoWire : public Stream
8585
using Print::write;
8686
};
8787

88+
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_TWOWIRE)
8889
extern TwoWire Wire;
90+
#endif
8991

9092
#endif
9193

0 commit comments

Comments
 (0)