(options)
| 100 | this.#status = "ready"; |
| 101 | } |
| 102 | configure(options) { |
| 103 | const io = this.#io; |
| 104 | let conf = io.readUint16(Register.TMP117_CONF, true); |
| 105 | |
| 106 | if (undefined !== options.shutdownMode) { |
| 107 | conf &= ~ConfigMask.MODE; |
| 108 | if (options.shutdownMode) { |
| 109 | conf |= 0b0000_0100_0000_0000; |
| 110 | this.#status = "shutdown"; |
| 111 | } |
| 112 | else |
| 113 | this.#status = "ready"; |
| 114 | } |
| 115 | |
| 116 | if (undefined !== options.highTemperature) |
| 117 | io.writeUint16(Register.TMP117_THI, (options.highTemperature / .0078125) | 0, true); |
| 118 | |
| 119 | if (undefined !== options.lowTemperature) |
| 120 | io.writeUint16(Register.TMP117_TLO, (options.lowTemperature / .0078125) | 0, true); |
| 121 | |
| 122 | if (undefined !== options.thermostatMode) { |
| 123 | conf &= ~ConfigMask.THERM; |
| 124 | if (options.thermostatMode === "interrupt") |
| 125 | conf |= 0b1_0000; |
| 126 | else if (options.thermostatMode !== "comparator") |
| 127 | this.#onError?.("bad thermostatMode"); |
| 128 | } |
| 129 | |
| 130 | if (undefined !== options.conversionRate) { |
| 131 | conf &= ~ConfigMask.CONV; |
| 132 | conf |= (options.conversionRate & 0b111) << 7; |
| 133 | } |
| 134 | |
| 135 | if (undefined !== options.polarity) { |
| 136 | conf &= ~ConfigMask.POL; |
| 137 | if (options.polarity) |
| 138 | conf |= ConfigMask.POL; |
| 139 | } |
| 140 | if (undefined !== options.averaging) { |
| 141 | conf &= ~ConfigMask.AVG; |
| 142 | switch (options.averaging) { |
| 143 | case 0: break; |
| 144 | case 8: conf |= 0b0010_0000; break; |
| 145 | case 32: conf |= 0b0100_0000; break; |
| 146 | case 64: conf |= 0b0110_0000; break; |
| 147 | default: this.#onError?.("invalid averaging"); |
| 148 | } |
| 149 | } |
| 150 | |
| 151 | io.writeUint16(Register.TMP117_CONF, conf, true); |
| 152 | } |
| 153 | close() { |
| 154 | if ("ready" === this.#status) { |
| 155 | const io = this.#io; |
nothing calls this directly
no test coverage detected