annotate core/PulseIn.cpp @ 269:ac8eb07afcf5

Oxygen text added to each render.cpp file for the default projects. Text includes project explanation from Wiki, edited in places. Empty project added as a default project. Doxyfile updated. Each of the project locations added to INPUT configuration option. Consider just watching the whole project file so all new projects are automatically pulled through.
author Robert Jack <robert.h.jack@gmail.com>
date Tue, 17 May 2016 15:40:16 +0100
parents 3c3d14654b7f
children e4392164b458
rev   line source
giuliomoro@193 1 /*
giuliomoro@193 2 * PulseIn.cpp
giuliomoro@193 3 *
giuliomoro@193 4 * Created on: 4 Feb 2016
giuliomoro@193 5 * Author: giulio
giuliomoro@193 6 */
giuliomoro@193 7
giuliomoro@193 8 #include "../include/PulseIn.h"
giuliomoro@193 9
giuliomoro@193 10 void PulseIn::init(BeagleRTContext* context, unsigned int digitalInput, int direction){
giuliomoro@193 11 _digitalInput = digitalInput;
giuliomoro@193 12 _pulseIsOn = false;
giuliomoro@193 13 _pulseOnState = direction == 1 ? 1 : 0;
giuliomoro@193 14 _array.resize(context->digitalFrames);
giuliomoro@193 15 _lastContext = (uint64_t)-1;
giuliomoro@193 16 pinModeFrame(context, 0, digitalInput, INPUT); //context is used to allocate the number of elements in the array
giuliomoro@193 17 }
giuliomoro@193 18
giuliomoro@193 19 void PulseIn::check(BeagleRTContext* context){
giuliomoro@193 20 if(_digitalInput == -1){ //must be init'ed before calling check();
giuliomoro@193 21 throw(1);
giuliomoro@193 22 }
giuliomoro@193 23 for(unsigned int n = 0; n < context->digitalFrames; n++){
giuliomoro@193 24 _array[n] = 0; //maybe a few of these will be overwritten below
giuliomoro@193 25 }
giuliomoro@193 26 for(unsigned int n = 0; n < context->digitalFrames; n++){
giuliomoro@193 27 if(_pulseIsOn == false){ // look for start edge
giuliomoro@193 28 if(digitalReadFrame(context, n, _digitalInput) == _pulseOnState){
giuliomoro@193 29 _pulseStart = context->audioSampleCount + n; // store location of start edge
giuliomoro@193 30 _pulseIsOn = true;
giuliomoro@193 31 }
giuliomoro@193 32 } else { // _pulseIsOn == true;
giuliomoro@193 33 if(digitalReadFrame(context, n, _digitalInput) == !_pulseOnState){ // look for stop edge
giuliomoro@193 34 _array[n] = context->audioSampleCount + n - _pulseStart; // compute and store pulse duration
giuliomoro@193 35 _pulseIsOn = false;
giuliomoro@193 36 }
giuliomoro@193 37 }
giuliomoro@193 38 }
giuliomoro@193 39 _lastContext = context->audioSampleCount;
giuliomoro@193 40 };
giuliomoro@193 41
giuliomoro@193 42 PulseIn::~PulseIn() {
giuliomoro@193 43 // TODO Auto-generated destructor stub
giuliomoro@193 44 }
giuliomoro@193 45