MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / onReading

Function onReading

examples/drivers/m5stickc-pedometer/main.js:74–87  ·  view source on GitHub ↗
(values)

Source from the content-addressed store, hash-verified

72const imu = new device.sensor.IMU();
73let oldData = {x: 0, y: 0, z: 0, init: false};
74function 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
89globalThis.button.a.onChanged = function() {
90 if (this.read()) {

Callers 1

main.jsFile · 0.70

Calls 1

redrawFunction · 0.85

Tested by

no test coverage detected