Skip to content

Commit f0b7454

Browse files
committed
SPI Thermistor improvements.
1 parent debcf84 commit f0b7454

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

generic/Temperature.ts

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { logger } from "../logger/Logger";
2+
import { DeviceBinding } from "../boards/Controller";
3+
import { setTimeout, clearTimeout } from "timers";
4+
import { utils } from "../boards/Constants";
5+
6+
import * as fs from 'fs';
7+
import { GenericDeviceBase } from "./genericDevices";
8+
import { webApp } from "../web/Server";
9+
10+
export class Themistor10k extends GenericDeviceBase {
11+
protected logError(err, msg?: string) { logger.error(`${this.device.name} ${typeof msg !== 'undefined' ? msg + ' ' : ''}${typeof err !== 'undefined' ? err.message : ''}`); }
12+
public async setValues(vals): Promise<any> {
13+
try {
14+
return Promise.resolve(this.values);
15+
}
16+
catch (err) { this.logError(err); Promise.reject(err); }
17+
finally { }
18+
}
19+
}
20+
21+

spi-adc/SpiAdcBus.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ export class SpiAdcChannel {
115115
return new Promise<void>((resolve, reject) => {
116116
this.busNumber = opts.busNumber;
117117
try {
118-
logger.info(`Attempting to open SPI Bus #${opts.busNumber} Channel #${this.channel}`);
118+
//logger.info(`Attempting to open SPI Bus #${opts.busNumber} Channel #${this.channel}`);
119119
this._spiDevice = spiBus.open(opts.busNumber || 0, this.channel, err => {
120120
if (err) {
121121
logger.error(`SPI${opts.busNumber} Channel ${this.channel} library error: ${err.message}`);
@@ -124,10 +124,10 @@ export class SpiAdcChannel {
124124
else {
125125
this.isOpen = true;
126126
setTimeout(async () => { await this.readAsync(); }, 500);
127+
logger.info(`Opened SPI Bus #${opts.busNumber} Channel #${this.channel}`);
127128
resolve();
128129
}
129130
});
130-
logger.info(`Opened SPI Bus #${opts.busNumber} Channel #${this.channel}`);
131131
} catch (err) { logger.error(`Error opening SPI${opts.busNumber} Channel ${this.channel}: ${err.message}`); }
132132
});
133133
}

0 commit comments

Comments
 (0)