-
Notifications
You must be signed in to change notification settings - Fork 0
/
FryEngine.h
70 lines (63 loc) · 2.28 KB
/
FryEngine.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/*
* Copyright (c) 2022, Vincent Bloemen (VinzzB)
* All rights reserved.
*
* This source code is licensed under the Apache 2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/
#ifndef FryEngine_h
#define FryEngine_h
#include "Arduino.h"
#include "Product.h"
//start heater when below this offset temperature.
//Lower = more precision
//Using zero could damage the relays. Use a value above 1
#define TEMP_OFFSET_LOW 5
#define PREHEAT_COMPLETE_STEP -1
#define ENGINE_STOPPED_STEP -2
typedef void (*callback)(int);
class FryEngine {
public:
FryEngine(byte heaterPin, byte fanPin, byte temperaturePin, int _preHeatTimeout, callback stepCompletedCallBack);
void setProduct(Product* product);
void start();
void start(Product* product);
void stop();
bool isRunning();
bool timer();
unsigned int getElapsedSeconds();
unsigned int getRemainingSeconds();
CookStep* getStep(byte stepIdx);
CookStep* getCurrentStep();
byte getCurrentStepIdx();
byte getStepsCount();
bool getPreHeatReached();
bool getPreHeat();
void setPreHeat(bool value);
byte getTemperature();
bool isOnTemperature();
byte resetTemperature();
private:
void adjustHeat(); //checks if heater needs to ben on or off... (in 'loop' function)
void powerFan(bool power); // fan on / off
void powerHeater(bool power);
void updateTemperature();
byte _heaterPin;
byte _fanPin;
byte _temperaturePin;
int _preHeatTimeout;
int _refreshInterval;
unsigned long _refreshedOn; //timer for temperature adjustement.
unsigned long _runningSince; //holds the starttime. (engine running)
bool _isOnTemp;
byte _temperatures[10]; //precision. (average temperature over 5s)
byte _tempIdx;
bool _preHeat;
bool _preHeatReached;
unsigned long _preHeatReachedTime;
byte _stepsCount;
byte _currentStep;
callback _stepCompletedCallBackPtr;
CookStep _steps[MAX_STEPS];
};
#endif