added tone request gateway before actually swithcing the pin

This commit is contained in:
Flo
2025-12-08 19:24:47 +01:00
commit f0e8b49854
68 changed files with 11057 additions and 0 deletions
+115
View File
@@ -0,0 +1,115 @@
/*
* PiepPattern.cpp
*
* Created on: 25.02.2020
* Author: flori
*/
#include "main.h"
#include "PiepPattern.h"
#include "PiepMode.h"
#define SERIAL_PRINT(x) // Serial.print(" "); Serial.print(x)
#define STANDBY 0
#define ON 1
/**
*
*/
PiepPattern::PiepPattern()
{
requestCount = 0;
numberModes = 0;
counter = 0;
modeIndex = 0;
startRequest = false;
stopRequest = false;
state = STANDBY;
outPin = 13;
piepModes = NULL;
}
/**
*
*/
IRAM_ATTR void PiepPattern::Start(uint8_t outPin)
{
startRequest = true;
this->outPin = outPin;
state = STANDBY;
}
/**
*
*/
IRAM_ATTR void PiepPattern::Stop()
{
stopRequest = true;
}
/**
*
*/
IRAM_ATTR void PiepPattern::TaskCyclic()
{
switch (state)
{
case STANDBY:
SERIAL_PRINT("STDBY");
stopRequest = false;
if (startRequest)
{
startRequest = false;
counter = 0;
modeIndex = 0;
if (numberModes > 0)
{
state = ON;
piepModes[modeIndex]->Start(outPin);
piepModes[modeIndex]->TaskCyclic();
}
}
break;
case ON:
SERIAL_PRINT(modeIndex);
SERIAL_PRINT(piepModes[modeIndex]->onTime);
startRequest = false;
piepModes[modeIndex]->TaskCyclic();
if (stopRequest)
{
piepModes[modeIndex]->Stop();
state = STANDBY;
}
else
{
if (piepModes[modeIndex]->HasCompleted())
{
if (++modeIndex < numberModes)
{
piepModes[modeIndex]->Start(outPin);
}
else if ( requestCount == 0)
{
modeIndex = 0;
piepModes[modeIndex]->Start(outPin);
}
else if ( ++counter < requestCount )
{
modeIndex = 0;
piepModes[modeIndex]->Start(outPin);
}
}
}
break;
default:
Serial.print(state);
break;
}
}