Skip to content

Commit

Permalink
minor fix that may introduce concurrency problem
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabiano Riccardi committed Nov 3, 2019
1 parent 77f72e2 commit 92fce73
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/thyristor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ struct PinDelay{
*/
static struct PinDelay pinDelay[Thyristor::N];

/**
* Summary about thyristors state used by interrupt (concurrent-safe)
*/
static bool _allThyristorsOnOff = true;

/**
* Tell if zero cross interrupt is enabled
*/
Expand Down Expand Up @@ -287,16 +292,12 @@ void zero_cross_int(){
pinDelay[i].delay=Thyristor::thyristors[i]->delay;
}
}
// for(int i=0;i<Thyristor::nThyristors;i++){
// Serial.print(String("int: ") + pinDelay[i].pin);
// Serial.print(" ");
// Serial.println(pinDelay[i].delay);
// }
_allThyristorsOnOff = Thyristor::allThyristorsOnOff;
}

thyristorManaged = 0;

if(Thyristor::allThyristorsOnOff){
if(_allThyristorsOnOff){
for(int i=0; i<Thyristor::nThyristors; i++){
if(pinDelay[i].delay==semiPeriodLength-endMargin){
digitalWrite(pinDelay[i].pin, LOW);
Expand Down

0 comments on commit 92fce73

Please sign in to comment.