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

Method sample

modules/drivers/sensors/tmp117/tmp117.js:170–191  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

168 return (val > 32768) ? -(65535 - val + 1) : val;
169 }
170 sample() {
171 const io = this.#io;
172 let conf = io.readUint16(Register.TMP117_CONF, true);
173 if ((conf & ConfigMask.MODE) == SHUTDOWN_MODE) {
174 conf |= ONE_SHOT;
175 io.writeUint16(Register.TMP117_CONF, conf, true);
176 Timer.delay(ONE_SHOT_DELAY[(conf & ConfigMask.AVE) >> 5]);
177 conf &= ~ConfigMask.MODE;
178 io.writeUint16(Register.TMP117_CONF, conf | SHUTDOWN_MODE, true);
179 }
180
181 let value = this.#twoC16(io.readUint16(Register.TMP117_TEMP, true)) * 0.0078125;
182
183 conf = io.readUint16(Register.TMP117_CONF, true);
184 let alert = 0;
185 if (conf & HIGH_ALERT)
186 alert |= 0b01;
187 if (conf & LOW_ALERT)
188 alert |= 0b10;
189
190 return { temperature: value, alert };
191 }
192
193 static {
194 this.prototype[Symbol.dispose] = this.prototype.close;

Callers

nothing calls this directly

Calls 4

#twoC16Method · 0.95
delayMethod · 0.80
readUint16Method · 0.45
writeUint16Method · 0.45

Tested by

no test coverage detected