Here Comes Siwat INC(R) DEVCON V3
This commit is contained in:
parent
7cde8d63dc
commit
435a92b5f8
|
@ -26,9 +26,11 @@
|
||||||
#include <Adafruit_MCP23017.h>
|
#include <Adafruit_MCP23017.h>
|
||||||
#include <Thread.h>
|
#include <Thread.h>
|
||||||
#include <ThreadController.h>
|
#include <ThreadController.h>
|
||||||
|
#include <AceButton.h>
|
||||||
Adafruit_MCP23017 mcp;
|
Adafruit_MCP23017 mcp;
|
||||||
long tslr = 0;
|
long tslr = 0;
|
||||||
WiFiClient espClient;
|
WiFiClient espClient;
|
||||||
|
AceButton gpio0(0);
|
||||||
PubSubClient client("siwatsystem.com", 1883, espClient);
|
PubSubClient client("siwatsystem.com", 1883, espClient);
|
||||||
PubSubClientTools mqtt(client);
|
PubSubClientTools mqtt(client);
|
||||||
ThreadController threadControl = ThreadController();
|
ThreadController threadControl = ThreadController();
|
||||||
|
@ -41,19 +43,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;
|
||||||
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 handleGPIO0(AceButton*, uint8_t, uint8_t);
|
||||||
void writelcd(String line1, String line2){
|
void writelcd(String line1, String line2){
|
||||||
|
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()
|
||||||
{
|
{
|
||||||
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();
|
||||||
|
@ -113,6 +119,8 @@ void setup() {
|
||||||
pinMode(14, INPUT_PULLUP);
|
pinMode(14, INPUT_PULLUP);
|
||||||
pinMode(12, INPUT);
|
pinMode(12, INPUT);
|
||||||
pinMode(13, INPUT);
|
pinMode(13, INPUT);
|
||||||
|
pinMode(0, INPUT_PULLUP);
|
||||||
|
gpio0.setEventHandler(handleGPIO0);
|
||||||
attachInterrupt(digitalPinToInterrupt(12), read1, RISING);
|
attachInterrupt(digitalPinToInterrupt(12), read1, RISING);
|
||||||
attachInterrupt(digitalPinToInterrupt(13), read2, RISING);
|
attachInterrupt(digitalPinToInterrupt(13), read2, RISING);
|
||||||
delay(1000);
|
delay(1000);
|
||||||
|
@ -158,4 +166,28 @@ void setup() {
|
||||||
void loop() {
|
void loop() {
|
||||||
if(online)client.loop();
|
if(online)client.loop();
|
||||||
threadControl.run();
|
threadControl.run();
|
||||||
|
gpio0.check();
|
||||||
|
}
|
||||||
|
void handleGPIO0(AceButton* , uint8_t eventType,
|
||||||
|
uint8_t ) {
|
||||||
|
switch (eventType) {
|
||||||
|
case AceButton::kEventPressed:
|
||||||
|
devcon=true; //no going back, Delete Waterish OS and Install Siwat INC(R) DEVCON OS
|
||||||
|
lcd.print(" SIWAT INC(R) ","DEVCON OS V3.2.4");
|
||||||
|
delay(1000);
|
||||||
|
lcd.print("DEVCON TOOLKITS","3 Extension Load");
|
||||||
|
delay(1000);
|
||||||
|
lcd.print("Initia Extension","connectionchck.c");
|
||||||
|
delay(2000);
|
||||||
|
lcd.print("Initia Extension","hall_pid_tuner.c")
|
||||||
|
delay(2000);
|
||||||
|
lcd.print("Initia Extension","credit_display.c");
|
||||||
|
delay(2000);
|
||||||
|
lcd.print("DEVCON TOOLKITS","set WTOS at 0x3D");
|
||||||
|
delay(1000);
|
||||||
|
break;
|
||||||
|
case AceButton::kEventReleased:
|
||||||
|
//debounce
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue