tactilus-mat-status
v1.0.34
Published
tactilus-mat-status is a lightweight and efficient library designed to analyze data from the Tactilus sensor mat and determine the user's body position in real-time
Downloads
35
Maintainers
Readme
tactilus-mat-status
tactilus-mat-status is a lightweight and efficient library designed to analyze data from the Tactilus sensor mat and determine the user's body position in real-time.
Features Detects the following positions on the mat:
- Standing
- Lying Down
- In Motion
- Falling Down
- No One on the Mat
Installation
Install Tactilus mat status with npm
npm install tactilus-mat-statusconst { EventSource } = require("eventsource")
const { getStatusFromMatSensors } = require("./app")
const es = new EventSource('http://10.0.0.1/api/sse');
const url = "http://10.0.0.1/api/frequency";
const maxFramesToKeep = 10;
fetch(url, {
headers: {
"content-type":
"application/x-www-form-urlencoded; charset=UTF-8",
},
body: (
3 * 3600
).toString(),
method: "put",
}).then(res=>{
const frames = [];
es.addEventListener('newframe', function (e) {
const pressureMatrix = JSON.parse(e.data);
const currentFrame = pressureMatrix.readings[0];
frames.push(currentFrame);
if (frames.length > maxFramesToKeep) {
frames.shift();
}
if (frames.length === maxFramesToKeep) {
console.log(getStatusFromMatSensors(frames));
}
});
})