MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / _setDate

Method _setDate

modules/drivers/rtc/ds3231.js:82–95  ·  view source on GitHub ↗
(date)

Source from the content-addressed store, hash-verified

80 }
81
82 _setDate(date) {
83 let buf = new ArrayBuffer(7*1);
84 let bytes = new Uint8Array(buf);
85
86 bytes[0] = this.decToBcd(date.seconds);
87 bytes[1] = this.decToBcd(date.minutes);
88 bytes[2] = this.decToBcd(date.hours);
89 bytes[3] = this.decToBcd(date.dow);
90 bytes[4] = this.decToBcd(date.date);
91 bytes[5] = this.decToBcd(date.month) | ((date.year > 2000) ? DS3231_CENTURY_BIT : 0);
92 bytes[6] = this.decToBcd(date.year % 100);
93
94 super.writeBlock(DS3231_TIME_CAL_ADDR, buf);
95 }
96 static probe() {
97 const i = new I2C({address: DS3231_ADDR, throw: false});
98 const result = i.read(1);

Callers

nothing calls this directly

Calls 2

decToBcdMethod · 0.80
writeBlockMethod · 0.45

Tested by

no test coverage detected