()
| 721 | } |
| 722 | |
| 723 | setupRtc() { |
| 724 | if (this.prefs.pin == 22 || this.prefs.pin == 21) |
| 725 | this.rtc = { exists: 0, valid: 0, enabled: 0 }; |
| 726 | else |
| 727 | |
| 728 | if (DS1307.probe()) { |
| 729 | this.rtc = new DS1307; |
| 730 | this.rtc.exists = 1; |
| 731 | try { |
| 732 | let now = this.rtc.seconds; |
| 733 | } |
| 734 | catch(e) { |
| 735 | this.rtc.enabled = 0; // turn it off, time was invalid |
| 736 | } |
| 737 | } |
| 738 | else if (DS3231.probe()) { |
| 739 | try { |
| 740 | this.rtc = new DS3231; |
| 741 | this.rtc.exists = 1; |
| 742 | try { |
| 743 | let now = this.rtc.seconds; |
| 744 | } |
| 745 | catch (e) { |
| 746 | this.rtc.enabled = 0; // turn it off, time was invalid |
| 747 | } |
| 748 | } |
| 749 | } |
| 750 | else if (RV3028.probe()) { |
| 751 | try { |
| 752 | this.rtc = new RV3028; |
| 753 | this.rtc.exists = 1; |
| 754 | try { |
| 755 | let now = this.rtc.seconds; |
| 756 | } |
| 757 | catch (e) { |
| 758 | this.rtc.enabled = 0; // turn it off, time was invalid |
| 759 | } |
| 760 | } |
| 761 | catch (e) { |
| 762 | trace(`no rtc\n`); |
| 763 | } |
| 764 | } |
| 765 | if (undefined === this.rtc) |
| 766 | this.rtc = { exists: 0, valid: 0, enabled: 0 }; |
| 767 | |
| 768 | if (!this.rtc.enabled) { |
| 769 | this.rtc.valid = 0; |
| 770 | } |
| 771 | else { |
| 772 | global.needsReboot = 0; // time is valid, don't need to reconnect |
| 773 | this.rtc.valid = 1; |
| 774 | this.setTime(this.rtc.seconds); |
| 775 | } |
| 776 | } |
| 777 | |
| 778 | checkDSTObserved() { |
| 779 | // 2nd sun March 2am to 1st sun Nov 2am |
no test coverage detected