Skip to content

Commit

Permalink
Updated OpenSeizureDetector readme file, and added commented out code…
Browse files Browse the repository at this point in the history
… for debugging using webIDE
  • Loading branch information
jones139 committed Dec 8, 2023
1 parent d4eeeee commit 720ec4f
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 37 deletions.
34 changes: 33 additions & 1 deletion OpenSeizureDetector.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,23 @@ which monitors body movement and heart rate using a smart watch.

It is possible to use a [BanjgleJS 2](https://banglejs.com/) watch with an experimental, testing version OpenSeizureDetector as described in this document.


Current Status
--------------
- Currently in the initial testing state.
- V0.12 and higher runs using V4.2.x of the [OpenSeizureDetector Android App](https://github.com/OpenSeizureDetector/Android_Pebble_SD/tree/V4.2.x).
- It only transmits vector magnitude data to the phone, not 3d data (so works with the normal OSD algorithm, but not good for data sharing)
- The vector magnitude is transmitted in 8 bits per measurement, scaled to give 0-4G range. (Need to compare this to Garmin)
- The BangleJS Heart rate appears higher than I would see on a Garmin (about 100 bpm rather than 60 bpm).
- The battery indication is a bit noisy - could do with calculating an averge to reduce noise.
- There is no feedback about the app state on the watch, no mute function.

Installation
------------

- Charge the BangleJS battery.
- Power on the BangleJS by pressing the button
- If this is the first run, you will see an introductory presentation about how to use BagleJS
- If this is the first run, you will see an introductory presentation about how to use BangleJS
- When it finishes, press the button again to start BangleJS
- In a web browser that supports WebBluetooth (e.g. Chrome), go to https://openseizuredetector.github.io/BangleApps/index.html
- Select the BangleJS 2 option
Expand All @@ -26,3 +37,24 @@ Installation
- When the watch re-starts it should show the OpenSeizureDetector logo in the top left hand corner of the screen.

The watch should now be ready to connect to the OpenSeizureDetector Android App and send data - it will do this without starting a specific watch app.

Start the Android App (V4.2.x or higher), select "Bluetooth Device" data source, then in general settings, click the "SELECT BLE DEVICE" button to choose which watch to connect to .


Development
-----------
- Use the Espruino [WebIDE](https://www.espruino.com/ide/)
- Uncomment the WIDGETS={}; and Bangle.drawWidgets(); lines from the top and bottom of the widget.js file.
- Copy the contents of widget.js into the Web IDE
- Upload the code to ram using the Web IDE
- Disconnect the Web IDE or the BLE services will not advertise.
- Deploy on Github pages
- Update medatadata.json and Changelog so that they both contain the same version number.
- Commit the changes and push to github.
- A github action should run to deploy the app loader to the [OpenSeizureDetector Github site](https://openseizuredetector.github.io/BangleApps/index.html?q=opens)
- Go to https://openseizuredetector.github.io/BangleApps/index.html?q=opens
- Connect to the BangleJS watch
- Update the OpenSeizureDetector widget
- Disconnect from the app loader or the BLE servies will not be advertised.


81 changes: 45 additions & 36 deletions apps/openseizure/widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
* 03 Oct 2023 - Graham Jones: Added heart rate data service
*/

// Uncomment for testing in ram using webIDE (https://espruino.com/ide)
//WIDGETS = {};


const WATCH_FW = "0.12";
const WATCH_ID = "BangleJs";

Expand Down Expand Up @@ -37,43 +41,46 @@ const CHAR_HR_LOC = 0x2A38; // Official BLE Sensor Location UUID

// accelerometer data callback.
Bangle.on('accel',function(a) {
accelData[accelIdx++] = E.clip(a.mag*64,0,255);
if (accelIdx>=accelData.length) {
accelIdx = 0;
batteryLevel = E.getBattery();
try {
var charOsdAccData = {
value : accelData,
notify : true
// Calculate vector magnitude of acceleration measurement, and scale it so 1g is value 64 (so we cover 0 to 4g)
accelData[accelIdx++] = E.clip(a.mag*64,0,255);
if (accelIdx>=accelData.length) {
accelIdx = 0;
batteryLevel = E.getBattery();
try {
var charOsdAccData = {
value : accelData,
notify : true
};
var charOsdBatData = {
value : batteryLevel,
notify : true
};
var charOsdBatData = {
value : batteryLevel,
notify : true
};
//var charOsdHrData = {
// value : hrVal,
// notify : true
//};
var charBleHrm = {
value : [0x06, hrVal], // Check what 0x06 is?
notify : true
};


var servOsd = {};
servOsd[CHAR_OSD_ACC_DATA] = charOsdAccData;
servOsd[CHAR_OSD_BAT_DATA] = charOsdBatData;
//servOsd[CHAR_OSD_HR_DATA] = charOsdHrData;
var servHrm = {};
servHrm[CHAR_HRM] = charBleHrm;

var servicesCfg = {};
servicesCfg[SERV_OSD] = servOsd;
servicesCfg[SERV_HRM] = servHrm;

NRF.updateServices(servicesCfg);
} catch(e) {}
}
//var charOsdHrData = {
// value : hrVal,
// notify : true
//};
var charBleHrm = {
value : [0x06, hrVal], // Check what 0x06 is?
notify : true
};


var servOsd = {};
servOsd[CHAR_OSD_ACC_DATA] = charOsdAccData;
servOsd[CHAR_OSD_BAT_DATA] = charOsdBatData;
//servOsd[CHAR_OSD_HR_DATA] = charOsdHrData;
var servHrm = {};
servHrm[CHAR_HRM] = charBleHrm;

var servicesCfg = {};
servicesCfg[SERV_OSD] = servOsd;
servicesCfg[SERV_HRM] = servHrm;

NRF.updateServices(servicesCfg);
} catch(e) {
E.showMessage(e,"OSD ERROR")
}
}
});


Expand Down Expand Up @@ -142,3 +149,5 @@ const CHAR_HR_LOC = 0x2A38; // Official BLE Sensor Location UUID
};
})();

// Uncomment for testing in RAM using webIDE
//Bangle.drawWidgets();

0 comments on commit 720ec4f

Please sign in to comment.