diff --git a/Contributors.md b/Contributors.md index bf1e64dbd..1bed7b6d4 100644 --- a/Contributors.md +++ b/Contributors.md @@ -3,7 +3,6 @@ These are the active contributors of this project that you may contact if there - [z3t0](https://github.com/z3t0) : Active Contributor and currently also the main contributor. * Email: zetoslab@gmail.com - * Skype: polarised16 - [shirriff](https://github.com/shirriff) : An amazing person who worked to create this awesome library and provide unending support - [AnalysIR](https:/github.com/AnalysIR): Active contributor and is amazing with providing support! - [Informatic](https://github.com/Informatic) : Active contributor diff --git a/IRremote.cpp b/IRremote.cpp index e811cfc7b..6b164b050 100644 --- a/IRremote.cpp +++ b/IRremote.cpp @@ -124,7 +124,7 @@ int MATCH_SPACE (int measured_ticks, int desired_us) // Gap width is recorded; Ready is cleared; New logging starts // #ifdef IR_TIMER_USE_ESP32 -void IRTimer() +IRAM_ATTR void IRTimer() #else ISR (TIMER_INTR_NAME) #endif @@ -138,9 +138,9 @@ ISR (TIMER_INTR_NAME) irparams.timer++; // One more 50uS tick if (irparams.rawlen >= RAWBUF) irparams.rcvstate = STATE_OVERFLOW ; // Buffer overflow - switch(irparams.rcvstate) { - //...................................................................... - case STATE_IDLE: // In the middle of a gap + //Switch case would be much more appropriate. However, it creates a PANIC in ESP32 + //which reads as "Cache disabled but cached memory region accessed". -- Phil5555 + if (irparams.rcvstate==STATE_IDLE) { if (irdata == MARK) { if (irparams.timer < GAP_TICKS) { // Not big enough to be a gap. irparams.timer = 0; @@ -154,17 +154,13 @@ ISR (TIMER_INTR_NAME) irparams.rcvstate = STATE_MARK; } } - break; - //...................................................................... - case STATE_MARK: // Timing Mark + } else if (irparams.rcvstate==STATE_MARK) { if (irdata == SPACE) { // Mark ended; Record time irparams.rawbuf[irparams.rawlen++] = irparams.timer; irparams.timer = 0; irparams.rcvstate = STATE_SPACE; } - break; - //...................................................................... - case STATE_SPACE: // Timing Space + } else if (irparams.rcvstate==STATE_SPACE) { if (irdata == MARK) { // Space just ended; Record time irparams.rawbuf[irparams.rawlen++] = irparams.timer; irparams.timer = 0; @@ -177,16 +173,11 @@ ISR (TIMER_INTR_NAME) // Don't reset timer; keep counting Space width irparams.rcvstate = STATE_STOP; } - break; - //...................................................................... - case STATE_STOP: // Waiting; Measuring Gap + } else if (irparams.rcvstate==STATE_STOP) { if (irdata == MARK) irparams.timer = 0 ; // Reset gap timer - break; - //...................................................................... - case STATE_OVERFLOW: // Flag up a read overflow; Stop the State Machine + } else if (irparams.rcvstate==STATE_OVERFLOW) { irparams.overflow = true; irparams.rcvstate = STATE_STOP; - break; } // If requested, flash LED while receiving IR data diff --git a/README.md b/README.md index 3d28ece1f..6402e03c8 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,7 @@ Whether you use the Adafruit Neopixel lib, or FastLED, interrupts get disabled o - ATtiny 84 / 85 - ESP32 - ESP8266 is supported in a fork based on an old codebase that isn't as recent, but it works reasonably well given that perfectly timed sub millisecond interrupts are different on that chip. See https://github.com/markszabo/IRremoteESP8266 +- Sparkfun Pro Micro We are open to suggestions for adding support to new boards, however we highly recommend you contact your supplier first and ask them to provide support from their side. @@ -51,6 +52,7 @@ We are open to suggestions for adding support to new boards, however we highly r | [ATmega64, ATmega128](https://github.com/MCUdude/MegaCore) | **13** | **1** | | ATmega1280, ATmega2560 | 5, 6, **9**, 11, 46 | 1, **2**, 3, 4, 5 | | [ESP32](http://esp32.net/) | **5** configurable in boarddefs.h | **1** | +| [Sparkfun Pro Micro](https://www.sparkfun.com/products/12640) | 9, **5**, 5 | 1, **3**, 4_HS | | [Teensy 1.0](https://www.pjrc.com/teensy/) | **17** | **1** | | [Teensy 2.0](https://www.pjrc.com/teensy/) | 9, **10**, 14 | 1, 3, **4_HS** | | [Teensy++ 1.0 / 2.0](https://www.pjrc.com/teensy/) | **1**, 16, 25 | 1, **2**, 3 | diff --git a/boarddefs.h b/boarddefs.h index 76f8c9bbc..a8605da83 100644 --- a/boarddefs.h +++ b/boarddefs.h @@ -15,6 +15,8 @@ // // JVC and Panasonic protocol added by Kristian Lauszus (Thanks to zenwheel and other people at the original blog post) // Whynter A/C ARC-110WD added by Francesco Meschia + +// Sparkfun Pro Micro support by Alastair McCormack //****************************************************************************** #ifndef boarddefs_h @@ -70,8 +72,14 @@ // switch IRremote to use a different timer. // +// Sparkfun Pro Micro +#if defined(ARDUINO_AVR_PROMICRO) + //#define IR_USE_TIMER1 // tx = pin 9 + #define IR_USE_TIMER3 // tx = pin 5 + //#define IR_USE_TIMER4_HS // tx = pin 5 + // Arduino Mega -#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) +#elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) //#define IR_USE_TIMER1 // tx = pin 11 #define IR_USE_TIMER2 // tx = pin 9 //#define IR_USE_TIMER3 // tx = pin 5 @@ -246,19 +254,18 @@ # define TIMER_PWM_PIN CORE_OC1A_PIN // Teensy #elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) # define TIMER_PWM_PIN 11 // Arduino Mega -#elif defined(__AVR_ATmega64__) || defined(__AVR_ATmega128__) -# define TIMER_PWM_PIN 13 // MegaCore #elif defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__) \ || defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__) \ || defined(__AVR_ATmega324P__) || defined(__AVR_ATmega324A__) \ || defined(__AVR_ATmega324PA__) || defined(__AVR_ATmega164A__) \ || defined(__AVR_ATmega164P__) || defined(__AVR_ATmega32__) \ -|| defined(__AVR_ATmega16__) || defined(__AVR_ATmega8535__) -# define TIMER_PWM_PIN 13 // MightyCore +|| defined(__AVR_ATmega16__) || defined(__AVR_ATmega8535__) \ +|| defined(__AVR_ATmega64__) || defined(__AVR_ATmega128__) +# define TIMER_PWM_PIN 13 // MightyCore, MegaCore #elif defined(__AVR_ATtiny84__) # define TIMER_PWM_PIN 6 #else -# define TIMER_PWM_PIN 9 // Arduino Duemilanove, Diecimila, LilyPad, etc +# define TIMER_PWM_PIN 9 // Arduino Duemilanove, Diecimila, LilyPad, Sparkfun Pro Micro etc #endif // ATmega48, ATmega88, ATmega168, ATmega328 //--------------------------------------------------------- @@ -291,8 +298,8 @@ //----------------- #if defined(CORE_OC3A_PIN) # define TIMER_PWM_PIN CORE_OC3A_PIN // Teensy -#elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) -# define TIMER_PWM_PIN 5 // Arduino Mega +#elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) || defined(ARDUINO_AVR_PROMICRO) +# define TIMER_PWM_PIN 5 // Arduino Mega, Sparkfun Pro Micro #elif defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__) # define TIMER_PWM_PIN 6 // MightyCore #else @@ -305,12 +312,21 @@ #elif defined(IR_USE_TIMER4_HS) #define TIMER_RESET -#define TIMER_ENABLE_PWM (TCCR4A |= _BV(COM4A1)) -#define TIMER_DISABLE_PWM (TCCR4A &= ~(_BV(COM4A1))) + +#if defined(ARDUINO_AVR_PROMICRO) // Sparkfun Pro Micro + #define TIMER_ENABLE_PWM (TCCR4A |= _BV(COM4A0)) // Use complimentary O̅C̅4̅A̅ output on pin 5 + #define TIMER_DISABLE_PWM (TCCR4A &= ~(_BV(COM4A0))) // (Pro Micro does not map PC7 (32/ICP3/CLK0/OC4A) + // of ATmega32U4 ) +#else + #define TIMER_ENABLE_PWM (TCCR4A |= _BV(COM4A1)) + #define TIMER_DISABLE_PWM (TCCR4A &= ~(_BV(COM4A1))) +#endif + #define TIMER_ENABLE_INTR (TIMSK4 = _BV(TOIE4)) #define TIMER_DISABLE_INTR (TIMSK4 = 0) #define TIMER_INTR_NAME TIMER4_OVF_vect + #define TIMER_CONFIG_KHZ(val) ({ \ const uint16_t pwmval = SYSCLOCK / 2000 / (val); \ TCCR4A = (1<decode_type; - int count = results->rawlen; + //int count = results->rawlen; if (codeType == UNKNOWN) { Serial.println("Received unknown code, saving as raw"); codeLen = results->rawlen - 1; diff --git a/examples/IRtest2/IRtest2.ino b/examples/IRtest2/IRtest2.ino index 56b8a4d2a..22a8fa2f8 100644 --- a/examples/IRtest2/IRtest2.ino +++ b/examples/IRtest2/IRtest2.ino @@ -61,7 +61,7 @@ void setup() // Wait for the gap between tests, to synchronize with // the sender. // Specifically, wait for a signal followed by a gap of at last gap ms. -void waitForGap(int gap) { +void waitForGap(unsigned long gap) { Serial.println("Waiting for gap"); while (1) { while (digitalRead(RECV_PIN) == LOW) { @@ -125,7 +125,7 @@ void dump(decode_results *results) { // The motivation behind this method is that the sender and the receiver // can do the same test calls, and the mode variable indicates whether // to send or receive. -void test(char *label, int type, unsigned long value, int bits) { +void test(const char *label, int type, unsigned long value, int bits) { if (mode == SENDER) { Serial.println(label); if (type == NEC) { @@ -175,7 +175,7 @@ void test(char *label, int type, unsigned long value, int bits) { // Test raw send or receive. This is similar to the test method, // except it send/receives raw data. -void testRaw(char *label, unsigned int *rawbuf, int rawlen) { +void testRaw(const char *label, unsigned int *rawbuf, int rawlen) { if (mode == SENDER) { Serial.println(label); irsend.sendRaw(rawbuf, rawlen, 38 /* kHz */); diff --git a/examples/LGACSendDemo/LGACSendDemo.ino b/examples/LGACSendDemo/LGACSendDemo.ino index da5db37eb..e3c7dfa3d 100644 --- a/examples/LGACSendDemo/LGACSendDemo.ino +++ b/examples/LGACSendDemo/LGACSendDemo.ino @@ -192,12 +192,12 @@ void loop() ac_activate(AC_TEMPERATURE, AC_FLOW); break; case 2: - if ( b == 0 | b == 1 ) { + if ( b == 0 || b == 1 ) { ac_change_air_swing(b); } break; case 3: // 1 : clean on, power on - if ( b == 0 | b == 1 ) { + if ( b == 0 || b == 1 ) { ac_air_clean(b); } break; diff --git a/readmdFrench.md b/readmdFrench.md new file mode 100644 index 000000000..e531e9442 --- /dev/null +++ b/readmdFrench.md @@ -0,0 +1,97 @@ +## IRremote Library + + +Cette bibliothèque vous permet d'envoyer et de recevoir des signaux infrarouges sur un Arduino. +Des tutoriels et plus d'informations seront disponibles sur la page d'accueil officielle. + +## Version - 2.2.3 + +## Installation +1. Allez à la [Releases](https://github.com/z3t0/Arduino-IRremote/releases) page. +2. Téléchargez la dernière version. +3. Extraire le fichier zip +4. Déplacez le dossier "IRremote" vers vos bibliothèques. +5. Assurez-vous de supprimer Arduino_Root / libraries / RobotIRremote. Où Arduino_Root fait référence au répertoire d'installation d'Arduino. La bibliothèque RobotIRremote a des définitions similaires à IRremote et provoque des erreurs. + + +## FAQ +Je ne travaille pas correctement en utilisant Neopixels (aka WS2811 / WS2812 / WS2812B) +Que vous utilisiez la librairie Adafruit Neopixel ou FastLED, les interruptions sont désactivées sur de nombreux processeurs bas de gamme comme les arduinos de base. À son tour, cela empêche le gestionnaire IR de s'exécuter quand il le faut. Il y a quelques solutions à ce processus, voir cette page de Marc MERLIN +[cette page de Marc MERLIN](http://marc.merlins.org/perso/arduino/post_2017-04-03_Arduino-328P-Uno-Teensy3_1-ESP8266-ESP32-IR-and-Neopixels.html) + + +## Conseils pris en charge + +- Teensy 1.0 / 1.0++ / 2.0 / 2++ / 3.0 / 3.1 / Teensy-LC; Crédits: @PaulStoffregen (Teensy Team) +- Sanguino +- ATmega8, 48, 88, 168, 328 +- ATmega8535, 16, 32, 164, 324, 644, 1284, +- ATmega64, 128 +- ATtiny 84 / 85 +- ESP32 (recevoir seulement) +- ESP8266 est basé sur un ancien code qui n'est pas très récent, mais cela fonctionne raisonnablement bien. Voir https://github.com/markszabo/IRremoteESP8266 +Sparkfun Pro Micro + + + + +Nous sommes ouverts aux suggestions d'ajout de support pour les nouveaux tableaux, cependant, nous vous recommandons fortement de contacter votre fournisseur et de fournir un soutien de leur côté. + + +## Spécifications matérielles + + +| Carte/CPU | Envoyer Pin | Compteurs | +|--------------------------------------------------------------------------|---------------------|-------------------| +| [ATtiny84](https://github.com/SpenceKonde/ATTinyCore) | **6** | **1** | +| [ATtiny85](https://github.com/SpenceKonde/ATTinyCore) | **1** | **TINY0** | +| [ATmega8](https://github.com/MCUdude/MiniCore) | **9** | **1** | +| Atmega32u4 | 5, 9, **13** | 1, 3, **4** | +| [ATmega48, ATmega88, ATmega168, ATmega328](https://github.com/MCUdude/MiniCore) | **3**, 9 | 1, **2** | +| [ATmega1284](https://github.com/MCUdude/MightyCore) | 13, 14, 6 | 1, **2**, 3 | +| [ATmega164, ATmega324, ATmega644](https://github.com/MCUdude/MightyCore) | 13, **14** | 1, **2** | +| [ATmega8535 ATmega16, ATmega32](https://github.com/MCUdude/MightyCore) | **13** | **1** | +| [ATmega64, ATmega128](https://github.com/MCUdude/MegaCore) | **13** | **1** | +| ATmega1280, ATmega2560 | 5, 6, **9**, 11, 46 | 1, **2**, 3, 4, 5 | +| [ESP32](http://esp32.net/) | N/A (insupporté) | **1** | +| [Sparkfun Pro Micro](https://www.sparkfun.com/products/12640) | 9, **5**, 5 | 1, **3**, 4_HS | +| [Teensy 1.0](https://www.pjrc.com/teensy/) | **17** | **1** | +| [Teensy 2.0](https://www.pjrc.com/teensy/) | 9, **10**, 14 | 1, 3, **4_HS** | +| [Teensy++ 1.0 / 2.0](https://www.pjrc.com/teensy/) | **1**, 16, 25 | 1, **2**, 3 | +| [Teensy 3.0 / 3.1](https://www.pjrc.com/teensy/) | **5** | **CMT** | +| [Teensy-LC](https://www.pjrc.com/teensy/) | **16** | **TPM1** | + + +## Patchs expérimentaux + +Voici les correctifs strictement pris en charge qui n'ont pas encore été intégrés. Si vous avez des questions, n'hésitez pas à demander ici. Si cela fonctionne, faites le nous savoir! + +[Arduino 101](https://github.com/z3t0/Arduino-IRremote/pull/481#issuecomment-311243146) + +Le tableau ci-dessus répertorie les temporisations actuellement supportées et les broches d'envoi correspondantes, beaucoup de ces broches supplémentaires sont ouvertes. + + +## Utilisation +- À faire TODO (Vérifier les exemples pour l'instant) + + +## Contribution +Si vous voulez contribuer à ce projet: +- Signaler les bogues et les erreurs +- Demander des améliorations +- Créer des problèmes et tirer des requêtes +- Parlez de cette bibliothèque à d'autres personnes +- Contribuer de nouveaux protocoles +Vérifiez ici [ici](Contributing.md) pour quelques guidelines + + +## Contact +Email: zetoslab@gmail.com +Please only email me if it is more appropriate than creating an Issue / PR. I **will** not respond to requests for adding support for particular boards, unless of course you are the creator of the board and would like to cooperate on the project. I will also **ignore** any emails asking me to tell you how to implement your ideas. However, if you have a private inquiry that you would only apply to you and you would prefer it to be via email, by all means. + +## Contributeurs +Check [here](Contributors.md) +@Lsuperman735 French translation + +## Copyright +Copyright 2009-2012 Ken Shirriff