y = 0 let oz = 0 let x = 0 let oy = 0 let xz = 0 let ox = 0 input.onButtonPressed(Button.B, () => { ox = input.acceleration(Dimension.X) oy = input.acceleration(Dimension.Y) oz = input.acceleration(Dimension.Z) px = 0 py = 0 xz = 0 }) basic.forever(() => { if (xz == 1) { x = input.acceleration(Dimension.X) - ox y = input.acceleration(Dimension.Z) - oz } else { x = input.acceleration(Dimension.X) - ox y = input.acceleration(Dimension.Y) - oy } basic.clearScreen() led.plot(2 + Math.clamp(-2, 2, (px + x) / 256), 2 - Math.clamp(-2, 2, (py + y) / 128)) px = x py = y }) input.onButtonPressed(Button.A, () => { ox = input.acceleration(Dimension.X) oy = input.acceleration(Dimension.Y) oz = input.acceleration(Dimension.Z) px = 0 py = 0 xz = 1 }) xz = 1 oy = input.acceleration(Dimension.Y) ox = input.acceleration(Dimension.X) oz = input.acceleration(Dimension.Z) px = 0 py = 0 input.setAccelerometerRange(AcceleratorRange.TwoG) 侧⦼כ侭侧ך