comparison examples/analogDigitalDemo/render.cpp @ 310:02c4ca0e3718 prerelease

Renamed pinModeFrame -> pinMode
author andrewm
date Fri, 27 May 2016 18:29:20 +0100
parents 1feb9c23ac57
children 493a07f6ec09
comparison
equal deleted inserted replaced
309:6b717992c8d2 310:02c4ca0e3718
54 // in the next buffer each frame of channel 0 will be initialized to 1 (the last value of this buffer) 54 // in the next buffer each frame of channel 0 will be initialized to 1 (the last value of this buffer)
55 digitalWrite(context, 0, P8_08, GPIO_HIGH); 55 digitalWrite(context, 0, P8_08, GPIO_HIGH);
56 digitalWrite(context, 2, P8_08, GPIO_LOW); 56 digitalWrite(context, 2, P8_08, GPIO_LOW);
57 digitalWrite(context, 4, P8_08, GPIO_HIGH); 57 digitalWrite(context, 4, P8_08, GPIO_HIGH);
58 digitalWrite(context, 5, P8_08, GPIO_LOW); 58 digitalWrite(context, 5, P8_08, GPIO_LOW);
59 pinModeFrame(context, 0, P9_16, GPIO_INPUT); // set channel 10 to input 59 pinMode(context, 0, P9_16, GPIO_INPUT); // set channel 10 to input
60 // in this buffer the frames of channel 1 will look like this: 1 1 0 0 1 0 0 0 .... 0 60 // in this buffer the frames of channel 1 will look like this: 1 1 0 0 1 0 0 0 .... 0
61 // in the next buffer each frame of channel 1 will be initialized to 0 (the last value of this buffer) 61 // in the next buffer each frame of channel 1 will be initialized to 0 (the last value of this buffer)
62 } 62 }
63 for(unsigned int n=0; n<context->audioFrames; n++){ 63 for(unsigned int n=0; n<context->audioFrames; n++){
64 for(unsigned int c=0; c<context->audioChannels; c++){ 64 for(unsigned int c=0; c<context->audioChannels; c++){
68 context->digital[n]=context->digital[n] & (~0b111111100); // set to zero (GPIO_OUTPUT) the bits in the lower word 68 context->digital[n]=context->digital[n] & (~0b111111100); // set to zero (GPIO_OUTPUT) the bits in the lower word
69 context->digital[n]=context->digital[n] & ((~0b111111100<<16) | 0xffff ); //initialize to zero the bits in the higher word (output value) 69 context->digital[n]=context->digital[n] & ((~0b111111100<<16) | 0xffff ); //initialize to zero the bits in the higher word (output value)
70 context->digital[n]=context->digital[n] | ( ((context->audioSampleCount&0b1111111)<<(16+2)) ) ; // set the bits in the higher word to the desired output value, keeping the lower word unchanged 70 context->digital[n]=context->digital[n] | ( ((context->audioSampleCount&0b1111111)<<(16+2)) ) ; // set the bits in the higher word to the desired output value, keeping the lower word unchanged
71 digitalWrite(context, n, P8_29, digitalRead(context, n, P8_30)); // echo the input from from channel 15 to channel 14 71 digitalWrite(context, n, P8_29, digitalRead(context, n, P8_30)); // echo the input from from channel 15 to channel 14
72 digitalWrite(context, n, P8_28, digitalRead(context, n, P9_16)); // echo the input from from channel 10 to channel 13 72 digitalWrite(context, n, P8_28, digitalRead(context, n, P9_16)); // echo the input from from channel 10 to channel 13
73 pinModeFrame(context, 0, P8_30, 0); //set channel 15 to input 73 pinMode(context, 0, P8_30, 0); //set channel 15 to input
74 } 74 }
75 75
76 for(unsigned int n=0; n<context->analogFrames; n++){ 76 for(unsigned int n=0; n<context->analogFrames; n++){
77 analogWrite(context, n, 1, (context->audioSampleCount&8191)/8192.0); // writes a single frame. channel 1 is a ramp that follows gCountFrames 77 analogWrite(context, n, 1, (context->audioSampleCount&8191)/8192.0); // writes a single frame. channel 1 is a ramp that follows gCountFrames
78 analogWrite(context, n, 2, analogRead(context, n, 2)); // writes a single frame. channel2 is just a passthrough 78 analogWrite(context, n, 2, analogRead(context, n, 2)); // writes a single frame. channel2 is just a passthrough