mirror of
https://github.com/Show-maket/IR-protocol.git
synced 2025-06-28 05:09:40 +00:00
enable-disable func
This commit is contained in:
@ -5,14 +5,13 @@
|
||||
#define ISR_Out 10
|
||||
#define TestOut 13
|
||||
|
||||
std::list<IR_Encoder*>& IR_Encoder::get_enc_list() // определение функции
|
||||
std::list<IR_Encoder *> &IR_Encoder::get_enc_list() // определение функции
|
||||
{
|
||||
static std::list<IR_Encoder*> dec_list; // статическая локальная переменная
|
||||
return dec_list; // возвращается ссылка на переменную
|
||||
static std::list<IR_Encoder *> dec_list; // статическая локальная переменная
|
||||
return dec_list; // возвращается ссылка на переменную
|
||||
}
|
||||
|
||||
|
||||
IR_Encoder::IR_Encoder(uint8_t pin, uint16_t addr, IR_DecoderRaw *decPair)
|
||||
IR_Encoder::IR_Encoder(uint8_t pin, uint16_t addr, IR_DecoderRaw *decPair, bool autoHandle)
|
||||
{
|
||||
setPin(pin);
|
||||
id = addr;
|
||||
@ -22,8 +21,7 @@ IR_Encoder::IR_Encoder(uint8_t pin, uint16_t addr, IR_DecoderRaw *decPair)
|
||||
#if disablePairDec
|
||||
if (decPair != nullptr)
|
||||
{
|
||||
blindDecoders = new IR_DecoderRaw *[1]
|
||||
{ decPair };
|
||||
blindDecoders = new IR_DecoderRaw *[1]{decPair};
|
||||
decodersCount = 1;
|
||||
}
|
||||
#endif
|
||||
@ -31,10 +29,33 @@ IR_Encoder::IR_Encoder(uint8_t pin, uint16_t addr, IR_DecoderRaw *decPair)
|
||||
{
|
||||
decPair->encoder = this;
|
||||
}
|
||||
pinMode(pin,OUTPUT);
|
||||
get_enc_list().push_back(this);
|
||||
pinMode(pin, OUTPUT);
|
||||
|
||||
if (autoHandle)
|
||||
{
|
||||
get_enc_list().push_back(this);
|
||||
}
|
||||
};
|
||||
|
||||
void IR_Encoder::enable()
|
||||
{
|
||||
auto &enc_list = get_enc_list();
|
||||
if (std::find(enc_list.begin(), enc_list.end(), this) == enc_list.end())
|
||||
{
|
||||
enc_list.push_back(this);
|
||||
}
|
||||
}
|
||||
|
||||
void IR_Encoder::disable()
|
||||
{
|
||||
auto &enc_list = get_enc_list();
|
||||
auto it = std::find(enc_list.begin(), enc_list.end(), this);
|
||||
if (it != enc_list.end())
|
||||
{
|
||||
enc_list.erase(it);
|
||||
}
|
||||
}
|
||||
|
||||
void IR_Encoder::setBlindDecoders(IR_DecoderRaw *decoders[], uint8_t count)
|
||||
{
|
||||
#if disablePairDec
|
||||
@ -149,7 +170,7 @@ void IR_Encoder::sendBack(uint8_t data)
|
||||
_sendBack(false, 0, &data, 1);
|
||||
}
|
||||
|
||||
void IR_Encoder::sendBack(uint8_t *data , uint8_t len)
|
||||
void IR_Encoder::sendBack(uint8_t *data, uint8_t len)
|
||||
{
|
||||
_sendBack(false, 0, data, len);
|
||||
}
|
||||
@ -238,9 +259,11 @@ 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()){
|
||||
for (const auto &element : get_enc_list())
|
||||
{
|
||||
element->_isr();
|
||||
}
|
||||
}
|
||||
@ -254,7 +277,6 @@ void IR_Encoder::_isr()
|
||||
|
||||
port->ODR &= ~(mask);
|
||||
port->ODR |= mask & (ir_out_virtual ? (uint16_t)0xFFFF : (uint16_t)0x0000);
|
||||
|
||||
|
||||
if (toggleCounter)
|
||||
{
|
||||
@ -389,11 +411,11 @@ void IR_Encoder::addSync(bool *prev, bool *next)
|
||||
}
|
||||
|
||||
uint8_t IR_Encoder::bitHigh[2] = {
|
||||
(bitPauseTakts) * 2 - 1,
|
||||
(bitActiveTakts) * 2 - 1};
|
||||
(bitPauseTakts) * 2 - 1,
|
||||
(bitActiveTakts) * 2 - 1};
|
||||
uint8_t IR_Encoder::bitLow[2] = {
|
||||
(bitPauseTakts/2 + bitActiveTakts) * 2 - 1,
|
||||
(bitPauseTakts) - 1};
|
||||
(bitPauseTakts / 2 + bitActiveTakts) * 2 - 1,
|
||||
(bitPauseTakts)-1};
|
||||
|
||||
// uint8_t* IR_Encoder::bitHigh = new uint8_t[2]{
|
||||
// (bitPauseTakts) * 2 - 0,
|
||||
|
Reference in New Issue
Block a user