diff --git a/examples/AllProtocolsOnLCD/ADCUtils.h b/examples/AllProtocolsOnLCD/ADCUtils.h index 5aaaaf7..cc7e629 100644 --- a/examples/AllProtocolsOnLCD/ADCUtils.h +++ b/examples/AllProtocolsOnLCD/ADCUtils.h @@ -115,8 +115,8 @@ extern float sVCCVoltage; extern uint16_t sVCCVoltageMillivolt; -extern long sLastVoltageCheckMillis; -extern uint8_t sVoltageTooLowCounter; +extern long sLastVCCCheckMillis; +extern uint8_t sVCCTooLowCounter; uint16_t readADCChannel(uint8_t aChannelNumber); uint16_t readADCChannelWithReference(uint8_t aChannelNumber, uint8_t aReference); @@ -157,7 +157,9 @@ float getTemperature(void); bool isVCCTooLowMultipleTimes(); void resetVCCTooLowMultipleTimes(); -bool isVoltageTooLow(); +bool isVCCTooLow(); +bool isVCCTooHigh(); +bool isVCCTooHighSimple(); #endif // defined(__AVR__) ... #endif // _ADC_UTILS_H diff --git a/examples/AllProtocolsOnLCD/ADCUtils.hpp b/examples/AllProtocolsOnLCD/ADCUtils.hpp index 079d177..752175c 100644 --- a/examples/AllProtocolsOnLCD/ADCUtils.hpp +++ b/examples/AllProtocolsOnLCD/ADCUtils.hpp @@ -61,8 +61,8 @@ float sVCCVoltage; uint16_t sVCCVoltageMillivolt; // for isVCCTooLowMultipleTimes() -long sLastVoltageCheckMillis; -uint8_t sVoltageTooLowCounter = 0; +long sLastVCCCheckMillis; +uint8_t sVCCTooLowCounter = 0; /* * Conversion time is defined as 0.104 milliseconds by ADC_PRESCALE in ADCUtils.h. @@ -155,7 +155,7 @@ uint8_t checkAndWaitForReferenceAndChannelToSwitch(uint8_t aChannelNumber, uint8 /* * Switch reference from DEFAULT to INTERNAL */ - delayMicroseconds(8000); // experimental value is >= 7600 us for Nano board and 6200 for UNO board + delayMicroseconds(8000); // experimental value is >= 7600 us for Nano board and 6200 for Uno board } else if ((tOldADMUX & 0x0F) != aChannelNumber) { if (aChannelNumber == ADC_1_1_VOLT_CHANNEL_MUX) { /* @@ -361,6 +361,10 @@ uint16_t readUntil4ConsecutiveValuesAreEqual(uint8_t aChannelNumber, uint8_t aDe * !!! Function without handling of switched reference and channel.!!! * Use it ONLY if you only call getVCCVoltageSimple() or getVCCVoltageMillivoltSimple() in your program. * !!! Resolution is only 20 millivolt !!! + * Raw reading of 1.1 V is 225 at 5 V. + * Raw reading of 1.1 V is 221 at 5.1 V. + * Raw reading of 1.1 V is 214 at 5.25 V (+5 %). + * Raw reading of 1.1 V is 204 at 5.5 V (+10 %). */ float getVCCVoltageSimple(void) { // use AVCC with (optional) external capacitor at AREF pin as reference @@ -384,7 +388,7 @@ uint16_t getVCCVoltageMillivoltSimple(void) { * Similar to getVCCVoltageMillivolt() * 1023 / 1100 */ uint16_t getVCCVoltageReadingFor1_1VoltReference(void) { - uint16_t tVCC = waitAndReadADCChannelWithReference(ADC_1_1_VOLT_CHANNEL_MUX, DEFAULT); // 225 for 1.1 V at 5 V VCC + uint16_t tVCC = waitAndReadADCChannelWithReference(ADC_1_1_VOLT_CHANNEL_MUX, DEFAULT); /* * Do not switch back ADMUX to enable checkAndWaitForReferenceAndChannelToSwitch() to work correctly for the next measurement */ @@ -402,6 +406,10 @@ float getVCCVoltage(void) { * Read value of 1.1 volt internal channel using VCC (DEFAULT) as reference. * Handles reference and channel switching by introducing the appropriate delays. * !!! Resolution is only 20 millivolt !!! + * Raw reading of 1.1 V is 225 at 5 V. + * Raw reading of 1.1 V is 221 at 5.1 V. + * Raw reading of 1.1 V is 214 at 5.25 V (+5 %). + * Raw reading of 1.1 V is 204 at 5.5 V (+10 %). */ uint16_t getVCCVoltageMillivolt(void) { uint16_t tVCC = waitAndReadADCChannelWithReference(ADC_1_1_VOLT_CHANNEL_MUX, DEFAULT); @@ -502,6 +510,12 @@ uint16_t getVoltageMillivoltWith_1_1VoltReference(uint8_t aADCChannelForVoltageM #if !defined(VCC_EMERGENCY_STOP_MILLIVOLT) #define VCC_EMERGENCY_STOP_MILLIVOLT 3000 // Many Li-ions are specified down to 3.0 volt #endif +#if !defined(VCC_TOO_HIGH_STOP_MILLIVOLT) +#define VCC_TOO_HIGH_STOP_MILLIVOLT 5250 // + 5 % operation voltage +#endif +#if !defined(VCC_TOO_HIGH_EMERGENCY_STOP_MILLIVOLT) +#define VCC_TOO_HIGH_EMERGENCY_STOP_MILLIVOLT 5500 // +10 %. Max recommended operation voltage +#endif #if !defined(VCC_CHECK_PERIOD_MILLIS) #define VCC_CHECK_PERIOD_MILLIS 10000 // Period of VCC checks #endif @@ -517,8 +531,8 @@ bool isVCCTooLowMultipleTimes() { * Check VCC every VCC_CHECK_PERIOD_MILLIS (10) seconds */ - if (millis() - sLastVoltageCheckMillis >= VCC_CHECK_PERIOD_MILLIS) { - sLastVoltageCheckMillis = millis(); + if (millis() - sLastVCCCheckMillis >= VCC_CHECK_PERIOD_MILLIS) { + sLastVCCCheckMillis = millis(); # if defined(INFO) readAndPrintVCCVoltageMillivolt(&Serial); @@ -526,31 +540,31 @@ bool isVCCTooLowMultipleTimes() { readVCCVoltageMillivolt(); # endif - if (sVoltageTooLowCounter < VCC_CHECKS_TOO_LOW_BEFORE_STOP) { + if (sVCCTooLowCounter < VCC_CHECKS_TOO_LOW_BEFORE_STOP) { /* * Do not check again if shutdown has happened */ if (sVCCVoltageMillivolt > VCC_STOP_THRESHOLD_MILLIVOLT) { - sVoltageTooLowCounter = 0; // reset counter + sVCCTooLowCounter = 0; // reset counter } else { /* * Voltage too low, wait VCC_CHECKS_TOO_LOW_BEFORE_STOP (6) times and then shut down. */ if (sVCCVoltageMillivolt < VCC_EMERGENCY_STOP_MILLIVOLT) { // emergency shutdown - sVoltageTooLowCounter = VCC_CHECKS_TOO_LOW_BEFORE_STOP; + sVCCTooLowCounter = VCC_CHECKS_TOO_LOW_BEFORE_STOP; # if defined(INFO) Serial.println(F("Voltage < " STR(VCC_EMERGENCY_STOP_MILLIVOLT) " mV detected -> emergency shutdown")); # endif } else { - sVoltageTooLowCounter++; + sVCCTooLowCounter++; # if defined(INFO) Serial.print(F("Voltage < " STR(VCC_STOP_THRESHOLD_MILLIVOLT) " mV detected: ")); - Serial.print(VCC_CHECKS_TOO_LOW_BEFORE_STOP - sVoltageTooLowCounter); + Serial.print(VCC_CHECKS_TOO_LOW_BEFORE_STOP - sVCCTooLowCounter); Serial.println(F(" tries left")); # endif } - if (sVoltageTooLowCounter == VCC_CHECKS_TOO_LOW_BEFORE_STOP) { + if (sVCCTooLowCounter == VCC_CHECKS_TOO_LOW_BEFORE_STOP) { /* * 6 times voltage too low -> shutdown */ @@ -562,12 +576,35 @@ bool isVCCTooLowMultipleTimes() { return false; } -void resetVCCTooLowMultipleTimes(){ - sVoltageTooLowCounter = 0; + +/* + * Return true if VCC_EMERGENCY_STOP_MILLIVOLT (3 V) reached + */ +bool isVCCTooLow(){ + return (sVCCVoltageMillivolt < VCC_EMERGENCY_STOP_MILLIVOLT); } -bool isVoltageTooLow(){ - return (sVoltageTooLowCounter >= VCC_CHECKS_TOO_LOW_BEFORE_STOP); + +void resetVCCTooLowMultipleTimes(){ + sVCCTooLowCounter = 0; +} + +/* + * Recommended VCC is 1.8 V to 5.5 V, absolute maximum VCC is 6.0 V. + * Check for 5.25 V, because such overvoltage is quite unlikely to happen during regular operation. + * Raw reading of 1.1 V is 225 at 5 V. + * Raw reading of 1.1 V is 221 at 5.1 V. + * Raw reading of 1.1 V is 214 at 5.25 V (+5 %). + * Raw reading of 1.1 V is 204 at 5.5 V (+10 %). + * @return true if 5 % overvoltage reached + */ +bool isVCCTooHigh(){ + readVCCVoltageMillivolt(); + return (sVCCVoltageMillivolt > VCC_TOO_HIGH_STOP_MILLIVOLT); +} +bool isVCCTooHighSimple(){ + readVCCVoltageMillivoltSimple(); + return (sVCCVoltageMillivolt > VCC_TOO_HIGH_STOP_MILLIVOLT); } /* diff --git a/examples/AllProtocolsOnLCD/AllProtocolsOnLCD.ino b/examples/AllProtocolsOnLCD/AllProtocolsOnLCD.ino index bc514a1..e26b643 100644 --- a/examples/AllProtocolsOnLCD/AllProtocolsOnLCD.ino +++ b/examples/AllProtocolsOnLCD/AllProtocolsOnLCD.ino @@ -182,7 +182,7 @@ void setup() { #if defined(USE_SERIAL_LCD) myLCD.init(); myLCD.clear(); - myLCD.backlight(); + myLCD.backlight(); // Switch backlight LED on #endif #if defined(USE_PARALLEL_LCD) myLCD.begin(LCD_COLUMNS, LCD_ROWS); // This also clears display diff --git a/examples/ReceiveDump/ReceiveDump.ino b/examples/ReceiveDump/ReceiveDump.ino index 0f32977..23b9b57 100644 --- a/examples/ReceiveDump/ReceiveDump.ino +++ b/examples/ReceiveDump/ReceiveDump.ino @@ -129,7 +129,7 @@ void loop() { * Example for using the compensateAndStorePronto() function. * Creating this String requires 2210 bytes program memory and 10 bytes RAM for the String class. * The String object itself requires additional 440 bytes RAM from the heap. - * This values are for an Arduino UNO. + * This values are for an Arduino Uno. */ // Serial.println(); // blank line between entries // String ProntoHEX = F("Pronto HEX contains: "); // Assign string to ProtoHex string object diff --git a/examples/UnitTest/UnitTest.ino b/examples/UnitTest/UnitTest.ino index b9a88d1..dfae7cb 100644 --- a/examples/UnitTest/UnitTest.ino +++ b/examples/UnitTest/UnitTest.ino @@ -379,7 +379,7 @@ void loop() { #if FLASHEND >= 0x3FFF // For 16k flash or more, like ATtiny1604. Code does not fit in program memory of ATtiny85 etc. if (sAddress == 0xFFF1) { -# if FLASHEND >= 0x7FFF // For 32k flash or more, like UNO. Code does not fit in program memory of ATtiny1604 etc. +# if FLASHEND >= 0x7FFF // For 32k flash or more, like Uno. Code does not fit in program memory of ATtiny1604 etc. /* * Send constant values only once in this demo */ diff --git a/src/IRReceive.hpp b/src/IRReceive.hpp index ddbd6a2..227a3ce 100644 --- a/src/IRReceive.hpp +++ b/src/IRReceive.hpp @@ -1651,20 +1651,11 @@ const char* IRrecv::getProtocolString() { * aResults->decode_type **********************************************************************************************************************/ bool IRrecv::decode_old(decode_results *aResults) { - static bool sDeprecationMessageSent = false; if (irparams.StateForISR != IR_REC_STATE_STOP) { return false; } - if (!sDeprecationMessageSent) { -#if !(defined(__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__) || defined(__AVR_ATtiny87__) || defined(__AVR_ATtiny167__)) -// Serial.println( -// "The function decode(&results)) is deprecated and may not work as expected! Just use decode() without a parameter and IrReceiver.decodedIRData. ."); -#endif - sDeprecationMessageSent = true; - } - // copy for usage by legacy programs aResults->rawbuf = irparams.rawbuf; aResults->rawlen = irparams.rawlen; diff --git a/src/IRremote.h b/src/IRremote.h index 9b2ab8c..90a91e4 100644 --- a/src/IRremote.h +++ b/src/IRremote.h @@ -33,6 +33,8 @@ bool IRrecv::decode(decode_results *aResults) { Serial.println(F(" https://github.com/Arduino-IRremote/Arduino-IRremote#examples-for-this-library")); Serial.println(F("A guide how to convert your 2.0 program is here:")); Serial.println(F(" https://github.com/Arduino-IRremote/Arduino-IRremote#converting-your-2x-program-to-the-4x-version")); + Serial.println(); + Serial.println(F("Thanks")); Serial.println(F("**************************************************************************************************")); Serial.println(); Serial.println();