Mercurial > hg > beaglert
comparison examples/gpioAnalogLoopbackTest/render.cpp @ 308:1feb9c23ac57 prerelease
Renamed read/write functions to remove the Frame --> e.g. analogWriteFrameOnce -> analogWriteOnce, digitalReadFrame -> digitalRead
author | andrewm |
---|---|
date | Fri, 27 May 2016 18:21:21 +0100 |
parents | e4392164b458 |
children | 02c4ca0e3718 |
comparison
equal
deleted
inserted
replaced
307:ff5f346a293e | 308:1feb9c23ac57 |
---|---|
97 static bool analog0In = false; | 97 static bool analog0In = false; |
98 static bool digitalAIn = false; | 98 static bool digitalAIn = false; |
99 static int count = 0; | 99 static int count = 0; |
100 bool doReadWrite = context->analogChannels<=4 ? true : ((context->analogChannels == 8) && (n&1)==0); | 100 bool doReadWrite = context->analogChannels<=4 ? true : ((context->analogChannels == 8) && (n&1)==0); |
101 if(doReadWrite){ | 101 if(doReadWrite){ |
102 digitalAIn = digitalReadFrame(context, n, gDigitalInACh); | 102 digitalAIn = digitalRead(context, n, gDigitalInACh); |
103 switch(context->analogChannels){ | 103 switch(context->analogChannels){ |
104 case 8: | 104 case 8: |
105 analog0In = analogReadFrame(context, n/2, 0) > 0.5; | 105 analog0In = analogRead(context, n/2, 0) > 0.5; |
106 analogWriteFrame(context, n/2, analogOut, writePattern[outPointer]); | 106 analogWrite(context, n/2, analogOut, writePattern[outPointer]); |
107 break; | 107 break; |
108 case 4: | 108 case 4: |
109 analog0In = analogReadFrame(context, n, 0) > 0.5; | 109 analog0In = analogRead(context, n, 0) > 0.5; |
110 analogWriteFrame(context, n, analogOut, writePattern[outPointer]); | 110 analogWrite(context, n, analogOut, writePattern[outPointer]); |
111 break; | 111 break; |
112 case 2: | 112 case 2: |
113 analog0In = analogReadFrame(context, n * 2 + 1, 0) > 0.5; | 113 analog0In = analogRead(context, n * 2 + 1, 0) > 0.5; |
114 analogWriteFrame(context, 2 * n, analogOut, writePattern[outPointer]); | 114 analogWrite(context, 2 * n, analogOut, writePattern[outPointer]); |
115 analogWriteFrame(context, 2 * n + 1, analogOut, writePattern[outPointer]); | 115 analogWrite(context, 2 * n + 1, analogOut, writePattern[outPointer]); |
116 break; | 116 break; |
117 } | 117 } |
118 gAnalogOutLoopDelay--; | 118 gAnalogOutLoopDelay--; |
119 outPointer++; | 119 outPointer++; |
120 if(gAnalogOutLoopDelay <= 0){ | 120 if(gAnalogOutLoopDelay <= 0){ |
148 * reading GPIO takes place before writing to it, therefore | 148 * reading GPIO takes place before writing to it, therefore |
149 * when reading a GPIOout, the GPIOin samples will always be one sample late | 149 * when reading a GPIOout, the GPIOin samples will always be one sample late |
150 */ | 150 */ |
151 bool doReadWrite = false; | 151 bool doReadWrite = false; |
152 static bool pastAnalog1In = false; | 152 static bool pastAnalog1In = false; |
153 digitalWriteFrameOnce(context, n, gDigitalOutCh, writePattern[digitalOutPointer]); | 153 digitalWriteOnce(context, n, gDigitalOutCh, writePattern[digitalOutPointer]); |
154 if(context->analogChannels == 8){ | 154 if(context->analogChannels == 8){ |
155 if((n&1) == 0){ //do it every other sample | 155 if((n&1) == 0){ //do it every other sample |
156 pastAnalog1In = analogReadFrame(context, n/2, 1) > 0.5; | 156 pastAnalog1In = analogRead(context, n/2, 1) > 0.5; |
157 digitalDIn = digitalReadFrame(context, n, gDigitalInDCh); | 157 digitalDIn = digitalRead(context, n, gDigitalInDCh); |
158 doReadWrite = true; | 158 doReadWrite = true; |
159 } | 159 } |
160 } | 160 } |
161 if(context->analogChannels == 4){ | 161 if(context->analogChannels == 4){ |
162 pastAnalog1In = analogReadFrame(context, n, 1) > 0.5; | 162 pastAnalog1In = analogRead(context, n, 1) > 0.5; |
163 digitalDIn = digitalReadFrame(context, n, gDigitalInDCh); | 163 digitalDIn = digitalRead(context, n, gDigitalInDCh); |
164 digitalWriteFrameOnce(context, n, gDigitalOutCh, writePattern[digitalOutPointer]); | 164 digitalWriteOnce(context, n, gDigitalOutCh, writePattern[digitalOutPointer]); |
165 doReadWrite = true; | 165 doReadWrite = true; |
166 } | 166 } |
167 if(context->analogChannels == 2){ | 167 if(context->analogChannels == 2){ |
168 pastAnalog1In = analogReadFrame(context, n * 2, 1) > 0.5; | 168 pastAnalog1In = analogRead(context, n * 2, 1) > 0.5; |
169 digitalDIn = digitalReadFrame(context, n, gDigitalInDCh); | 169 digitalDIn = digitalRead(context, n, gDigitalInDCh); |
170 digitalWriteFrameOnce(context, n, gDigitalOutCh, writePattern[digitalOutPointer]); | 170 digitalWriteOnce(context, n, gDigitalOutCh, writePattern[digitalOutPointer]); |
171 doReadWrite = true; | 171 doReadWrite = true; |
172 } | 172 } |
173 bool expectedDigitalIn = writePattern[digitalInPointer]; | 173 bool expectedDigitalIn = writePattern[digitalInPointer]; |
174 if(doReadWrite == true){ | 174 if(doReadWrite == true){ |
175 gDigitalOutLoopDelay--; | 175 gDigitalOutLoopDelay--; |