@@ -78,7 +78,20 @@ We used a text-to-speech program called ...
...
@@ -78,7 +78,20 @@ We used a text-to-speech program called ...
% - mp3 module sending the signal start/stop "file number on the sd card"
% - mp3 module sending the signal start/stop "file number on the sd card"
Another challenge was to not halt the main loop when we want to say something.
Another challenge was to not halt the main loop when we want to say something.
For example if we want to
For example if we want to say the ``twenty five'' we would love to simply call the functions as \\
play(twenty); play(five); \\
But unfortunately the mp3 module we used does not have a queue functionality so what would actually happen is that the first few milliseconds of the ``twenty'' are getting played, but then it gets stopped and instead ``five'' is being played.
For this reason we needed to implement our own queue.
We simply have a global list of integers (by default all of them are zero), a global variable that saves the current playing index, and a global variable that saves the current end index of the queue.
We then one function that gets called on every loop.
It checks whether the mp3 module is still busy.
If it is not any more, it looks if there is a file to play at the current playing index.
If there is (indicated by a non-zero entry), then we start playing that file, and increment
the current playing index.
We have another function for adding files to the queue.
It simply puts the number of the file to play at the current end index of the queue,
and increments the queue.
Both index variables get set back to zero in case they reach the the end of the queue.