Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
SYN6288.cpp
00001 #include "SYN6288.h" 00002 void voice_play(std::string value, Serial* ser) 00003 { 00004 voice_play(value.c_str(), ser); 00005 } 00006 void voice_play(char* value, Serial* ser) { 00007 int size = strlen(value); 00008 int data_length = 1+2+1+1+size; 00009 int* data = (int*)malloc(sizeof(int)*(data_length+1)); 00010 00011 int start = 0xfd; 00012 int length = size + 3; 00013 int length_h = length / 256; 00014 int length_l = length % 256; 00015 int command = 0x01; 00016 int param = 0x01; 00017 00018 data[0] = start; 00019 data[1] = length_h; 00020 data[2] = length_l; 00021 data[3] = command; 00022 data[4] = param; 00023 00024 for (int i=5; i<5+size; i++) { 00025 data[i] = value[i-5]; 00026 } 00027 00028 // calculate check bit 00029 int check_bit = data[0]; 00030 for (int i=1; i<data_length; i++) { 00031 check_bit ^= data[i]; 00032 } 00033 data[data_length] = check_bit; 00034 00035 for (int i=0; i<=data_length; i++) { 00036 ser->putc(data[i]); 00037 } 00038 00039 free(data); 00040 00041 //int recv = ser->getc(); 00042 //PC.printf("%c", recv); 00043 //int done = ser->getc(); 00044 //PC.printf("%c", done); 00045 } 00046
Generated on Sun Jul 31 2022 02:11:56 by
1.7.2