This page contains information on how to hack the ORPHE CORE module with js, along with basic information on BLE and sample code. ORPHE-CORE.js uses BLE, so please be sure to check its compatibility with a CHROME browser. The environment that has been tested in this document is , Chrome browser on macOS, Windows, Linux and Android.
[known issue] For AndroidOS Users: In the case of an example that uses multiple graphs displayed by chartjs, the BLE data update speed may become slow due to performance degradation.
[known issue] For AndroidOS Users: ANALYSIS and RAW Starter Template won't work.
Happy hacking with ORPHE CORE Module and javascript.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>ORPHE CORE JS DEMO</title>
</head>
<body>
<h1>Hello, ORPHE!</h1>
<button onclick="ble.setLED(1,0);">connect</button>
<script src="https://cdn.jsdelivr.net/gh/Orphe-OSS/ORPHE-CORE.js/js/ORPHE-CORE.js"
crossorigin="anonymous"></script>
<script>
var ble = new Orphe(0);
window.onload = function () {
// ORPHE CORE Init
ble.setup();
}
</script>
</body>
</html>
If you make LEDs glow, you'll be tempted to make them blink.Don't you ever do that? Let's make LED BLINKING happen with this code. Hello ORPHE-CORE World!!
The sample code below also describes how to set the notificaiton type and sensor sensitivity from the beginning when calling ble.begin. Normally, the begin() function can be used by calling it without any arguments, but if you have detailed specifications, please refer to it.
API Reference:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>ORPHE CORE JS DEMO</title>
</head>
<body>
<h1>Hello, ORPHE!</h1>
<button onclick="mystart()">connect</button>
<script src="https://cdn.jsdelivr.net/gh/Orphe-OSS/ORPHE-CORE.js/js/ORPHE-CORE.js" crossorigin="anonymous"></script>
<script>
var ble = new Orphe(0);
window.onload = function () {
ble.setup();
}
async function mystart() {
await ble.begin();
// alternative begin function call
// ANALYSIS, RAW, ANALYSIS_AND_RAW
// await ble.begin('ANALYSIS', { range: { acc: 16, gyro: 2000 } });
ble.setLED(1, 0);
let flg = true;
setInterval(function () {
if (flg == true) ble.setLED(0, 0);
else ble.setLED(1, 0);
flg = !flg;
}, 1000);
}
</script>
</body>
</html>
ORPHE-CORE.js can be run with a few lines of code, but it can be somewhat cumbersome to configure detailed settings such as sensor sensitivity and data reception format. coretoolkit.js can add an integrated UI, including module settings, with a single line of code. This may be useful when developing large scale applications.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>CoreToolkit.js</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.2/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-Zenh87qX5JnK2Jl0vWa8Ck2rdkQ2Bzep5IDxbcnCeuOxjzrPF/et3URy9Bv1WTRi" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.2/font/bootstrap-icons.css">
</head>
<body>
<h1>Hello, CoreToolkit.js</h1>
<div id="toolkit_placeholder"></div>
<script src="https://cdn.jsdelivr.net/gh/Orphe-OSS/ORPHE-CORE.js/js/ORPHE-CORE.js"
crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/gh/Orphe-OSS/ORPHE-CORE.js/js/CoreToolkit.js" crossorigin="anonymous"
type="text/javascript"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.2/dist/js/bootstrap.min.js"
integrity="sha384-IDwe1+LCz02ROU9k972gdyvl+AESN10+x7tBKgc9I5HFtuNz0wWnPclzo6p9vxnk"
crossorigin="anonymous"></script>
<script>
window.onload = function () {
// ORPHE CORE Init; bles[0] and bles[1] are used by CoreToolkit.js
bles[0].setup();
buildCoreToolkit(document.querySelector('#toolkit_placeholder'), '01', 0, 'RAW');
// alternatibe begin function call
// buildCoreToolkit(document.querySelector('#toolkit_placeholder'),
// '01', // name to be shown on the UI
// 0, // index of bles array
// 'ANALYSIS', // ANALYSIS, RAW, ANALYSIS_AND_RAW
// { range: { acc: 8, gyro: 1000 } } // sensor range
// );
bles[0].gotAcc = function (acc) {
}
}
</script>
</body>
</html>
Programming workshops using ORPHE CORE are available on youtube. have a fun, enjoy!!
Using the previous contents, you already have easy and speedy access to the ORPHE CORE module. Still not enough? In this section, we will use Electron to make the ORPHE CORE module even more fun.
Electron is a framework for building desktop applications using JavaScript, HTML, and CSS. By embedding Chromium and Node.js into its binary, Electron allows you to maintain one JavaScript codebase and create cross-platform apps that work on Windows, macOS, and Linux — no native development experience required.