2018-11-26 11:58:15 +00:00
|
|
|
/*
|
|
|
|
* This file is part of the "bluetoothheater" distribution
|
|
|
|
* (https://gitlab.com/mrjones.id.au/bluetoothheater)
|
|
|
|
*
|
|
|
|
* Copyright (C) 2018 Ray Jones <ray@mrjones.id.au>
|
|
|
|
*
|
|
|
|
* 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 <https://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2018-09-23 06:31:09 +00:00
|
|
|
#include <Arduino.h>
|
2018-09-23 09:15:49 +00:00
|
|
|
#include "Protocol.h"
|
2018-09-23 06:31:09 +00:00
|
|
|
|
|
|
|
class CTxManage
|
|
|
|
{
|
2018-09-23 08:59:19 +00:00
|
|
|
const int m_nStartDelay = 20;
|
|
|
|
const int m_nFrameTime = 14;
|
|
|
|
const int m_nFrontPorch = 2;
|
|
|
|
|
2018-09-23 06:31:09 +00:00
|
|
|
public:
|
2018-10-20 07:11:23 +00:00
|
|
|
CTxManage(int TxGatePin, HardwareSerial& serial);
|
2018-11-07 10:31:00 +00:00
|
|
|
void queueOnRequest(bool set = true); // use false to remove repeating command
|
|
|
|
void queueOffRequest(bool set = true); // use false to remove repeating command
|
2018-11-06 09:43:54 +00:00
|
|
|
void queueRawCommand(unsigned char val);
|
2018-10-20 07:11:23 +00:00
|
|
|
void PrepareFrame(const CProtocol& Frame, bool isBTCmaster);
|
|
|
|
void Start(unsigned long timenow);
|
2018-09-23 08:59:19 +00:00
|
|
|
bool CheckTx(unsigned long timenow);
|
2018-09-23 06:31:09 +00:00
|
|
|
void begin();
|
2018-10-20 07:11:23 +00:00
|
|
|
const CProtocol& getFrame() const { return m_TxFrame; };
|
2018-09-23 06:31:09 +00:00
|
|
|
|
|
|
|
private:
|
2018-10-20 07:11:23 +00:00
|
|
|
CProtocol m_TxFrame;
|
2018-09-23 06:31:09 +00:00
|
|
|
bool m_bOnReq;
|
|
|
|
bool m_bOffReq;
|
|
|
|
bool m_bTxPending;
|
2018-10-20 07:11:23 +00:00
|
|
|
int m_nTxGatePin;
|
2018-11-06 09:43:54 +00:00
|
|
|
unsigned char _rawCommand;
|
2018-09-23 06:31:09 +00:00
|
|
|
unsigned long m_nStartTime;
|
2018-10-20 07:11:23 +00:00
|
|
|
HardwareSerial& m_BlueWireSerial;
|
2018-09-23 06:31:09 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2018-10-18 09:49:14 +00:00
|
|
|
extern CTxManage TxManage;
|
|
|
|
|