changes:
add I2C1.setup() sample for Espruino boards
function isDeviceOnBus(i2c,id) { try { return i2c.readFrom(id,1); } catch(err) { return -1; } } function detect(i2c,first, last) { first = first | 0; last = last | 0x77; var idsOnBus = Array(); for (var id = first; id <= last; id++) { if ( isDeviceOnBus(i2c,id) != -1) { idsOnBus.push(id); } } return idsOnBus; } // Espruino boards // I2C1.setup( {scl: B8, sda: B9} ); // ESP8266 I2C1.setup({sda: D2, scl: D4} ); console.log('I2C detect as array:',detect(I2C1));
@MaBe 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.
changes:
add I2C1.setup() sample for Espruino boards