Originally Posted by
baseball07
Hello, I would like to condense my code down but I am not sure how I can do it. I repeat the same lines of code (putchar commands), but modify whats in the the writespeech parentheses when I want to speak something different, so I was wondering if there was a way to call the commands each time I want to use it. The code I repeat is a serries of commands that I send to my text to speech module, with the text I want to speak right in the middle. Everytime I want to speak a different line of text I need to repeat these lines of command with different text inside. The text gets spoken after the 0x1A command is sent.
Code:
putchar(0x80); //sp03 commands
DelayMs(1);
putchar(0x01);
DelayMs(1);
putchar(0x05);
DelayMs(1);
putchar(0x01);
DelayMs(1);
//sends text to speech module
Writespeech("Welcome to the accessible home vital signs monitor");
DelayMs(1);
putchar(0x1A); //speaks it after 0x1A is sent
DelayMs(1);
putchar(0x00);
(half code really)
Code:
Speak(int n, int i, *pointer to the right array index of char pointers) {
for (i = 0; i < 5; i++) {
char ch = char Array[i]
putchar(ch)
DelayMS(n)
if (i == 4) {
WriteSpeech(pointer to array of char pointers to text messages)
DelayMS(n)
}
} /* end of for */
putchar(i) /* the final putchar has no matching delayMS() */
} /* end of function */
A little log should help with setting up the right messages:
===========
1 - Welcome
2 - Inquiry
3- Calling for help
etc.,
where #1 is the pointer to the welcome string of char's
Adak