Skip to content

Instantly share code, notes, and snippets.

@conoro
Created December 18, 2019 16:34
Show Gist options
  • Save conoro/b980b937f0afeac02016185d6f58f3f5 to your computer and use it in GitHub Desktop.
Save conoro/b980b937f0afeac02016185d6f58f3f5 to your computer and use it in GitHub Desktop.
Output the detected accelerometer data from Bangle.js to train a TensorFlow model
name="Gesture";
function gotGesture(d) {
print(name+"("+d.length/3+"),",d.slice().join(","));
g.clear();
g.setColor(1,1,1);
var my = g.getHeight()/2;
var sy = my/128;
var sx = g.getWidth()/(50*3);
g.drawLine(0,my,g.getWidth(),my);
for (var i=0;i<d.length-3;i+=3) {
for (var c=0;c<3;c++) {
g.setColor(c==0,c==1,c==2);
g.drawLine(i*sx, my+d[i+c]*sy, (i+3)*sx, my+d[i+c+3]*sy);
}
}
g.flip(1);
}
Bangle.on('gesture',gotGesture);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment