add midi example and i2c test

(cherry picked from commit 436e376)
This commit is contained in:
Matthias L. Jugel 2017-03-25 13:42:52 +01:00
parent 7618996c0e
commit 28aa7d451f
4 changed files with 63 additions and 0 deletions

18
libs/calliope-i2c/i2c.ts Normal file
View File

@ -0,0 +1,18 @@
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);
serial.writeNumber(pins.i2cReadNumber(0x44, NumberFormat.UInt8BE));
serial.writeString(",");
pins.i2cWriteNumber(0x44, 0x0C, NumberFormat.UInt8BE);
serial.writeNumber(pins.i2cReadNumber(0x44, NumberFormat.UInt8BE));
serial.writeString(",");
pins.i2cWriteNumber(0x44, 0x0E, NumberFormat.UInt8BE);
serial.writeNumber(pins.i2cReadNumber(0x44, NumberFormat.UInt8LE));
serial.writeLine("]");
basic.pause(1000);
});

View File

@ -0,0 +1,11 @@
{
"name": "calliope-i2c",
"description": "Calliope I2C test",
"files": [
"i2c.ts"
],
"public": true,
"dependencies": {
"core": "file:../core"
}
}

View File

@ -0,0 +1,23 @@
serial.redirect(
SerialPin.P0,
SerialPin.P1,
31250
);
basic.forever(() => {
for (let note = 0; note <= 90 - 1; note++) {
// Note on channel 1 (0x90), some note value (note),
// middle velocity (0x45):
serial.writeString(String.fromCharCode(144));
serial.writeString(String.fromCharCode(note));
serial.writeString(String.fromCharCode(69));
basic.pause(100);
// Note on channel 1 (0x90), some note value (note),
// silent velocity (0x00):
serial.writeString(String.fromCharCode(144));
serial.writeString(String.fromCharCode(note));
serial.writeString("\0");
basic.pause(100);
basic.pause(1000);
}
});

View File

@ -0,0 +1,11 @@
{
"name": "midi",
"description": "MIDI Example via Serial",
"files": [
"midi.ts"
],
"public": true,
"dependencies": {
"core": "file:../core"
}
}