From 6d58a466b2b5e34eaac066fa9637056fecae0128 Mon Sep 17 00:00:00 2001 From: stweedo Date: Thu, 29 Jun 2023 08:43:45 -0500 Subject: [PATCH 1/3] [gassist] - New app for voice control --- apps/gassist/ChangeLog | 1 + apps/gassist/app.js | 11 +++++++++++ apps/gassist/app.png | Bin 0 -> 799 bytes apps/gassist/boot.js | 21 +++++++++++++++++++++ apps/gassist/gassist.json | 1 + apps/gassist/icon.js | 1 + apps/gassist/metadata.json | 18 ++++++++++++++++++ apps/gassist/settings.js | 32 ++++++++++++++++++++++++++++++++ 8 files changed, 85 insertions(+) create mode 100644 apps/gassist/ChangeLog create mode 100644 apps/gassist/app.js create mode 100644 apps/gassist/app.png create mode 100644 apps/gassist/boot.js create mode 100644 apps/gassist/gassist.json create mode 100644 apps/gassist/icon.js create mode 100644 apps/gassist/metadata.json create mode 100644 apps/gassist/settings.js diff --git a/apps/gassist/ChangeLog b/apps/gassist/ChangeLog new file mode 100644 index 000000000..5560f00bc --- /dev/null +++ b/apps/gassist/ChangeLog @@ -0,0 +1 @@ +0.01: New App! diff --git a/apps/gassist/app.js b/apps/gassist/app.js new file mode 100644 index 000000000..69e8001e3 --- /dev/null +++ b/apps/gassist/app.js @@ -0,0 +1,11 @@ +Bluetooth.println(""); +Bluetooth.println(JSON.stringify({ + t:"intent", + target:"activity", + action:"android.intent.action.VOICE_COMMAND", + flags:["FLAG_ACTIVITY_NEW_TASK"] +})); + +setTimeout(function() { + Bangle.showClock(); +}, 0); diff --git a/apps/gassist/app.png b/apps/gassist/app.png new file mode 100644 index 0000000000000000000000000000000000000000..8c190d3449e27cc6f84461dc0ea0c2a84fd25c45 GIT binary patch literal 799 zcmV+)1K|9LP)RCt{2S4(RXQ4~IC$;CflXB1nIuH5U!WUIC_k|4NsBNT*2 zK{J!?vJk;PAU=MANCI6HtgV@Be6(qkdlNTZTdlg%WTC4gXVSD|U|z}GW+L;!AtBH2 zJCE<43y>f|fpC&gbcK5G$0bQ>q~rZK9?? z-!Q~?)!_H&d*h}K%7ag{ipd*+h!2EarDA(#Y~-iS#wFDh--aQ7R1LnbEVnL>CG+a2 zXfw zzM^{{jP`CLRRI4TMu0}-D>>|kR>`h;enFN4IV$iulz>XM^N)aX?w5}Md#jW;0|ws= zBS5FN30Z+>a)($v2|WXq>>5=Gmym$SeS;c9T}+NWw;J; zJ&7-r+9?P5$Cv?hiAO_=urDuCD$u$;ka;)qy-0&T!Zs?lqa9vRhnp`?Is{k&1iT%- z3dQyeT}C2up8YfTTj!j=k7?-m3dn%BW%_|`QX`9Sxse4F@DoM_RbuG<$Po3x%pVFM zxAAYG4TuCKJfRetx5!0;x{ZB#@wkDJRR*Yl22p}6koNiBVaKA2SAn6Gx{Fro1J+pA4tic?d3q1x3|v2T z7A@Aq8bg<8&}SgNnfD}*ha%!w3A=6l$>TvRLEL~A`xsn6>OI5_SYw?K73jc33$WPe z3tiNh{1&RR{A3UDDlpq3gV<;r0xgE)Imo<4G-7*@^+DOi8e5`1KN#!|)>7~6*W#M_ d1PLI1_zPVw3^6G-%sBu6002ovPDHLkV1jq+Ys>%u literal 0 HcmV?d00001 diff --git a/apps/gassist/boot.js b/apps/gassist/boot.js new file mode 100644 index 000000000..eb2155796 --- /dev/null +++ b/apps/gassist/boot.js @@ -0,0 +1,21 @@ +// load settings +var settings = Object.assign({ + enableTap: true +}, require("Storage").readJSON("gassist.json", true) || {}); + +if (settings.enableTap) { + Bangle.on("tap", function(e) { + if (e.dir=="front" && e.double) { + Bluetooth.println(""); + Bluetooth.println(JSON.stringify({ + t:"intent", + target:"activity", + action:"android.intent.action.VOICE_COMMAND", + flags:["FLAG_ACTIVITY_NEW_TASK"] + })); + } + }); +} + +// clear variable +settings = undefined; \ No newline at end of file diff --git a/apps/gassist/gassist.json b/apps/gassist/gassist.json new file mode 100644 index 000000000..26c61fc04 --- /dev/null +++ b/apps/gassist/gassist.json @@ -0,0 +1 @@ +gassist.json \ No newline at end of file diff --git a/apps/gassist/icon.js b/apps/gassist/icon.js new file mode 100644 index 000000000..9e84990e3 --- /dev/null +++ b/apps/gassist/icon.js @@ -0,0 +1 @@ +require("heatshrink").decompress(atob("mEwxH+AH4A/AH4ALiAAFFtoxmFpQxjFxwwfFyAwdFyQwcF9wuUGDQvuFywwYF/4vUnAABF9YuCGBAv/F/6/PGC4bE3QACG5YvdFoYxSLzAvuFw4wjLxbCidhAvVGB4UFF7QxMCZAuaGJIRKF7oATFtoA/AEPMAAQttGNQuHGE4vuFxIwlF/4v/d/4vwGBAumGIwtpAH4A/AEIA==")) \ No newline at end of file diff --git a/apps/gassist/metadata.json b/apps/gassist/metadata.json new file mode 100644 index 000000000..995c44adb --- /dev/null +++ b/apps/gassist/metadata.json @@ -0,0 +1,18 @@ +{ + "id": "gassist", + "name": "Google Assist", + "version": "0.01", + "description": "A simple way to initiate Google Assistant on Android. Intents must be enabled in Gadgetbridge.", + "icon": "app.png", + "type": "app", + "tags": "tool, voice, tasker", + "supports": ["BANGLEJS","BANGLEJS2"], + "allow_emulator": false, + "storage": [ + {"name":"gassist.boot.js","url":"boot.js"}, + {"name":"gassist.app.js","url":"app.js"}, + {"name":"gassist.settings.js","url":"settings.js"}, + {"name":"gassist.img","url":"icon.js","evaluate":true} + ], + "data": [{"name":"gassist.json"}] +} \ No newline at end of file diff --git a/apps/gassist/settings.js b/apps/gassist/settings.js new file mode 100644 index 000000000..f264d99fa --- /dev/null +++ b/apps/gassist/settings.js @@ -0,0 +1,32 @@ +let storage = require('Storage'); + +(function (back) { + // Load and set default settings + let appSettings = Object.assign({ + enableTap : true + }, storage.readJSON("gassist.json", true) || {}); + + // Save settings to storage + function writeSettings() { + storage.writeJSON("gassist.json", appSettings); + } + + function showMenu() { + E.showMenu({ + "": { + "title": "Google Assist" + }, + "< Back": () => back(), + 'Front Tap:': { + value: (appSettings.enableTap === true), + format: v => v ? "On" : "Off", + onchange: v => { + appSettings.enableTap = v; + writeSettings(); + } + }, + }); + } + // Initially show the menu + showMenu(); +}); \ No newline at end of file From 297d8b15acb55b34afd48fb350f60dbaa6412e58 Mon Sep 17 00:00:00 2001 From: stweedo Date: Thu, 29 Jun 2023 12:25:38 -0500 Subject: [PATCH 2/3] Fix scoping, add 'file' variable --- apps/gassist/gassist.json | 1 - apps/gassist/settings.js | 11 ++++++----- 2 files changed, 6 insertions(+), 6 deletions(-) delete mode 100644 apps/gassist/gassist.json diff --git a/apps/gassist/gassist.json b/apps/gassist/gassist.json deleted file mode 100644 index 26c61fc04..000000000 --- a/apps/gassist/gassist.json +++ /dev/null @@ -1 +0,0 @@ -gassist.json \ No newline at end of file diff --git a/apps/gassist/settings.js b/apps/gassist/settings.js index f264d99fa..987c3fdfc 100644 --- a/apps/gassist/settings.js +++ b/apps/gassist/settings.js @@ -1,14 +1,15 @@ -let storage = require('Storage'); - (function (back) { + let storage = require('Storage'); + let file = "gassist.json"; + // Load and set default settings let appSettings = Object.assign({ enableTap : true - }, storage.readJSON("gassist.json", true) || {}); + }, storage.readJSON(file, true) || {}); // Save settings to storage function writeSettings() { - storage.writeJSON("gassist.json", appSettings); + storage.writeJSON(file, appSettings); } function showMenu() { @@ -29,4 +30,4 @@ let storage = require('Storage'); } // Initially show the menu showMenu(); -}); \ No newline at end of file +}); From 3e8e2adb6088f7b3f1951d4b62904a572a28b190 Mon Sep 17 00:00:00 2001 From: Rob Pilling Date: Thu, 29 Jun 2023 22:55:23 +0100 Subject: [PATCH 3/3] chimer: sleep between buzzes, instead of during --- apps/chimer/ChangeLog | 1 + apps/chimer/metadata.json | 2 +- apps/chimer/widget.js | 7 ++++--- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/apps/chimer/ChangeLog b/apps/chimer/ChangeLog index 51842b5cd..6c6f5312e 100644 --- a/apps/chimer/ChangeLog +++ b/apps/chimer/ChangeLog @@ -1,3 +1,4 @@ 0.01: Initial Creation 0.02: Fixed some sleep bugs. Added a sleep mode toggle 0.03: Reduce busy-loop and code +0.04: Separate buzz-time and sleep-time diff --git a/apps/chimer/metadata.json b/apps/chimer/metadata.json index dfbabf405..cfa0da00f 100644 --- a/apps/chimer/metadata.json +++ b/apps/chimer/metadata.json @@ -1,7 +1,7 @@ { "id": "chimer", "name": "Chimer", - "version": "0.03", + "version": "0.04", "description": "A fork of Hour Chime that adds extra features such as: \n - Buzz or beep on every 60, 30 or 15 minutes. \n - Repeat Chime up to 3 times \n - Set hours to disable chime", "icon": "widget.png", "type": "widget", diff --git a/apps/chimer/widget.js b/apps/chimer/widget.js index a587b61de..3b7de9d7a 100644 --- a/apps/chimer/widget.js +++ b/apps/chimer/widget.js @@ -20,15 +20,16 @@ let count = settings.repeat; const chime1 = () => { + let p; if (settings.type === 1) { - Bangle.buzz(100); + p = Bangle.buzz(100); } else if (settings.type === 2) { - Bangle.beep(); + p = Bangle.beep(); } else { return; } if (--count > 0) - setTimeout(chime1, 150); + p.then(() => setTimeout(chime1, 150)); }; chime1();