comparison examples/basic_blink/render.cpp @ 314:611306d840b3 prerelease

Merge
author Giulio Moro <giuliomoro@yahoo.it>
date Fri, 27 May 2016 19:00:43 +0100
parents 02c4ca0e3718
children db2fe4e1b88e
comparison
equal deleted inserted replaced
313:c770cdf3d8b2 314:611306d840b3
12 // 12 //
13 // Return true on success; returning false halts the program. 13 // Return true on success; returning false halts the program.
14 14
15 bool setup(BelaContext *context, void *userData) 15 bool setup(BelaContext *context, void *userData)
16 { 16 {
17 pinModeFrame(context, 0, P8_07, OUTPUT); 17 pinMode(context, 0, P8_07, OUTPUT);
18 return true; 18 return true;
19 } 19 }
20 20
21 // render() is called regularly at the highest priority by the audio engine. 21 // render() is called regularly at the highest priority by the audio engine.
22 // Input and output are given from the audio hardware and the other 22 // Input and output are given from the audio hardware and the other
34 float interval=0.5; //how often to toggle the LED (in seconds) 34 float interval=0.5; //how often to toggle the LED (in seconds)
35 static int status=GPIO_LOW; 35 static int status=GPIO_LOW;
36 for(unsigned int n=0; n<context->digitalFrames; n++){ 36 for(unsigned int n=0; n<context->digitalFrames; n++){
37 if(count==context->digitalSampleRate*interval){ //if enough samples have elapsed 37 if(count==context->digitalSampleRate*interval){ //if enough samples have elapsed
38 count=0; //reset the counter 38 count=0; //reset the counter
39 // status=digitalReadFrame(context, 0, P8_07); 39 // status=digitalRead(context, 0, P8_07);
40 if(status==GPIO_LOW) { //toggle the status 40 if(status==GPIO_LOW) { //toggle the status
41 digitalWriteFrame(context, n, P8_07, status); //write the status to the LED 41 digitalWrite(context, n, P8_07, status); //write the status to the LED
42 status=GPIO_HIGH; 42 status=GPIO_HIGH;
43 } 43 }
44 else { 44 else {
45 digitalWriteFrame(context, n, P8_07, status); //write the status to the LED 45 digitalWrite(context, n, P8_07, status); //write the status to the LED
46 status=GPIO_LOW; 46 status=GPIO_LOW;
47 } 47 }
48 } 48 }
49 count++; 49 count++;
50 } 50 }