9 void BumpSensors::readRaw()
11 FastGPIO::Pin<emitterPin>::setOutputLow();
13 FastGPIO::Pin<bumpLeftPin>::setOutputHigh();
14 FastGPIO::Pin<bumpRightPin>::setOutputHigh();
21 uint16_t startTime = micros();
22 FastGPIO::Pin<bumpLeftPin>::setInput();
23 FastGPIO::Pin<bumpRightPin>::setInput();
29 uint16_t time = micros() - startTime;
38 __builtin_avr_delay_cycles(4);
41 FastGPIO::Pin<emitterPin>::setInput();
46 uint32_t sum[2] = {0, 0};
48 for (uint8_t i = 0; i < count; i++)
57 baseline[s] = (sum[s] + count / 2) / count;
76 bitField |= pressed[s] << s;
uint16_t sensorValues[2]
Raw reflectance sensor readings.
uint16_t threshold[2]
Thresholds for bump sensor press detection.
uint16_t marginPercentage
The amount, as a percentage, that will be added to the measured baseline to get the threshold.
uint16_t baseline[2]
Baseline readings obtained from calibration.
uint8_t read()
Reads both bump sensors.
uint16_t timeout
Timeout for bump sensor readings (in microseconds).
void calibrate(uint8_t count=50)
Calibrates the bump sensors.
Top-level namespace for the Pololu3piPlus32U4 library.
@ BumpRight
Right bump sensor.
@ BumpLeft
Left bump sensor.