Skip to content

Commit

Permalink
Merge pull request #33 from aleemont1/emanuele
Browse files Browse the repository at this point in the history
Merge the last features
  • Loading branch information
23Emaaaa authored Dec 4, 2023
2 parents 54efaa7 + a7abd1e commit 0846138
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 22 deletions.
1 change: 1 addition & 0 deletions smart_bridge/src/tasks/CountDown.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

CountDown::CountDown(int countDown) : Task()
{
Serial.println("CountDownTask created");
this->setStatus(false);
this->lcd = new LCD(0x27, 16, 2);
this->resetCountDown(N3);
Expand Down
14 changes: 5 additions & 9 deletions smart_bridge/src/tasks/TemperatureTask.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include "TemperatureTask.h"

TemperatureTask::TemperatureTask()
: Task(),
voltageConversionFactor(100),
: TaskWithTimer(),
voltageConversionFactor(30),
voltageOffset(0.5)
{
Serial.println("TemperatureTask created");
Expand Down Expand Up @@ -39,25 +39,21 @@ void TemperatureTask::setTemperature(int temperature)
void TemperatureTask::printTemperature()
{
int temp = getTemperature();
lcd->write(("Temperature: " + String(temp) + "°C").c_str(), 0, 0);
lcd->write(("Temperature: " + String(temp) + (char)223 + "C").c_str(), 0, 0);
}

bool TemperatureTask::checkForCriticalTemperature()
{
if (temperature > MAXTEMP)
{
if (timeExceededMaxTemp == 0)
{
timeExceededMaxTemp = millis();
}
else if (millis() - timeExceededMaxTemp >= N5 * 1000)
if (this->elapsedTime() >= N5 * 1000)
{
return true;
}
}
else
{
timeExceededMaxTemp = 0;
this->resetTime();
}
return false;
}
Expand Down
4 changes: 2 additions & 2 deletions smart_bridge/src/tasks/TemperatureTask.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef __TEMPERATURE_TASK__
#define __TEMPERATURE_TASK__

#include "kernel/Task.h"
#include "kernel/TaskWithTimer.h"
#include "Arduino.h"
#include "config/config.h"
#include "components/api/LCD.h"
Expand All @@ -14,7 +14,7 @@
*
* @extends Task
*/
class TemperatureTask : public Task
class TemperatureTask : public TaskWithTimer
{
public:
/**
Expand Down
23 changes: 15 additions & 8 deletions smart_bridge/src/tasks/WashingTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,26 +53,33 @@ void WashingTask::printWashingCompletedMessage()
void WashingTask::handleStartWashing()
{
this->blinkTask->setActive(true);
this->countDownTask->setActive(true);
this->temperatureTask->setActive(true);
this->setState(STARTS_COUNTDOWN);
}

void WashingTask::handleStartsCountdown()
{
this->countDownTask->tick();
this->temperatureTask->tick();
if (this->temperatureTask->checkForCriticalTemperature() == true && this->countDownTask->getStatus() == false)
// this->countDownTask->tick();
// this->temperatureTask->tick();
if (this->elapsedTime() >= checkInterval)
{
this->setState(ERROR);
}
if (this->countDownTask->getStatus() == true)
{
this->setState(ENDS_COUNTDOWN);
this->resetTime();
if (this->temperatureTask->checkForCriticalTemperature() == true && this->countDownTask->getStatus() == false)
{
this->setState(ERROR);
}
if (this->countDownTask->getStatus() == true)
{
this->setState(ENDS_COUNTDOWN);
}
}
}

void WashingTask::handleEndsCountdown()
{
this->countDownTask->endsCountDown();
this->temperatureTask->setCompleted();
this->blinkTask->setActive(false);
this->L3->switchOn();
this->printWashingCompletedMessage();
Expand Down
7 changes: 4 additions & 3 deletions smart_bridge/src/tasks/WashingTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,10 @@ class WashingTask : public DependantTaskWithState
ERROR, ///< The task is currently handling an error.
};

int savedCountDown;
unsigned long savedTimeInState;
int countDown;
int savedCountDown; ///< The saved value of the countdown.
unsigned long savedTimeInState; ///< The time that the task has been in the current state.
int checkInterval = 5000; ///< 5 seconds
int countDown; ///< The current value of the countdown.
Led *L2; ///< Pointer to the L2 LED object.
Led *L3; ///< Pointer to the L3 LED object.
Temp *tempSensor; ///< Pointer to the temperature sensor object.
Expand Down

0 comments on commit 0846138

Please sign in to comment.