forked from FOSS/BangleApps
Setting to turn Bluetooth on and off
parent
4d3bcd94a3
commit
75f8f7b86a
|
@ -1,8 +1,9 @@
|
|||
{
|
||||
ble: false, // Bluetooth disabled by default
|
||||
timeout: 10, // Default LCD timeout in seconds
|
||||
vibrate: true, // Vibration enabled by default. App must support
|
||||
beep: true, // Beep enabled by default. App must support
|
||||
timezone: 0, // Set the timezone for the device
|
||||
HID : false, // BLE HID mode, off by default
|
||||
HID: false, // BLE HID mode, off by default
|
||||
debug: false, // Debug mode disabled by default. App must support
|
||||
}
|
||||
|
|
|
@ -1,80 +1,87 @@
|
|||
(function() {
|
||||
var s = require('Storage').readJSON('@setting');
|
||||
var adv = { uart: true };
|
||||
if (s.HID) {
|
||||
// Report from https://notes.iopush.net/custom-usb-hid-device-descriptor-media-keyboard/
|
||||
Bangle.HID = new Uint8Array([
|
||||
// Keyboard Controls
|
||||
0x05, 0x01,
|
||||
0x09, 0x06,
|
||||
0xA1, 0x01,
|
||||
0x85, 0x02,
|
||||
0x05, 0x07,
|
||||
0x19, 0xe0,
|
||||
0x29, 0xe7,
|
||||
0x15, 0x00,
|
||||
0x25, 0x01,
|
||||
0x75, 0x01,
|
||||
0x95, 0x08,
|
||||
0x81, 0x02,
|
||||
0x95, 0x01,
|
||||
0x75, 0x08,
|
||||
0x81, 0x01,
|
||||
0x95, 0x05,
|
||||
0x75, 0x01,
|
||||
0x05, 0x08,
|
||||
0x19, 0x01,
|
||||
0x29, 0x05,
|
||||
0x91, 0x02,
|
||||
0x95, 0x01,
|
||||
0x75, 0x03,
|
||||
0x91, 0x01,
|
||||
0x95, 0x06,
|
||||
0x75, 0x08,
|
||||
0x15, 0x00,
|
||||
0x25, 0x73,
|
||||
0x05, 0x07,
|
||||
0x19, 0x00,
|
||||
0x29, 0x73,
|
||||
0x81, 0x00,
|
||||
0x09, 0x05,
|
||||
0x15, 0x00,
|
||||
0x26, 0xFF, 0x00,
|
||||
0x75, 0x08,
|
||||
0x95, 0x02,
|
||||
0xB1, 0x02,
|
||||
0xC0,
|
||||
if (s.ble) {
|
||||
var adv = { uart: true };
|
||||
if (s.HID) {
|
||||
// Report from https://notes.iopush.net/custom-usb-hid-device-descriptor-media-keyboard/
|
||||
Bangle.HID = new Uint8Array([
|
||||
// Keyboard Controls
|
||||
0x05, 0x01,
|
||||
0x09, 0x06,
|
||||
0xA1, 0x01,
|
||||
0x85, 0x02,
|
||||
0x05, 0x07,
|
||||
0x19, 0xe0,
|
||||
0x29, 0xe7,
|
||||
0x15, 0x00,
|
||||
0x25, 0x01,
|
||||
0x75, 0x01,
|
||||
0x95, 0x08,
|
||||
0x81, 0x02,
|
||||
0x95, 0x01,
|
||||
0x75, 0x08,
|
||||
0x81, 0x01,
|
||||
0x95, 0x05,
|
||||
0x75, 0x01,
|
||||
0x05, 0x08,
|
||||
0x19, 0x01,
|
||||
0x29, 0x05,
|
||||
0x91, 0x02,
|
||||
0x95, 0x01,
|
||||
0x75, 0x03,
|
||||
0x91, 0x01,
|
||||
0x95, 0x06,
|
||||
0x75, 0x08,
|
||||
0x15, 0x00,
|
||||
0x25, 0x73,
|
||||
0x05, 0x07,
|
||||
0x19, 0x00,
|
||||
0x29, 0x73,
|
||||
0x81, 0x00,
|
||||
0x09, 0x05,
|
||||
0x15, 0x00,
|
||||
0x26, 0xFF, 0x00,
|
||||
0x75, 0x08,
|
||||
0x95, 0x02,
|
||||
0xB1, 0x02,
|
||||
0xC0,
|
||||
|
||||
// Music Controls
|
||||
0x05, 0x0C,
|
||||
0x09, 0x01,
|
||||
0xA1, 0x01,
|
||||
0x85, 0x01,
|
||||
0x15, 0x00,
|
||||
0x25, 0x01,
|
||||
0x75, 0x01,
|
||||
0x95, 0x01,
|
||||
0x09, 0xB5,
|
||||
0x81, 0x02,
|
||||
0x09, 0xB6,
|
||||
0x81, 0x02,
|
||||
0x09, 0xB7,
|
||||
0x81, 0x02,
|
||||
0x09, 0xB8,
|
||||
0x81, 0x02,
|
||||
0x09, 0xCD,
|
||||
0x81, 0x02,
|
||||
0x09, 0xE2,
|
||||
0x81, 0x02,
|
||||
0x09, 0xE9,
|
||||
0x81, 0x02,
|
||||
0x09, 0xEA,
|
||||
0x81, 0x02,
|
||||
0xC0
|
||||
]);
|
||||
adv.hid = Bangle.HID;
|
||||
// Music Controls
|
||||
0x05, 0x0C,
|
||||
0x09, 0x01,
|
||||
0xA1, 0x01,
|
||||
0x85, 0x01,
|
||||
0x15, 0x00,
|
||||
0x25, 0x01,
|
||||
0x75, 0x01,
|
||||
0x95, 0x01,
|
||||
0x09, 0xB5,
|
||||
0x81, 0x02,
|
||||
0x09, 0xB6,
|
||||
0x81, 0x02,
|
||||
0x09, 0xB7,
|
||||
0x81, 0x02,
|
||||
0x09, 0xB8,
|
||||
0x81, 0x02,
|
||||
0x09, 0xCD,
|
||||
0x81, 0x02,
|
||||
0x09, 0xE2,
|
||||
0x81, 0x02,
|
||||
0x09, 0xE9,
|
||||
0x81, 0x02,
|
||||
0x09, 0xEA,
|
||||
0x81, 0x02,
|
||||
0xC0
|
||||
]);
|
||||
adv.hid = Bangle.HID;
|
||||
}
|
||||
NRF.setServices(undefined, adv);
|
||||
try {
|
||||
NRF.wake();
|
||||
} catch (e) {}
|
||||
} else {
|
||||
NRF.sleep();
|
||||
}
|
||||
NRF.setServices(undefined, adv);
|
||||
|
||||
if (!s.vibrate) Bangle.buzz=()=>Promise.resolve();
|
||||
if (!s.beep) Bangle.beep=()=>Promise.resolve();
|
||||
|
|
|
@ -18,6 +18,7 @@ function updateSettings() {
|
|||
|
||||
function resetSettings() {
|
||||
settings = {
|
||||
ble: false,
|
||||
timeout: 10,
|
||||
vibrate: true,
|
||||
beep: true,
|
||||
|
@ -39,6 +40,14 @@ const boolFormat = (v) => v ? "On" : "Off";
|
|||
function showMainMenu() {
|
||||
const mainmenu = {
|
||||
'': { 'title': 'Settings' },
|
||||
'BLE': {
|
||||
value: settings.ble,
|
||||
format: boolFormat,
|
||||
onchange: () => {
|
||||
settings.ble = !settings.ble;
|
||||
updateSettings();
|
||||
}
|
||||
},
|
||||
'LCD Timeout': {
|
||||
value: settings.timeout,
|
||||
min: 0,
|
||||
|
|
Loading…
Reference in New Issue