Use settings from EEPROM.
This commit is contained in:
parent
f75cbe5f6c
commit
3a1d2ad3ad
@ -23,6 +23,7 @@ uint8_t KettleDuty = 0;
|
|||||||
uint8_t KettleTemp;
|
uint8_t KettleTemp;
|
||||||
uint8_t KettleSetpoint;
|
uint8_t KettleSetpoint;
|
||||||
modes KettleMode = OFF;
|
modes KettleMode = OFF;
|
||||||
|
const int UpdateInterval = 5000;
|
||||||
|
|
||||||
/* Defined in config.h for now */
|
/* Defined in config.h for now */
|
||||||
// uint8_t ThreshPWR = 5;
|
// uint8_t ThreshPWR = 5;
|
||||||
@ -41,7 +42,7 @@ thermoControl KettleController;
|
|||||||
void MessageReceived(char*, byte*, unsigned int);
|
void MessageReceived(char*, byte*, unsigned int);
|
||||||
|
|
||||||
EthernetClient net;
|
EthernetClient net;
|
||||||
PubSubClient mqtt_client(MQTT_BROKER, 1883, MessageReceived, net);
|
PubSubClient mqtt_client;
|
||||||
|
|
||||||
unsigned long lastRun = 0;
|
unsigned long lastRun = 0;
|
||||||
|
|
||||||
@ -99,12 +100,14 @@ LiquidScreen home_screen(kettle_state_line, kettle_power_line);
|
|||||||
LiquidMenu menu(lcd);
|
LiquidMenu menu(lcd);
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
|
ConfigData config;
|
||||||
|
EEPROM.get(ConfAddress, config);
|
||||||
|
|
||||||
|
|
||||||
unsigned long lastRun = millis() - UpdateInterval;
|
unsigned long lastRun = millis() - UpdateInterval;
|
||||||
Serial.begin(9600);
|
Serial.begin(9600);
|
||||||
rotary.begin();
|
rotary.begin();
|
||||||
Ethernet.begin(mac, ip);
|
Ethernet.begin(config.mac, config.ip);
|
||||||
Serial.println("Setting up...");
|
|
||||||
|
|
||||||
attachInterrupt(digitalPinToInterrupt(encoderCLK), doEncoder, CHANGE);
|
attachInterrupt(digitalPinToInterrupt(encoderCLK), doEncoder, CHANGE);
|
||||||
attachInterrupt(digitalPinToInterrupt(encoderDT), doEncoder, CHANGE);
|
attachInterrupt(digitalPinToInterrupt(encoderDT), doEncoder, CHANGE);
|
||||||
@ -112,16 +115,17 @@ void setup() {
|
|||||||
pinMode(encoderCLK, INPUT_PULLUP);
|
pinMode(encoderCLK, INPUT_PULLUP);
|
||||||
pinMode(encoderDT, INPUT_PULLUP);
|
pinMode(encoderDT, INPUT_PULLUP);
|
||||||
Enter.begin(encoderBTN);
|
Enter.begin(encoderBTN);
|
||||||
boilPWM.begin(kettlePWM, PeriodPWM);
|
boilPWM.begin(kettlePWM, config.period);
|
||||||
KettleThermo.begin(MAX31865_3WIRE);
|
KettleThermo.begin(MAX31865_3WIRE);
|
||||||
|
|
||||||
|
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(&KettleTemp, &KettleSetpoint, &KettleDuty, config.threshold, config.hysteresis);
|
||||||
// if you get a connection, report back via serial:
|
// if you get a connection, report back via serial:
|
||||||
if (Ethernet.linkStatus() == LinkON) {
|
if (Ethernet.linkStatus() == LinkON) {
|
||||||
ConnectMQTT();
|
ConnectMQTT();
|
||||||
} else {
|
|
||||||
// if you didn't get a connection to the server:
|
|
||||||
Serial.println("connection failed");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
lcd.init();
|
lcd.init();
|
||||||
|
Loading…
Reference in New Issue
Block a user