Don't ad-block us - support your favorite websites. We have safe, unobstrusive, robotics related ads that you actually want to see - see here for more.
0 Members and 1 Guest are viewing this topic.
Then when my brain wants to play a noise, would i simply do, rprintf("PC F /MP3_Voice/Curse.mp3");
Example SessionThis example session opens a log file, writes data, and then retrieves it.>O 1 W /LOGS/JANUARY/JAN03.LOG{cr}>W 1 18{cr}13:22:02 ADC1=4.9V>C 1{cr}>O 1 R /LOGS/JANUARY/JAN03.LOG{cr}>R 1 18{cr}13:22:02 ADC1=4.9V>C 1{cr}>
rprintf("O 1 R /LOGS/FEBRUARY/FEB30.LOG\r");// the \r for carriage return, I think . . .
SEROUT MP3R,N9600T,["PC F /Dramatic-Reveal-Horns1.mp3",CR]
main(){rprintf("a");//Send Blackfin command for 160x128 resolutionBlackfin_Echo(2);// the expected return data is size of 3}//Repeat Response, read in from Camera UART, output to another UART (for hyperterminal)void Blackfin_Echo(int response_counter) //echos # of characters expected for each command { int temp; int counter=0; rprintfInit(uart0SendByte);//change UART to bluetooth to output data to hyperterminal while(1) { temp=uart3GetByte();//get data from camera UART, returns -1 if no data present //rprintf("trapped!");//debugging code, repeats if there is an error somewhere if (temp != -1)//if data received { rprintf("%c",temp);//output to hyperterminal response[counter]=temp & 0x0F;//store values into an array, &0x0F strips ascii off to use in char strings counter++; if(counter >= response_counter || temp == '\n') { rprintf("\r\n\r\n");//new line uartFlushReceiveBuffer(3);//flush out receive camera buffer to stop phase shifting break; } } } }
Can i safely assume that any data returned means i can send it data again?
int wait_for_ready(void) { int temp; while (uart0GetByte() != -1) {delay_ms(1);}; // drain any characters for(int k = 0; k < 5; ++k) { uart0SendByte(CARRIAGERETURN);// send carriage return delay_ms(2); temp = uart0GetByte(); if(temp == uMP3READY) return TRUE; for(int j = 0; ((j < 20) && (temp == -1)); ++j) { delay_ms(2); temp=uart0GetByte(); if(temp == uMP3READY) return TRUE; } } return FALSE; }int consume_to_ready(void) { int temp; temp = uart0GetByte(); //rprintf("temp = %d\r\n",temp); if(temp == uMP3READY) return TRUE; for(int j = 0; ((j < 20) && (temp != uMP3READY)); ++j) { delay_ms(2); temp = uart0GetByte(); //rprintf("temp = %d\r\n",temp); } //rprintf("temp final = %d\r\n",temp); if(temp == uMP3READY) return TRUE; return FALSE; }int check_for_playing(void) { int temp; for(int j = 0; ((j < 20) && (!wait_for_ready())); ++j) { rprintf("Not Ready\r\n"); delay_ms(1); } rprintfInit(uart0SendByte);// initialize rprintf system and configure uart0 (USB) for rprintf rprintf("PC Z\r"); // get status from uMP3 rprintfInit(uart1SendByte); temp=uart0GetByte(); //rprintf("check_for_playing : Temp = %d\r\n", temp); for(int j = 0; ((j < 20) && (temp == -1)); ++j) { delay_ms(2); temp=uart0GetByte(); //rprintf("check_for_playing : Temp = %d\r\n", temp); } //if(temp == -1) return FALSE; if(temp == 80) //"P" { rprintf("Playing something\r\n"); //rprintf("check_for_playing final: Temp = %d\r\n", temp); //while (uart0GetByte() != -1); // drain any other characters consume_to_ready(); return TRUE; } else { rprintf("Not playing something\r\n"); //rprintf("check_for_playing final: Temp = %d\r\n", temp); //while (uart0GetByte() != -1); // drain any other characters consume_to_ready(); } return FALSE; }void init_uMP3(void) { //int temp; uMP3init = FALSE; for(int i = 0; i < 32; ++i) // loop for at most 8 seconds { if(wait_for_ready()) //if(temp == uMP3READY) { rprintf("uMP3 ready\r\n"); //rprintf("Setting Volume\r\n"); rprintfInit(uart0SendByte);//change UART to uMP3 rprintf("ST V "); // set volume to maximum uart0SendByte(254); rprintf("\r"); rprintfInit(uart1SendByte); if(consume_to_ready()) { uMP3init = TRUE; rprintf("uMP3 ready!\r\n"); return;// if we get ready response ">" we are through } else { rprintf("failed setting command\r\n"); } } else { rprintf("uMP3 NOT ready\r\n"); } delay_ms(250); } //rprintfInit(uart1SendByte);// initialize rprintf system and configure uart1 (USB) for rprintf }void play_track(char preamble, int track) { if(uMP3init == TRUE) { rprintf("Playing track %c", preamble); rprintf("%d.mp3\r\n",track); rprintfInit(uart0SendByte);//change UART to uMP3 rprintf("PC F /"); // play track on uMP3 rprintf("%c%d.MP3\r", preamble, track); rprintfInit(uart1SendByte); } else rprintf("uMP3 not initalized\r\n"); }