forked from FOSS/BangleApps
OpenSeizureDetector Widget
parent
c4e62a3819
commit
a8dc1dbb17
13
apps.json
13
apps.json
|
@ -2118,6 +2118,19 @@
|
||||||
{"name":"osgridref.img","url":"app-icon.js","evaluate":true}
|
{"name":"osgridref.img","url":"app-icon.js","evaluate":true}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{ "id": "openseizure",
|
||||||
|
"name": "OpenSeizureDetector Widget",
|
||||||
|
"shortName":"Short Name",
|
||||||
|
"icon": "widget.png",
|
||||||
|
"version":"0.01",
|
||||||
|
"description": "[BETA!] A widget to work alongside [OpenSeizureDetector](https://www.openseizuredetector.org.uk/)",
|
||||||
|
"tags": "widget",
|
||||||
|
"type": "widget",
|
||||||
|
"readme": "README.md",
|
||||||
|
"storage": [
|
||||||
|
{"name":"openseizure.wid.js","url":"widget.js"}
|
||||||
|
]
|
||||||
|
},
|
||||||
{"id": "counter",
|
{"id": "counter",
|
||||||
"name": "Counter",
|
"name": "Counter",
|
||||||
"icon": "counter_icon.png",
|
"icon": "counter_icon.png",
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
0.01: New Widget!
|
|
@ -0,0 +1,12 @@
|
||||||
|
# OpenSeizureDetector Widget
|
||||||
|
|
||||||
|
A widget to work alongside [OpenSeizureDetector](https://www.openseizuredetector.org.uk/)
|
||||||
|
|
||||||
|
This is currently just a test and is not ready for everyday use.
|
||||||
|
|
||||||
|
When the widget is running it puts the accelerometer into 25Hz mode, and then
|
||||||
|
roughly every second it outputs 20 samples (bytes) of acceleration data as a notification
|
||||||
|
on BLE Service `"a19585e9-0001-39d0-015f-b3e2b9a0c854"`, characteristic `"a19585e9-0002-39d0-015f-b3e2b9a0c854"`.
|
||||||
|
|
||||||
|
Each byte is 1/25th of a second, with a magnitude of acceleration. It is scaled
|
||||||
|
such that 1g is 64.
|
|
@ -0,0 +1,41 @@
|
||||||
|
(() => {
|
||||||
|
function draw() {
|
||||||
|
g.reset();
|
||||||
|
g.drawImage(E.toArrayBuffer(atob("GBiEBAAAAAABEREQAAAAAAAAAAAKmZkgAAAAAAAAAAAKmZkgAAAAAAAAAAAKkzkgAAAAAAACIQAKkzkgABIgAAAZmSAKPykgApmRAAApmZoqMjkiqZmSAAKZmZmZ8zmpmZmZIAKZmZmZMzmZmZmZIAEpmZmZkzqZmZmSEAACqZmZkjOZmZogAAAAApmZkjOZmSAAAAAAApmZn/mZmSAAAAACqZmZrymZmZogAAEpmZmZkzmZmZmSEAqZmZmZkjqZmZmZoAKZmZmamvmpmZmZIAApmZIan6mhKZmSAAAZmiAKkymgAqmRAAACIAAKkimgAAIgAAAAAAAKkimgAAAAAAAAAAAKmZmgAAAAAAAAAAAKmZmgAAAAAAAAAAABEREQAAAAAA==")), this.x, this.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
var accelData = new Uint8Array(20);
|
||||||
|
var accelIdx = 0;
|
||||||
|
//http://kionixfs.kionix.com/en/datasheet/KX023-1025%20Specifications%20Rev%2012.0.pdf
|
||||||
|
Bangle.accelWr(0x1B,0x01 | 0x40); // 25hz output, ODR/2 filter
|
||||||
|
Bangle.setPollInterval(40); // 25hz input
|
||||||
|
Bangle.on('accel',function(a) {
|
||||||
|
accelData[accelIdx++] = E.clip(a.mag*64,0,255);
|
||||||
|
if (accelIdx>=accelData.length) {
|
||||||
|
accelIdx = 0;
|
||||||
|
try { NRF.updateServices({
|
||||||
|
"a19585e9-0001-39d0-015f-b3e2b9a0c854" : {
|
||||||
|
"a19585e9-0002-39d0-015f-b3e2b9a0c854" : {
|
||||||
|
value : accelData, notify : true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})} catch(e) {};
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
NRF.setServices({
|
||||||
|
"a19585e9-0001-39d0-015f-b3e2b9a0c854" : {
|
||||||
|
"a19585e9-0002-39d0-015f-b3e2b9a0c854" : {
|
||||||
|
value : accelData,
|
||||||
|
maxLen : 20,
|
||||||
|
readable : true,
|
||||||
|
notify : true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// add your widget
|
||||||
|
WIDGETS["openseizure"]={
|
||||||
|
area:"tl", width: 24, draw:draw
|
||||||
|
};
|
||||||
|
})()
|
Binary file not shown.
After Width: | Height: | Size: 2.9 KiB |
Loading…
Reference in New Issue