Mercurial > hg > beaglert
diff core/Utilities.cpp @ 52:a6d223473ea2 newapi
Updated examples for new API. tank_wars not yet updated; audio_in_FFT and oscillator_bank not working properly yet.
author | andrewm |
---|---|
date | Sun, 31 May 2015 02:13:39 -0500 |
parents | 579c86316008 |
children | d837fb676977 |
line wrap: on
line diff
--- a/core/Utilities.cpp Sat May 30 13:25:51 2015 -0500 +++ b/core/Utilities.cpp Sun May 31 02:13:39 2015 -0500 @@ -10,7 +10,7 @@ // analogReadFrame() // // Returns the value of the given analog input at the given frame number. -inline float analogReadFrame(BeagleRTContext *context, int frame, int channel) { +float analogReadFrame(BeagleRTContext *context, int frame, int channel) { return context->analogIn[frame * context->analogChannels + channel]; } @@ -18,7 +18,7 @@ // // Sets a given channel to a value for the current frame and, if persistent outputs are // enabled, for all subsequent frames -inline void analogWriteFrame(BeagleRTContext *context, int frame, int channel, float value) { +void analogWriteFrame(BeagleRTContext *context, int frame, int channel, float value) { if(context->flags & BEAGLERT_FLAG_ANALOG_OUTPUTS_PERSIST) { for(unsigned int f = frame; f < context->analogFrames; f++) context->analogOut[frame * context->analogChannels + channel] = value; @@ -30,21 +30,21 @@ // analogWriteFrameOnce() // // Sets a given channel to a value for only the current frame -inline void analogWriteFrameOnce(BeagleRTContext *context, int frame, int channel, float value) { +void analogWriteFrameOnce(BeagleRTContext *context, int frame, int channel, float value) { context->analogOut[frame * context->analogChannels + channel] = value; } // digitalReadFrame() // // Returns the value of a given digital input at the given frame number -inline int digitalReadFrame(BeagleRTContext *context, int frame, int channel) { +int digitalReadFrame(BeagleRTContext *context, int frame, int channel) { return getBit(context->digital[frame], channel + 16); } // digitalWriteFrame() // // Sets a given digital output channel to a value for the current frame and all subsequent frames -inline void digitalWriteFrame(BeagleRTContext *context, int frame, int channel, int value) { +void digitalWriteFrame(BeagleRTContext *context, int frame, int channel, int value) { for(unsigned int f = frame; f < context->digitalFrames; f++) { if(value) context->digital[f] |= 1 << (channel + 16); @@ -56,7 +56,7 @@ // digitalWriteFrameOnce() // // Sets a given digital output channel to a value for the current frame only -inline void digitalWriteFrameOnce(BeagleRTContext *context, int frame, int channel, int value) { +void digitalWriteFrameOnce(BeagleRTContext *context, int frame, int channel, int value) { if(value) context->digital[frame] |= 1 << (channel + 16); else @@ -66,7 +66,7 @@ // pinModeFrame() // // Sets the direction of a digital pin for the current frame and all subsequent frames -inline void pinModeFrame(BeagleRTContext *context, int frame, int channel, int mode) { +void pinModeFrame(BeagleRTContext *context, int frame, int channel, int mode) { for(unsigned int f = frame; f < context->digitalFrames; f++) { if(mode) context->digital[f] |= (1 << channel); @@ -78,7 +78,7 @@ // pinModeFrameOnce() // // Sets the direction of a digital pin for the current frame only -inline void pinModeFrameOnce(BeagleRTContext *context, int frame, int channel, int mode) { +void pinModeFrameOnce(BeagleRTContext *context, int frame, int channel, int mode) { if(mode) context->digital[frame] |= (1 << channel); else @@ -91,7 +91,7 @@ // x is the value to scale; in_min and in_max are the input range; out_min and out_max // are the output range. -inline float map(float x, float in_min, float in_max, float out_min, float out_max) +float map(float x, float in_min, float in_max, float out_min, float out_max) { return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; } @@ -101,7 +101,7 @@ // Clips an input value to be between two end points // x is the value to constrain; min_val and max_val are the range -inline float constrain(float x, float min_val, float max_val) +float constrain(float x, float min_val, float max_val) { if(x < min_val) return min_val; if(x > max_val) return max_val;