ADS1X15.prototype.getADC = function(channelSpec, callback) { var config = CONFIG.CQUE_NONE | // Disable the comparator (default val) CONFIG.CLAT_NONLAT | // Non-latching (default val) CONFIG.CPOL_ACTVLOW | // Alert/Rdy active low (default val) CONFIG.CMODE_TRAD | // Traditional comparator (default val) CONFIG.DR_1600SPS | // 1600 samples per second (default) CONFIG.MODE_SINGLE; // Single-shot mode (default) // single ended (channelSpec is a number) or differential (channelSpec is array w/ valid channel duo) if ("number" == typeof channelSpec) { // Set single-ended input channel config |= [CONFIG.MUX_SINGLE_0,CONFIG.MUX_SINGLE_1,CONFIG.MUX_SINGLE_2,CONFIG.MUX_SINGLE_3][channelSpec]; } else { // Set differential input channels from channelSpec var dif = DIFFS[channelSpec]; if (typeof dif === "undefined") throw new Error("Invalid differential channelSpec " + channelSpec); config |= dif; }
Looking at the module code, I can't see how it's getting to that error with 0 as the channelSpec.... since "number"==typeof 0 should be true...
"number"==typeof 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.
Looking at the module code, I can't see how it's getting to that error with 0 as the channelSpec.... since
"number"==typeof 0
should be true...