Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow global object instances be switch off with defines #2344

Merged
merged 1 commit into from
Aug 1, 2016
Merged

allow global object instances be switch off with defines #2344

merged 1 commit into from
Aug 1, 2016

Conversation

everslick
Copy link
Contributor

creating global objects can be switched off by the following defines:

globally:

NO_GLOBAL_INSTANCES

locally:

NO_GLOBAL_SPIFFS
NO_GLOBAL_NETBIOS
NO_GLOBAL_SD
NO_GLOBAL_SPI
NO_GLOBAL_TWOWIRE
NO_GLOBAL_EEPROM
NO_GLOBAL_ETHERNET
NO_GLOBAL_ARDUINOOTA
NO_GLOBAL_MDNS
NO_GLOBAL_TFT
NO_GLOBAL_SPISLAVE
NO_GLOBAL_HTTPUPDATE
NO_GLOBAL_SSDP

i tried to find the most logical name for the define derived from the class name. creation of the global objects have been unified on the go.

EEPROM class got a new constructor, to allow 'external' instantiation of the class the same way es the global one (without knowing the location in flash).

@codecov-io
Copy link

Current coverage is 27.62% (diff: 100%)

Merging #2344 into master will not change coverage

@@             master      #2344   diff @@
==========================================
  Files            20         20          
  Lines          3656       3656          
  Methods         335        335          
  Messages          0          0          
  Branches        678        678          
==========================================
  Hits           1010       1010          
  Misses         2468       2468          
  Partials        178        178          

Powered by Codecov. Last update b7c7bc0...7d4430d

@everslick
Copy link
Contributor Author

I want to add, that the only global object, that is not affected by this PR is WiFi. The object is referenced from different places from within the ESP8266Wifi library and simply removing it, would not work. We'd need to refactor the WiFi class and pass around the instance pointer or reference to the parts that need it. Or we just leave it that way for the time being under the assumption that ESP needs WiFi, end of story.

@igrr igrr merged commit 1829745 into esp8266:master Aug 1, 2016
@hallard
Copy link
Contributor

hallard commented Aug 5, 2016

This one seems very interesting ;-)

I'm not sure it's the best way, but did you think about adding this one (or other name) NO_GLOBAL_WIFI_ENABLE that could early disable WiFi hardware to save power at startup.
As seen in #2111 this one could add @igrr modifications on user_init() in core_esp8266_main.cpp to disable WiFi hardware

extern "C" void user_init(void) {
// previous existing code
#if defined(NO_GLOBAL_WIFI_ENABLE )
  WiFi.persistent(false);
  WiFi.mode(WIFI_OFF);
  WiFi.forceSleepBegin();
#endif
}

@everslick everslick deleted the no-global-instances branch August 5, 2016 16:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants