Obniz.M5StackBasic

Class Reference
TypeScript

Obniz.M5StackBasic is a predefined class for M5's M5StackBasic.

Defined Parts

In this class, the devices in the parts library are used to create
The electronic components on the device (M5Stack Basic) are pre-registered in the class.
They are automatically initialized and ready for use when connected.

buttonA

Left Button

var obniz = new Obniz.M5StickC('OBNIZ_ID_HERE');
obniz.onconnect = async function() {
  obniz.buttonA.onchange = () => {
    console.log("changed");
  }
}

buttonB

Center Button

var obniz = new Obniz.M5StickC('OBNIZ_ID_HERE');
obniz.onconnect = async function() {
  obniz.buttonB.onchange = () => {
    console.log("changed");
  }
}

buttonC

Right Button

var obniz = new Obniz.M5StickC('OBNIZ_ID_HERE');
obniz.onconnect = async function() {
  obniz.buttonC.onchange = () => {
    console.log("changed");
  }
}

Interface

Below interface is prepared

grove0

Grove Connector on M5Stack Basic.

let obniz = new Obniz.M5StickC("OBNIZ_ID");
obniz.onconnect = async () => {
    const speaker = obniz.wired("Grove_Speaker", {grove: obniz.grove0});
    speaker.play(1000); //1000hz
    await obniz.wait(1000);
    speaker.stop();
}

関連の質問