(values)
| 72 | const imu = new device.sensor.IMU(); |
| 73 | let oldData = {x: 0, y: 0, z: 0, init: false}; |
| 74 | function onReading(values) { |
| 75 | const {x,y,z} = values; |
| 76 | if (oldData.init){ |
| 77 | const delta = Math.abs(x - oldData.x) + Math.abs(y - oldData.y) + Math.abs(z - oldData.z); |
| 78 | if (delta > SHAKEVALUE) { |
| 79 | stepCount++; |
| 80 | redraw(); |
| 81 | } |
| 82 | } |
| 83 | oldData.x = x; |
| 84 | oldData.y = y; |
| 85 | oldData.z = z; |
| 86 | oldData.init = true; |
| 87 | } |
| 88 | |
| 89 | globalThis.button.a.onChanged = function() { |
| 90 | if (this.read()) { |