From e281e1adf869aea9f5e2d2a1cb5fdf0d86145d38 Mon Sep 17 00:00:00 2001 From: rljonesau Date: Sat, 6 Apr 2019 21:45:25 +1100 Subject: [PATCH] Initial mode IP1 ON, IP2 OFF - works! --- Arduino/BTCDieselHeater/BTCDieselHeater.ino | 5 ++ .../BTCDieselHeater/src/OLED/BasicScreen.cpp | 54 +++++++++---------- .../src/OLED/ExperimentalSettingsScreen.cpp | 2 +- Arduino/BTCDieselHeater/src/OLED/Screen.cpp | 21 ++++++++ .../BTCDieselHeater/src/OLED/ScreenHeader.cpp | 21 ++++++++ .../src/OLED/ScreenManager.cpp | 21 ++++++++ Arduino/BTCDieselHeater/src/cfg/pins.h | 12 +++-- 7 files changed, 102 insertions(+), 34 deletions(-) diff --git a/Arduino/BTCDieselHeater/BTCDieselHeater.ino b/Arduino/BTCDieselHeater/BTCDieselHeater.ino index 6a1ba6d..042b5f7 100644 --- a/Arduino/BTCDieselHeater/BTCDieselHeater.ino +++ b/Arduino/BTCDieselHeater/BTCDieselHeater.ino @@ -101,6 +101,7 @@ #include "src/Utility/DebugPort.h" #include "src/Utility/UtilClasses.h" #include "src/Utility/BTC_JSON.h" +#include "src/Utility/GPIO.h" #include "src/OLED/ScreenManager.h" #include "src/OLED/keypad.h" #include @@ -156,6 +157,7 @@ CSmartError SmartError; CKeyPad KeyPad; CScreenManager ScreenManager; TelnetSpy DebugPort; +CGPIOin GPIOin; sRxLine PCline; long lastRxTime; // used to observe inter character delays @@ -408,6 +410,7 @@ void setup() { bBTconnected = false; Bluetooth.begin(); + GPIOin.begin(GPIOin1_pin, GPIOin2_pin, GPIOinOn1Off2); } @@ -442,6 +445,8 @@ void loop() Bluetooth.check(); // check for Bluetooth activity + GPIOin.manageGPIO(); + // manage changes in Bluetooth connection status if(Bluetooth.isConnected()) { if(!bBTconnected) { diff --git a/Arduino/BTCDieselHeater/src/OLED/BasicScreen.cpp b/Arduino/BTCDieselHeater/src/OLED/BasicScreen.cpp index 93cf8d4..88fb7c3 100644 --- a/Arduino/BTCDieselHeater/src/OLED/BasicScreen.cpp +++ b/Arduino/BTCDieselHeater/src/OLED/BasicScreen.cpp @@ -271,39 +271,37 @@ CBasicScreen::showRunState() static bool toggle = false; const char* toPrint = NULL; _display.setTextColor(WHITE, BLACK); -// if(runstate >= 0 && runstate <= 8) { if(errstate && ((runstate == 0) || (runstate > 5))) { - // flash error code - char msg[16]; - toggle = !toggle; - if(toggle) { - // create an "E-XX" message to display - sprintf(msg, "E-%02d", errstate); - } - else { - strcpy(msg, " "); - } - int xPos = _display.xCentre(); - int yPos = _display.height() - 2*_display.textHeight(); - _printMenuText(xPos, yPos, msg, false, eCentreJustify); - - toPrint = getHeaterInfo().getErrStateStr(); + // flash error code + char msg[16]; + toggle = !toggle; + if(toggle) { + // create an "E-XX" message to display + sprintf(msg, "E-%02d", errstate); } else { - if(runstate) { - toPrint = getHeaterInfo().getRunStateStr(); - // simplify starting states - switch(runstate) { - case 1: - case 2: - case 3: - case 4: - toPrint = "Starting"; - break; - } + strcpy(msg, " "); + } + int xPos = _display.xCentre(); + int yPos = _display.height() - 2*_display.textHeight(); + _printMenuText(xPos, yPos, msg, false, eCentreJustify); + + toPrint = getHeaterInfo().getErrStateStr(); + } + else { + if(runstate) { + toPrint = getHeaterInfo().getRunStateStr(); + // simplify starting states + switch(runstate) { + case 1: + case 2: + case 3: + case 4: + toPrint = "Starting"; + break; } - // } + } } if(toPrint) { // locate at bottom centre diff --git a/Arduino/BTCDieselHeater/src/OLED/ExperimentalSettingsScreen.cpp b/Arduino/BTCDieselHeater/src/OLED/ExperimentalSettingsScreen.cpp index a55ac64..258b6ae 100644 --- a/Arduino/BTCDieselHeater/src/OLED/ExperimentalSettingsScreen.cpp +++ b/Arduino/BTCDieselHeater/src/OLED/ExperimentalSettingsScreen.cpp @@ -80,7 +80,7 @@ CExperimentalSettingsScreen::show() } else { _printInverted(_display.xCentre(), 0, " Experimental ", true, eCentreJustify); - _printMenuText(65, Line3, "Overtemp:", false, eRightJustify); + _printMenuText(65, Line3, "Suspend:", false, eRightJustify); _printMenuText(65, Line2, "Thermostat:", false, eRightJustify); _printMenuText(65, Line1, "Window:", false, eRightJustify); sprintf(msg, "%.1f\367C", _window); // \367 is octal for Adafruit degree symbol diff --git a/Arduino/BTCDieselHeater/src/OLED/Screen.cpp b/Arduino/BTCDieselHeater/src/OLED/Screen.cpp index e457d13..a5587ba 100644 --- a/Arduino/BTCDieselHeater/src/OLED/Screen.cpp +++ b/Arduino/BTCDieselHeater/src/OLED/Screen.cpp @@ -1,3 +1,24 @@ +/* + * This file is part of the "bluetoothheater" distribution + * (https://gitlab.com/mrjones.id.au/bluetoothheater) + * + * Copyright (C) 2018 Ray Jones + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + #include #include "Screen.h" diff --git a/Arduino/BTCDieselHeater/src/OLED/ScreenHeader.cpp b/Arduino/BTCDieselHeater/src/OLED/ScreenHeader.cpp index 83b669b..aff479d 100644 --- a/Arduino/BTCDieselHeater/src/OLED/ScreenHeader.cpp +++ b/Arduino/BTCDieselHeater/src/OLED/ScreenHeader.cpp @@ -1,3 +1,24 @@ +/* + * This file is part of the "bluetoothheater" distribution + * (https://gitlab.com/mrjones.id.au/bluetoothheater) + * + * Copyright (C) 2018 Ray Jones + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + #include #include "ScreenHeader.h" #include "../Protocol/Protocol.h" diff --git a/Arduino/BTCDieselHeater/src/OLED/ScreenManager.cpp b/Arduino/BTCDieselHeater/src/OLED/ScreenManager.cpp index 43ea113..73fef47 100644 --- a/Arduino/BTCDieselHeater/src/OLED/ScreenManager.cpp +++ b/Arduino/BTCDieselHeater/src/OLED/ScreenManager.cpp @@ -1,3 +1,24 @@ +/* + * This file is part of the "bluetoothheater" distribution + * (https://gitlab.com/mrjones.id.au/bluetoothheater) + * + * Copyright (C) 2018 Ray Jones + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + #include "ScreenManager.h" #include "DetailedScreen.h" #include "BasicScreen.h" diff --git a/Arduino/BTCDieselHeater/src/cfg/pins.h b/Arduino/BTCDieselHeater/src/cfg/pins.h index 51a861e..f28a916 100644 --- a/Arduino/BTCDieselHeater/src/cfg/pins.h +++ b/Arduino/BTCDieselHeater/src/cfg/pins.h @@ -26,9 +26,9 @@ const uint8_t LED_Pin = 2; const uint8_t UART_Rx = 3; const uint8_t HC05_KeyPin = 4; const uint8_t TxEnbPin = 5; -const uint8_t GPIO12_pin = 12; // HSPI std pins -const uint8_t GPIO13_pin = 13; // " -const uint8_t GPIO14_pin = 14; // " +const uint8_t Tx433MHz_pin = 12; // HSPI std pins +const uint8_t Rx433MHz_pin = 13; // " +const uint8_t GPIOout2_pin = 14; // " const uint8_t DS18B20_Pin = 15; const uint8_t Rx1Pin = 16; const uint8_t Tx1Pin = 17; @@ -37,10 +37,12 @@ const uint8_t Rx2Pin = 19; const uint8_t OLED_SDA_pin = 21; // I2C std pins const uint8_t OLED_SCL_pin = 22; // " const uint8_t HC05_SensePin = 23; -const uint8_t GPIO26_pin = 26; -const uint8_t GPIO27_pin = 27; +const uint8_t GPIOin2_pin = 25; +const uint8_t AlgInput_pin = 26; +const uint8_t GPIOout1_pin = 27; const uint8_t keyUp_pin = 32; +const uint8_t GPIOin1_pin = 33; const uint8_t keyDown_pin = 34; // input only, no chip pullup const uint8_t keyCentre_pin = 35; // input only, no chip pullup const uint8_t keyRight_pin = 36; // input only, no chip pullup