2021-03-13 10:35:18 +01:00
|
|
|
/*********
|
2021-04-03 19:07:15 +02:00
|
|
|
** Program : output_ext.ino
|
2021-11-06 16:03:20 +01:00
|
|
|
** Version : v0.9.0
|
2021-04-03 19:07:15 +02:00
|
|
|
**
|
|
|
|
** Copyright (c) 2021 Robert van den Breemen
|
|
|
|
** Contributed by Sjorsjuhmaniac
|
|
|
|
**
|
|
|
|
** TERMS OF USE: MIT License. See bottom of file.
|
2021-03-13 10:35:18 +01:00
|
|
|
*********/
|
|
|
|
|
|
|
|
|
|
|
|
// adds support to activiate a digital output
|
|
|
|
//
|
|
|
|
void setOutputState(bool set_HIGH);
|
|
|
|
|
|
|
|
|
|
|
|
void initOutputs() {
|
|
|
|
DebugTf("inside initOutputsO%d...\r\n", 1);
|
|
|
|
|
|
|
|
if (!settingGPIOOUTPUTSenabled) return;
|
|
|
|
|
|
|
|
DebugTf("init GPIO Output on GPIO%d...\r\n", settingGPIOOUTPUTSpin);
|
|
|
|
|
|
|
|
pinMode(settingGPIOOUTPUTSpin, OUTPUT);
|
|
|
|
setOutputState(OFF);
|
|
|
|
|
|
|
|
// set the LED with the ledState of the variable:
|
|
|
|
// digitalWrite(ledPin, ledState);
|
|
|
|
}
|
|
|
|
|
|
|
|
// still need to hook into processOTGW
|
2021-04-12 17:32:07 +02:00
|
|
|
void setOutputState(uint8_t status = ON){
|
2021-03-13 10:35:18 +01:00
|
|
|
(status == ON) ? setOutputState(true) : setOutputState(false);
|
|
|
|
}
|
2021-04-12 17:32:07 +02:00
|
|
|
|
|
|
|
void setOutputState(bool set_HIGH = true){
|
2021-03-13 10:35:18 +01:00
|
|
|
if(!settingGPIOOUTPUTSenabled) return;
|
|
|
|
digitalWrite(settingGPIOOUTPUTSpin,ON);
|
|
|
|
DebugTf("Output GPIO%d set to %d", settingGPIOOUTPUTSpin, digitalRead(settingGPIOOUTPUTSpin));
|
|
|
|
}
|
|
|
|
|
2021-04-12 17:32:07 +02:00
|
|
|
void evalOutputs(){
|
2021-04-13 22:31:42 +02:00
|
|
|
if(!settingGPIOOUTPUTSenabled) return;
|
|
|
|
// master HB
|
2021-03-13 10:35:18 +01:00
|
|
|
// bit: [clear/0, set/1]
|
|
|
|
// 0: CH enable [ CH is disabled, CH is enabled]
|
|
|
|
// 1: DHW enable [ DHW is disabled, DHW is enabled]
|
|
|
|
// 2: Cooling enable [ Cooling is disabled, Cooling is enabled]]
|
|
|
|
// 3: OTC active [OTC not active, OTC is active]
|
|
|
|
// 4: CH2 enable [CH2 is disabled, CH2 is enabled]
|
|
|
|
// 5: reserved
|
|
|
|
// 6: reserved
|
|
|
|
// 7: reserved
|
|
|
|
|
2021-04-13 22:31:42 +02:00
|
|
|
// slave LB
|
2021-03-13 10:35:18 +01:00
|
|
|
// 0: fault indication [ no fault, fault ]
|
|
|
|
// 1: CH mode [CH not active, CH active]
|
|
|
|
// 2: DHW mode [ DHW not active, DHW active]
|
|
|
|
// 3: Flame status [ flame off, flame on ]
|
|
|
|
// 4: Cooling status [ cooling mode not active, cooling mode active ]
|
|
|
|
// 5: CH2 mode [CH2 not active, CH2 active]
|
|
|
|
// 6: diagnostic indication [no diagnostics, diagnostic event]
|
|
|
|
// 7: reserved
|
2021-04-12 17:32:07 +02:00
|
|
|
if (!settingMyDEBUG) return;
|
2021-03-13 10:35:18 +01:00
|
|
|
settingMyDEBUG = false;
|
|
|
|
DebugTf("current gpio output state: %d \r\n", digitalRead(settingGPIOOUTPUTSpin));
|
|
|
|
DebugFlush();
|
|
|
|
|
2021-04-13 22:31:42 +02:00
|
|
|
bool bitState = (OTdataObject.Statusflags & (2^settingGPIOOUTPUTStriggerBit));
|
2021-03-13 10:35:18 +01:00
|
|
|
DebugTf("bitState: bit: %d , state %d \r\n", settingGPIOOUTPUTStriggerBit, bitState);
|
|
|
|
|
|
|
|
setOutputState(bitState);
|
|
|
|
|
|
|
|
DebugTf("end void: current gpio output state: %d \r\n", digitalRead(settingGPIOOUTPUTSpin));
|
2021-04-03 19:07:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***************************************************************************
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
* copy of this software and associated documentation files (the
|
|
|
|
* "Software"), to deal in the Software without restriction, including
|
|
|
|
* without limitation the rights to use, copy, modify, merge, publish,
|
|
|
|
* distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
|
|
* persons to whom the Software is furnished to do so, subject to the
|
|
|
|
* following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included
|
|
|
|
* in all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
|
|
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
|
|
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
|
|
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
|
|
|
|
* OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
|
|
|
|
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
*
|
|
|
|
****************************************************************************
|
|
|
|
*/
|