28 #define LIGHT_SENSOR IN_3
29 #define LIGHT_SENSOR_SAMPLING_PERIOD 36
30 #define LIGHT_SENSOR_SAMPLING_RATE 30
42 SetSensorLight(LIGHT_SENSOR);
44 ResetAllTachoCounts(OUT_B);
45 SamplerInit(sampler, 0, LIGHT_SENSOR_SAMPLING_PERIOD);
52 int tachoCount = GetOutput(OUT_B, TachoCount);
53 int lightSense = Sensor(LIGHT_SENSOR);
56 int lightSenseSample =
SamplerGet(sampler, tachoCount, lightSense);
57 if (lightSenseSample < 0)
64 LineOut(t, 16, t, 16 + lowPassOut,
false);
71 }
while (sampler.hasMore);
int LowPassFilter(LowPassFilterContext &context, int sampleInput)
Steps through the filter using the current sample sampleInput. This must be called at the sampling ra...
High Pass filter implementation.
void LowPassFilterInit(LowPassFilterContext &context, int RC, int samplingRate)
Initializes a low pass filter context with the given RC constant and sampling rate. RC is given as 2 * PI * Freq (in cycles per second. Sampling rate is in samples per second.
A sampler to sample a stream of inputs at periodic interval.
void SamplerInit(SamplerContext &context, int currentPosition, int samplingPeriod)
Initializes the sampler with given sampling period and initial position.
void HighPassFilterInit(HighPassFilterContext &context, int RC, int samplingRate)
Initializes the given high pass filter context with the given RC constant and sampling rate...
Low Pass filter implementation.
int HighPassFilter(HighPassFilterContext &context, int sampleInput)
Steps through the filter using the current sample sampleInput. This must be called at the sampling ra...
int SamplerGet(SamplerContext &context, int currentPosition, int sampleInput)
Returns sampleInput at the sampling periods and -1 for all others.
The class to hold sampler context.