Skip to content

Add memory management, remove static declarations and store/restore timer register values#14

Open
idhanu wants to merge 1 commit intogoing-digital:masterfrom
idhanu:master
Open

Add memory management, remove static declarations and store/restore timer register values#14
idhanu wants to merge 1 commit intogoing-digital:masterfrom
idhanu:master

Conversation

@idhanu
Copy link

@idhanu idhanu commented Feb 5, 2016

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()); }

@idhanu idhanu changed the title Add memory management, static declarations and store/restore timer register values Add memory management, remove static declarations and store/restore timer register values Feb 5, 2016
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.

1 participant