Code that I threw together to get decimal places to work. It looks a bit rough, but it seems to work.
function s7s (sensor, theAddress) { this.displayFor = sensor; this.address = theAddress; this.displayTable = { "Clear" : 0x76, "dp" : { "cmd" : 0x77, "location" : [ 0b00000001, //Digit 0 0b00000010, //Digit 1 0b00000100, //Digit 2 0b00001000 //Digit 3 ] } }; } setInterval(function (e) { ph.getSensorResult(function(value) { var toChar = ""; var a = phDisplay.address; var clr = phDisplay.displayTable.Clear; //Display clear command var dpc = phDisplay.displayTable.dp.cmd; //Decimal point command var dplo = phDisplay.displayTable.dp.location; //Decimal point location map var i; I2C1.writeTo(a, clr); //Clear display if(value[0] === 1) { for(i=0; i<value.length; i++) { if (value[i] !== 1 && value[i] !== 0) { var c = String.fromCharCode(value[i]); if (c != '.') { toChar += c; } if (c == '.') { var n = i - 2; I2C1.writeTo(a, dpc); I2C1.writeTo(a, dplo[n]); } if (i == (value.length - 2)) { console.log(toChar); I2C1.writeTo(a, toChar); toChar=""; } } } } }); }, 2000);
@d0773d 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.
Code that I threw together to get decimal places to work. It looks a bit rough, but it seems to work.