Skip to content

Commit 36e4a19

Browse files
committed
Documentation
1 parent 5507618 commit 36e4a19

File tree

7 files changed

+62
-30
lines changed

7 files changed

+62
-30
lines changed

examples/AllProtocolsOnLCD/ADCUtils.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@
115115
extern float sVCCVoltage;
116116
extern uint16_t sVCCVoltageMillivolt;
117117

118-
extern long sLastVoltageCheckMillis;
119-
extern uint8_t sVoltageTooLowCounter;
118+
extern long sLastVCCCheckMillis;
119+
extern uint8_t sVCCTooLowCounter;
120120

121121
uint16_t readADCChannel(uint8_t aChannelNumber);
122122
uint16_t readADCChannelWithReference(uint8_t aChannelNumber, uint8_t aReference);
@@ -157,7 +157,9 @@ float getTemperature(void);
157157

158158
bool isVCCTooLowMultipleTimes();
159159
void resetVCCTooLowMultipleTimes();
160-
bool isVoltageTooLow();
160+
bool isVCCTooLow();
161+
bool isVCCTooHigh();
162+
bool isVCCTooHighSimple();
161163

162164
#endif // defined(__AVR__) ...
163165
#endif // _ADC_UTILS_H

examples/AllProtocolsOnLCD/ADCUtils.hpp

Lines changed: 52 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ float sVCCVoltage;
6161
uint16_t sVCCVoltageMillivolt;
6262

6363
// for isVCCTooLowMultipleTimes()
64-
long sLastVoltageCheckMillis;
65-
uint8_t sVoltageTooLowCounter = 0;
64+
long sLastVCCCheckMillis;
65+
uint8_t sVCCTooLowCounter = 0;
6666

6767
/*
6868
* 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
155155
/*
156156
* Switch reference from DEFAULT to INTERNAL
157157
*/
158-
delayMicroseconds(8000); // experimental value is >= 7600 us for Nano board and 6200 for UNO board
158+
delayMicroseconds(8000); // experimental value is >= 7600 us for Nano board and 6200 for Uno board
159159
} else if ((tOldADMUX & 0x0F) != aChannelNumber) {
160160
if (aChannelNumber == ADC_1_1_VOLT_CHANNEL_MUX) {
161161
/*
@@ -361,6 +361,10 @@ uint16_t readUntil4ConsecutiveValuesAreEqual(uint8_t aChannelNumber, uint8_t aDe
361361
* !!! Function without handling of switched reference and channel.!!!
362362
* Use it ONLY if you only call getVCCVoltageSimple() or getVCCVoltageMillivoltSimple() in your program.
363363
* !!! Resolution is only 20 millivolt !!!
364+
* Raw reading of 1.1 V is 225 at 5 V.
365+
* Raw reading of 1.1 V is 221 at 5.1 V.
366+
* Raw reading of 1.1 V is 214 at 5.25 V (+5 %).
367+
* Raw reading of 1.1 V is 204 at 5.5 V (+10 %).
364368
*/
365369
float getVCCVoltageSimple(void) {
366370
// use AVCC with (optional) external capacitor at AREF pin as reference
@@ -384,7 +388,7 @@ uint16_t getVCCVoltageMillivoltSimple(void) {
384388
* Similar to getVCCVoltageMillivolt() * 1023 / 1100
385389
*/
386390
uint16_t getVCCVoltageReadingFor1_1VoltReference(void) {
387-
uint16_t tVCC = waitAndReadADCChannelWithReference(ADC_1_1_VOLT_CHANNEL_MUX, DEFAULT); // 225 for 1.1 V at 5 V VCC
391+
uint16_t tVCC = waitAndReadADCChannelWithReference(ADC_1_1_VOLT_CHANNEL_MUX, DEFAULT);
388392
/*
389393
* Do not switch back ADMUX to enable checkAndWaitForReferenceAndChannelToSwitch() to work correctly for the next measurement
390394
*/
@@ -402,6 +406,10 @@ float getVCCVoltage(void) {
402406
* Read value of 1.1 volt internal channel using VCC (DEFAULT) as reference.
403407
* Handles reference and channel switching by introducing the appropriate delays.
404408
* !!! Resolution is only 20 millivolt !!!
409+
* Raw reading of 1.1 V is 225 at 5 V.
410+
* Raw reading of 1.1 V is 221 at 5.1 V.
411+
* Raw reading of 1.1 V is 214 at 5.25 V (+5 %).
412+
* Raw reading of 1.1 V is 204 at 5.5 V (+10 %).
405413
*/
406414
uint16_t getVCCVoltageMillivolt(void) {
407415
uint16_t tVCC = waitAndReadADCChannelWithReference(ADC_1_1_VOLT_CHANNEL_MUX, DEFAULT);
@@ -502,6 +510,12 @@ uint16_t getVoltageMillivoltWith_1_1VoltReference(uint8_t aADCChannelForVoltageM
502510
#if !defined(VCC_EMERGENCY_STOP_MILLIVOLT)
503511
#define VCC_EMERGENCY_STOP_MILLIVOLT 3000 // Many Li-ions are specified down to 3.0 volt
504512
#endif
513+
#if !defined(VCC_TOO_HIGH_STOP_MILLIVOLT)
514+
#define VCC_TOO_HIGH_STOP_MILLIVOLT 5250 // + 5 % operation voltage
515+
#endif
516+
#if !defined(VCC_TOO_HIGH_EMERGENCY_STOP_MILLIVOLT)
517+
#define VCC_TOO_HIGH_EMERGENCY_STOP_MILLIVOLT 5500 // +10 %. Max recommended operation voltage
518+
#endif
505519
#if !defined(VCC_CHECK_PERIOD_MILLIS)
506520
#define VCC_CHECK_PERIOD_MILLIS 10000 // Period of VCC checks
507521
#endif
@@ -517,40 +531,40 @@ bool isVCCTooLowMultipleTimes() {
517531
* Check VCC every VCC_CHECK_PERIOD_MILLIS (10) seconds
518532
*/
519533

520-
if (millis() - sLastVoltageCheckMillis >= VCC_CHECK_PERIOD_MILLIS) {
521-
sLastVoltageCheckMillis = millis();
534+
if (millis() - sLastVCCCheckMillis >= VCC_CHECK_PERIOD_MILLIS) {
535+
sLastVCCCheckMillis = millis();
522536

523537
# if defined(INFO)
524538
readAndPrintVCCVoltageMillivolt(&Serial);
525539
# else
526540
readVCCVoltageMillivolt();
527541
# endif
528542

529-
if (sVoltageTooLowCounter < VCC_CHECKS_TOO_LOW_BEFORE_STOP) {
543+
if (sVCCTooLowCounter < VCC_CHECKS_TOO_LOW_BEFORE_STOP) {
530544
/*
531545
* Do not check again if shutdown has happened
532546
*/
533547
if (sVCCVoltageMillivolt > VCC_STOP_THRESHOLD_MILLIVOLT) {
534-
sVoltageTooLowCounter = 0; // reset counter
548+
sVCCTooLowCounter = 0; // reset counter
535549
} else {
536550
/*
537551
* Voltage too low, wait VCC_CHECKS_TOO_LOW_BEFORE_STOP (6) times and then shut down.
538552
*/
539553
if (sVCCVoltageMillivolt < VCC_EMERGENCY_STOP_MILLIVOLT) {
540554
// emergency shutdown
541-
sVoltageTooLowCounter = VCC_CHECKS_TOO_LOW_BEFORE_STOP;
555+
sVCCTooLowCounter = VCC_CHECKS_TOO_LOW_BEFORE_STOP;
542556
# if defined(INFO)
543557
Serial.println(F("Voltage < " STR(VCC_EMERGENCY_STOP_MILLIVOLT) " mV detected -> emergency shutdown"));
544558
# endif
545559
} else {
546-
sVoltageTooLowCounter++;
560+
sVCCTooLowCounter++;
547561
# if defined(INFO)
548562
Serial.print(F("Voltage < " STR(VCC_STOP_THRESHOLD_MILLIVOLT) " mV detected: "));
549-
Serial.print(VCC_CHECKS_TOO_LOW_BEFORE_STOP - sVoltageTooLowCounter);
563+
Serial.print(VCC_CHECKS_TOO_LOW_BEFORE_STOP - sVCCTooLowCounter);
550564
Serial.println(F(" tries left"));
551565
# endif
552566
}
553-
if (sVoltageTooLowCounter == VCC_CHECKS_TOO_LOW_BEFORE_STOP) {
567+
if (sVCCTooLowCounter == VCC_CHECKS_TOO_LOW_BEFORE_STOP) {
554568
/*
555569
* 6 times voltage too low -> shutdown
556570
*/
@@ -562,12 +576,35 @@ bool isVCCTooLowMultipleTimes() {
562576
return false;
563577
}
564578

579+
580+
/*
581+
* Return true if VCC_EMERGENCY_STOP_MILLIVOLT (3 V) reached
582+
*/
583+
bool isVCCTooLow(){
584+
return (sVCCVoltageMillivolt < VCC_EMERGENCY_STOP_MILLIVOLT);
585+
}
586+
587+
565588
void resetVCCTooLowMultipleTimes(){
566-
sVoltageTooLowCounter = 0;
589+
sVCCTooLowCounter = 0;
567590
}
568591

569-
bool isVoltageTooLow(){
570-
return (sVoltageTooLowCounter >= VCC_CHECKS_TOO_LOW_BEFORE_STOP);
592+
/*
593+
* Recommended VCC is 1.8 V to 5.5 V, absolute maximum VCC is 6.0 V.
594+
* Check for 5.25 V, because such overvoltage is quite unlikely to happen during regular operation.
595+
* Raw reading of 1.1 V is 225 at 5 V.
596+
* Raw reading of 1.1 V is 221 at 5.1 V.
597+
* Raw reading of 1.1 V is 214 at 5.25 V (+5 %).
598+
* Raw reading of 1.1 V is 204 at 5.5 V (+10 %).
599+
* @return true if 5 % overvoltage reached
600+
*/
601+
bool isVCCTooHigh(){
602+
readVCCVoltageMillivolt();
603+
return (sVCCVoltageMillivolt > VCC_TOO_HIGH_STOP_MILLIVOLT);
604+
}
605+
bool isVCCTooHighSimple(){
606+
readVCCVoltageMillivoltSimple();
607+
return (sVCCVoltageMillivolt > VCC_TOO_HIGH_STOP_MILLIVOLT);
571608
}
572609

573610
/*

examples/AllProtocolsOnLCD/AllProtocolsOnLCD.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ void setup() {
182182
#if defined(USE_SERIAL_LCD)
183183
myLCD.init();
184184
myLCD.clear();
185-
myLCD.backlight();
185+
myLCD.backlight(); // Switch backlight LED on
186186
#endif
187187
#if defined(USE_PARALLEL_LCD)
188188
myLCD.begin(LCD_COLUMNS, LCD_ROWS); // This also clears display

examples/ReceiveDump/ReceiveDump.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ void loop() {
129129
* Example for using the compensateAndStorePronto() function.
130130
* Creating this String requires 2210 bytes program memory and 10 bytes RAM for the String class.
131131
* The String object itself requires additional 440 bytes RAM from the heap.
132-
* This values are for an Arduino UNO.
132+
* This values are for an Arduino Uno.
133133
*/
134134
// Serial.println(); // blank line between entries
135135
// String ProntoHEX = F("Pronto HEX contains: "); // Assign string to ProtoHex string object

examples/UnitTest/UnitTest.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ void loop() {
379379
#if FLASHEND >= 0x3FFF // For 16k flash or more, like ATtiny1604. Code does not fit in program memory of ATtiny85 etc.
380380

381381
if (sAddress == 0xFFF1) {
382-
# if FLASHEND >= 0x7FFF // For 32k flash or more, like UNO. Code does not fit in program memory of ATtiny1604 etc.
382+
# if FLASHEND >= 0x7FFF // For 32k flash or more, like Uno. Code does not fit in program memory of ATtiny1604 etc.
383383
/*
384384
* Send constant values only once in this demo
385385
*/

src/IRReceive.hpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1651,20 +1651,11 @@ const char* IRrecv::getProtocolString() {
16511651
* aResults->decode_type
16521652
**********************************************************************************************************************/
16531653
bool IRrecv::decode_old(decode_results *aResults) {
1654-
static bool sDeprecationMessageSent = false;
16551654

16561655
if (irparams.StateForISR != IR_REC_STATE_STOP) {
16571656
return false;
16581657
}
16591658

1660-
if (!sDeprecationMessageSent) {
1661-
#if !(defined(__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__) || defined(__AVR_ATtiny87__) || defined(__AVR_ATtiny167__))
1662-
// Serial.println(
1663-
// "The function decode(&results)) is deprecated and may not work as expected! Just use decode() without a parameter and IrReceiver.decodedIRData.<fieldname> .");
1664-
#endif
1665-
sDeprecationMessageSent = true;
1666-
}
1667-
16681659
// copy for usage by legacy programs
16691660
aResults->rawbuf = irparams.rawbuf;
16701661
aResults->rawlen = irparams.rawlen;

src/IRremote.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ bool IRrecv::decode(decode_results *aResults) {
3333
Serial.println(F(" https://github.com/Arduino-IRremote/Arduino-IRremote#examples-for-this-library"));
3434
Serial.println(F("A guide how to convert your 2.0 program is here:"));
3535
Serial.println(F(" https://github.com/Arduino-IRremote/Arduino-IRremote#converting-your-2x-program-to-the-4x-version"));
36+
Serial.println();
37+
Serial.println(F("Thanks"));
3638
Serial.println(F("**************************************************************************************************"));
3739
Serial.println();
3840
Serial.println();

0 commit comments

Comments
 (0)