Updated on my site. Code is:
exports.connect = function(spi,cs) { return new MAX31855(spi,cs); }; function MAX31855(spi,cs) { this.spi=spi; this.cs=cs; } MAX31855.prototype.getTemp = function () { var d = SPI1.send("\0\0\0\0",this.cs); if (d.charCodeAt(1) & 1) { var trtn = {fault: (d.charCodeAt(3) & 7)}; switch (trtn.fault) { case 1: trtn.faultstring="No probe detected"; break; case 3: trtn.faultstring="Probe shorted to Ground"; break; case 4: trtn.faultstring="Probe shorted to VCC"; break; } return trtn; } else { return {temp: (d.charCodeAt(0)<<6 | d.charCodeAt(1)>>2)*0.25, fault: 0}; } };
@DrAzzy started
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Updated on my site. Code is: