comparison core/PulseIn.cpp @ 301:e4392164b458 prerelease

RENAMED BeagleRT to Bela AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA, scripts probably not working
author Giulio Moro <giuliomoro@yahoo.it>
date Fri, 27 May 2016 14:34:41 +0100
parents 3c3d14654b7f
children 1feb9c23ac57
comparison
equal deleted inserted replaced
300:dbeed520b014 301:e4392164b458
5 * Author: giulio 5 * Author: giulio
6 */ 6 */
7 7
8 #include "../include/PulseIn.h" 8 #include "../include/PulseIn.h"
9 9
10 void PulseIn::init(BeagleRTContext* context, unsigned int digitalInput, int direction){ 10 void PulseIn::init(BelaContext* context, unsigned int digitalInput, int direction){
11 _digitalInput = digitalInput; 11 _digitalInput = digitalInput;
12 _pulseIsOn = false; 12 _pulseIsOn = false;
13 _pulseOnState = direction == 1 ? 1 : 0; 13 _pulseOnState = direction == 1 ? 1 : 0;
14 _array.resize(context->digitalFrames); 14 _array.resize(context->digitalFrames);
15 _lastContext = (uint64_t)-1; 15 _lastContext = (uint64_t)-1;
16 pinModeFrame(context, 0, digitalInput, INPUT); //context is used to allocate the number of elements in the array 16 pinModeFrame(context, 0, digitalInput, INPUT); //context is used to allocate the number of elements in the array
17 } 17 }
18 18
19 void PulseIn::check(BeagleRTContext* context){ 19 void PulseIn::check(BelaContext* context){
20 if(_digitalInput == -1){ //must be init'ed before calling check(); 20 if(_digitalInput == -1){ //must be init'ed before calling check();
21 throw(1); 21 throw(1);
22 } 22 }
23 for(unsigned int n = 0; n < context->digitalFrames; n++){ 23 for(unsigned int n = 0; n < context->digitalFrames; n++){
24 _array[n] = 0; //maybe a few of these will be overwritten below 24 _array[n] = 0; //maybe a few of these will be overwritten below