I want to make a library that not take any storage and ram. And i'm doing a simple research at the arduino ide.
If we make a new file in the IDE and compile it, compiler return :
Sketch uses 444 bytes (1%) of program storage space. Maximum is 32256 bytes.
Global variables use 9 bytes (0%) of dynamic memory, leaving 2039 bytes for local variables. Maximum is 2048 bytes.
if we include a library like newping , compiler return same as not include anything :
Sketch uses 444 bytes (1%) of program storage space. Maximum is 32256 bytes.
Global variables use 9 bytes (0%) of dynamic memory, leaving 2039 bytes for local variables. Maximum is 2048 bytes.
Sketch uses 968 bytes (3%) of program storage space. Maximum is 32256 bytes.
Global variables use 167 bytes (8%) of dynamic memory, leaving 1881 bytes for local variables. Maximum is 2048 bytes.
Then i check the library not much different in the header (or i don't know). I want to know what's the different about including library and the structure (maybe?) in the library affect ram and storage?
If your library simply defines a class, then including it, without creating an instance of the class, then no additional SRAM or FLASH memory is used.
If your library defines a bunch of global variables, then including it will cause all the global variables to be created, using SRAM but no FLASH memory.
If your library defines a class AND creates a global instance of the class, then SRAM and FLASH will be used.
Your goal of creating a library that uses no FLASH and no SRAM is completely unrealistic unless your library does nothing.
robtillaart:
Can you show the test sketches you used?
Blank:
void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
}
ir remote:
#include <IRremote.h>
void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
}
NewPing :
#include <NewPing.h>
void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
}
PaulS:
If your library simply defines a class, then including it, without creating an instance of the class, then no additional SRAM or FLASH memory is used.
If your library defines a bunch of global variables, then including it will cause all the global variables to be created, using SRAM but no FLASH memory.
If your library defines a class AND creates a global instance of the class, then SRAM and FLASH will be used.
Your goal of creating a library that uses no FLASH and no SRAM is completely unrealistic unless your library does nothing.
i missed something i don't mean to make library without no flash and sram but just like your first point.