mirror of
				https://github.com/Show-maket/IR-protocol.git
				synced 2025-10-29 01:52:35 +00:00 
			
		
		
		
	| @ -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,6 +36,19 @@ IR_Encoder::IR_Encoder(uint8_t pin, uint16_t addr, IR_DecoderRaw *decPair, bool | |||||||
|     } |     } | ||||||
| }; | }; | ||||||
|  |  | ||||||
|  | HardwareTimer IR_Encoder::IR_Timer; | ||||||
|  |  | ||||||
|  | inline HardwareTimer* IR_Encoder::get_IR_Timer(){return &IR_Encoder::IR_Timer;} | ||||||
|  |  | ||||||
|  | void IR_Encoder::begin(HardwareTimer timer, uint8_t channel, IRQn_Type IRQn){ | ||||||
|  |     IR_Timer = timer; | ||||||
|  |     IR_Timer.setOverflow(carrierFrec * 2, HERTZ_FORMAT); | ||||||
|  |     IR_Timer.attachInterrupt(channel, IR_Encoder::isr); | ||||||
|  |     NVIC_SetPriority(IRQn, 0); | ||||||
|  |     IR_Timer.resume(); | ||||||
|  | } | ||||||
|  |  | ||||||
|  |  | ||||||
| void IR_Encoder::enable() | void IR_Encoder::enable() | ||||||
| { | { | ||||||
|     auto &enc_list = get_enc_list(); |     auto &enc_list = get_enc_list(); | ||||||
| @ -44,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() | ||||||
| @ -54,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) | ||||||
|  | |||||||
| @ -9,6 +9,7 @@ class IR_Encoder : public IR_FOX | |||||||
|     friend IR_DecoderRaw; |     friend IR_DecoderRaw; | ||||||
|  |  | ||||||
| public: | public: | ||||||
|  |     static HardwareTimer IR_Timer; | ||||||
| private: | private: | ||||||
|     // uint16_t id; /// @brief Адрес передатчика |     // uint16_t id; /// @brief Адрес передатчика | ||||||
| public: | public: | ||||||
| @ -18,6 +19,8 @@ public: | |||||||
|     /// @param decPair Приёмник, для которого отключается приём в момент передачи передатчиком |     /// @param decPair Приёмник, для которого отключается приём в момент передачи передатчиком | ||||||
|     IR_Encoder(uint8_t pin, uint16_t addr = 0, IR_DecoderRaw *decPair = nullptr, bool autoHandle = true); |     IR_Encoder(uint8_t pin, uint16_t addr = 0, IR_DecoderRaw *decPair = nullptr, bool autoHandle = true); | ||||||
|     static void isr(); |     static void isr(); | ||||||
|  |     static void begin(HardwareTimer IR_Timer, uint8_t channel, IRQn_Type IRQn); | ||||||
|  |     static HardwareTimer* get_IR_Timer(); | ||||||
|  |  | ||||||
|     void enable(); |     void enable(); | ||||||
|     void disable(); |     void disable(); | ||||||
|  | |||||||
| @ -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) | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user
	 DashyFox
					DashyFox