diff --git a/examples/batmobile_remote.js b/examples/batmobile_remote.js index 05cc851..2084c4f 100644 --- a/examples/batmobile_remote.js +++ b/examples/batmobile_remote.js @@ -30,26 +30,26 @@ poweredUP.on("discover", async (hub) => { // Wait to Batmobile and Remote remote.on("button", async (button, state) => { if (batmobile) { switch (state) { - case PoweredUP.Consts.ButtonStates.UP: // If up is pressed, move the wheels forward + case PoweredUP.Consts.ButtonState.UP: // If up is pressed, move the wheels forward { lastButton = state; batmobile.setMotorSpeed(button === "LEFT" ? "B" : "A", button === "LEFT" ? -100 : 100); break; } - case PoweredUP.Consts.ButtonStates.DOWN: // If down is pressed, move the wheels backwards + case PoweredUP.Consts.ButtonState.DOWN: // If down is pressed, move the wheels backwards { lastButton = state; batmobile.setMotorSpeed(button === "LEFT" ? "B" : "A", button === "LEFT" ? 100 : -100); break; } - case PoweredUP.Consts.ButtonStates.RELEASED: // Stop the wheels when the button is released + case PoweredUP.Consts.ButtonState.RELEASED: // Stop the wheels when the button is released { - if (lastButton === PoweredUP.Consts.ButtonStates.UP || lastButton === PoweredUP.Consts.ButtonStates.DOWN) { + if (lastButton === PoweredUP.Consts.ButtonState.UP || lastButton === PoweredUP.Consts.ButtonState.DOWN) { batmobile.setMotorSpeed(button === "LEFT" ? "B" : "A", 0); } break; } - case PoweredUP.Consts.ButtonStates.STOP: // When left red button is pressed, do a retreat. When right red button is pressed, scan the area. + case PoweredUP.Consts.ButtonState.STOP: // When left red button is pressed, do a retreat. When right red button is pressed, scan the area. { lastButton = state; if (button === "LEFT") { @@ -66,7 +66,7 @@ poweredUP.on("discover", async (hub) => { // Wait to Batmobile and Remote } break; } - case PoweredUP.Consts.ButtonStates.PRESSED: // Do a wheelie when the green button is pressed + case PoweredUP.Consts.ButtonState.PRESSED: // Do a wheelie when the green button is pressed { lastButton = state; if (button === "GREEN") { diff --git a/examples/train_controller.js b/examples/train_controller.js index e4eaaec..922ff85 100644 --- a/examples/train_controller.js +++ b/examples/train_controller.js @@ -65,7 +65,7 @@ poweredUP.on("discover", async (hub) => { hub.on("button", (button, state) => { if (button === "GREEN") { - if (state === PoweredUP.Consts.ButtonStates.PRESSED) { + if (state === PoweredUP.Consts.ButtonState.PRESSED) { hub._currentTrain++; if (hub._currentTrain >= trains.length) { hub._currentTrain = 0; @@ -73,19 +73,19 @@ poweredUP.on("discover", async (hub) => { hub.setLEDColor(trains[hub._currentTrain].color); console.log(`Switched active train on remote ${hub.name} to ${trains[hub._currentTrain].name}`); } - } else if ((button === "LEFT" || button === "RIGHT") && state !== PoweredUP.Consts.ButtonStates.RELEASED) { + } else if ((button === "LEFT" || button === "RIGHT") && state !== PoweredUP.Consts.ButtonState.RELEASED) { trains[hub._currentTrain]._speed = trains[hub._currentTrain]._speed || 0; - if (state === PoweredUP.Consts.ButtonStates.UP) { + if (state === PoweredUP.Consts.ButtonState.UP) { trains[hub._currentTrain]._speed += 10; if (trains[hub._currentTrain]._speed > 100) { trains[hub._currentTrain]._speed = 100; } - } else if (state === PoweredUP.Consts.ButtonStates.DOWN) { + } else if (state === PoweredUP.Consts.ButtonState.DOWN) { trains[hub._currentTrain]._speed -= 10; if (trains[hub._currentTrain]._speed < -100) { trains[hub._currentTrain]._speed = -100; } - } else if (state === PoweredUP.Consts.ButtonStates.STOP) { + } else if (state === PoweredUP.Consts.ButtonState.STOP) { trains[hub._currentTrain]._speed = 0; } for (let trainHub in trains[hub._currentTrain].hubs) { diff --git a/examples/vernie_remote.js b/examples/vernie_remote.js index c9da37c..8f2afa4 100644 --- a/examples/vernie_remote.js +++ b/examples/vernie_remote.js @@ -28,29 +28,29 @@ poweredUP.on("discover", async (hub) => { // Wait to discover Vernie and Remote remote.on("button", async (button, state) => { if (vernie) { switch (state) { - case PoweredUP.Consts.ButtonStates.UP: // If up is pressed, move the track forward + case PoweredUP.Consts.ButtonState.UP: // If up is pressed, move the track forward { vernie.setMotorSpeed(button === "LEFT" ? "A" : "B", 50); break; } - case PoweredUP.Consts.ButtonStates.DOWN: // If down is pressed, move the track backwards + case PoweredUP.Consts.ButtonState.DOWN: // If down is pressed, move the track backwards { vernie.setMotorSpeed(button === "LEFT" ? "A" : "B", -50); break; } - case PoweredUP.Consts.ButtonStates.RELEASED: // Stop the track when the button is released + case PoweredUP.Consts.ButtonState.RELEASED: // Stop the track when the button is released { if (button !== "GREEN") { vernie.setMotorSpeed(button === "LEFT" ? "A" : "B", 0); } break; } - case PoweredUP.Consts.ButtonStates.STOP: // Move the head left or right when a red button is pressed + case PoweredUP.Consts.ButtonState.STOP: // Move the head left or right when a red button is pressed { await vernie.setMotorAngle("D", 35, button === "LEFT" ? -20 : 20); break; } - case PoweredUP.Consts.ButtonStates.PRESSED: // Fire when the green button is pressed + case PoweredUP.Consts.ButtonState.PRESSED: // Fire when the green button is pressed { if (button === "GREEN") { await vernie.setMotorAngle("D", 80, 20);