1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-04-19 23:22:16 +03:00

allows global object instances be switch off with defines (#2344)

This commit is contained in:
Clemens Kirchgatterer 2016-08-01 05:21:50 +02:00 committed by Ivan Grokhotkov
parent bd01e44c76
commit 18297458be
26 changed files with 72 additions and 11 deletions

View File

@ -139,6 +139,8 @@ using fs::SeekEnd;
using fs::FSInfo;
#endif //FS_NO_GLOBALS
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_SPIFFS)
extern fs::FS SPIFFS;
#endif
#endif //FS_H

View File

@ -124,11 +124,13 @@ extern "C" uint32_t _SPIFFS_block;
#define SPIFFS_MAX_OPEN_FILES 5
#endif
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_SPIFFS)
FS SPIFFS = FS(FSImplPtr(new SPIFFSImpl(
SPIFFS_PHYS_ADDR,
SPIFFS_PHYS_SIZE,
SPIFFS_PHYS_PAGE,
SPIFFS_PHYS_BLOCK,
SPIFFS_MAX_OPEN_FILES)));
#endif
#endif

View File

@ -334,4 +334,6 @@ int ArduinoOTAClass::getCommand() {
return _cmd;
}
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_ARDUINOOTA)
ArduinoOTAClass ArduinoOTA;
#endif

View File

@ -68,6 +68,8 @@ class ArduinoOTAClass
String readStringUntil(char end);
};
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_ARDUINOOTA)
extern ArduinoOTAClass ArduinoOTA;
#endif
#endif /* __ARDUINO_OTA_H */

View File

@ -30,6 +30,8 @@
#include "spi_flash.h"
}
extern "C" uint32_t _SPIFFS_end;
EEPROMClass::EEPROMClass(uint32_t sector)
: _sector(sector)
, _data(0)
@ -38,6 +40,14 @@ EEPROMClass::EEPROMClass(uint32_t sector)
{
}
EEPROMClass::EEPROMClass(void)
: _sector((((uint32_t)&_SPIFFS_end - 0x40200000) / SPI_FLASH_SEC_SIZE))
, _data(0)
, _size(0)
, _dirty(false)
{
}
void EEPROMClass::begin(size_t size) {
if (size <= 0)
return;
@ -121,5 +131,6 @@ uint8_t * EEPROMClass::getDataPtr() {
return &_data[0];
}
extern "C" uint32_t _SPIFFS_end;
EEPROMClass EEPROM((((uint32_t)&_SPIFFS_end - 0x40200000) / SPI_FLASH_SEC_SIZE));
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_EEPROM)
EEPROMClass EEPROM;
#endif

View File

@ -29,6 +29,7 @@
class EEPROMClass {
public:
EEPROMClass(uint32_t sector);
EEPROMClass(void);
void begin(size_t size);
uint8_t read(int address);
@ -64,7 +65,9 @@ protected:
bool _dirty;
};
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_EEPROM)
extern EEPROMClass EEPROM;
#endif
#endif

View File

@ -261,5 +261,8 @@ void ESP8266NetBIOS::_s_recv(void *arg, udp_pcb *upcb, pbuf *p, struct ip_addr *
reinterpret_cast<ESP8266NetBIOS*>(arg)->_recv(upcb, p, addr, port);
}
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_NETBIOS)
ESP8266NetBIOS NBNS;
#endif
// EOF

View File

@ -33,6 +33,8 @@ public:
void end();
};
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_NETBIOS)
extern ESP8266NetBIOS NBNS;
#endif
#endif

View File

@ -431,4 +431,6 @@ void SSDPClass::_startTimer() {
os_timer_arm(tm, interval, 1 /* repeat */);
}
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_SSDP)
SSDPClass SSDP;
#endif

View File

@ -121,6 +121,8 @@ class SSDPClass{
char _modelNumber[SSDP_MODEL_VERSION_SIZE];
};
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_SSDP)
extern SSDPClass SSDP;
#endif
#endif

View File

@ -383,6 +383,6 @@ bool ESP8266HTTPUpdate::runUpdate(Stream& in, uint32_t size, String md5, int com
return true;
}
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_HTTPUPDATE)
ESP8266HTTPUpdate ESPhttpUpdate;
#endif

View File

@ -105,6 +105,8 @@ protected:
bool _rebootOnUpdate = true;
};
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_HTTPUPDATE)
extern ESP8266HTTPUpdate ESPhttpUpdate;
#endif
#endif /* ESP8266HTTPUPDATE_H_ */

View File

@ -1046,4 +1046,6 @@ void MDNSResponder::_reply(uint8_t replyMask, char * service, char *proto, uint1
_conn->send();
}
MDNSResponder MDNS = MDNSResponder();
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_MDNS)
MDNSResponder MDNS;
#endif

View File

@ -131,6 +131,8 @@ private:
void _restart();
};
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_MDNS)
extern MDNSResponder MDNS;
#endif
#endif //ESP8266MDNS_H

View File

@ -139,4 +139,6 @@ IPAddress EthernetClass::dnsServerIP()
return _dnsServerAddress;
}
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_ETHERNET)
EthernetClass Ethernet;
#endif

View File

@ -36,6 +36,8 @@ public:
friend class EthernetServer;
};
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_ETHERNET)
extern EthernetClass Ethernet;
#endif
#endif

View File

@ -611,4 +611,6 @@ void File::rewindDirectory(void) {
_file->rewind();
}
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_SD)
SDClass SD;
#endif

View File

@ -132,6 +132,8 @@ private:
friend boolean callback_openPath(SdFile&, char *, boolean, void *);
};
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_SD)
extern SDClass SD;
#endif
#endif

View File

@ -33,8 +33,6 @@ typedef union {
};
} spiClk_t;
SPIClass SPI;
SPIClass::SPIClass() {
useHwCs = false;
}
@ -486,3 +484,6 @@ void SPIClass::transferBytes_(uint8_t * out, uint8_t * in, uint8_t size) {
}
}
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_SPI)
SPIClass SPI;
#endif

View File

@ -79,6 +79,8 @@ private:
inline void setDataBits(uint16_t bits);
};
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_SPI)
extern SPIClass SPI;
#endif
#endif

View File

@ -100,4 +100,6 @@ void SPISlaveClass::onStatusSent(SpiSlaveSentHandler cb)
_status_sent_cb = cb;
}
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_SPISLAVE)
SPISlaveClass SPISlave;
#endif

View File

@ -64,6 +64,8 @@ public:
void onStatusSent(SpiSlaveSentHandler cb);
};
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_SPISLAVE)
extern SPISlaveClass SPISlave;
#endif
#endif

View File

@ -567,7 +567,10 @@ INT8U TFT::drawFloat(float floatNumber,INT16U poX, INT16U poY,INT16U size,INT16U
return f;
}
TFT Tft=TFT();
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_TFT)
TFT Tft;
#endif
/*********************************************************************************************************
END FILE
*********************************************************************************************************/

View File

@ -213,7 +213,9 @@ public:
};
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_TFT)
extern TFT Tft;
#endif
#endif

View File

@ -251,4 +251,6 @@ void TwoWire::onRequest( void (*function)(void) ){
// Preinstantiate Objects //////////////////////////////////////////////////////
TwoWire Wire = TwoWire();
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_TWOWIRE)
TwoWire Wire;
#endif

View File

@ -85,7 +85,9 @@ class TwoWire : public Stream
using Print::write;
};
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_TWOWIRE)
extern TwoWire Wire;
#endif
#endif