Add memory management, remove static declarations and store/restore timer register values#14
Open
idhanu wants to merge 1 commit intogoing-digital:masterfrom
Open
Add memory management, remove static declarations and store/restore timer register values#14idhanu wants to merge 1 commit intogoing-digital:masterfrom
idhanu wants to merge 1 commit intogoing-digital:masterfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I was working in a project which is tight on memory and the MCU has to switch between tasks. So, I improved memory management in the library to be local to the object. Please feel free to use/distribute my suggestions. I also added .begin() and .end() functions which respectively store and restore timer register values modified in the library. Now the library uses less than 10 bytes of statically allocated memory.
Following is a example usage in which the library is allocated in the call stack and released after the function call. The destructor calls .end() and clean up after use.
void sayGreeting() { Talkie voice; voice.begin(); voice.say(spGOOD); voice.say(spMORNING); voice.say(spPAUSE1); voice.say(spTHE); voice.say(spTIME); voice.say(spIS); voice.say(spELEVEN); voice.say(spTHIRTY); voice.say(spFOURTY); voice.say(spFIFTY); voice.say(spEIGHTEEN); voice.say(spSIX); voice.say(spA_M_); voice.say(spPAUSE1); Serial.print("freeMemory()="); Serial.println(freeMemory()); }