2017-04-03 18:44:25 +02:00
|
|
|
import rgbw = basic.rgbw;
|
2017-03-25 13:42:52 +01:00
|
|
|
serial.writeLine("I2C");
|
|
|
|
// send to 0x44, register 0x00, value 0x46 (RESET ISL29125)
|
|
|
|
pins.i2cWriteNumber(0x44, 0x0046, NumberFormat.UInt16BE);
|
|
|
|
// send to 0x44, register 0x01, value 0x05 (GRB SAMPLING)
|
|
|
|
pins.i2cWriteNumber(0x44, 0x0105, NumberFormat.UInt16BE);
|
|
|
|
basic.forever(() => {
|
|
|
|
serial.writeString("[");
|
|
|
|
pins.i2cWriteNumber(0x44, 0x0A, NumberFormat.Int8BE);
|
2017-04-03 18:44:25 +02:00
|
|
|
let g = pins.i2cReadNumber(0x44, NumberFormat.UInt8BE);
|
|
|
|
serial.writeNumber(r);
|
2017-03-25 13:42:52 +01:00
|
|
|
serial.writeString(",");
|
|
|
|
pins.i2cWriteNumber(0x44, 0x0C, NumberFormat.UInt8BE);
|
2017-04-03 18:44:25 +02:00
|
|
|
let r = pins.i2cReadNumber(0x44, NumberFormat.UInt8BE);
|
|
|
|
serial.writeNumber(g);
|
2017-03-25 13:42:52 +01:00
|
|
|
serial.writeString(",");
|
|
|
|
pins.i2cWriteNumber(0x44, 0x0E, NumberFormat.UInt8BE);
|
2017-04-03 18:44:25 +02:00
|
|
|
let b = pins.i2cReadNumber(0x44, NumberFormat.UInt8LE);
|
|
|
|
serial.writeNumber(b);
|
2017-03-25 13:42:52 +01:00
|
|
|
serial.writeLine("]");
|
2017-04-03 18:44:25 +02:00
|
|
|
basic.setLedColor(basic.rgbw(r,g,b, 0));
|
2017-03-25 13:42:52 +01:00
|
|
|
basic.pause(1000);
|
|
|
|
});
|