no message
This commit is contained in:
parent
68166c9d2a
commit
059e160474
|
@ -31,7 +31,7 @@ Adafruit_MCP23017 mcp;
|
||||||
using namespace ace_button;
|
using namespace ace_button;
|
||||||
long tslr = 0;
|
long tslr = 0;
|
||||||
WiFiClient espClient;
|
WiFiClient espClient;
|
||||||
boolean allowbuttonint=true;
|
boolean allowbuttonint = true;
|
||||||
PubSubClient client("siwatsystem.com", 1883, espClient);
|
PubSubClient client("siwatsystem.com", 1883, espClient);
|
||||||
PubSubClientTools mqtt(client);
|
PubSubClientTools mqtt(client);
|
||||||
ThreadController threadControl = ThreadController();
|
ThreadController threadControl = ThreadController();
|
||||||
|
@ -44,23 +44,23 @@ boolean lastsensorstate[12];
|
||||||
boolean firstrun = true;
|
boolean firstrun = true;
|
||||||
FlowMeter sensor1 = FlowMeter(12);
|
FlowMeter sensor1 = FlowMeter(12);
|
||||||
FlowMeter sensor2 = FlowMeter(13);
|
FlowMeter sensor2 = FlowMeter(13);
|
||||||
boolean devcon=false;
|
boolean devcon = false;
|
||||||
int devconmenu=0;
|
int devconmenu = 0;
|
||||||
volatile boolean awakenByInterrupt = false;
|
volatile boolean awakenByInterrupt = false;
|
||||||
LiquidCrystal_I2C lcd(0x3F, 16, 2);
|
LiquidCrystal_I2C lcd(0x3F, 16, 2);
|
||||||
int menu;
|
int menu;
|
||||||
void writelcd(String line1, String line2){
|
void writelcd(String line1, String line2) {
|
||||||
if(!devcon){
|
if (!devcon) {
|
||||||
lcd.clear();
|
lcd.clear();
|
||||||
lcd.print(line1);
|
lcd.print(line1);
|
||||||
lcd.setCursor(0,1);
|
lcd.setCursor(0, 1);
|
||||||
lcd.print(line2);
|
lcd.print(line2);
|
||||||
Serial.print("Writing to LCD: "+line1+" "+line2+"\n");
|
Serial.print("Writing to LCD: " + line1 + " " + line2 + "\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void updatelcd()
|
void updatelcd()
|
||||||
{
|
{
|
||||||
if(!devcon)writelcd("1: "+String((int)sensor1.getCurrentFlowrate())+"L/h "+String(sensor1.getTotalVolume())+"L","2:"+String((int)sensor2.getCurrentFlowrate())+"L/h "+String(sensor2.getTotalVolume())+"L");
|
if (!devcon)writelcd("1: " + String((int)sensor1.getCurrentFlowrate()) + "L/h " + String(sensor1.getTotalVolume()) + "L", "2:" + String((int)sensor2.getCurrentFlowrate()) + "L/h " + String(sensor2.getTotalVolume()) + "L");
|
||||||
}
|
}
|
||||||
void ICACHE_RAM_ATTR read1() {
|
void ICACHE_RAM_ATTR read1() {
|
||||||
sensor1.count();
|
sensor1.count();
|
||||||
|
@ -83,21 +83,21 @@ void updatemqtt() {
|
||||||
// ESPCommander EXTENDED v1.2
|
// ESPCommander EXTENDED v1.2
|
||||||
// For Legal Distribution of this code, the comment must not be removed!
|
// For Legal Distribution of this code, the comment must not be removed!
|
||||||
void espcommander(String topic, String rawcommand) {
|
void espcommander(String topic, String rawcommand) {
|
||||||
StaticJsonDocument<200> doc;
|
StaticJsonDocument<200> doc;
|
||||||
DeserializationError error = deserializeJson(doc, rawcommand);
|
DeserializationError error = deserializeJson(doc, rawcommand);
|
||||||
if (error) {
|
if (error) {
|
||||||
Serial.print(F("deserializeJson() failed: "));
|
Serial.print(F("deserializeJson() failed: "));
|
||||||
Serial.println(error.c_str());
|
Serial.println(error.c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const char* command = doc["command"];
|
const char* command = doc["command"];
|
||||||
const char* value = doc["value"];
|
const char* value = doc["value"];
|
||||||
}
|
}
|
||||||
//END OF ESPCOMMANDER CODE
|
//END OF ESPCOMMANDER CODE
|
||||||
void setup() {
|
void setup() {
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
lcd.begin();
|
lcd.begin();
|
||||||
writelcd(" Siwat INC (tm) "," Waterish OS");
|
writelcd(" Siwat INC (tm) ", " Waterish OS");
|
||||||
delay(1000);
|
delay(1000);
|
||||||
WiFi.mode(WIFI_STA);
|
WiFi.mode(WIFI_STA);
|
||||||
WiFi.disconnect(true);
|
WiFi.disconnect(true);
|
||||||
|
@ -106,18 +106,18 @@ void setup() {
|
||||||
while (WiFi.status() != WL_CONNECTED && online)
|
while (WiFi.status() != WL_CONNECTED && online)
|
||||||
{
|
{
|
||||||
//wait for it ... (Wait for Wifi Connection)
|
//wait for it ... (Wait for Wifi Connection)
|
||||||
writelcd("WiFi Connecting"," Attempt "+String(connectionattempt));
|
writelcd("WiFi Connecting", " Attempt " + String(connectionattempt));
|
||||||
connectionattempt++;
|
connectionattempt++;
|
||||||
delay(500);
|
delay(500);
|
||||||
if (connectionattempt >= 60) {
|
if (connectionattempt >= 60) {
|
||||||
writelcd(" Cannot Connect"," Going Offline!");
|
writelcd(" Cannot Connect", " Going Offline!");
|
||||||
online = false;
|
online = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
String wifiname(ssid);
|
String wifiname(ssid);
|
||||||
if(online)writelcd(" WiFi Connected",wifiname);
|
if (online)writelcd(" WiFi Connected", wifiname);
|
||||||
delay(3000);
|
delay(3000);
|
||||||
writelcd("Boot Sequence P3"," Loading Kernel");
|
writelcd("Boot Sequence P3", " Loading Kernel");
|
||||||
pinMode(14, INPUT_PULLUP);
|
pinMode(14, INPUT_PULLUP);
|
||||||
pinMode(12, INPUT);
|
pinMode(12, INPUT);
|
||||||
pinMode(13, INPUT);
|
pinMode(13, INPUT);
|
||||||
|
@ -126,9 +126,9 @@ void setup() {
|
||||||
attachInterrupt(digitalPinToInterrupt(12), read1, RISING);
|
attachInterrupt(digitalPinToInterrupt(12), read1, RISING);
|
||||||
attachInterrupt(digitalPinToInterrupt(13), read2, RISING);
|
attachInterrupt(digitalPinToInterrupt(13), read2, RISING);
|
||||||
delay(1000);
|
delay(1000);
|
||||||
writelcd("Boot Sequence P3","Waking Processor");
|
writelcd("Boot Sequence P3", "Waking Processor");
|
||||||
delay(1000);
|
delay(1000);
|
||||||
writelcd(" SETTINGS.H","co-processor:OFF");
|
writelcd(" SETTINGS.H", "co-processor:OFF");
|
||||||
delay(3000);
|
delay(3000);
|
||||||
mcp.begin();
|
mcp.begin();
|
||||||
for (int i = 0; i <= 15; i++)
|
for (int i = 0; i <= 15; i++)
|
||||||
|
@ -138,58 +138,58 @@ void setup() {
|
||||||
mcp.setupInterruptPin(i, RISING);
|
mcp.setupInterruptPin(i, RISING);
|
||||||
}
|
}
|
||||||
delay(1000);
|
delay(1000);
|
||||||
writelcd("Boot Sequence P3"," Success!");
|
writelcd("Boot Sequence P3", " Success!");
|
||||||
delay(2000);
|
delay(2000);
|
||||||
writelcd("Waterish OS a3.9","Reading Sensors");
|
writelcd("Waterish OS a3.9", "Reading Sensors");
|
||||||
delay(1000);
|
delay(1000);
|
||||||
writelcd(" Telemetry Node","siwatsystem.com");
|
writelcd(" Telemetry Node", "siwatsystem.com");
|
||||||
if (client.connect("waterishos",telemetryuser,telemetrykey)) {
|
if (client.connect("waterishos", telemetryuser, telemetrykey)) {
|
||||||
writelcd(" Telemetry Node","Connected");
|
writelcd(" Telemetry Node", "Connected");
|
||||||
mqtt.subscribe("/waterishos/node" + nodename + "command", espcommander);
|
mqtt.subscribe("/waterishos/node" + nodename + "command", espcommander);
|
||||||
delay(1000);
|
delay(1000);
|
||||||
} else {
|
} else {
|
||||||
writelcd(" Telemetry Node"," Failed Offline");
|
writelcd(" Telemetry Node", " Failed Offline");
|
||||||
online=false;
|
online = false;
|
||||||
delay(3000);
|
delay(3000);
|
||||||
}
|
}
|
||||||
datacollector.onRun(collectdata);
|
datacollector.onRun(collectdata);
|
||||||
datacollector.setInterval(1000);
|
datacollector.setInterval(1000);
|
||||||
if(online)mqttupdater.onRun(updatemqtt);
|
if (online)mqttupdater.onRun(updatemqtt);
|
||||||
if(online)mqttupdater.setInterval(1000);
|
if (online)mqttupdater.setInterval(1000);
|
||||||
lcdmanager.onRun(updatelcd);
|
lcdmanager.onRun(updatelcd);
|
||||||
lcdmanager.setInterval(250);
|
lcdmanager.setInterval(250);
|
||||||
threadControl.add(&datacollector);
|
threadControl.add(&datacollector);
|
||||||
threadControl.add(&lcdmanager);
|
threadControl.add(&lcdmanager);
|
||||||
if(online)threadControl.add(&mqttupdater);
|
if (online)threadControl.add(&mqttupdater);
|
||||||
if(online)updatemqtt();
|
if (online)updatemqtt();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
if(online)client.loop();
|
if (online)client.loop();
|
||||||
if(!devcon)threadControl.run();
|
if (!devcon)threadControl.run();
|
||||||
}
|
}
|
||||||
void drawcon(){
|
void drawcon() {
|
||||||
if(devconmenu==1){
|
if (devconmenu == 1) {
|
||||||
writelcd("connectionchck.c","Check Connection");
|
writelcd("connectionchck.c", "Check Connection");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void startdevcon(){
|
void startdevcon() {
|
||||||
allowbuttonint=false;
|
allowbuttonint = false;
|
||||||
devcon=true; //no going back, Delete Waterish OS and Install Siwat INC(R) DEVCON OS
|
devcon = true; //no going back, Delete Waterish OS and Install Siwat INC(R) DEVCON OS
|
||||||
writelcd(" SIWAT INC(R) ","DEVCON OS V3.2.4");
|
writelcd(" SIWAT INC(R) ", "DEVCON OS V3.2.4");
|
||||||
delay(1000);
|
delay(1000);
|
||||||
writelcd("DEVCON TOOLKITS","3 Extension Load");
|
writelcd("DEVCON TOOLKITS", "3 Extension Load");
|
||||||
delay(1000);
|
delay(1000);
|
||||||
writelcd("Initia Extension","connectionchck.c");
|
writelcd("Initia Extension", "connectionchck.c");
|
||||||
delay(2000);
|
delay(2000);
|
||||||
writelcd("Initia Extension","hall_pid_tuner.c")
|
writelcd("Initia Extension", "hall_pid_tuner.c")
|
||||||
delay(2000);
|
delay(2000);
|
||||||
writelcd("Initia Extension","credit_display.c");
|
writelcd("Initia Extension", "credit_display.c");
|
||||||
delay(2000);
|
delay(2000);
|
||||||
writelcd("DEVCON TOOLKITS","set WTOS at 0x3D");
|
writelcd("DEVCON TOOLKITS", "set WTOS at 0x3D");
|
||||||
delay(1000);
|
delay(1000);
|
||||||
allowbuttonint=true;
|
allowbuttonint = true;
|
||||||
devconmenu=1;
|
devconmenu = 1;
|
||||||
drawcon();
|
drawcon();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue