Add Shield
Shield typically rely on using an existing board definition
and with extra configuration using configureHardware
and the logic to start drivers.
- create a class
Shield(rename to your shield name) and add the@devsPart,@devsWhenUsedattribute in the jsdoc.
/**
* A shield driver
* @devsPart My Shield name
* @devsWhenUsed
*/
export class Shield {}
- call
configureHardwarein the constructor to setup additional hardware configuration like I2C.
export class Shield {
constructor() {
configureHardware({
...
})
}
}
- add instance methods to start each driver
export class Shield {
startButton() {
return startButton({
pin: pins.GP10,
activeHigh: true,
})
}
}
Add to this repository
- fork the
microsoft/devicescriptrepository - add driver in
packages/drivers(see others), export frompackages/drivers/index.ts - add documentation page under
website/docs/devices/shields, see others - add entry in
website/docs/devices/index.tsx
How-to publish on npm
start a new DeviceScript project
run the DeviceScript: add npm... command to prepare it for publishing
add the board package for your target device
update the README with examples and documentation
publish a release of your package
send us a pull request so we list your shield package!