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

Lines changed: 2 additions & 0 deletions
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

Lines changed: 2 additions & 0 deletions
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

Lines changed: 2 additions & 0 deletions
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

Lines changed: 2 additions & 0 deletions
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

Lines changed: 14 additions & 3 deletions
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

Lines changed: 3 additions & 0 deletions
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

Lines changed: 3 additions & 0 deletions
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

Lines changed: 2 additions & 0 deletions
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

Lines changed: 2 additions & 0 deletions
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

Lines changed: 2 additions & 0 deletions
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

0 commit comments

Comments
 (0)