26 Serial.println(
"Starting the Ultrasonic loop thread");
35 Serial.println(
"ERROR Pid thread died!");
76 delayMicroseconds(10);
83 portENTER_CRITICAL(&
synch);
90 portEXIT_CRITICAL(&
synch);
98 Serial.println(
"Spawing rangefinder timeout thread");
100 xTaskCreatePinnedToCore(
onTimer,
"Rangefinder Thread", 8192, NULL, 2,
104 if (Rangefinder::list[i] == NULL) {
106 delayMicroseconds(2);
107 Rangefinder::list[i] =
this;
145 portENTER_CRITICAL(&
synch);
147 portEXIT_CRITICAL(&
synch);
float getDistanceCM()
get the distance of an object from the sensor in centimeters
static int getTimeoutState()
Function used by the timeout check thread to determine if this object has timed out.
static Rangefinder * list[MAX_POSSIBLE_INTERRUPT_RANGEFINDER]
list of attached rangefinders
void sensorISR()
The method called from the ISR indicating the echo pin changed state.
void IRAM_ATTR sensorISR0()
void IRAM_ATTR sensorISR3()
static bool timoutThreadStarted
long getRoundTripTimeMicroSeconds()
get the time of latest round trip in microseconds
Rangefinder objects wrap a FreeRTOS thread with pin change interrupts to read trigger/echo style ultr...
void IRAM_ATTR sensorISR2()
#define MAX_POSSIBLE_INTERRUPT_RANGEFINDER
void onTimer(void *param)
volatile unsigned long startTime
static void checkTimeout()
check the current state of timeout and fire if its time to do so
static int numberOfFinders
static TaskHandle_t complexHandlerTaskUS
void attach(int trigger, int echo)
Attach 2 pins to be used as triger and echo.
static void fire()
fire a strobe of the trig pin
volatile unsigned long roundTripTime
static long threadTimeout
void IRAM_ATTR sensorISR1()