mirror of
https://github.com/Show-maket/IR-protocol.git
synced 2025-05-04 07:10:16 +00:00
enable/disable fix
This commit is contained in:
parent
79bb804bb4
commit
b6b9d2c820
@ -23,12 +23,14 @@ void IR_Decoder::enable()
|
|||||||
{
|
{
|
||||||
dec_list.push_back(this);
|
dec_list.push_back(this);
|
||||||
}
|
}
|
||||||
|
pinMode(pin, INPUT_PULLUP);
|
||||||
attachInterrupt(pin, (*this)(), CHANGE);
|
attachInterrupt(pin, (*this)(), CHANGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IR_Decoder::disable()
|
void IR_Decoder::disable()
|
||||||
{
|
{
|
||||||
detachInterrupt(pin);
|
detachInterrupt(pin);
|
||||||
|
pinMode(pin, INPUT);
|
||||||
auto &dec_list = get_dec_list();
|
auto &dec_list = get_dec_list();
|
||||||
auto it = std::find(dec_list.begin(), dec_list.end(), this);
|
auto it = std::find(dec_list.begin(), dec_list.end(), this);
|
||||||
if (it != dec_list.end())
|
if (it != dec_list.end())
|
||||||
|
@ -29,7 +29,6 @@ IR_Encoder::IR_Encoder(uint8_t pin, uint16_t addr, IR_DecoderRaw *decPair, bool
|
|||||||
{
|
{
|
||||||
decPair->encoder = this;
|
decPair->encoder = this;
|
||||||
}
|
}
|
||||||
pinMode(pin, OUTPUT);
|
|
||||||
|
|
||||||
if (autoHandle)
|
if (autoHandle)
|
||||||
{
|
{
|
||||||
@ -37,12 +36,6 @@ IR_Encoder::IR_Encoder(uint8_t pin, uint16_t addr, IR_DecoderRaw *decPair, bool
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
void WEAK EncoderISR()
|
|
||||||
{
|
|
||||||
IR_Encoder::isr();
|
|
||||||
}
|
|
||||||
|
|
||||||
HardwareTimer IR_Encoder::IR_Timer;
|
HardwareTimer IR_Encoder::IR_Timer;
|
||||||
|
|
||||||
inline HardwareTimer* IR_Encoder::get_IR_Timer(){return &IR_Encoder::IR_Timer;}
|
inline HardwareTimer* IR_Encoder::get_IR_Timer(){return &IR_Encoder::IR_Timer;}
|
||||||
@ -50,7 +43,7 @@ inline HardwareTimer* IR_Encoder::get_IR_Timer(){return &IR_Encoder::IR_Timer;}
|
|||||||
void IR_Encoder::begin(HardwareTimer timer, uint8_t channel, IRQn_Type IRQn){
|
void IR_Encoder::begin(HardwareTimer timer, uint8_t channel, IRQn_Type IRQn){
|
||||||
IR_Timer = timer;
|
IR_Timer = timer;
|
||||||
IR_Timer.setOverflow(carrierFrec * 2, HERTZ_FORMAT);
|
IR_Timer.setOverflow(carrierFrec * 2, HERTZ_FORMAT);
|
||||||
IR_Timer.attachInterrupt(channel, EncoderISR);
|
IR_Timer.attachInterrupt(channel, IR_Encoder::isr);
|
||||||
NVIC_SetPriority(IRQn, 0);
|
NVIC_SetPriority(IRQn, 0);
|
||||||
IR_Timer.resume();
|
IR_Timer.resume();
|
||||||
}
|
}
|
||||||
@ -63,6 +56,8 @@ void IR_Encoder::enable()
|
|||||||
{
|
{
|
||||||
enc_list.push_back(this);
|
enc_list.push_back(this);
|
||||||
}
|
}
|
||||||
|
pinMode(pin, OUTPUT);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void IR_Encoder::disable()
|
void IR_Encoder::disable()
|
||||||
@ -73,6 +68,7 @@ void IR_Encoder::disable()
|
|||||||
{
|
{
|
||||||
enc_list.erase(it);
|
enc_list.erase(it);
|
||||||
}
|
}
|
||||||
|
pinMode(pin, INPUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IR_Encoder::setBlindDecoders(IR_DecoderRaw *decoders[], uint8_t count)
|
void IR_Encoder::setBlindDecoders(IR_DecoderRaw *decoders[], uint8_t count)
|
||||||
|
@ -4,7 +4,6 @@ void IR_FOX::setPin(uint8_t pin){
|
|||||||
this->pin = pin;
|
this->pin = pin;
|
||||||
port = digitalPinToPort(pin);
|
port = digitalPinToPort(pin);
|
||||||
mask = digitalPinToBitMask(pin);
|
mask = digitalPinToBitMask(pin);
|
||||||
pinMode(pin, INPUT_PULLUP);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void IR_FOX::checkAddressRuleApply(uint16_t address, uint16_t id, bool &flag)
|
void IR_FOX::checkAddressRuleApply(uint16_t address, uint16_t id, bool &flag)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user