Merge branch 'espruino:master' into master

pull/3467/head
jeonlab 2024-05-26 20:52:05 -05:00 committed by GitHub
commit bf106b8c0c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 34 additions and 31 deletions

View File

@ -35,3 +35,5 @@
0.33: Fix alarms created in Gadgetbridge not repeating
0.34: Implement API for activity tracks fetching (Recorder app logs).
0.35: Implement API to enable/disable acceleration data tracking.
0.36: Move from wrapper function to {} and let - faster execution at boot
Allow `calendar-` to take an array of items to remove

View File

@ -1,22 +1,22 @@
/* global GB */
(function() {
function gbSend(message) {
{
let gbSend = function(message) {
Bluetooth.println("");
Bluetooth.println(JSON.stringify(message));
}
var lastMsg; // for music messages - may not be needed now...
var actInterval; // Realtime activity reporting interval when `act` is true
var actHRMHandler; // For Realtime activity reporting
var gpsState = {}; // keep information on GPS via Gadgetbridge
let lastMsg; // for music messages - may not be needed now...
let actInterval; // Realtime activity reporting interval when `act` is true
let actHRMHandler; // For Realtime activity reporting
let gpsState = {}; // keep information on GPS via Gadgetbridge
// this settings var is deleted after this executes to save memory
var settings = require("Storage").readJSON("android.settings.json",1)||{};
let settings = require("Storage").readJSON("android.settings.json",1)||{};
//default alarm settings
if (settings.rp == undefined) settings.rp = true;
if (settings.as == undefined) settings.as = true;
if (settings.vibrate == undefined) settings.vibrate = "..";
require('Storage').writeJSON("android.settings.json", settings);
var _GB = global.GB;
let _GB = global.GB;
let fetchRecInterval;
global.GB = (event) => {
// feed a copy to other handlers if there were any
@ -122,7 +122,10 @@
var cal = require("Storage").readJSON("android.calendar.json",true);
//if any of those happen we are out of sync!
if (!cal || !Array.isArray(cal)) cal = [];
cal = cal.filter(e=>e.id!=event.id);
if (Array.isArray(event.id))
cal = cal.filter(e=>!event.id.includes(e.id));
else
cal = cal.filter(e=>e.id!=event.id);
require("Storage").writeJSON("android.calendar.json", cal);
},
//triggered by GB, send all ids
@ -337,7 +340,7 @@
};
// Battery monitor
function sendBattery() { gbSend({ t: "status", bat: E.getBattery(), chg: Bangle.isCharging()?1:0 }); }
let sendBattery = function() { gbSend({ t: "status", bat: E.getBattery(), chg: Bangle.isCharging()?1:0 }); }
Bangle.on("charging", sendBattery);
NRF.on("connect", () => setTimeout(function() {
sendBattery();
@ -432,4 +435,4 @@
// remove settings object so it's not taking up RAM
delete settings;
})();
}

View File

@ -2,7 +2,7 @@
"id": "android",
"name": "Android Integration",
"shortName": "Android",
"version": "0.35",
"version": "0.36",
"description": "Display notifications/music/etc sent from the Gadgetbridge app on Android. This replaces the old 'Gadgetbridge' Bangle.js widget.",
"icon": "app.png",
"tags": "tool,system,messages,notifications,gadgetbridge",

View File

@ -1,4 +1,5 @@
0.01: New App!
0.02: added settings options to change date format
0.03: Remove un-needed font requirement, now outputs transparent image
0.04: Fix image after 0.03 regression
0.04: Fix image after 0.03 regression
0.05: Remove duplicated day in calendar when format setting is 'dd MMM'

View File

@ -5,7 +5,7 @@
var getDateString = function(dt) {
switch(settings.fmt) {
case "dd MMM":
return '' + dt.getDate() + ' ' + require("locale").month(dt,1).toUpperCase();
return require("locale").month(dt,1).toUpperCase();
case "DDD dd":
return require("locale").dow(dt,1).toUpperCase() + ' ' + dt.getDate();
default: // DDD

View File

@ -1,6 +1,6 @@
{ "id": "clkinfocal",
"name": "Calendar Clockinfo",
"version":"0.04",
"version":"0.05",
"description": "For clocks that display 'clockinfo' (messages that can be cycled through using the clock_info module) this displays the day of the month in the icon, and the weekday. There is also a settings menu to select the format of the text",
"icon": "app.png",
"screenshots": [{"url":"screenshot.png"}],

View File

@ -5,3 +5,5 @@
functionality, both via `.back` and `"< Back"` items, displaying an
entry and the `setUI` back widget. Fix `setUI`'s back overwrite. Add
support for scroll.
0.05: Fix display of final menu item when no options are given and
handling of E.showMenu() with no arguments

View File

@ -12,12 +12,10 @@ E.showMenu = function (items) {
g.fillPoly(RectRnd(x1, y1, x2, y2, r));
g.setColor(255, 255, 255);
};
var options = items && items[""] || {};
if (items)
delete items[""];
var menuItems = Object.keys(items);
var options = items[""] || {};
if (!(options instanceof Object))
options = {};
if (options)
menuItems.splice(menuItems.indexOf(""), 1);
var fontHeight = options.fontHeight || 25;
var selected = options.scroll || options.selected || 0;
var ar = Bangle.appRect;
@ -144,7 +142,7 @@ E.showMenu = function (items) {
l.draw();
var back = options.back;
if (!back) {
var backItem = items["< Back"];
var backItem = items && items["< Back"];
if (typeof backItem === "function")
back = backItem;
else if (backItem && "back" in backItem)

View File

@ -1,6 +1,6 @@
type ActualMenuItem = Exclude<Menu["..."], MenuOptions | undefined>;
(E.showMenu as any) = (items: Menu): MenuInstance => {
E.showMenu = (items?: Menu): MenuInstance => {
const RectRnd = (x1: number, y1: number, x2: number, y2: number, r: number) => {
const pp = [];
pp.push(...g.quadraticBezier([x2 - r, y1, x2, y1, x2, y1 + r]));
@ -14,12 +14,9 @@ type ActualMenuItem = Exclude<Menu["..."], MenuOptions | undefined>;
g.fillPoly(RectRnd(x1, y1, x2, y2, r));
g.setColor(255, 255, 255);
};
let options = items && items[""] || {};
if (items) delete items[""];
const menuItems = Object.keys(items);
let options = items[""] || {};
if (!(options instanceof Object)) options = {};
if (options)
menuItems.splice(menuItems.indexOf(""), 1);
const fontHeight = options.fontHeight||25;
@ -63,7 +60,7 @@ type ActualMenuItem = Exclude<Menu["..."], MenuOptions | undefined>;
}
while (rows--) {
const name = menuItems[idx];
const item = items[name]! as ActualMenuItem;
const item = items![name]! as ActualMenuItem;
const hl = (idx === selected && !selectEdit);
if(g.theme.dark){
@ -118,7 +115,7 @@ type ActualMenuItem = Exclude<Menu["..."], MenuOptions | undefined>;
g.flip();
},
select: () => {
const item = items[menuItems[selected]] as ActualMenuItem;
const item = items![menuItems[selected]] as ActualMenuItem;
if (typeof item === "function") {
item();
@ -164,7 +161,7 @@ type ActualMenuItem = Exclude<Menu["..."], MenuOptions | undefined>;
let back = options.back;
if (!back) {
const backItem = items["< Back"];
const backItem = items && items["< Back"];
if (typeof backItem === "function")
back = backItem;
else if (backItem && "back" in backItem)

View File

@ -1,7 +1,7 @@
{
"id": "promenu",
"name": "Pro Menu",
"version": "0.04",
"version": "0.05",
"description": "Replace the built in menu function. Supports Bangle.js 1 and Bangle.js 2.",
"icon": "icon.png",
"type": "bootloader",