@@ -51,10 +51,12 @@ boolean SFE_MAX1704X::begin(TwoWire &wirePort)
5151
5252 if (isConnected () == false )
5353 {
54+ #if MAX1704X_ENABLE_DEBUGLOG
5455 if (_printDebug == true )
5556 {
5657 _debugPort->println (F (" begin: isConnected returned false" ));
5758 }
59+ #endif // if MAX1704X_ENABLE_DEBUGLOG
5860 return (false );
5961 }
6062
@@ -87,20 +89,24 @@ boolean SFE_MAX1704X::isConnected(void)
8789 else
8890 {
8991 retries--;
92+ #if MAX1704X_ENABLE_DEBUGLOG
9093 if (_printDebug == true )
9194 {
9295 _debugPort->println (F (" SFE_MAX1704X::isConnected: retrying..." ));
9396 }
97+ #endif // if MAX1704X_ENABLE_DEBUGLOG
9498 delay (50 );
9599 }
96100 }
97101
98102 if (!success) // Return now if the version could not be read
99103 {
104+ #if MAX1704X_ENABLE_DEBUGLOG
100105 if (_printDebug == true )
101106 {
102107 _debugPort->println (F (" SFE_MAX1704X::isConnected: failed to detect IC!" ));
103108 }
109+ #endif // if MAX1704X_ENABLE_DEBUGLOG
104110 return (success);
105111 }
106112
@@ -120,13 +126,17 @@ boolean SFE_MAX1704X::isConnected(void)
120126// Enable or disable the printing of debug messages
121127void SFE_MAX1704X::enableDebugging (Stream &debugPort)
122128{
129+ #if MAX1704X_ENABLE_DEBUGLOG
123130 _debugPort = &debugPort; // Grab which port the user wants us to use for debugging
124131 _printDebug = true ; // Should we print the commands we send? Good for debugging
132+ #endif // if MAX1704X_ENABLE_DEBUGLOG
125133}
126134
127135void SFE_MAX1704X::disableDebugging (void )
128136{
137+ #if MAX1704X_ENABLE_DEBUGLOG
129138 _printDebug = false ; // Turn off extra print statements
139+ #endif // if MAX1704X_ENABLE_DEBUGLOG
130140}
131141
132142uint8_t SFE_MAX1704X::quickStart ()
@@ -192,10 +202,12 @@ uint8_t SFE_MAX1704X::getID()
192202{
193203 if (_device <= MAX1704X_MAX17044)
194204 {
205+ #if MAX1704X_ENABLE_DEBUGLOG
195206 if (_printDebug == true )
196207 {
197208 _debugPort->println (F (" getID: not supported on this device" ));
198209 }
210+ #endif // if MAX1704X_ENABLE_DEBUGLOG
199211 return (0 );
200212 }
201213
@@ -209,10 +221,12 @@ uint8_t SFE_MAX1704X::setResetVoltage(uint8_t threshold)
209221{
210222 if (_device <= MAX1704X_MAX17044)
211223 {
224+ #if MAX1704X_ENABLE_DEBUGLOG
212225 if (_printDebug == true )
213226 {
214227 _debugPort->println (F (" setResetVoltage: not supported on this device" ));
215228 }
229+ #endif // if MAX1704X_ENABLE_DEBUGLOG
216230 return (MAX17043_GENERIC_ERROR);
217231 }
218232
@@ -233,10 +247,12 @@ uint8_t SFE_MAX1704X::getResetVoltage(void)
233247{
234248 if (_device <= MAX1704X_MAX17044)
235249 {
250+ #if MAX1704X_ENABLE_DEBUGLOG
236251 if (_printDebug == true )
237252 {
238253 _debugPort->println (F (" getResetVoltage: not supported on this device" ));
239254 }
255+ #endif // if MAX1704X_ENABLE_DEBUGLOG
240256 return (0 );
241257 }
242258
@@ -248,10 +264,12 @@ uint8_t SFE_MAX1704X::enableComparator(void)
248264{
249265 if (_device <= MAX1704X_MAX17044)
250266 {
267+ #if MAX1704X_ENABLE_DEBUGLOG
251268 if (_printDebug == true )
252269 {
253270 _debugPort->println (F (" enableComparator: not supported on this device" ));
254271 }
272+ #endif // if MAX1704X_ENABLE_DEBUGLOG
255273 return (MAX17043_GENERIC_ERROR);
256274 }
257275
@@ -264,10 +282,12 @@ uint8_t SFE_MAX1704X::disableComparator(void)
264282{
265283 if (_device <= MAX1704X_MAX17044)
266284 {
285+ #if MAX1704X_ENABLE_DEBUGLOG
267286 if (_printDebug == true )
268287 {
269288 _debugPort->println (F (" disableComparator: not supported on this device" ));
270289 }
290+ #endif // if MAX1704X_ENABLE_DEBUGLOG
271291 return (MAX17043_GENERIC_ERROR);
272292 }
273293
@@ -280,10 +300,12 @@ float SFE_MAX1704X::getChangeRate(void)
280300{
281301 if (_device <= MAX1704X_MAX17044)
282302 {
303+ #if MAX1704X_ENABLE_DEBUGLOG
283304 if (_printDebug == true )
284305 {
285306 _debugPort->println (F (" getChangeRate: not supported on this device" ));
286307 }
308+ #endif // if MAX1704X_ENABLE_DEBUGLOG
287309 return (0.0 );
288310 }
289311
@@ -296,10 +318,12 @@ uint8_t SFE_MAX1704X::getStatus(void)
296318{
297319 if (_device <= MAX1704X_MAX17044)
298320 {
321+ #if MAX1704X_ENABLE_DEBUGLOG
299322 if (_printDebug == true )
300323 {
301324 _debugPort->println (F (" getStatus: not supported on this device" ));
302325 }
326+ #endif // if MAX1704X_ENABLE_DEBUGLOG
303327 return (0 );
304328 }
305329
@@ -421,10 +445,12 @@ bool SFE_MAX1704X::enableSOCAlert()
421445{
422446 if (_device <= MAX1704X_MAX17044)
423447 {
448+ #if MAX1704X_ENABLE_DEBUGLOG
424449 if (_printDebug == true )
425450 {
426451 _debugPort->println (F (" enableSOCAlert: not supported on this device" ));
427452 }
453+ #endif // if MAX1704X_ENABLE_DEBUGLOG
428454 return (false );
429455 }
430456
@@ -446,10 +472,12 @@ bool SFE_MAX1704X::disableSOCAlert()
446472{
447473 if (_device <= MAX1704X_MAX17044)
448474 {
475+ #if MAX1704X_ENABLE_DEBUGLOG
449476 if (_printDebug == true )
450477 {
451478 _debugPort->println (F (" disableSOCAlert: not supported on this device" ));
452479 }
480+ #endif // if MAX1704X_ENABLE_DEBUGLOG
453481 return (false );
454482 }
455483
@@ -473,10 +501,12 @@ uint8_t SFE_MAX1704X::enableAlert(void)
473501{
474502 if (_device <= MAX1704X_MAX17044)
475503 {
504+ #if MAX1704X_ENABLE_DEBUGLOG
476505 if (_printDebug == true )
477506 {
478507 _debugPort->println (F (" enableAlert: not supported on this device" ));
479508 }
509+ #endif // if MAX1704X_ENABLE_DEBUGLOG
480510 return (MAX17043_GENERIC_ERROR);
481511 }
482512
@@ -489,10 +519,12 @@ uint8_t SFE_MAX1704X::disableAlert(void)
489519{
490520 if (_device <= MAX1704X_MAX17044)
491521 {
522+ #if MAX1704X_ENABLE_DEBUGLOG
492523 if (_printDebug == true )
493524 {
494525 _debugPort->println (F (" disableAlert: not supported on this device" ));
495526 }
527+ #endif // if MAX1704X_ENABLE_DEBUGLOG
496528 return (MAX17043_GENERIC_ERROR);
497529 }
498530
@@ -552,10 +584,12 @@ uint8_t SFE_MAX1704X::sleep()
552584 uint16_t configReg = read16 (MAX17043_CONFIG);
553585 if (configReg & MAX17043_CONFIG_SLEEP)
554586 {
587+ #if MAX1704X_ENABLE_DEBUGLOG
555588 if (_printDebug == true )
556589 {
557590 _debugPort->println (F (" sleep: MAX17043 is already sleeping!" ));
558591 }
592+ #endif // if MAX1704X_ENABLE_DEBUGLOG
559593 return MAX17043_GENERIC_ERROR; // Already sleeping, do nothing but return an error
560594 }
561595
@@ -570,10 +604,12 @@ uint8_t SFE_MAX1704X::wake()
570604 uint16_t configReg = read16 (MAX17043_CONFIG);
571605 if (!(configReg & MAX17043_CONFIG_SLEEP))
572606 {
607+ #if MAX1704X_ENABLE_DEBUGLOG
573608 if (_printDebug == true )
574609 {
575610 _debugPort->println (F (" wake: MAX17043 is already awake!" ));
576611 }
612+ #endif // if MAX1704X_ENABLE_DEBUGLOG
577613 return MAX17043_GENERIC_ERROR; // Already sleeping, do nothing but return an error
578614 }
579615 configReg &= ~MAX17043_CONFIG_SLEEP; // Clear sleep bit
@@ -640,10 +676,12 @@ uint8_t SFE_MAX1704X::setVALRTMax(uint8_t threshold)
640676{
641677 if (_device <= MAX1704X_MAX17044)
642678 {
679+ #if MAX1704X_ENABLE_DEBUGLOG
643680 if (_printDebug == true )
644681 {
645682 _debugPort->println (F (" setVALRTMax: not supported on this device" ));
646683 }
684+ #endif // if MAX1704X_ENABLE_DEBUGLOG
647685 return (MAX17043_GENERIC_ERROR);
648686 }
649687
@@ -662,10 +700,12 @@ uint8_t SFE_MAX1704X::getVALRTMax()
662700{
663701 if (_device <= MAX1704X_MAX17044)
664702 {
703+ #if MAX1704X_ENABLE_DEBUGLOG
665704 if (_printDebug == true )
666705 {
667706 _debugPort->println (F (" getVALRTMax: not supported on this device" ));
668707 }
708+ #endif // if MAX1704X_ENABLE_DEBUGLOG
669709 return (0 );
670710 }
671711
@@ -678,10 +718,12 @@ uint8_t SFE_MAX1704X::setVALRTMin(uint8_t threshold)
678718{
679719 if (_device <= MAX1704X_MAX17044)
680720 {
721+ #if MAX1704X_ENABLE_DEBUGLOG
681722 if (_printDebug == true )
682723 {
683724 _debugPort->println (F (" setVALRTMin: not supported on this device" ));
684725 }
726+ #endif // if MAX1704X_ENABLE_DEBUGLOG
685727 return (MAX17043_GENERIC_ERROR);
686728 }
687729
@@ -700,10 +742,12 @@ uint8_t SFE_MAX1704X::getVALRTMin()
700742{
701743 if (_device <= MAX1704X_MAX17044)
702744 {
745+ #if MAX1704X_ENABLE_DEBUGLOG
703746 if (_printDebug == true )
704747 {
705748 _debugPort->println (F (" getVALRTMin: not supported on this device" ));
706749 }
750+ #endif // if MAX1704X_ENABLE_DEBUGLOG
707751 return (0 );
708752 }
709753
@@ -716,10 +760,12 @@ bool SFE_MAX1704X::isHibernating()
716760{
717761 if (_device <= MAX1704X_MAX17044)
718762 {
763+ #if MAX1704X_ENABLE_DEBUGLOG
719764 if (_printDebug == true )
720765 {
721766 _debugPort->println (F (" isHibernating: not supported on this device" ));
722767 }
768+ #endif // if MAX1704X_ENABLE_DEBUGLOG
723769 return (false );
724770 }
725771
@@ -731,10 +777,12 @@ uint8_t SFE_MAX1704X::getHIBRTActThr()
731777{
732778 if (_device <= MAX1704X_MAX17044)
733779 {
780+ #if MAX1704X_ENABLE_DEBUGLOG
734781 if (_printDebug == true )
735782 {
736783 _debugPort->println (F (" getHIBRTActThr: not supported on this device" ));
737784 }
785+ #endif // if MAX1704X_ENABLE_DEBUGLOG
738786 return (0 );
739787 }
740788
@@ -747,10 +795,12 @@ uint8_t SFE_MAX1704X::setHIBRTActThr(uint8_t threshold)
747795{
748796 if (_device <= MAX1704X_MAX17044)
749797 {
798+ #if MAX1704X_ENABLE_DEBUGLOG
750799 if (_printDebug == true )
751800 {
752801 _debugPort->println (F (" setHIBRTActThr: not supported on this device" ));
753802 }
803+ #endif // if MAX1704X_ENABLE_DEBUGLOG
754804 return (MAX17043_GENERIC_ERROR);
755805 }
756806
@@ -770,10 +820,12 @@ uint8_t SFE_MAX1704X::getHIBRTHibThr()
770820{
771821 if (_device <= MAX1704X_MAX17044)
772822 {
823+ #if MAX1704X_ENABLE_DEBUGLOG
773824 if (_printDebug == true )
774825 {
775826 _debugPort->println (F (" getHIBRTHibThr: not supported on this device" ));
776827 }
828+ #endif // if MAX1704X_ENABLE_DEBUGLOG
777829 return (0 );
778830 }
779831
@@ -786,10 +838,12 @@ uint8_t SFE_MAX1704X::setHIBRTHibThr(uint8_t threshold)
786838{
787839 if (_device <= MAX1704X_MAX17044)
788840 {
841+ #if MAX1704X_ENABLE_DEBUGLOG
789842 if (_printDebug == true )
790843 {
791844 _debugPort->println (F (" setHIBRTHibThr: not supported on this device" ));
792845 }
846+ #endif // if MAX1704X_ENABLE_DEBUGLOG
793847 return (MAX17043_GENERIC_ERROR);
794848 }
795849
@@ -809,10 +863,12 @@ uint8_t SFE_MAX1704X::enableHibernate()
809863{
810864 if (_device <= MAX1704X_MAX17044)
811865 {
866+ #if MAX1704X_ENABLE_DEBUGLOG
812867 if (_printDebug == true )
813868 {
814869 _debugPort->println (F (" enableHibernate: not supported on this device" ));
815870 }
871+ #endif // if MAX1704X_ENABLE_DEBUGLOG
816872 return (MAX17043_GENERIC_ERROR);
817873 }
818874
@@ -823,10 +879,12 @@ uint8_t SFE_MAX1704X::disableHibernate()
823879{
824880 if (_device <= MAX1704X_MAX17044)
825881 {
882+ #if MAX1704X_ENABLE_DEBUGLOG
826883 if (_printDebug == true )
827884 {
828885 _debugPort->println (F (" disableHibernate: not supported on this device" ));
829886 }
887+ #endif // if MAX1704X_ENABLE_DEBUGLOG
830888 return (MAX17043_GENERIC_ERROR);
831889 }
832890
@@ -867,19 +925,23 @@ uint16_t SFE_MAX1704X::read16(uint8_t address)
867925 else
868926 {
869927 retries--;
928+ #if MAX1704X_ENABLE_DEBUGLOG
870929 if (_printDebug == true )
871930 {
872931 _debugPort->println (F (" SFE_MAX1704X::read16: retrying..." ));
873932 }
933+ #endif // if MAX1704X_ENABLE_DEBUGLOG
874934 delay (50 );
875935 }
876936 }
877937
938+ #if MAX1704X_ENABLE_DEBUGLOG
878939 if (_printDebug == true )
879940 {
880941 if (!success)
881942 _debugPort->println (F (" SFE_MAX1704X::read16: failed to read data!" ));
882943 }
944+ #endif // if MAX1704X_ENABLE_DEBUGLOG
883945
884946 return (result);
885947}
0 commit comments