#include "Pomodoro.h" bool useLed=true; bool useBuzzer=true; uint32_t timeWork=25*60*1000; uint32_t timeShortRest=5*60*1000; uint32_t timeLongRest=15*60*1000; int workBetweenLongBreak=4; int workDone=0; bool work=true; int currentWait=timeWork; uint32_t timerLastValue=0; const int pinLedWork=25; const int pinLedShortBreak=33; const int pinLedLongBreak=32; const int ledFrequency=5000; const int ledResolution=8; const int ledChannelWork=0; const int ledChannelShortBreak=1; const int ledChannelLongBreak=2; int ledWorkMaxValue=1; int ledShortBreakMaxValue=1; int ledLongBreakMaxValue=1; const int pinBuzzer=27; const int buzzerFrequency=2000; const int buzzerResolution=8; const int buzzerChannel=3; void setupPomodoro(){ //pinMode(pinLedWork,OUTPUT); //pinMode(pinLedShortBreak,OUTPUT); //pinMode(pinLedLongBreak,OUTPUT); ledcSetup(ledChannelWork, ledFrequency, ledResolution); ledcSetup(ledChannelShortBreak, ledFrequency, ledResolution); ledcSetup(ledChannelLongBreak, ledFrequency, ledResolution); ledcAttachPin(pinLedWork, ledChannelWork); ledcAttachPin(pinLedShortBreak, ledChannelShortBreak); ledcAttachPin(pinLedLongBreak, ledChannelLongBreak); ledcSetup(buzzerChannel,buzzerFrequency,buzzerResolution); ledcAttachPin(pinBuzzer,buzzerChannel); } void writeToBuzzer(int note,int duration,bool continuous=false){ if(useBuzzer){ ledcWriteTone(buzzerChannel,note); if(!continuous){ delay(duration); ledcWriteTone(buzzerChannel,0); } } } void writeToLed(int led,int value){ if(useLed){ ledcWrite(led,value); } } void displayWork(bool afterLongBreak){ Serial.println("Return to work"); writeToLed(ledChannelWork,ledWorkMaxValue); writeToLed(ledChannelShortBreak,0); writeToLed(ledChannelLongBreak,0); //digitalWrite(LED_WORK,HIGH); //digitalWrite(LED_SHORT_BREAK,LOW); //digitalWrite(LED_LONG_BREAK,LOW); if(afterLongBreak){ for(int i=0;i<3;i++){ writeToBuzzer(NOTE_C4,200); writeToBuzzer(NOTE_CS4,200); delay(500); } }else{ writeToBuzzer(NOTE_C1,200); } } void displayShortRest(){ Serial.println("Short rest"); writeToLed(ledChannelWork,0); writeToLed(ledChannelShortBreak,ledShortBreakMaxValue); writeToLed(ledChannelLongBreak,0); //digitalWrite(LED_WORK,LOW); //digitalWrite(LED_SHORT_BREAK,HIGH); //digitalWrite(LED_LONG_BREAK,LOW); writeToBuzzer(NOTE_F1,200); } void displayLongRest(){ Serial.println("Long rest"); writeToLed(ledChannelWork,0); writeToLed(ledChannelShortBreak,0); writeToLed(ledChannelLongBreak,ledLongBreakMaxValue); //digitalWrite(LED_WORK,LOW); //digitalWrite(LED_SHORT_BREAK,LOW); //digitalWrite(LED_LONG_BREAK,HIGH); writeToBuzzer(NOTE_DS4,200); writeToBuzzer(NOTE_D4,200); }