mirror of
https://github.com/Show-maket/IR-protocol.git
synced 2025-06-28 05:09:40 +00:00
refactor
This commit is contained in:
@ -5,8 +5,15 @@
|
||||
#define ISR_Out 10
|
||||
#define TestOut 13
|
||||
|
||||
IR_Encoder::IR_Encoder(uint16_t addr, IR_DecoderRaw *decPair)
|
||||
std::list<IR_Encoder*>& IR_Encoder::get_enc_list() // определение функции
|
||||
{
|
||||
static std::list<IR_Encoder*> dec_list; // статическая локальная переменная
|
||||
return dec_list; // возвращается ссылка на переменную
|
||||
}
|
||||
|
||||
IR_Encoder::IR_Encoder(uint8_t pin, uint16_t addr, IR_DecoderRaw *decPair)
|
||||
{
|
||||
this->pin = pin;
|
||||
id = addr;
|
||||
this->decPair = decPair;
|
||||
signal = noSignal;
|
||||
@ -23,7 +30,10 @@ IR_Encoder::IR_Encoder(uint16_t addr, IR_DecoderRaw *decPair)
|
||||
{
|
||||
decPair->encoder = this;
|
||||
}
|
||||
pinMode(pin,OUTPUT);
|
||||
get_enc_list().push_back(this);
|
||||
};
|
||||
|
||||
void IR_Encoder::setBlindDecoders(IR_DecoderRaw *decoders[], uint8_t count)
|
||||
{
|
||||
#if disablePairDec
|
||||
@ -38,6 +48,7 @@ IR_Encoder::~IR_Encoder()
|
||||
{
|
||||
delete[] bitLow;
|
||||
delete[] bitHigh;
|
||||
get_enc_list().remove(this);
|
||||
};
|
||||
|
||||
void IR_Encoder::sendData(uint16_t addrTo, uint8_t dataByte, bool needAccept)
|
||||
@ -141,6 +152,7 @@ void IR_Encoder::sendBack(uint8_t data)
|
||||
{
|
||||
_sendBack(false, 0, &data, 1);
|
||||
}
|
||||
|
||||
void IR_Encoder::sendBack(uint8_t *data , uint8_t len)
|
||||
{
|
||||
_sendBack(false, 0, data, len);
|
||||
@ -230,12 +242,21 @@ void IR_Encoder::rawSend(uint8_t *ptr, uint8_t len)
|
||||
// interrupts();
|
||||
}
|
||||
|
||||
void IR_Encoder::isr()
|
||||
void IR_Encoder::isr(){
|
||||
// Serial.println(get_enc_list().size());
|
||||
for(const auto &element : get_enc_list()){
|
||||
element->_isr();
|
||||
}
|
||||
}
|
||||
|
||||
void IR_Encoder::_isr()
|
||||
{
|
||||
if (!isSending)
|
||||
return;
|
||||
|
||||
ir_out_virtual = !ir_out_virtual && state;
|
||||
digitalWrite(pin, ir_out_virtual);
|
||||
|
||||
|
||||
if (toggleCounter)
|
||||
{
|
||||
@ -369,34 +390,6 @@ void IR_Encoder::addSync(bool *prev, bool *next)
|
||||
}
|
||||
}
|
||||
|
||||
void IR_Encoder::send_HIGH(bool prevBite)
|
||||
{
|
||||
|
||||
// if (/* prevBite */1) {
|
||||
// meanderBlock(bitPauseTakts * 2, halfPeriod, LOW);
|
||||
// meanderBlock(bitActiveTakts, halfPeriod, HIGH);
|
||||
// } else { // более короткий HIGH после нуля
|
||||
// meanderBlock(bitTakts - (bitActiveTakts - bitPauseTakts), halfPeriod, LOW);
|
||||
// meanderBlock(bitActiveTakts - bitPauseTakts, halfPeriod, HIGH);
|
||||
// }
|
||||
}
|
||||
|
||||
void IR_Encoder::send_LOW()
|
||||
{
|
||||
// meanderBlock(bitPauseTakts, halfPeriod, LOW);
|
||||
// meanderBlock(bitActiveTakts, halfPeriod, LOW);
|
||||
// meanderBlock(bitPauseTakts, halfPeriod, HIGH);
|
||||
}
|
||||
|
||||
void IR_Encoder::send_EMPTY(uint8_t count)
|
||||
{
|
||||
// for (size_t i = 0; i < count * 2; i++) {
|
||||
// meanderBlock((bitPauseTakts * 2 + bitActiveTakts), halfPeriod, prevPreambBit);
|
||||
// prevPreambBit = !prevPreambBit;
|
||||
// }
|
||||
// meanderBlock(bitPauseTakts * 2 + bitActiveTakts, halfPeriod, 0); //TODO: Отодвинуть преамбулу
|
||||
}
|
||||
|
||||
uint8_t* IR_Encoder::bitHigh = new uint8_t[2]{
|
||||
(bitPauseTakts) * 2 - 1,
|
||||
(bitActiveTakts) * 2 - 1};
|
||||
|
Reference in New Issue
Block a user