Changed pin names because I can.
This commit is contained in:
parent
e12f3e262f
commit
c7857c1b03
@ -31,7 +31,7 @@ const int UpdateInterval = 5000;
|
||||
|
||||
// User I/O objects.
|
||||
Button Enter;
|
||||
MD_REncoder rotary = MD_REncoder(encoderDT, encoderCLK);
|
||||
MD_REncoder rotary = MD_REncoder(I_DT, I_CLK);
|
||||
LiquidCrystal_I2C lcd(0x27,20,4);
|
||||
|
||||
// Internal I/O
|
||||
@ -117,20 +117,20 @@ void setup() {
|
||||
rotary.begin();
|
||||
Ethernet.begin(config.mac, config.ip);
|
||||
|
||||
attachInterrupt(digitalPinToInterrupt(encoderCLK), doEncoder, CHANGE);
|
||||
attachInterrupt(digitalPinToInterrupt(encoderDT), doEncoder, CHANGE);
|
||||
attachInterrupt(digitalPinToInterrupt(I_CLK), doEncoder, CHANGE);
|
||||
attachInterrupt(digitalPinToInterrupt(I_DT), doEncoder, CHANGE);
|
||||
|
||||
pinMode(encoderCLK, INPUT_PULLUP);
|
||||
pinMode(encoderDT, INPUT_PULLUP);
|
||||
Enter.begin(encoderBTN);
|
||||
boilPWM.begin(kettlePWM, config.period);
|
||||
KettleThermo.begin(MAX31865_3WIRE);
|
||||
pinMode(I_CLK, INPUT_PULLUP);
|
||||
pinMode(I_DT, INPUT_PULLUP);
|
||||
Enter.begin(I_BTN);
|
||||
boilPWM.begin(O_PWM, config.period);
|
||||
|
||||
mqtt_client.setServer(config.mqtt.broker, 1883);
|
||||
mqtt_client.setClient(net);
|
||||
mqtt_client.setCallback(MessageReceived);
|
||||
|
||||
KettleController.begin(&KettleTemp, &KettleSetpoint, &KettleDuty, config.threshold, config.hysteresis);
|
||||
KettleController.begin((int8_t)I_CS1, 0, 0, config.threshold, config.hysteresis);
|
||||
|
||||
// if you get a connection, report back via serial:
|
||||
if (Ethernet.linkStatus() == LinkON) {
|
||||
ConnectMQTT();
|
||||
@ -165,11 +165,11 @@ void UpdateBoilKettle(){
|
||||
menu.update();
|
||||
}
|
||||
|
||||
if (KettleMode != OFF) {
|
||||
KettleController.Compute();
|
||||
digitalWrite(kettlePWM, boilPWM.compute(KettleDuty));
|
||||
if (KettleController.Mode() != OFF) {
|
||||
if (KettleController.Compute()) KettleDuty = KettleController.Power();
|
||||
digitalWrite(O_PWM, boilPWM.compute(KettleDuty));
|
||||
} else {
|
||||
digitalWrite(kettlePWM, boilPWM.compute(0));
|
||||
digitalWrite(O_PWM, boilPWM.compute(0));
|
||||
}
|
||||
}
|
||||
|
||||
|
71
boil_kettle/globals.h
Normal file
71
boil_kettle/globals.h
Normal file
@ -0,0 +1,71 @@
|
||||
#ifndef GLOBALS_h
|
||||
#define GLOBALS_h
|
||||
|
||||
const uint8_t CompileTimeP[] PROGMEM = __DATE__ " " __TIME__;
|
||||
const size_t ConfAddress = sizeof(CompileTimeP);
|
||||
|
||||
void ConnectMQTT();
|
||||
static void SendSensorData();
|
||||
void MessageReceived(char*, byte*, unsigned int);
|
||||
|
||||
char* ShowKettleState();
|
||||
char* ShowKettleSetting();
|
||||
void doEncoder();
|
||||
void UpdateBoilKettle();
|
||||
|
||||
struct Vessel {
|
||||
char name[16];
|
||||
char setpoint[20];
|
||||
char sensor[20];
|
||||
double Rref;
|
||||
double RNominal;
|
||||
};
|
||||
|
||||
struct Topic {
|
||||
char root[10];
|
||||
Vessel mash;
|
||||
Vessel boil;
|
||||
};
|
||||
|
||||
struct Mqtt {
|
||||
IPAddress broker;
|
||||
char user[10];
|
||||
char password[21];
|
||||
Topic topic;
|
||||
};
|
||||
|
||||
struct ConfigData {
|
||||
Mqtt mqtt;
|
||||
byte mac[6];
|
||||
IPAddress ip;
|
||||
int interval;
|
||||
int period;
|
||||
uint8_t threshold;
|
||||
uint8_t hysteresis;
|
||||
};
|
||||
|
||||
uint8_t KettleDuty = 0;
|
||||
bool SettingChanged = false;
|
||||
const int UpdateInterval = 5000;
|
||||
unsigned long lastRun = 0;
|
||||
|
||||
// Pin Definitions
|
||||
#ifndef I_CLK
|
||||
#define I_CLK 2
|
||||
#endif
|
||||
#ifndef I_DT
|
||||
#define I_DT 3
|
||||
#endif
|
||||
#ifndef I_BTN
|
||||
#define I_BTN 4
|
||||
#endif
|
||||
#ifndef O_PWM
|
||||
#define O_PWM 5
|
||||
#endif
|
||||
#ifndef I_CS1
|
||||
#define I_CS1 47
|
||||
#endif
|
||||
#ifndef I_CS2
|
||||
#define I_CS2 48
|
||||
#endif
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user