From 39c3a11d9f65730baac527c5586799709aba9055 Mon Sep 17 00:00:00 2001 From: Sebastian Di Luzio Date: Tue, 7 Dec 2021 21:38:09 +0100 Subject: [PATCH 01/80] first draft: does not export to correct path yet --- typescript/sharedLib/.gitignore | 2 ++ typescript/sharedLib/README.md | 27 +++++++++++++++++++ typescript/sharedLib/package-lock.json | 37 ++++++++++++++++++++++++++ typescript/sharedLib/package.json | 20 ++++++++++++++ typescript/sharedLib/src/app.ts | 2 ++ typescript/sharedLib/tsconfig.json | 8 ++++++ 6 files changed, 96 insertions(+) create mode 100644 typescript/sharedLib/.gitignore create mode 100644 typescript/sharedLib/README.md create mode 100644 typescript/sharedLib/package-lock.json create mode 100644 typescript/sharedLib/package.json create mode 100644 typescript/sharedLib/src/app.ts create mode 100644 typescript/sharedLib/tsconfig.json diff --git a/typescript/sharedLib/.gitignore b/typescript/sharedLib/.gitignore new file mode 100644 index 000000000..b2af6e004 --- /dev/null +++ b/typescript/sharedLib/.gitignore @@ -0,0 +1,2 @@ +node_modules/ +!package-lock.json \ No newline at end of file diff --git a/typescript/sharedLib/README.md b/typescript/sharedLib/README.md new file mode 100644 index 000000000..78b07b332 --- /dev/null +++ b/typescript/sharedLib/README.md @@ -0,0 +1,27 @@ +# BangleTS + +A generic project setup for compiling apps from Typescript to Bangle.js ready, readable Javascript. +It includes types for *some* of the modules and globals that are exposed for apps to use. +The goal is to have types for everything, but that will take some time. Feel free to help out by contributing! + +## Using the types +TODO + +## Compilation + +Install [npm](https://www.npmjs.com/get-npm) if you haven't already. +Make sure you are using version ^8 by running `npm -v`. If the version is incorrect, run `npm i -g npm@^8`. + +After having installed npm for your platform, open a terminal, and navigate into the `/typescript/sharedLib` folder. Then run: + +``` +npm ci +``` + +to install the project's build tools, and: + +``` +npm run build:app pathToYourApp.ts +``` + +To build your app. The last command will generate the `app.js` file containing the transpiled code for the BangleJS. diff --git a/typescript/sharedLib/package-lock.json b/typescript/sharedLib/package-lock.json new file mode 100644 index 000000000..9df411a91 --- /dev/null +++ b/typescript/sharedLib/package-lock.json @@ -0,0 +1,37 @@ +{ + "name": "banglets", + "version": "0.1.0", + "lockfileVersion": 2, + "requires": true, + "packages": { + "": { + "name": "banglets", + "version": "0.1.0", + "license": "MIT", + "devDependencies": { + "typescript": "^4.5.2" + } + }, + "node_modules/typescript": { + "version": "4.5.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.5.2.tgz", + "integrity": "sha512-5BlMof9H1yGt0P8/WF+wPNw6GfctgGjXp5hkblpyT+8rkASSmkUKMXrxR0Xg8ThVCi/JnHQiKXeBaEwCeQwMFw==", + "dev": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=4.2.0" + } + } + }, + "dependencies": { + "typescript": { + "version": "4.5.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.5.2.tgz", + "integrity": "sha512-5BlMof9H1yGt0P8/WF+wPNw6GfctgGjXp5hkblpyT+8rkASSmkUKMXrxR0Xg8ThVCi/JnHQiKXeBaEwCeQwMFw==", + "dev": true + } + } +} diff --git a/typescript/sharedLib/package.json b/typescript/sharedLib/package.json new file mode 100644 index 000000000..2bf45de2e --- /dev/null +++ b/typescript/sharedLib/package.json @@ -0,0 +1,20 @@ +{ + "name": "bangle.ts", + "version": "0.1.0", + "description": "Typescript configuration and typings for Bangle.js", + "main": "app.js", + "types": "app.d.ts", + "scripts": { + "build:testapp": "tsc src/app.ts", + "build:types": "tsc src/bangle.d.ts", + "build:app": "tsc" + }, + "author": { + "name": "Sebastian Di Luzio", + "email": "sebastian@diluz.io" + }, + "license": "MIT", + "devDependencies": { + "typescript": "^4.5.2" + } +} diff --git a/typescript/sharedLib/src/app.ts b/typescript/sharedLib/src/app.ts new file mode 100644 index 000000000..6e5739557 --- /dev/null +++ b/typescript/sharedLib/src/app.ts @@ -0,0 +1,2 @@ +const testString = 'test hehe'; +console.log(testString); diff --git a/typescript/sharedLib/tsconfig.json b/typescript/sharedLib/tsconfig.json new file mode 100644 index 000000000..42b34ec65 --- /dev/null +++ b/typescript/sharedLib/tsconfig.json @@ -0,0 +1,8 @@ +{ + "compilerOptions": { + "module": "es2015", + "noImplicitAny": true, + "target": "es2015", + "outDir": "../dist" + } +} From 3cd9c3952560dec0f7689de0cf2eb9302125afb6 Mon Sep 17 00:00:00 2001 From: Sebastian Di Luzio Date: Tue, 7 Dec 2021 21:46:28 +0100 Subject: [PATCH 02/80] add build example to export to correct path --- typescript/sharedLib/README.md | 5 +++-- typescript/sharedLib/package.json | 5 ++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/typescript/sharedLib/README.md b/typescript/sharedLib/README.md index 78b07b332..a54a4c75a 100644 --- a/typescript/sharedLib/README.md +++ b/typescript/sharedLib/README.md @@ -1,10 +1,11 @@ # BangleTS A generic project setup for compiling apps from Typescript to Bangle.js ready, readable Javascript. -It includes types for *some* of the modules and globals that are exposed for apps to use. +It includes types for _some_ of the modules and globals that are exposed for apps to use. The goal is to have types for everything, but that will take some time. Feel free to help out by contributing! ## Using the types + TODO ## Compilation @@ -21,7 +22,7 @@ npm ci to install the project's build tools, and: ``` -npm run build:app pathToYourApp.ts +npx tsc ./relativePathToYourApp/app.ts --outDir ./relativePathToYourApp/dist ``` To build your app. The last command will generate the `app.js` file containing the transpiled code for the BangleJS. diff --git a/typescript/sharedLib/package.json b/typescript/sharedLib/package.json index 2bf45de2e..814db8f3e 100644 --- a/typescript/sharedLib/package.json +++ b/typescript/sharedLib/package.json @@ -5,9 +5,8 @@ "main": "app.js", "types": "app.d.ts", "scripts": { - "build:testapp": "tsc src/app.ts", - "build:types": "tsc src/bangle.d.ts", - "build:app": "tsc" + "build:testapp": "tsc ./src/app.ts --outDir ./dist", + "build:types": "tsc ./src/bangle.d.ts" }, "author": { "name": "Sebastian Di Luzio", From 61cc93b0b6e461b25daa5225497466c00a099662 Mon Sep 17 00:00:00 2001 From: Sebastian Di Luzio Date: Tue, 7 Dec 2021 22:27:09 +0100 Subject: [PATCH 03/80] prepare for using with widChargingStatus global types are not yet received correctly, but we're close! - use widChargerStatus as first example to make setup work - add github action to compile supplied types/globals on pushes --- .github/workflows/nodejs.yml | 25 +++ .../{widget.js => widget.ts} | 0 typescript/{sharedLib => }/.gitignore | 0 typescript/{sharedLib => }/README.md | 0 typescript/globals.d.ts | 145 ++++++++++++++++++ typescript/{sharedLib => }/package-lock.json | 0 typescript/{sharedLib => }/package.json | 4 +- typescript/sharedLib/src/app.ts | 2 - typescript/{sharedLib => }/tsconfig.json | 6 +- 9 files changed, 176 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/nodejs.yml rename apps/widChargingStatus/{widget.js => widget.ts} (100%) rename typescript/{sharedLib => }/.gitignore (100%) rename typescript/{sharedLib => }/README.md (100%) create mode 100644 typescript/globals.d.ts rename typescript/{sharedLib => }/package-lock.json (100%) rename typescript/{sharedLib => }/package.json (70%) delete mode 100644 typescript/sharedLib/src/app.ts rename typescript/{sharedLib => }/tsconfig.json (52%) diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml new file mode 100644 index 000000000..9503d8934 --- /dev/null +++ b/.github/workflows/nodejs.yml @@ -0,0 +1,25 @@ +name: Node CI + +on: [push] + +jobs: + build: + + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [16.x] + + steps: + - uses: actions/checkout@v1 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + - name: go to typescript directory + run: cd typescript + - name: npm ci + run: npm ci + - name: build types + run: npm run build:types \ No newline at end of file diff --git a/apps/widChargingStatus/widget.js b/apps/widChargingStatus/widget.ts similarity index 100% rename from apps/widChargingStatus/widget.js rename to apps/widChargingStatus/widget.ts diff --git a/typescript/sharedLib/.gitignore b/typescript/.gitignore similarity index 100% rename from typescript/sharedLib/.gitignore rename to typescript/.gitignore diff --git a/typescript/sharedLib/README.md b/typescript/README.md similarity index 100% rename from typescript/sharedLib/README.md rename to typescript/README.md diff --git a/typescript/globals.d.ts b/typescript/globals.d.ts new file mode 100644 index 000000000..702ef26cb --- /dev/null +++ b/typescript/globals.d.ts @@ -0,0 +1,145 @@ +// TODO all of these globals (copied from eslintrc need to be typed at some point) +/* "globals": { + // Methods and Fields at https://banglejs.com/reference + "Array": "readonly", + "ArrayBuffer": "readonly", + "ArrayBufferView": "readonly", + "Bangle": "readonly", + "BluetoothDevice": "readonly", + "BluetoothRemoteGATTCharacteristic": "readonly", + "BluetoothRemoteGATTServer": "readonly", + "BluetoothRemoteGATTService": "readonly", + "Boolean": "readonly", + "console": "readonly", + "DataView": "readonly", + "Date": "readonly", + "E": "readonly", + "Error": "readonly", + "Flash": "readonly", + "Float32Array": "readonly", + "Float64Array": "readonly", + "fs": "readonly", + "Function": "readonly", + "Graphics": "readonly", + "heatshrink": "readonly", + "I2C": "readonly", + "Int16Array": "readonly", + "Int32Array": "readonly", + "Int8Array": "readonly", + "InternalError": "readonly", + "JSON": "readonly", + "Math": "readonly", + "Modules": "readonly", + "NRF": "readonly", + "Number": "readonly", + "Object": "readonly", + "OneWire": "readonly", + "Pin": "readonly", + "process": "readonly", + "Promise": "readonly", + "ReferenceError": "readonly", + "RegExp": "readonly", + "Serial": "readonly", + "SPI": "readonly", + "Storage": "readonly", + "StorageFile": "readonly", + "String": "readonly", + "SyntaxError": "readonly", + "tensorflow": "readonly", + "TFMicroInterpreter": "readonly", + "TypeError": "readonly", + "Uint16Array": "readonly", + "Uint24Array": "readonly", + "Uint32Array": "readonly", + "Uint8Array": "readonly", + "Uint8ClampedArray": "readonly", + "Waveform": "readonly", + // Methods and Fields at https://banglejs.com/reference + "analogRead": "readonly", + "analogWrite": "readonly", + "arguments": "readonly", + "atob": "readonly", + "Bluetooth": "readonly", + "BTN": "readonly", + "BTN1": "readonly", + "BTN2": "readonly", + "BTN3": "readonly", + "BTN4": "readonly", + "BTN5": "readonly", + "btoa": "readonly", + "changeInterval": "readonly", + "clearInterval": "readonly", + "clearTimeout": "readonly", + "clearWatch": "readonly", + "decodeURIComponent": "readonly", + "digitalPulse": "readonly", + "digitalRead": "readonly", + "digitalWrite": "readonly", + "dump": "readonly", + "echo": "readonly", + "edit": "readonly", + "encodeURIComponent": "readonly", + "eval": "readonly", + "getPinMode": "readonly", + "getSerial": "readonly", + "getTime": "readonly", + "global": "readonly", + "HIGH": "readonly", + "I2C1": "readonly", + "Infinity": "readonly", + "isFinite": "readonly", + "isNaN": "readonly", + "LED": "readonly", + "LED1": "readonly", + "LED2": "readonly", + "load": "readonly", + "LoopbackA": "readonly", + "LoopbackB": "readonly", + "LOW": "readonly", + "NaN": "readonly", + "parseFloat": "readonly", + "parseInt": "readonly", + "peek16": "readonly", + "peek32": "readonly", + "peek8": "readonly", + "pinMode": "readonly", + "poke16": "readonly", + "poke32": "readonly", + "poke8": "readonly", + "print": "readonly", + "require": "readonly", + "reset": "readonly", + "save": "readonly", + "Serial1": "readonly", + "setBusyIndicator": "readonly", + "setInterval": "readonly", + "setSleepIndicator": "readonly", + "setTime": "readonly", + "setTimeout": "readonly", + "setWatch": "readonly", + "shiftOut": "readonly", + "SPI1": "readonly", + "Terminal": "readonly", + "trace": "readonly", + "VIBRATE": "readonly", + // Aliases and not defined at https://banglejs.com/reference + "g": "readonly", + */ + +declare const Bangle: { + // functions + buzz: () => void; + drawWidgets: () => void; + isCharging: () => boolean; + // events + on(event: 'charging', listener: (charging: boolean) => void): void; + // TODO add more +}; + +type Widget = { + area: 'tr' | 'tl'; + width: number; + draw: () => void; +}; + +declare const WIDGETS: { [key: string]: Widget }; diff --git a/typescript/sharedLib/package-lock.json b/typescript/package-lock.json similarity index 100% rename from typescript/sharedLib/package-lock.json rename to typescript/package-lock.json diff --git a/typescript/sharedLib/package.json b/typescript/package.json similarity index 70% rename from typescript/sharedLib/package.json rename to typescript/package.json index 814db8f3e..513e7b7df 100644 --- a/typescript/sharedLib/package.json +++ b/typescript/package.json @@ -5,8 +5,8 @@ "main": "app.js", "types": "app.d.ts", "scripts": { - "build:testapp": "tsc ./src/app.ts --outDir ./dist", - "build:types": "tsc ./src/bangle.d.ts" + "build:example": "tsc ../apps/widChargingStatus/widget.ts --outDir ../apps/widChargingStatus/dist", + "build:types": "tsc ./globals.d.ts" }, "author": { "name": "Sebastian Di Luzio", diff --git a/typescript/sharedLib/src/app.ts b/typescript/sharedLib/src/app.ts deleted file mode 100644 index 6e5739557..000000000 --- a/typescript/sharedLib/src/app.ts +++ /dev/null @@ -1,2 +0,0 @@ -const testString = 'test hehe'; -console.log(testString); diff --git a/typescript/sharedLib/tsconfig.json b/typescript/tsconfig.json similarity index 52% rename from typescript/sharedLib/tsconfig.json rename to typescript/tsconfig.json index 42b34ec65..ce8e6278b 100644 --- a/typescript/sharedLib/tsconfig.json +++ b/typescript/tsconfig.json @@ -3,6 +3,8 @@ "module": "es2015", "noImplicitAny": true, "target": "es2015", - "outDir": "../dist" - } + "outDir": "../dist", + "isolatedModules": false + }, + "include": ["./globals.d.ts"] } From 63b26f5d1ffeb069c373d94eb9a9705004a1c1c1 Mon Sep 17 00:00:00 2001 From: Sebastian Di Luzio Date: Wed, 8 Dec 2021 20:22:39 +0100 Subject: [PATCH 04/80] move dev dependencies to main package.json, get first compiling version of test widget - i still want to be able to get the types ambiently defined without any weird import needed - it would be nice to be able to have a separate package.json in ./typescirpt. not sure if it's possible, I would move working on that part to the end --- apps.json | 2 +- apps/widChargingStatus/dist/widget.js | 31 +++++++++++ apps/widChargingStatus/widget.ts | 60 +++++++++++---------- package.json | 8 ++- tsconfig.json | 7 +++ typescript/.gitignore | 2 - typescript/package-lock.json | 37 ------------- typescript/package.json | 19 ------- typescript/tsconfig.json | 10 ---- typescript/{ => types}/globals.d.ts | 77 ++++++++++++++++----------- 10 files changed, 124 insertions(+), 129 deletions(-) create mode 100644 apps/widChargingStatus/dist/widget.js create mode 100644 tsconfig.json delete mode 100644 typescript/.gitignore delete mode 100644 typescript/package-lock.json delete mode 100644 typescript/package.json delete mode 100644 typescript/tsconfig.json rename typescript/{ => types}/globals.d.ts (75%) diff --git a/apps.json b/apps.json index 13bb5892d..58a67d8c2 100644 --- a/apps.json +++ b/apps.json @@ -4763,7 +4763,7 @@ "tags": "widget", "supports": ["BANGLEJS","BANGLEJS2"], "storage": [ - {"name":"widChargingStatus.wid.js","url":"widget.js"} + {"name":"widChargingStatus.wid.js","url":"./dist/widget.js"} ] }, { diff --git a/apps/widChargingStatus/dist/widget.js b/apps/widChargingStatus/dist/widget.js new file mode 100644 index 000000000..7772a5b87 --- /dev/null +++ b/apps/widChargingStatus/dist/widget.js @@ -0,0 +1,31 @@ +"use strict"; +exports.__esModule = true; +(function () { + var icon = require('heatshrink').decompress(atob('ikggMAiEAgYIBmEAg4EB+EAh0AgPggEeCAIEBnwQBAgP+gEP//x///j//8f//k///H//4BYOP/4lBv4bDvwEB4EAvAEBwEAuA7DCAI7BgAQBhEAA')); + var iconWidth = 18; + function draw() { + g.reset(); + if (Bangle.isCharging()) { + g.setColor('#FD0'); + g.drawImage(icon, this.x + 1, this.y + 1, { + scale: 0.6875 + }); + } + } + WIDGETS.chargingStatus = { + area: 'tr', + width: Bangle.isCharging() ? iconWidth : 0, + draw: draw + }; + Bangle.on('charging', function (charging) { + if (charging) { + Bangle.buzz(); + WIDGETS.chargingStatus.width = iconWidth; + } + else { + WIDGETS.chargingStatus.width = 0; + } + Bangle.drawWidgets(); // re-layout widgets + g.flip(); + }); +})(); diff --git a/apps/widChargingStatus/widget.ts b/apps/widChargingStatus/widget.ts index 90f9199fa..e3ce2d7e2 100644 --- a/apps/widChargingStatus/widget.ts +++ b/apps/widChargingStatus/widget.ts @@ -1,31 +1,37 @@ +import { loadGlobals } from '../../typescript/types/globals'; // TODO find a nicer way to load ambient type definitions than this + (() => { - const icon = require("heatshrink").decompress(atob("ikggMAiEAgYIBmEAg4EB+EAh0AgPggEeCAIEBnwQBAgP+gEP//x///j//8f//k///H//4BYOP/4lBv4bDvwEB4EAvAEBwEAuA7DCAI7BgAQBhEAA")); - const iconWidth = 18; + const icon = require('heatshrink').decompress( + atob( + 'ikggMAiEAgYIBmEAg4EB+EAh0AgPggEeCAIEBnwQBAgP+gEP//x///j//8f//k///H//4BYOP/4lBv4bDvwEB4EAvAEBwEAuA7DCAI7BgAQBhEAA' + ) + ); + const iconWidth = 18; - function draw() { - g.reset(); - if (Bangle.isCharging()) { - g.setColor("#FD0"); - g.drawImage(icon, this.x + 1, this.y + 1, { - scale: 0.6875 - }); - } - } + function draw() { + g.reset(); + if (Bangle.isCharging()) { + g.setColor('#FD0'); + g.drawImage(icon, this.x + 1, this.y + 1, { + scale: 0.6875, + }); + } + } - WIDGETS.chargingStatus = { - area: 'tr', - width: Bangle.isCharging() ? iconWidth : 0, - draw: draw, - }; + WIDGETS.chargingStatus = { + area: 'tr', + width: Bangle.isCharging() ? iconWidth : 0, + draw: draw, + }; - Bangle.on('charging', (charging) => { - if (charging) { - Bangle.buzz(); - WIDGETS.chargingStatus.width = iconWidth; - } else { - WIDGETS.chargingStatus.width = 0; - } - Bangle.drawWidgets(); // re-layout widgets - g.flip(); - }); -})(); \ No newline at end of file + Bangle.on('charging', (charging) => { + if (charging) { + Bangle.buzz(); + WIDGETS.chargingStatus.width = iconWidth; + } else { + WIDGETS.chargingStatus.width = 0; + } + Bangle.drawWidgets(); // re-layout widgets + g.flip(); + }); +})(); diff --git a/package.json b/package.json index b796044c9..1ecfb6280 100644 --- a/package.json +++ b/package.json @@ -4,12 +4,16 @@ "author": "Gordon Williams (http://espruino.com)", "version": "0.0.1", "devDependencies": { - "eslint": "7.1.0" + "eslint": "7.1.0", + "@types/node": "16.11.12", + "typescript": "4.5.2" }, "scripts": { "lint-apps": "eslint ./apps --ext .js", "test": "node bin/sanitycheck.js && eslint ./apps --ext .js", - "start": "npx http-server -c-1" + "start": "npx http-server -c-1", + "build:example": "tsc ./apps/widChargingStatus/widget.ts --outDir ./apps/widChargingStatus/dist", + "build:types": "tsc .typescript/types/globals.d.ts" }, "dependencies": { "acorn": "^7.2.0" diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 000000000..46a557e89 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,7 @@ +{ + "compilerOptions": { + "module": "es2015", + "noImplicitAny": true, + "target": "es2015" + } +} diff --git a/typescript/.gitignore b/typescript/.gitignore deleted file mode 100644 index b2af6e004..000000000 --- a/typescript/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -node_modules/ -!package-lock.json \ No newline at end of file diff --git a/typescript/package-lock.json b/typescript/package-lock.json deleted file mode 100644 index 9df411a91..000000000 --- a/typescript/package-lock.json +++ /dev/null @@ -1,37 +0,0 @@ -{ - "name": "banglets", - "version": "0.1.0", - "lockfileVersion": 2, - "requires": true, - "packages": { - "": { - "name": "banglets", - "version": "0.1.0", - "license": "MIT", - "devDependencies": { - "typescript": "^4.5.2" - } - }, - "node_modules/typescript": { - "version": "4.5.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.5.2.tgz", - "integrity": "sha512-5BlMof9H1yGt0P8/WF+wPNw6GfctgGjXp5hkblpyT+8rkASSmkUKMXrxR0Xg8ThVCi/JnHQiKXeBaEwCeQwMFw==", - "dev": true, - "bin": { - "tsc": "bin/tsc", - "tsserver": "bin/tsserver" - }, - "engines": { - "node": ">=4.2.0" - } - } - }, - "dependencies": { - "typescript": { - "version": "4.5.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.5.2.tgz", - "integrity": "sha512-5BlMof9H1yGt0P8/WF+wPNw6GfctgGjXp5hkblpyT+8rkASSmkUKMXrxR0Xg8ThVCi/JnHQiKXeBaEwCeQwMFw==", - "dev": true - } - } -} diff --git a/typescript/package.json b/typescript/package.json deleted file mode 100644 index 513e7b7df..000000000 --- a/typescript/package.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "name": "bangle.ts", - "version": "0.1.0", - "description": "Typescript configuration and typings for Bangle.js", - "main": "app.js", - "types": "app.d.ts", - "scripts": { - "build:example": "tsc ../apps/widChargingStatus/widget.ts --outDir ../apps/widChargingStatus/dist", - "build:types": "tsc ./globals.d.ts" - }, - "author": { - "name": "Sebastian Di Luzio", - "email": "sebastian@diluz.io" - }, - "license": "MIT", - "devDependencies": { - "typescript": "^4.5.2" - } -} diff --git a/typescript/tsconfig.json b/typescript/tsconfig.json deleted file mode 100644 index ce8e6278b..000000000 --- a/typescript/tsconfig.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "compilerOptions": { - "module": "es2015", - "noImplicitAny": true, - "target": "es2015", - "outDir": "../dist", - "isolatedModules": false - }, - "include": ["./globals.d.ts"] -} diff --git a/typescript/globals.d.ts b/typescript/types/globals.d.ts similarity index 75% rename from typescript/globals.d.ts rename to typescript/types/globals.d.ts index 702ef26cb..97a40ae54 100644 --- a/typescript/globals.d.ts +++ b/typescript/types/globals.d.ts @@ -1,33 +1,19 @@ // TODO all of these globals (copied from eslintrc need to be typed at some point) /* "globals": { // Methods and Fields at https://banglejs.com/reference - "Array": "readonly", - "ArrayBuffer": "readonly", - "ArrayBufferView": "readonly", - "Bangle": "readonly", "BluetoothDevice": "readonly", "BluetoothRemoteGATTCharacteristic": "readonly", "BluetoothRemoteGATTServer": "readonly", "BluetoothRemoteGATTService": "readonly", - "Boolean": "readonly", - "console": "readonly", "DataView": "readonly", - "Date": "readonly", "E": "readonly", "Error": "readonly", "Flash": "readonly", - "Float32Array": "readonly", - "Float64Array": "readonly", "fs": "readonly", "Function": "readonly", - "Graphics": "readonly", "heatshrink": "readonly", "I2C": "readonly", - "Int16Array": "readonly", - "Int32Array": "readonly", - "Int8Array": "readonly", "InternalError": "readonly", - "JSON": "readonly", "Math": "readonly", "Modules": "readonly", "NRF": "readonly", @@ -122,24 +108,53 @@ "Terminal": "readonly", "trace": "readonly", "VIBRATE": "readonly", - // Aliases and not defined at https://banglejs.com/reference - "g": "readonly", */ -declare const Bangle: { - // functions - buzz: () => void; - drawWidgets: () => void; - isCharging: () => boolean; - // events - on(event: 'charging', listener: (charging: boolean) => void): void; - // TODO add more -}; +export type loadGlobals = {}; -type Widget = { - area: 'tr' | 'tl'; - width: number; - draw: () => void; -}; +declare global { + const Bangle: { + // functions + buzz: () => void; + drawWidgets: () => void; + isCharging: () => boolean; + // events + on(event: 'charging', listener: (charging: boolean) => void): void; + // TODO add more + }; -declare const WIDGETS: { [key: string]: Widget }; + type Image = { + width: number; + height: number; + bpp?: number; + buffer: ArrayBuffer | string; + transparent?: number; + palette?: Uint16Array; + }; + + type GraphicsApi = { + reset: () => void; + flip: () => void; + setColor: (color: string) => void; // TODO we can most likely type color more usefully than this + drawImage: ( + image: string | Image | ArrayBuffer, + xOffset: number, + yOffset: number, + options?: { + rotate?: number; + scale?: number; + } + ) => void; + // TODO add more + }; + + const Graphics: GraphicsApi; + const g: GraphicsApi; + + type Widget = { + area: 'tr' | 'tl'; + width: number; + draw: () => void; + }; + const WIDGETS: { [key: string]: Widget }; +} From d46736c01a4fa85888e78a8c8814ddcd26384908 Mon Sep 17 00:00:00 2001 From: Sebastian Di Luzio Date: Wed, 8 Dec 2021 20:23:14 +0100 Subject: [PATCH 05/80] adjust github actions --- .github/workflows/nodejs.yml | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 9503d8934..e2a12cc51 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -4,7 +4,6 @@ on: [push] jobs: build: - runs-on: ubuntu-latest strategy: @@ -12,14 +11,12 @@ jobs: node-version: [16.x] steps: - - uses: actions/checkout@v1 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 - with: - node-version: ${{ matrix.node-version }} - - name: go to typescript directory - run: cd typescript - - name: npm ci - run: npm ci - - name: build types - run: npm run build:types \ No newline at end of file + - uses: actions/checkout@v1 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + - name: npm i + run: npm i + - name: build types + run: npm run build:types From 0a2426a6dd9add940909a552663eb0b25ce86ade Mon Sep 17 00:00:00 2001 From: Sebastian Di Luzio Date: Wed, 8 Dec 2021 20:24:11 +0100 Subject: [PATCH 06/80] fix type build script --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1ecfb6280..f6426e7e2 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "test": "node bin/sanitycheck.js && eslint ./apps --ext .js", "start": "npx http-server -c-1", "build:example": "tsc ./apps/widChargingStatus/widget.ts --outDir ./apps/widChargingStatus/dist", - "build:types": "tsc .typescript/types/globals.d.ts" + "build:types": "tsc ./typescript/types/globals.d.ts" }, "dependencies": { "acorn": "^7.2.0" From 83d445c1a28c7257cfd09b819a0b949ce439507e Mon Sep 17 00:00:00 2001 From: Sebastian Di Luzio Date: Fri, 10 Dec 2021 20:52:17 +0100 Subject: [PATCH 07/80] move package back within typescript --- package.json | 8 +--- typescript/.gitignore | 2 + typescript/README.md | 4 +- typescript/package-lock.json | 49 +++++++++++++++++++++++ typescript/package.json | 14 +++++++ tsconfig.json => typescript/tsconfig.json | 0 6 files changed, 69 insertions(+), 8 deletions(-) create mode 100644 typescript/.gitignore create mode 100644 typescript/package-lock.json create mode 100644 typescript/package.json rename tsconfig.json => typescript/tsconfig.json (100%) diff --git a/package.json b/package.json index f6426e7e2..b796044c9 100644 --- a/package.json +++ b/package.json @@ -4,16 +4,12 @@ "author": "Gordon Williams (http://espruino.com)", "version": "0.0.1", "devDependencies": { - "eslint": "7.1.0", - "@types/node": "16.11.12", - "typescript": "4.5.2" + "eslint": "7.1.0" }, "scripts": { "lint-apps": "eslint ./apps --ext .js", "test": "node bin/sanitycheck.js && eslint ./apps --ext .js", - "start": "npx http-server -c-1", - "build:example": "tsc ./apps/widChargingStatus/widget.ts --outDir ./apps/widChargingStatus/dist", - "build:types": "tsc ./typescript/types/globals.d.ts" + "start": "npx http-server -c-1" }, "dependencies": { "acorn": "^7.2.0" diff --git a/typescript/.gitignore b/typescript/.gitignore new file mode 100644 index 000000000..630f61ee5 --- /dev/null +++ b/typescript/.gitignore @@ -0,0 +1,2 @@ +./node_modules +!package-lock.json diff --git a/typescript/README.md b/typescript/README.md index a54a4c75a..9b38459ae 100644 --- a/typescript/README.md +++ b/typescript/README.md @@ -13,7 +13,7 @@ TODO Install [npm](https://www.npmjs.com/get-npm) if you haven't already. Make sure you are using version ^8 by running `npm -v`. If the version is incorrect, run `npm i -g npm@^8`. -After having installed npm for your platform, open a terminal, and navigate into the `/typescript/sharedLib` folder. Then run: +After having installed npm for your platform, open a terminal, and navigate into the `/typescript` folder. Then run: ``` npm ci @@ -22,7 +22,7 @@ npm ci to install the project's build tools, and: ``` -npx tsc ./relativePathToYourApp/app.ts --outDir ./relativePathToYourApp/dist +npx tsc ../apps/relativePathToYourApp/app.ts --outDir ../apps/relativePathToYourApp/dist ``` To build your app. The last command will generate the `app.js` file containing the transpiled code for the BangleJS. diff --git a/typescript/package-lock.json b/typescript/package-lock.json new file mode 100644 index 000000000..bd3cfc702 --- /dev/null +++ b/typescript/package-lock.json @@ -0,0 +1,49 @@ +{ + "name": "Bangle.ts", + "version": "0.0.1", + "lockfileVersion": 2, + "requires": true, + "packages": { + "": { + "name": "Bangle.ts", + "version": "0.0.1", + "devDependencies": { + "@types/node": "16.11.12", + "typescript": "4.5.2" + } + }, + "node_modules/@types/node": { + "version": "16.11.12", + "resolved": "https://registry.npmjs.org/@types/node/-/node-16.11.12.tgz", + "integrity": "sha512-+2Iggwg7PxoO5Kyhvsq9VarmPbIelXP070HMImEpbtGCoyWNINQj4wzjbQCXzdHTRXnqufutJb5KAURZANNBAw==", + "dev": true + }, + "node_modules/typescript": { + "version": "4.5.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.5.2.tgz", + "integrity": "sha512-5BlMof9H1yGt0P8/WF+wPNw6GfctgGjXp5hkblpyT+8rkASSmkUKMXrxR0Xg8ThVCi/JnHQiKXeBaEwCeQwMFw==", + "dev": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=4.2.0" + } + } + }, + "dependencies": { + "@types/node": { + "version": "16.11.12", + "resolved": "https://registry.npmjs.org/@types/node/-/node-16.11.12.tgz", + "integrity": "sha512-+2Iggwg7PxoO5Kyhvsq9VarmPbIelXP070HMImEpbtGCoyWNINQj4wzjbQCXzdHTRXnqufutJb5KAURZANNBAw==", + "dev": true + }, + "typescript": { + "version": "4.5.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.5.2.tgz", + "integrity": "sha512-5BlMof9H1yGt0P8/WF+wPNw6GfctgGjXp5hkblpyT+8rkASSmkUKMXrxR0Xg8ThVCi/JnHQiKXeBaEwCeQwMFw==", + "dev": true + } + } +} diff --git a/typescript/package.json b/typescript/package.json new file mode 100644 index 000000000..03f435497 --- /dev/null +++ b/typescript/package.json @@ -0,0 +1,14 @@ +{ + "name": "Bangle.ts", + "description": "Bangle.js Typescript Project Setup and Types", + "author": "Sebastian Di Luzio (https://diluz.io)", + "version": "0.0.1", + "devDependencies": { + "@types/node": "16.11.12", + "typescript": "4.5.2" + }, + "scripts": { + "build:example": "tsc ../apps/widChargingStatus/widget.ts --outDir ../apps/widChargingStatus/dist", + "build:types": "tsc ./types/globals.d.ts" + } +} diff --git a/tsconfig.json b/typescript/tsconfig.json similarity index 100% rename from tsconfig.json rename to typescript/tsconfig.json From 45bd654eca724a8cb15cddf1eab883978c38bd87 Mon Sep 17 00:00:00 2001 From: Sebastian Di Luzio Date: Fri, 10 Dec 2021 21:19:01 +0100 Subject: [PATCH 08/80] fix global vars inside IDE (only cli to go) --- apps/widChargingStatus/dist/widget.js | 2 - apps/widChargingStatus/widget.ts | 2 - typescript/package-lock.json | 13 - typescript/package.json | 1 - typescript/tsconfig.json | 3 +- typescript/types/globals.d.ts | 327 ++++++++++++++------------ 6 files changed, 177 insertions(+), 171 deletions(-) diff --git a/apps/widChargingStatus/dist/widget.js b/apps/widChargingStatus/dist/widget.js index 7772a5b87..eea96ce58 100644 --- a/apps/widChargingStatus/dist/widget.js +++ b/apps/widChargingStatus/dist/widget.js @@ -1,5 +1,3 @@ -"use strict"; -exports.__esModule = true; (function () { var icon = require('heatshrink').decompress(atob('ikggMAiEAgYIBmEAg4EB+EAh0AgPggEeCAIEBnwQBAgP+gEP//x///j//8f//k///H//4BYOP/4lBv4bDvwEB4EAvAEBwEAuA7DCAI7BgAQBhEAA')); var iconWidth = 18; diff --git a/apps/widChargingStatus/widget.ts b/apps/widChargingStatus/widget.ts index e3ce2d7e2..a8cf2ed94 100644 --- a/apps/widChargingStatus/widget.ts +++ b/apps/widChargingStatus/widget.ts @@ -1,5 +1,3 @@ -import { loadGlobals } from '../../typescript/types/globals'; // TODO find a nicer way to load ambient type definitions than this - (() => { const icon = require('heatshrink').decompress( atob( diff --git a/typescript/package-lock.json b/typescript/package-lock.json index bd3cfc702..52be5f98a 100644 --- a/typescript/package-lock.json +++ b/typescript/package-lock.json @@ -8,16 +8,9 @@ "name": "Bangle.ts", "version": "0.0.1", "devDependencies": { - "@types/node": "16.11.12", "typescript": "4.5.2" } }, - "node_modules/@types/node": { - "version": "16.11.12", - "resolved": "https://registry.npmjs.org/@types/node/-/node-16.11.12.tgz", - "integrity": "sha512-+2Iggwg7PxoO5Kyhvsq9VarmPbIelXP070HMImEpbtGCoyWNINQj4wzjbQCXzdHTRXnqufutJb5KAURZANNBAw==", - "dev": true - }, "node_modules/typescript": { "version": "4.5.2", "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.5.2.tgz", @@ -33,12 +26,6 @@ } }, "dependencies": { - "@types/node": { - "version": "16.11.12", - "resolved": "https://registry.npmjs.org/@types/node/-/node-16.11.12.tgz", - "integrity": "sha512-+2Iggwg7PxoO5Kyhvsq9VarmPbIelXP070HMImEpbtGCoyWNINQj4wzjbQCXzdHTRXnqufutJb5KAURZANNBAw==", - "dev": true - }, "typescript": { "version": "4.5.2", "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.5.2.tgz", diff --git a/typescript/package.json b/typescript/package.json index 03f435497..83ea7d82b 100644 --- a/typescript/package.json +++ b/typescript/package.json @@ -4,7 +4,6 @@ "author": "Sebastian Di Luzio (https://diluz.io)", "version": "0.0.1", "devDependencies": { - "@types/node": "16.11.12", "typescript": "4.5.2" }, "scripts": { diff --git a/typescript/tsconfig.json b/typescript/tsconfig.json index 46a557e89..8a7ab3342 100644 --- a/typescript/tsconfig.json +++ b/typescript/tsconfig.json @@ -3,5 +3,6 @@ "module": "es2015", "noImplicitAny": true, "target": "es2015" - } + }, + "include": ["../apps/**/*", "./**/*"] } diff --git a/typescript/types/globals.d.ts b/typescript/types/globals.d.ts index 97a40ae54..359d5d294 100644 --- a/typescript/types/globals.d.ts +++ b/typescript/types/globals.d.ts @@ -1,160 +1,183 @@ // TODO all of these globals (copied from eslintrc need to be typed at some point) -/* "globals": { - // Methods and Fields at https://banglejs.com/reference - "BluetoothDevice": "readonly", - "BluetoothRemoteGATTCharacteristic": "readonly", - "BluetoothRemoteGATTServer": "readonly", - "BluetoothRemoteGATTService": "readonly", - "DataView": "readonly", - "E": "readonly", - "Error": "readonly", - "Flash": "readonly", - "fs": "readonly", - "Function": "readonly", - "heatshrink": "readonly", - "I2C": "readonly", - "InternalError": "readonly", - "Math": "readonly", - "Modules": "readonly", - "NRF": "readonly", - "Number": "readonly", - "Object": "readonly", - "OneWire": "readonly", - "Pin": "readonly", - "process": "readonly", - "Promise": "readonly", - "ReferenceError": "readonly", - "RegExp": "readonly", - "Serial": "readonly", - "SPI": "readonly", - "Storage": "readonly", - "StorageFile": "readonly", - "String": "readonly", - "SyntaxError": "readonly", - "tensorflow": "readonly", - "TFMicroInterpreter": "readonly", - "TypeError": "readonly", - "Uint16Array": "readonly", - "Uint24Array": "readonly", - "Uint32Array": "readonly", - "Uint8Array": "readonly", - "Uint8ClampedArray": "readonly", - "Waveform": "readonly", - // Methods and Fields at https://banglejs.com/reference - "analogRead": "readonly", - "analogWrite": "readonly", - "arguments": "readonly", - "atob": "readonly", - "Bluetooth": "readonly", - "BTN": "readonly", - "BTN1": "readonly", - "BTN2": "readonly", - "BTN3": "readonly", - "BTN4": "readonly", - "BTN5": "readonly", - "btoa": "readonly", - "changeInterval": "readonly", - "clearInterval": "readonly", - "clearTimeout": "readonly", - "clearWatch": "readonly", - "decodeURIComponent": "readonly", - "digitalPulse": "readonly", - "digitalRead": "readonly", - "digitalWrite": "readonly", - "dump": "readonly", - "echo": "readonly", - "edit": "readonly", - "encodeURIComponent": "readonly", - "eval": "readonly", - "getPinMode": "readonly", - "getSerial": "readonly", - "getTime": "readonly", - "global": "readonly", - "HIGH": "readonly", - "I2C1": "readonly", - "Infinity": "readonly", - "isFinite": "readonly", - "isNaN": "readonly", - "LED": "readonly", - "LED1": "readonly", - "LED2": "readonly", - "load": "readonly", - "LoopbackA": "readonly", - "LoopbackB": "readonly", - "LOW": "readonly", - "NaN": "readonly", - "parseFloat": "readonly", - "parseInt": "readonly", - "peek16": "readonly", - "peek32": "readonly", - "peek8": "readonly", - "pinMode": "readonly", - "poke16": "readonly", - "poke32": "readonly", - "poke8": "readonly", - "print": "readonly", - "require": "readonly", - "reset": "readonly", - "save": "readonly", - "Serial1": "readonly", - "setBusyIndicator": "readonly", - "setInterval": "readonly", - "setSleepIndicator": "readonly", - "setTime": "readonly", - "setTimeout": "readonly", - "setWatch": "readonly", - "shiftOut": "readonly", - "SPI1": "readonly", - "Terminal": "readonly", - "trace": "readonly", - "VIBRATE": "readonly", +/* { + // Methods and Fields at https://banglejs.com/reference + "Array": "readonly", + "ArrayBuffer": "readonly", + "ArrayBufferView": "readonly", + "Bangle": "readonly", + "BluetoothDevice": "readonly", + "BluetoothRemoteGATTCharacteristic": "readonly", + "BluetoothRemoteGATTServer": "readonly", + "BluetoothRemoteGATTService": "readonly", + "Boolean": "readonly", + "console": "readonly", + "DataView": "readonly", + "Date": "readonly", + "E": "readonly", + "Error": "readonly", + "Flash": "readonly", + "Float32Array": "readonly", + "Float64Array": "readonly", + "fs": "readonly", + "Function": "readonly", + "Graphics": "readonly", // partly done + "heatshrink": "readonly", + "I2C": "readonly", + "Int16Array": "readonly", + "Int32Array": "readonly", + "Int8Array": "readonly", + "InternalError": "readonly", + "JSON": "readonly", + "Math": "readonly", + "Modules": "readonly", + "NRF": "readonly", + "Number": "readonly", + "Object": "readonly", + "OneWire": "readonly", + "Pin": "readonly", + "process": "readonly", + "Promise": "readonly", + "ReferenceError": "readonly", + "RegExp": "readonly", + "Serial": "readonly", + "SPI": "readonly", + "Storage": "readonly", + "StorageFile": "readonly", + "String": "readonly", + "SyntaxError": "readonly", + "tensorflow": "readonly", + "TFMicroInterpreter": "readonly", + "TypeError": "readonly", + "Uint16Array": "readonly", + "Uint24Array": "readonly", + "Uint32Array": "readonly", + "Uint8Array": "readonly", + "Uint8ClampedArray": "readonly", + "Waveform": "readonly", + // Methods and Fields at https://banglejs.com/reference + "analogRead": "readonly", + "analogWrite": "readonly", + "arguments": "readonly", + "atob": "readonly", + "Bluetooth": "readonly", + "BTN": "readonly", + "BTN1": "readonly", + "BTN2": "readonly", + "BTN3": "readonly", + "BTN4": "readonly", + "BTN5": "readonly", + "btoa": "readonly", + "changeInterval": "readonly", + "clearInterval": "readonly", + "clearTimeout": "readonly", + "clearWatch": "readonly", + "decodeURIComponent": "readonly", + "digitalPulse": "readonly", + "digitalRead": "readonly", + "digitalWrite": "readonly", + "dump": "readonly", + "echo": "readonly", + "edit": "readonly", + "encodeURIComponent": "readonly", + "eval": "readonly", + "getPinMode": "readonly", + "getSerial": "readonly", + "getTime": "readonly", + "global": "readonly", + "HIGH": "readonly", + "I2C1": "readonly", + "Infinity": "readonly", + "isFinite": "readonly", + "isNaN": "readonly", + "LED": "readonly", + "LED1": "readonly", + "LED2": "readonly", + "load": "readonly", + "LoopbackA": "readonly", + "LoopbackB": "readonly", + "LOW": "readonly", + "NaN": "readonly", + "parseFloat": "readonly", + "parseInt": "readonly", + "peek16": "readonly", + "peek32": "readonly", + "peek8": "readonly", + "pinMode": "readonly", + "poke16": "readonly", + "poke32": "readonly", + "poke8": "readonly", + "print": "readonly", + "require": "readonly", + "reset": "readonly", + "save": "readonly", + "Serial1": "readonly", + "setBusyIndicator": "readonly", + "setInterval": "readonly", + "setSleepIndicator": "readonly", + "setTime": "readonly", + "setTimeout": "readonly", + "setWatch": "readonly", + "shiftOut": "readonly", + "SPI1": "readonly", + "Terminal": "readonly", + "trace": "readonly", + "VIBRATE": "readonly", + // Aliases and not defined at https://banglejs.com/reference + "g": "readonly", // done + "WIDGETS": "readonly" // done + } */ -export type loadGlobals = {}; +// ambient JS definitions -declare global { - const Bangle: { - // functions - buzz: () => void; - drawWidgets: () => void; - isCharging: () => boolean; - // events - on(event: 'charging', listener: (charging: boolean) => void): void; - // TODO add more - }; +declare const require: ((module: 'heatshrink') => { + decompress: (compressedString: string) => string; +}) & // TODO add more + ((module: 'otherString') => {}); - type Image = { - width: number; - height: number; - bpp?: number; - buffer: ArrayBuffer | string; - transparent?: number; - palette?: Uint16Array; - }; +// ambient bangle.js definitions - type GraphicsApi = { - reset: () => void; - flip: () => void; - setColor: (color: string) => void; // TODO we can most likely type color more usefully than this - drawImage: ( - image: string | Image | ArrayBuffer, - xOffset: number, - yOffset: number, - options?: { - rotate?: number; - scale?: number; - } - ) => void; - // TODO add more - }; +declare const Bangle: { + // functions + buzz: () => void; + drawWidgets: () => void; + isCharging: () => boolean; + // events + on(event: 'charging', listener: (charging: boolean) => void): void; + // TODO add more +}; - const Graphics: GraphicsApi; - const g: GraphicsApi; +declare type Image = { + width: number; + height: number; + bpp?: number; + buffer: ArrayBuffer | string; + transparent?: number; + palette?: Uint16Array; +}; - type Widget = { - area: 'tr' | 'tl'; - width: number; - draw: () => void; - }; - const WIDGETS: { [key: string]: Widget }; -} +declare type GraphicsApi = { + reset: () => void; + flip: () => void; + setColor: (color: string) => void; // TODO we can most likely type color more usefully than this + drawImage: ( + image: string | Image | ArrayBuffer, + xOffset: number, + yOffset: number, + options?: { + rotate?: number; + scale?: number; + } + ) => void; + // TODO add more +}; + +declare const Graphics: GraphicsApi; +declare const g: GraphicsApi; + +declare type Widget = { + area: 'tr' | 'tl'; + width: number; + draw: () => void; +}; +declare const WIDGETS: { [key: string]: Widget }; From 15d24ac1b3f5a1412adda885b116894d47c749a2 Mon Sep 17 00:00:00 2001 From: Sebastian Di Luzio Date: Fri, 10 Dec 2021 21:36:42 +0100 Subject: [PATCH 09/80] update TS rules to make them stricter --- apps/widChargingStatus/dist/widget.js | 19 +++++++++++-------- apps/widChargingStatus/widget.ts | 21 ++++++++++++--------- typescript/tsconfig.json | 11 ++++++++++- typescript/types/globals.d.ts | 2 +- 4 files changed, 34 insertions(+), 19 deletions(-) diff --git a/apps/widChargingStatus/dist/widget.js b/apps/widChargingStatus/dist/widget.js index eea96ce58..6cac1931f 100644 --- a/apps/widChargingStatus/dist/widget.js +++ b/apps/widChargingStatus/dist/widget.js @@ -16,14 +16,17 @@ draw: draw }; Bangle.on('charging', function (charging) { - if (charging) { - Bangle.buzz(); - WIDGETS.chargingStatus.width = iconWidth; + var widget = WIDGETS.chargingStatus; + if (widget) { + if (charging) { + Bangle.buzz(); + widget.width = iconWidth; + } + else { + widget.width = 0; + } + Bangle.drawWidgets(); // re-layout widgets + g.flip(); } - else { - WIDGETS.chargingStatus.width = 0; - } - Bangle.drawWidgets(); // re-layout widgets - g.flip(); }); })(); diff --git a/apps/widChargingStatus/widget.ts b/apps/widChargingStatus/widget.ts index a8cf2ed94..712bf4f97 100644 --- a/apps/widChargingStatus/widget.ts +++ b/apps/widChargingStatus/widget.ts @@ -6,7 +6,7 @@ ); const iconWidth = 18; - function draw() { + function draw(this: { x: number; y: number }) { g.reset(); if (Bangle.isCharging()) { g.setColor('#FD0'); @@ -19,17 +19,20 @@ WIDGETS.chargingStatus = { area: 'tr', width: Bangle.isCharging() ? iconWidth : 0, - draw: draw, + draw, }; Bangle.on('charging', (charging) => { - if (charging) { - Bangle.buzz(); - WIDGETS.chargingStatus.width = iconWidth; - } else { - WIDGETS.chargingStatus.width = 0; + const widget = WIDGETS.chargingStatus; + if (widget) { + if (charging) { + Bangle.buzz(); + widget.width = iconWidth; + } else { + widget.width = 0; + } + Bangle.drawWidgets(); // re-layout widgets + g.flip(); } - Bangle.drawWidgets(); // re-layout widgets - g.flip(); }); })(); diff --git a/typescript/tsconfig.json b/typescript/tsconfig.json index 8a7ab3342..09101094b 100644 --- a/typescript/tsconfig.json +++ b/typescript/tsconfig.json @@ -2,7 +2,16 @@ "compilerOptions": { "module": "es2015", "noImplicitAny": true, - "target": "es2015" + "target": "es2015", + "allowUnreachableCode": false, + "allowUnusedLabels": false, + "noImplicitOverride": true, + "noImplicitReturns": true, + "noImplicitThis": true, + "noUncheckedIndexedAccess": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "strict": true }, "include": ["../apps/**/*", "./**/*"] } diff --git a/typescript/types/globals.d.ts b/typescript/types/globals.d.ts index 359d5d294..46d1e3b0a 100644 --- a/typescript/types/globals.d.ts +++ b/typescript/types/globals.d.ts @@ -178,6 +178,6 @@ declare const g: GraphicsApi; declare type Widget = { area: 'tr' | 'tl'; width: number; - draw: () => void; + draw: (this: { x: number; y: number }) => void; }; declare const WIDGETS: { [key: string]: Widget }; From 96b099b10ac58143d15b0ea28e1476a81d573c57 Mon Sep 17 00:00:00 2001 From: Sebastian Di Luzio Date: Fri, 10 Dec 2021 21:51:35 +0100 Subject: [PATCH 10/80] make tsconfig work for all ts apps --- .github/workflows/nodejs.yml | 9 +++++++-- apps.json | 2 +- apps/widChargingStatus/{dist => }/widget.js | 15 ++++++++------- typescript/package.json | 2 +- typescript/tsconfig.json | 3 ++- 5 files changed, 19 insertions(+), 12 deletions(-) rename apps/widChargingStatus/{dist => }/widget.js (61%) diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index e2a12cc51..8187fc890 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -16,7 +16,12 @@ jobs: uses: actions/setup-node@v1 with: node-version: ${{ matrix.node-version }} - - name: npm i - run: npm i + - name: npm ci + working-directory: ./typescript + run: npm ci - name: build types + working-directory: ./typescript + run: npm run build:types + - name: build all TS apps + working-directory: ./typescript run: npm run build:types diff --git a/apps.json b/apps.json index 58a67d8c2..6e85c19d7 100644 --- a/apps.json +++ b/apps.json @@ -4763,7 +4763,7 @@ "tags": "widget", "supports": ["BANGLEJS","BANGLEJS2"], "storage": [ - {"name":"widChargingStatus.wid.js","url":"./dist/widget.js"} + {"name":"widChargingStatus.wid.js","url":"./widget.js"} ] }, { diff --git a/apps/widChargingStatus/dist/widget.js b/apps/widChargingStatus/widget.js similarity index 61% rename from apps/widChargingStatus/dist/widget.js rename to apps/widChargingStatus/widget.js index 6cac1931f..68a7c0aca 100644 --- a/apps/widChargingStatus/dist/widget.js +++ b/apps/widChargingStatus/widget.js @@ -1,22 +1,23 @@ -(function () { - var icon = require('heatshrink').decompress(atob('ikggMAiEAgYIBmEAg4EB+EAh0AgPggEeCAIEBnwQBAgP+gEP//x///j//8f//k///H//4BYOP/4lBv4bDvwEB4EAvAEBwEAuA7DCAI7BgAQBhEAA')); - var iconWidth = 18; +"use strict"; +(() => { + const icon = require('heatshrink').decompress(atob('ikggMAiEAgYIBmEAg4EB+EAh0AgPggEeCAIEBnwQBAgP+gEP//x///j//8f//k///H//4BYOP/4lBv4bDvwEB4EAvAEBwEAuA7DCAI7BgAQBhEAA')); + const iconWidth = 18; function draw() { g.reset(); if (Bangle.isCharging()) { g.setColor('#FD0'); g.drawImage(icon, this.x + 1, this.y + 1, { - scale: 0.6875 + scale: 0.6875, }); } } WIDGETS.chargingStatus = { area: 'tr', width: Bangle.isCharging() ? iconWidth : 0, - draw: draw + draw, }; - Bangle.on('charging', function (charging) { - var widget = WIDGETS.chargingStatus; + Bangle.on('charging', (charging) => { + const widget = WIDGETS.chargingStatus; if (widget) { if (charging) { Bangle.buzz(); diff --git a/typescript/package.json b/typescript/package.json index 83ea7d82b..4bfb88d27 100644 --- a/typescript/package.json +++ b/typescript/package.json @@ -7,7 +7,7 @@ "typescript": "4.5.2" }, "scripts": { - "build:example": "tsc ../apps/widChargingStatus/widget.ts --outDir ../apps/widChargingStatus/dist", + "build:apps": "tsc", "build:types": "tsc ./types/globals.d.ts" } } diff --git a/typescript/tsconfig.json b/typescript/tsconfig.json index 09101094b..aff7a6d38 100644 --- a/typescript/tsconfig.json +++ b/typescript/tsconfig.json @@ -13,5 +13,6 @@ "noUnusedParameters": true, "strict": true }, - "include": ["../apps/**/*", "./**/*"] + "include": ["../apps/**/*", "./**/*"], + "exclude": ["../apps/banglerun", "../apps/hebrew_calendar"] } From a393d573d644993927b4155c0c5c6ca570cb88a0 Mon Sep 17 00:00:00 2001 From: Sebastian Di Luzio Date: Fri, 10 Dec 2021 21:52:26 +0100 Subject: [PATCH 11/80] Update nodejs.yml --- .github/workflows/nodejs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 8187fc890..a9ada5e5e 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -21,7 +21,7 @@ jobs: run: npm ci - name: build types working-directory: ./typescript - run: npm run build:types + run: npm run build:apps - name: build all TS apps working-directory: ./typescript run: npm run build:types From d7be82bcc71a2445993e7adcec8074142cfa6038 Mon Sep 17 00:00:00 2001 From: Sebastian Di Luzio Date: Fri, 10 Dec 2021 22:01:01 +0100 Subject: [PATCH 12/80] Update README.md --- typescript/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/typescript/README.md b/typescript/README.md index 9b38459ae..66506924e 100644 --- a/typescript/README.md +++ b/typescript/README.md @@ -22,7 +22,7 @@ npm ci to install the project's build tools, and: ``` -npx tsc ../apps/relativePathToYourApp/app.ts --outDir ../apps/relativePathToYourApp/dist +npm run build:apps ``` -To build your app. The last command will generate the `app.js` file containing the transpiled code for the BangleJS. +To build all Typescript apps. The last command will generate the `app.js` files containing the transpiled code for the BangleJS. From a86f2c108dfc119de10d8ac3b65e1bc21009649b Mon Sep 17 00:00:00 2001 From: Sebastian Di Luzio Date: Fri, 10 Dec 2021 22:02:41 +0100 Subject: [PATCH 13/80] Update README.md --- typescript/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/typescript/README.md b/typescript/README.md index 66506924e..d1f60fd0b 100644 --- a/typescript/README.md +++ b/typescript/README.md @@ -6,7 +6,8 @@ The goal is to have types for everything, but that will take some time. Feel fre ## Using the types -TODO +All currently typed modules can be found in `/typescript/types.globals.d.ts`. +The typing is an ongoing process. If anything is still missing, you can add it! It will automatically be available in your TS files. ## Compilation From 4990c426752586600ebb08ae472d71cbe2ed22c4 Mon Sep 17 00:00:00 2001 From: Sebastian Di Luzio Date: Fri, 10 Dec 2021 22:04:43 +0100 Subject: [PATCH 14/80] Update tsconfig.json --- typescript/tsconfig.json | 1 + 1 file changed, 1 insertion(+) diff --git a/typescript/tsconfig.json b/typescript/tsconfig.json index aff7a6d38..40537c680 100644 --- a/typescript/tsconfig.json +++ b/typescript/tsconfig.json @@ -14,5 +14,6 @@ "strict": true }, "include": ["../apps/**/*", "./**/*"], + // these apps have been excluded because they were built before this configuration was created and are using their own "exclude": ["../apps/banglerun", "../apps/hebrew_calendar"] } From 4511520c88c4f4e2174639c41bb24195f3a82d83 Mon Sep 17 00:00:00 2001 From: Sebastian Di Luzio Date: Fri, 10 Dec 2021 22:17:06 +0100 Subject: [PATCH 15/80] upgrade chargingStatus version --- apps.json | 2 +- apps/widChargingStatus/ChangeLog | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/apps.json b/apps.json index 3466ab0fb..0a6cebba7 100644 --- a/apps.json +++ b/apps.json @@ -4782,7 +4782,7 @@ "name": "Charging Status", "shortName":"ChargingStatus", "icon": "widget.png", - "version":"0.1", + "version":"0.2", "type": "widget", "description": "A simple widget that shows a yellow lightning icon to indicate whenever the watch is charging. This way one can see the charging status at a glance, no matter which battery widget is being used.", "tags": "widget", diff --git a/apps/widChargingStatus/ChangeLog b/apps/widChargingStatus/ChangeLog index d3175e1ab..ceb7cb883 100644 --- a/apps/widChargingStatus/ChangeLog +++ b/apps/widChargingStatus/ChangeLog @@ -1 +1,2 @@ -0.1: First release. \ No newline at end of file +0.1: First release. +0.2: No functional changes, just moved codebase to Typescript. \ No newline at end of file From d255d42a8c34b70c762cd8f4f3197aedfcf78a21 Mon Sep 17 00:00:00 2001 From: Sebastian Di Luzio Date: Fri, 10 Dec 2021 22:27:25 +0100 Subject: [PATCH 16/80] disable strict to see if that fixes widget --- apps/widChargingStatus/widget.js | 1 - typescript/tsconfig.json | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/apps/widChargingStatus/widget.js b/apps/widChargingStatus/widget.js index 68a7c0aca..042e225f7 100644 --- a/apps/widChargingStatus/widget.js +++ b/apps/widChargingStatus/widget.js @@ -1,4 +1,3 @@ -"use strict"; (() => { const icon = require('heatshrink').decompress(atob('ikggMAiEAgYIBmEAg4EB+EAh0AgPggEeCAIEBnwQBAgP+gEP//x///j//8f//k///H//4BYOP/4lBv4bDvwEB4EAvAEBwEAuA7DCAI7BgAQBhEAA')); const iconWidth = 18; diff --git a/typescript/tsconfig.json b/typescript/tsconfig.json index 40537c680..114e01ac3 100644 --- a/typescript/tsconfig.json +++ b/typescript/tsconfig.json @@ -11,7 +11,7 @@ "noUncheckedIndexedAccess": true, "noUnusedLocals": true, "noUnusedParameters": true, - "strict": true + "noImplicitUseStrict": true }, "include": ["../apps/**/*", "./**/*"], // these apps have been excluded because they were built before this configuration was created and are using their own From 0ece5ccdb0d8f61b963c7473ef00c47466b86900 Mon Sep 17 00:00:00 2001 From: Sebastian Di Luzio Date: Fri, 10 Dec 2021 22:32:36 +0100 Subject: [PATCH 17/80] more testing to get app back running --- apps.json | 2 +- apps/widChargingStatus/widget.js | 2 +- apps/widChargingStatus/widget.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apps.json b/apps.json index 0a6cebba7..6f53c0c48 100644 --- a/apps.json +++ b/apps.json @@ -4782,7 +4782,7 @@ "name": "Charging Status", "shortName":"ChargingStatus", "icon": "widget.png", - "version":"0.2", + "version":"0.3", "type": "widget", "description": "A simple widget that shows a yellow lightning icon to indicate whenever the watch is charging. This way one can see the charging status at a glance, no matter which battery widget is being used.", "tags": "widget", diff --git a/apps/widChargingStatus/widget.js b/apps/widChargingStatus/widget.js index 042e225f7..386b84947 100644 --- a/apps/widChargingStatus/widget.js +++ b/apps/widChargingStatus/widget.js @@ -13,7 +13,7 @@ WIDGETS.chargingStatus = { area: 'tr', width: Bangle.isCharging() ? iconWidth : 0, - draw, + draw: draw, }; Bangle.on('charging', (charging) => { const widget = WIDGETS.chargingStatus; diff --git a/apps/widChargingStatus/widget.ts b/apps/widChargingStatus/widget.ts index 712bf4f97..14b4df4a4 100644 --- a/apps/widChargingStatus/widget.ts +++ b/apps/widChargingStatus/widget.ts @@ -19,7 +19,7 @@ WIDGETS.chargingStatus = { area: 'tr', width: Bangle.isCharging() ? iconWidth : 0, - draw, + draw: draw, }; Bangle.on('charging', (charging) => { From 0499f04dc3de9c1d5725c325ad67ddb6d676b939 Mon Sep 17 00:00:00 2001 From: Sebastian Di Luzio Date: Fri, 10 Dec 2021 22:36:22 +0100 Subject: [PATCH 18/80] try to use strict again --- apps/widChargingStatus/widget.js | 1 + typescript/tsconfig.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/widChargingStatus/widget.js b/apps/widChargingStatus/widget.js index 386b84947..5d9ea3837 100644 --- a/apps/widChargingStatus/widget.js +++ b/apps/widChargingStatus/widget.js @@ -1,3 +1,4 @@ +"use strict"; (() => { const icon = require('heatshrink').decompress(atob('ikggMAiEAgYIBmEAg4EB+EAh0AgPggEeCAIEBnwQBAgP+gEP//x///j//8f//k///H//4BYOP/4lBv4bDvwEB4EAvAEBwEAuA7DCAI7BgAQBhEAA')); const iconWidth = 18; diff --git a/typescript/tsconfig.json b/typescript/tsconfig.json index 114e01ac3..40537c680 100644 --- a/typescript/tsconfig.json +++ b/typescript/tsconfig.json @@ -11,7 +11,7 @@ "noUncheckedIndexedAccess": true, "noUnusedLocals": true, "noUnusedParameters": true, - "noImplicitUseStrict": true + "strict": true }, "include": ["../apps/**/*", "./**/*"], // these apps have been excluded because they were built before this configuration was created and are using their own From 8baa3eca7235085698f08c5c8b2501048da1aa44 Mon Sep 17 00:00:00 2001 From: Sebastian Di Luzio Date: Fri, 10 Dec 2021 22:38:26 +0100 Subject: [PATCH 19/80] Update apps.json --- apps.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps.json b/apps.json index 6f53c0c48..3f2363a31 100644 --- a/apps.json +++ b/apps.json @@ -4782,7 +4782,7 @@ "name": "Charging Status", "shortName":"ChargingStatus", "icon": "widget.png", - "version":"0.3", + "version":"0.4", "type": "widget", "description": "A simple widget that shows a yellow lightning icon to indicate whenever the watch is charging. This way one can see the charging status at a glance, no matter which battery widget is being used.", "tags": "widget", From 5c851714ee17ad55ca6692a6e9ad49e717a16d11 Mon Sep 17 00:00:00 2001 From: Sebastian Di Luzio Date: Fri, 10 Dec 2021 22:43:33 +0100 Subject: [PATCH 20/80] revert chargingStatus version --- apps.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps.json b/apps.json index 3f2363a31..0a6cebba7 100644 --- a/apps.json +++ b/apps.json @@ -4782,7 +4782,7 @@ "name": "Charging Status", "shortName":"ChargingStatus", "icon": "widget.png", - "version":"0.4", + "version":"0.2", "type": "widget", "description": "A simple widget that shows a yellow lightning icon to indicate whenever the watch is charging. This way one can see the charging status at a glance, no matter which battery widget is being used.", "tags": "widget", From c462547a2bfe283e610ea093bfa34a9cc98faf75 Mon Sep 17 00:00:00 2001 From: Sebastian Di Luzio Date: Fri, 10 Dec 2021 22:45:10 +0100 Subject: [PATCH 21/80] fix github actions --- .github/workflows/nodejs.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index a9ada5e5e..c268c884c 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -21,7 +21,7 @@ jobs: run: npm ci - name: build types working-directory: ./typescript - run: npm run build:apps + run: npm run build:types - name: build all TS apps working-directory: ./typescript - run: npm run build:types + run: npm run build:apps From fc2c3c86a4c9c68b9ec56f5731775955f710b4c3 Mon Sep 17 00:00:00 2001 From: Sebastian Di Luzio Date: Fri, 10 Dec 2021 23:17:18 +0100 Subject: [PATCH 22/80] document typing progress --- typescript/types/globals.d.ts | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/typescript/types/globals.d.ts b/typescript/types/globals.d.ts index 46d1e3b0a..2ef52dcdf 100644 --- a/typescript/types/globals.d.ts +++ b/typescript/types/globals.d.ts @@ -1,10 +1,12 @@ -// TODO all of these globals (copied from eslintrc need to be typed at some point) -/* { +// TODO all of these globals (copied from eslintrc) need to be typed at some point +/* The typing status is listed on the left of the attribute, e.g.: +status "Attribute" + // Methods and Fields at https://banglejs.com/reference "Array": "readonly", "ArrayBuffer": "readonly", "ArrayBufferView": "readonly", - "Bangle": "readonly", +started "Bangle": "readonly", "BluetoothDevice": "readonly", "BluetoothRemoteGATTCharacteristic": "readonly", "BluetoothRemoteGATTServer": "readonly", @@ -20,8 +22,8 @@ "Float64Array": "readonly", "fs": "readonly", "Function": "readonly", - "Graphics": "readonly", // partly done - "heatshrink": "readonly", +started "Graphics": "readonly", +done "heatshrink": "readonly", "I2C": "readonly", "Int16Array": "readonly", "Int32Array": "readonly", @@ -107,7 +109,7 @@ "poke32": "readonly", "poke8": "readonly", "print": "readonly", - "require": "readonly", +started "require": "readonly", "reset": "readonly", "save": "readonly", "Serial1": "readonly", @@ -123,9 +125,8 @@ "trace": "readonly", "VIBRATE": "readonly", // Aliases and not defined at https://banglejs.com/reference - "g": "readonly", // done - "WIDGETS": "readonly" // done - } +done "g": "readonly", +done "WIDGETS": "readonly" */ // ambient JS definitions From 4dbec88b7f1e4bb741916fbaeb3c156b2c95fd08 Mon Sep 17 00:00:00 2001 From: Adam Schmalhofer Date: Tue, 14 Dec 2021 21:42:58 +0100 Subject: [PATCH 23/80] Port banglerun to new typescript system --- apps/banglerun/README.md | 19 +------------------ apps/banglerun/{src => }/activity.ts | 0 apps/banglerun/{src => }/app.ts | 0 apps/banglerun/{src => }/display.ts | 0 apps/banglerun/{src => }/gps.ts | 0 apps/banglerun/{src => }/hrm.ts | 0 apps/banglerun/{src => }/log.ts | 8 +++++--- apps/banglerun/package.json | 27 --------------------------- apps/banglerun/{src => }/state.ts | 18 +++++++++++++----- apps/banglerun/{src => }/step.ts | 0 apps/banglerun/tsconfig.json | 10 ---------- apps/banglerun/tsconfig.spec.json | 10 ---------- typescript/tsconfig.json | 4 ++-- 13 files changed, 21 insertions(+), 75 deletions(-) rename apps/banglerun/{src => }/activity.ts (100%) rename apps/banglerun/{src => }/app.ts (100%) rename apps/banglerun/{src => }/display.ts (100%) rename apps/banglerun/{src => }/gps.ts (100%) rename apps/banglerun/{src => }/hrm.ts (100%) rename apps/banglerun/{src => }/log.ts (80%) delete mode 100644 apps/banglerun/package.json rename apps/banglerun/{src => }/state.ts (80%) rename apps/banglerun/{src => }/step.ts (100%) delete mode 100644 apps/banglerun/tsconfig.json delete mode 100644 apps/banglerun/tsconfig.spec.json diff --git a/apps/banglerun/README.md b/apps/banglerun/README.md index 80e984bfa..99fbaaf1a 100644 --- a/apps/banglerun/README.md +++ b/apps/banglerun/README.md @@ -5,21 +5,4 @@ An app for running sessions. Displays info and logs your run for later viewing. ## Compilation The app is written in Typescript, and needs to be transpiled in order to be -run on the BangleJS. The easiest way to perform this step is by using the -ubiquitous [NPM package manager](https://www.npmjs.com/get-npm). - -After having installed NPM for your platform, checkout the `BangleApps` repo, -open a terminal, and navigate into the `apps/banglerun` folder. Then issue: - -``` -npm i -``` - -to install the project's build tools, and: - -``` -npm run build -``` - -To build the app. The last command will generate the `app.js` file, containing -the transpiled code for the BangleJS. +run on the BangleJS. See ../../typescript/README.md for instructions. diff --git a/apps/banglerun/src/activity.ts b/apps/banglerun/activity.ts similarity index 100% rename from apps/banglerun/src/activity.ts rename to apps/banglerun/activity.ts diff --git a/apps/banglerun/src/app.ts b/apps/banglerun/app.ts similarity index 100% rename from apps/banglerun/src/app.ts rename to apps/banglerun/app.ts diff --git a/apps/banglerun/src/display.ts b/apps/banglerun/display.ts similarity index 100% rename from apps/banglerun/src/display.ts rename to apps/banglerun/display.ts diff --git a/apps/banglerun/src/gps.ts b/apps/banglerun/gps.ts similarity index 100% rename from apps/banglerun/src/gps.ts rename to apps/banglerun/gps.ts diff --git a/apps/banglerun/src/hrm.ts b/apps/banglerun/hrm.ts similarity index 100% rename from apps/banglerun/src/hrm.ts rename to apps/banglerun/hrm.ts diff --git a/apps/banglerun/src/log.ts b/apps/banglerun/log.ts similarity index 80% rename from apps/banglerun/src/log.ts rename to apps/banglerun/log.ts index b6714e407..282115e1a 100644 --- a/apps/banglerun/src/log.ts +++ b/apps/banglerun/log.ts @@ -1,17 +1,19 @@ -import { AppState } from './state'; +import { AppState, AppStateWithLog } from './state'; declare var require: any; -function initLog(state: AppState): void { +function initLog(state: AppState): AppStateWithLog { const datetime = new Date().toISOString().replace(/[-:]/g, ''); const date = datetime.substr(2, 6); const time = datetime.substr(9, 6); const filename = `banglerun_${date}_${time}`; + state = state; state.file = require('Storage').open(filename, 'w'); state.fileWritten = false; + return state; } -function updateLog(state: AppState): void { +function updateLog(state: AppStateWithLog): void { if (!state.fileWritten) { state.file.write([ 'timestamp', diff --git a/apps/banglerun/package.json b/apps/banglerun/package.json deleted file mode 100644 index 1f5cc677b..000000000 --- a/apps/banglerun/package.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "name": "banglerun", - "version": "0.5.0", - "description": "Bangle.js app for running sessions", - "main": "app.js", - "types": "app.d.ts", - "scripts": { - "build": "rollup -c", - "test": "ts-node -P tsconfig.spec.json node_modules/jasmine/bin/jasmine --config=jasmine.json" - }, - "author": { - "name": "Stefano Baldan", - "email": "singintime@gmail.com" - }, - "license": "ISC", - "devDependencies": { - "@rollup/plugin-typescript": "^4.1.1", - "@types/jasmine": "^3.5.10", - "jasmine": "^3.5.0", - "rollup": "^2.10.2", - "rollup-plugin-terser": "^5.3.0", - "terser": "^4.7.0", - "ts-node": "^8.10.2", - "tslib": "^2.0.0", - "typescript": "^3.9.2" - } -} diff --git a/apps/banglerun/src/state.ts b/apps/banglerun/state.ts similarity index 80% rename from apps/banglerun/src/state.ts rename to apps/banglerun/state.ts index 14ef2dc5d..1ba9bca26 100644 --- a/apps/banglerun/src/state.ts +++ b/apps/banglerun/state.ts @@ -4,7 +4,7 @@ enum ActivityStatus { Running = 'RUN', } -interface AppState { +interface BasicAppState { // GPS NMEA data fix: number; lat: number; @@ -28,14 +28,12 @@ interface AppState { hrError: number, // Logger data - file: File; fileWritten: boolean; // Drawing data drawing: boolean; // Activity data - status: ActivityStatus; duration: number; distance: number; speed: number; @@ -43,6 +41,17 @@ interface AppState { cadence: number; } +interface AppStateWithoutLog extends BasicAppState { + status: 'STOP'; +} + +interface AppStateWithLog extends BasicAppState { + file: File; + status: ActivityStatus; +} + +type AppState = AppStateWithLog | AppStateWithoutLog; + interface File { read: Function; write: Function; @@ -68,7 +77,6 @@ function initState(): AppState { hr: 60, hrError: 100, - file: null, fileWritten: false, drawing: false, @@ -82,4 +90,4 @@ function initState(): AppState { } } -export { ActivityStatus, AppState, File, initState }; +export { ActivityStatus, AppState, AppStateWithLog, File, initState }; diff --git a/apps/banglerun/src/step.ts b/apps/banglerun/step.ts similarity index 100% rename from apps/banglerun/src/step.ts rename to apps/banglerun/step.ts diff --git a/apps/banglerun/tsconfig.json b/apps/banglerun/tsconfig.json deleted file mode 100644 index a341a5a5e..000000000 --- a/apps/banglerun/tsconfig.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "compilerOptions": { - "module": "es2015", - "noImplicitAny": true, - "target": "es2015" - }, - "include": [ - "src" - ] -} diff --git a/apps/banglerun/tsconfig.spec.json b/apps/banglerun/tsconfig.spec.json deleted file mode 100644 index 136ae137b..000000000 --- a/apps/banglerun/tsconfig.spec.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "noImplicitAny": true, - "target": "es2015" - }, - "include": [ - "test" - ] -} diff --git a/typescript/tsconfig.json b/typescript/tsconfig.json index 40537c680..e9327be68 100644 --- a/typescript/tsconfig.json +++ b/typescript/tsconfig.json @@ -14,6 +14,6 @@ "strict": true }, "include": ["../apps/**/*", "./**/*"], - // these apps have been excluded because they were built before this configuration was created and are using their own - "exclude": ["../apps/banglerun", "../apps/hebrew_calendar"] + // this app is excluded because it was built before this configuration was created and is using its own + "exclude": ["../apps/hebrew_calendar"] } From 7b37391553c654f03a29a95f4f29b9c1849a3925 Mon Sep 17 00:00:00 2001 From: Sebastian Di Luzio Date: Thu, 20 Jan 2022 20:58:26 +0100 Subject: [PATCH 24/80] remove unused files from /banglerun, replace banglerun js code with newly compiled code --- apps/banglerun/.gitignore | 1 - apps/banglerun/README.md | 8 --- apps/banglerun/activity.js | 35 ++++++++++++ apps/banglerun/app.js | 14 ++++- apps/banglerun/display.js | 95 +++++++++++++++++++++++++++++++++ apps/banglerun/gps.js | 66 +++++++++++++++++++++++ apps/banglerun/hrm.js | 15 ++++++ apps/banglerun/jasmine.json | 6 --- apps/banglerun/log.js | 36 +++++++++++++ apps/banglerun/rollup.config.js | 15 ------ apps/banglerun/state.js | 33 ++++++++++++ apps/banglerun/step.js | 10 ++++ typescript/tsconfig.json | 4 +- 13 files changed, 304 insertions(+), 34 deletions(-) delete mode 100644 apps/banglerun/.gitignore delete mode 100644 apps/banglerun/README.md create mode 100644 apps/banglerun/activity.js create mode 100644 apps/banglerun/display.js create mode 100644 apps/banglerun/gps.js create mode 100644 apps/banglerun/hrm.js delete mode 100644 apps/banglerun/jasmine.json create mode 100644 apps/banglerun/log.js delete mode 100644 apps/banglerun/rollup.config.js create mode 100644 apps/banglerun/state.js create mode 100644 apps/banglerun/step.js diff --git a/apps/banglerun/.gitignore b/apps/banglerun/.gitignore deleted file mode 100644 index c2658d7d1..000000000 --- a/apps/banglerun/.gitignore +++ /dev/null @@ -1 +0,0 @@ -node_modules/ diff --git a/apps/banglerun/README.md b/apps/banglerun/README.md deleted file mode 100644 index 99fbaaf1a..000000000 --- a/apps/banglerun/README.md +++ /dev/null @@ -1,8 +0,0 @@ -# BangleRun - -An app for running sessions. Displays info and logs your run for later viewing. - -## Compilation - -The app is written in Typescript, and needs to be transpiled in order to be -run on the BangleJS. See ../../typescript/README.md for instructions. diff --git a/apps/banglerun/activity.js b/apps/banglerun/activity.js new file mode 100644 index 000000000..818f9cf2a --- /dev/null +++ b/apps/banglerun/activity.js @@ -0,0 +1,35 @@ +import { draw } from './display'; +import { initLog } from './log'; +import { ActivityStatus } from './state'; +function startActivity(state) { + if (state.status === ActivityStatus.Stopped) { + initLog(state); + } + if (state.status === ActivityStatus.Running) { + state.status = ActivityStatus.Paused; + } + else { + state.status = ActivityStatus.Running; + } + draw(state); +} +function stopActivity(state) { + if (state.status === ActivityStatus.Paused) { + clearActivity(state); + } + if (state.status === ActivityStatus.Running) { + state.status = ActivityStatus.Paused; + } + else { + state.status = ActivityStatus.Stopped; + } + draw(state); +} +function clearActivity(state) { + state.duration = 0; + state.distance = 0; + state.speed = 0; + state.steps = 0; + state.cadence = 0; +} +export { clearActivity, startActivity, stopActivity }; diff --git a/apps/banglerun/app.js b/apps/banglerun/app.js index b79255171..af5413cc0 100644 --- a/apps/banglerun/app.js +++ b/apps/banglerun/app.js @@ -1 +1,13 @@ -!function(){"use strict";var t;!function(t){t.Stopped="STOP",t.Paused="PAUSE",t.Running="RUN"}(t||(t={}));const n={STOP:63488,PAUSE:65504,RUN:2016};function e(t,n,e){g.setColor(0),g.fillRect(n-60,e,n+60,e+30),g.setColor(65535),g.drawString(t,n,e)}function i(i){var s;g.setFontVector(30),g.setFontAlign(0,-1,0),e((i.distance/1e3).toFixed(2),60,55),e(function(t){const n=Math.round(t),e=Math.floor(n/3600),i=Math.floor(n/60)%60,s=n%60;return(e?e+":":"")+("0"+i).substr(-2)+":"+("0"+s).substr(-2)}(i.duration),172,55),e(function(t){if(t<.1667)return"__'__\"";const n=Math.round(1e3/t),e=Math.floor(n/60),i=n%60;return("0"+e).substr(-2)+"'"+("0"+i).substr(-2)+'"'}(i.speed),60,115),e(i.hr.toFixed(0),172,115),e(i.steps.toFixed(0),60,175),e(i.cadence.toFixed(0),172,175),g.setFont("6x8",2),g.setColor(i.gpsValid?2016:63488),g.fillRect(0,216,80,240),g.setColor(0),g.drawString("GPS",40,220),g.setColor(65535),g.fillRect(80,216,160,240),g.setColor(0),g.drawString(("0"+(s=new Date).getHours()).substr(-2)+":"+("0"+s.getMinutes()).substr(-2),120,220),g.setColor(n[i.status]),g.fillRect(160,216,230,240),g.setColor(0),g.drawString(i.status,200,220),g.setFont("6x8").setFontAlign(0,0,1).setColor(-1),i.status===t.Paused?g.drawString("START",236,60,1).drawString(" CLEAR ",236,180,1):i.status===t.Running?g.drawString(" PAUSE ",236,60,1).drawString(" PAUSE ",236,180,1):g.drawString("START",236,60,1).drawString(" ",236,180,1)}function s(t){g.clear(),g.setColor(50712),g.setFont("6x8",2),g.setFontAlign(0,-1,0),g.drawString("DIST (KM)",60,32),g.drawString("TIME",180,32),g.drawString("PACE",60,92),g.drawString("HEART",180,92),g.drawString("STEPS",60,152),g.drawString("CADENCE",180,152),i(t),Bangle.drawWidgets()}function a(n){n.status===t.Stopped&&function(t){const n=(new Date).toISOString().replace(/[-:]/g,""),e=`banglerun_${n.substr(2,6)}_${n.substr(9,6)}`;t.file=require("Storage").open(e,"w"),t.fileWritten=!1}(n),n.status===t.Running?n.status=t.Paused:n.status=t.Running,i(n)}const r={fix:NaN,lat:NaN,lon:NaN,alt:NaN,vel:NaN,dop:NaN,gpsValid:!1,x:NaN,y:NaN,z:NaN,t:NaN,timeSinceLog:0,hr:60,hrError:100,file:null,fileWritten:!1,drawing:!1,status:t.Stopped,duration:0,distance:0,speed:0,steps:0,cadence:0};var o;o=r,Bangle.on("GPS",n=>function(n,e){n.lat=e.lat,n.lon=e.lon,n.alt=e.alt,n.vel=e.speed/3.6,n.fix=e.fix,n.dop=e.hdop,n.gpsValid=n.fix>0,function(n){const e=Date.now();let i=(e-n.t)/1e3;if(isFinite(i)||(i=0),n.t=e,n.timeSinceLog+=i,n.status===t.Running&&(n.duration+=i),!n.gpsValid)return;const s=6371008.8+n.alt,a=n.lat*Math.PI/180,r=n.lon*Math.PI/180,o=s*Math.cos(a)*Math.cos(r),g=s*Math.cos(a)*Math.sin(r),d=s*Math.sin(a);if(!n.x)return n.x=o,n.y=g,void(n.z=d);const u=o-n.x,l=g-n.y,c=d-n.z,f=Math.sqrt(u*u+l*l+c*c);n.x=o,n.y=g,n.z=d,n.status===t.Running&&(n.distance+=f,n.speed=n.distance/n.duration||0,n.cadence=60*n.steps/n.duration||0)}(n),i(n),n.gpsValid&&n.status===t.Running&&n.timeSinceLog>5&&(n.timeSinceLog=0,function(t){t.fileWritten||(t.file.write(["timestamp","latitude","longitude","altitude","duration","distance","heartrate","steps"].join(",")+"\n"),t.fileWritten=!0),t.file.write([Date.now().toFixed(0),t.lat.toFixed(6),t.lon.toFixed(6),t.alt.toFixed(2),t.duration.toFixed(0),t.distance.toFixed(2),t.hr.toFixed(0),t.steps.toFixed(0)].join(",")+"\n")}(n))}(o,n)),Bangle.setGPSPower(1),function(t){Bangle.on("HRM",n=>function(t,n){if(0===n.confidence)return;const e=n.bpm-t.hr,i=Math.abs(e)+101-n.confidence,s=t.hrError/(t.hrError+i)||0;t.hr+=e*s,t.hrError+=(i-t.hrError)*s}(t,n)),Bangle.setHRMPower(1)}(r),function(n){Bangle.on("step",()=>function(n){n.status===t.Running&&(n.steps+=1)}(n))}(r),function(t){Bangle.loadWidgets(),Bangle.on("lcdPower",n=>{t.drawing=n,n&&s(t)}),s(t)}(r),setWatch(()=>a(r),BTN1,{repeat:!0,edge:"falling"}),setWatch(()=>function(n){n.status===t.Paused&&function(t){t.duration=0,t.distance=0,t.speed=0,t.steps=0,t.cadence=0}(n),n.status===t.Running?n.status=t.Paused:n.status=t.Stopped,i(n)}(r),BTN3,{repeat:!0,edge:"falling"})}(); +import { startActivity, stopActivity } from './activity'; +import { initDisplay } from './display'; +import { initGps } from './gps'; +import { initHrm } from './hrm'; +import { initState } from './state'; +import { initStep } from './step'; +const appState = initState(); +initGps(appState); +initHrm(appState); +initStep(appState); +initDisplay(appState); +setWatch(() => startActivity(appState), BTN1, { repeat: true, edge: 'falling' }); +setWatch(() => stopActivity(appState), BTN3, { repeat: true, edge: 'falling' }); diff --git a/apps/banglerun/display.js b/apps/banglerun/display.js new file mode 100644 index 000000000..2768e8973 --- /dev/null +++ b/apps/banglerun/display.js @@ -0,0 +1,95 @@ +import { ActivityStatus } from './state'; +const STATUS_COLORS = { + 'STOP': 0xF800, + 'PAUSE': 0xFFE0, + 'RUN': 0x07E0, +}; +function initDisplay(state) { + Bangle.loadWidgets(); + Bangle.on('lcdPower', (on) => { + state.drawing = on; + if (on) { + drawAll(state); + } + }); + drawAll(state); +} +function drawBackground() { + g.clear(); + g.setColor(0xC618); + g.setFont('6x8', 2); + g.setFontAlign(0, -1, 0); + g.drawString('DIST (KM)', 60, 32); + g.drawString('TIME', 172, 32); + g.drawString('PACE', 60, 92); + g.drawString('HEART', 172, 92); + g.drawString('STEPS', 60, 152); + g.drawString('CADENCE', 172, 152); +} +function drawValue(value, x, y) { + g.setColor(0x0000); + g.fillRect(x - 60, y, x + 60, y + 30); + g.setColor(0xFFFF); + g.drawString(value, x, y); +} +function draw(state) { + g.setFontVector(30); + g.setFontAlign(0, -1, 0); + drawValue(formatDistance(state.distance), 60, 55); + drawValue(formatTime(state.duration), 172, 55); + drawValue(formatPace(state.speed), 60, 115); + drawValue(state.hr.toFixed(0), 172, 115); + drawValue(state.steps.toFixed(0), 60, 175); + drawValue(state.cadence.toFixed(0), 172, 175); + g.setFont('6x8', 2); + g.setColor(state.gpsValid ? 0x07E0 : 0xF800); + g.fillRect(0, 216, 80, 240); + g.setColor(0x0000); + g.drawString('GPS', 40, 220); + g.setColor(0xFFFF); + g.fillRect(80, 216, 160, 240); + g.setColor(0x0000); + g.drawString(formatClock(new Date()), 120, 220); + g.setColor(STATUS_COLORS[state.status]); + g.fillRect(160, 216, 230, 240); + g.setColor(0x0000); + g.drawString(state.status, 200, 220); + g.setFont("6x8").setFontAlign(0, 0, 1).setColor(-1); + if (state.status === ActivityStatus.Paused) { + g.drawString("START", 236, 60, 1).drawString(" CLEAR ", 236, 180, 1); + } + else if (state.status === ActivityStatus.Running) { + g.drawString(" PAUSE ", 236, 60, 1).drawString(" PAUSE ", 236, 180, 1); + } + else { + g.drawString("START", 236, 60, 1).drawString(" ", 236, 180, 1); + } +} +function drawAll(state) { + drawBackground(); + draw(state); + Bangle.drawWidgets(); +} +function formatClock(date) { + return ('0' + date.getHours()).substr(-2) + ':' + ('0' + date.getMinutes()).substr(-2); +} +function formatDistance(meters) { + return (meters / 1000).toFixed(2); +} +function formatPace(speed) { + if (speed < 0.1667) { + return `__'__"`; + } + const pace = Math.round(1000 / speed); + const min = Math.floor(pace / 60); + const sec = pace % 60; + return ('0' + min).substr(-2) + `'` + ('0' + sec).substr(-2) + `"`; +} +function formatTime(time) { + const seconds = Math.round(time); + const hrs = Math.floor(seconds / 3600); + const min = Math.floor(seconds / 60) % 60; + const sec = seconds % 60; + return (hrs ? hrs + ':' : '') + ('0' + min).substr(-2) + `:` + ('0' + sec).substr(-2); +} +export { draw, drawAll, drawBackground, drawValue, formatClock, formatDistance, formatPace, formatTime, initDisplay, }; diff --git a/apps/banglerun/gps.js b/apps/banglerun/gps.js new file mode 100644 index 000000000..d06215cd5 --- /dev/null +++ b/apps/banglerun/gps.js @@ -0,0 +1,66 @@ +import { draw } from './display'; +import { updateLog } from './log'; +import { ActivityStatus } from './state'; +const EARTH_RADIUS = 6371008.8; +function initGps(state) { + Bangle.on('GPS', (gps) => readGps(state, gps)); + Bangle.setGPSPower(1); +} +function readGps(state, gps) { + state.lat = gps.lat; + state.lon = gps.lon; + state.alt = gps.alt; + state.vel = gps.speed / 3.6; + state.fix = gps.fix; + state.dop = gps.hdop; + state.gpsValid = state.fix > 0; + updateGps(state); + draw(state); + /* Only log GPS data every 5 secs if we + have a fix and we're running. */ + if (state.gpsValid && + state.status === ActivityStatus.Running && + state.timeSinceLog > 5) { + state.timeSinceLog = 0; + updateLog(state); + } +} +function updateGps(state) { + const t = Date.now(); + let dt = (t - state.t) / 1000; + if (!isFinite(dt)) + dt = 0; + state.t = t; + state.timeSinceLog += dt; + if (state.status === ActivityStatus.Running) { + state.duration += dt; + } + if (!state.gpsValid) { + return; + } + const r = EARTH_RADIUS + state.alt; + const lat = state.lat * Math.PI / 180; + const lon = state.lon * Math.PI / 180; + const x = r * Math.cos(lat) * Math.cos(lon); + const y = r * Math.cos(lat) * Math.sin(lon); + const z = r * Math.sin(lat); + if (!state.x) { + state.x = x; + state.y = y; + state.z = z; + return; + } + const dx = x - state.x; + const dy = y - state.y; + const dz = z - state.z; + const dpMag = Math.sqrt(dx * dx + dy * dy + dz * dz); + state.x = x; + state.y = y; + state.z = z; + if (state.status === ActivityStatus.Running) { + state.distance += dpMag; + state.speed = (state.distance / state.duration) || 0; + state.cadence = (60 * state.steps / state.duration) || 0; + } +} +export { initGps, readGps, updateGps }; diff --git a/apps/banglerun/hrm.js b/apps/banglerun/hrm.js new file mode 100644 index 000000000..35804f5e8 --- /dev/null +++ b/apps/banglerun/hrm.js @@ -0,0 +1,15 @@ +function initHrm(state) { + Bangle.on('HRM', (hrm) => updateHrm(state, hrm)); + Bangle.setHRMPower(1); +} +function updateHrm(state, hrm) { + if (hrm.confidence === 0) { + return; + } + const dHr = hrm.bpm - state.hr; + const hrError = Math.abs(dHr) + 101 - hrm.confidence; + const hrGain = (state.hrError / (state.hrError + hrError)) || 0; + state.hr += dHr * hrGain; + state.hrError += (hrError - state.hrError) * hrGain; +} +export { initHrm, updateHrm }; diff --git a/apps/banglerun/jasmine.json b/apps/banglerun/jasmine.json deleted file mode 100644 index 813363b27..000000000 --- a/apps/banglerun/jasmine.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "spec_dir": "test", - "spec_files": [ - "**/*.spec.ts" - ] -} \ No newline at end of file diff --git a/apps/banglerun/log.js b/apps/banglerun/log.js new file mode 100644 index 000000000..b11409de6 --- /dev/null +++ b/apps/banglerun/log.js @@ -0,0 +1,36 @@ +function initLog(state) { + const datetime = new Date().toISOString().replace(/[-:]/g, ''); + const date = datetime.substr(2, 6); + const time = datetime.substr(9, 6); + const filename = `banglerun_${date}_${time}`; + state = state; + state.file = require('Storage').open(filename, 'w'); + state.fileWritten = false; + return state; +} +function updateLog(state) { + if (!state.fileWritten) { + state.file.write([ + 'timestamp', + 'latitude', + 'longitude', + 'altitude', + 'duration', + 'distance', + 'heartrate', + 'steps', + ].join(',') + '\n'); + state.fileWritten = true; + } + state.file.write([ + Date.now().toFixed(0), + state.lat.toFixed(6), + state.lon.toFixed(6), + state.alt.toFixed(2), + state.duration.toFixed(0), + state.distance.toFixed(2), + state.hr.toFixed(0), + state.steps.toFixed(0), + ].join(',') + '\n'); +} +export { initLog, updateLog }; diff --git a/apps/banglerun/rollup.config.js b/apps/banglerun/rollup.config.js deleted file mode 100644 index f7027eb2b..000000000 --- a/apps/banglerun/rollup.config.js +++ /dev/null @@ -1,15 +0,0 @@ -import typescript from '@rollup/plugin-typescript'; -import { terser } from 'rollup-plugin-terser'; - -export default { - input: './src/app.ts', - output: { - dir: '.', - format: 'iife', - name: 'banglerun' - }, - plugins: [ - typescript(), - terser(), - ] -}; diff --git a/apps/banglerun/state.js b/apps/banglerun/state.js new file mode 100644 index 000000000..8629d69a7 --- /dev/null +++ b/apps/banglerun/state.js @@ -0,0 +1,33 @@ +var ActivityStatus; +(function (ActivityStatus) { + ActivityStatus["Stopped"] = "STOP"; + ActivityStatus["Paused"] = "PAUSE"; + ActivityStatus["Running"] = "RUN"; +})(ActivityStatus || (ActivityStatus = {})); +function initState() { + return { + fix: NaN, + lat: NaN, + lon: NaN, + alt: NaN, + vel: NaN, + dop: NaN, + gpsValid: false, + x: NaN, + y: NaN, + z: NaN, + t: NaN, + timeSinceLog: 0, + hr: 60, + hrError: 100, + fileWritten: false, + drawing: false, + status: ActivityStatus.Stopped, + duration: 0, + distance: 0, + speed: 0, + steps: 0, + cadence: 0, + }; +} +export { ActivityStatus, initState }; diff --git a/apps/banglerun/step.js b/apps/banglerun/step.js new file mode 100644 index 000000000..b258a853d --- /dev/null +++ b/apps/banglerun/step.js @@ -0,0 +1,10 @@ +import { ActivityStatus } from './state'; +function initStep(state) { + Bangle.on('step', () => updateStep(state)); +} +function updateStep(state) { + if (state.status === ActivityStatus.Running) { + state.steps += 1; + } +} +export { initStep, updateStep }; diff --git a/typescript/tsconfig.json b/typescript/tsconfig.json index e9327be68..7def102b7 100644 --- a/typescript/tsconfig.json +++ b/typescript/tsconfig.json @@ -13,7 +13,5 @@ "noUnusedParameters": true, "strict": true }, - "include": ["../apps/**/*", "./**/*"], - // this app is excluded because it was built before this configuration was created and is using its own - "exclude": ["../apps/hebrew_calendar"] + "include": ["../apps/**/*", "./**/*"], } From 643c304a1ee4ad4d0c196f3467811e279b8356f9 Mon Sep 17 00:00:00 2001 From: Sebastian Di Luzio Date: Thu, 20 Jan 2022 21:00:04 +0100 Subject: [PATCH 25/80] trigger github actions on PR as well --- .github/workflows/nodejs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index c268c884c..0c256c97b 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -1,6 +1,6 @@ name: Node CI -on: [push] +on: [push, pull_request] jobs: build: From da0e2a79096e1898d9da29cd3300f424196e9dae Mon Sep 17 00:00:00 2001 From: Sebastian Di Luzio Date: Thu, 20 Jan 2022 21:04:42 +0100 Subject: [PATCH 26/80] Update metadata.json --- apps/widChargingStatus/metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/widChargingStatus/metadata.json b/apps/widChargingStatus/metadata.json index f68ccf5b4..573c594e7 100644 --- a/apps/widChargingStatus/metadata.json +++ b/apps/widChargingStatus/metadata.json @@ -2,7 +2,7 @@ "name": "Charging Status", "shortName":"ChargingStatus", "icon": "widget.png", - "version":"0.01", + "version":"0.02", "type": "widget", "description": "A simple widget that shows a yellow lightning icon to indicate whenever the watch is charging. This way one can see the charging status at a glance, no matter which battery widget is being used.", "tags": "widget", From 4727652627ce864ea6148cae87002847fd2c43dd Mon Sep 17 00:00:00 2001 From: Sebastian Di Luzio Date: Thu, 20 Jan 2022 21:09:57 +0100 Subject: [PATCH 27/80] rename build step to be less confusing for widgets --- .github/workflows/nodejs.yml | 4 ++-- typescript/README.md | 8 ++++---- typescript/package.json | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 0c256c97b..bb27b367e 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -22,6 +22,6 @@ jobs: - name: build types working-directory: ./typescript run: npm run build:types - - name: build all TS apps + - name: build all TS apps and widgets working-directory: ./typescript - run: npm run build:apps + run: npm run build diff --git a/typescript/README.md b/typescript/README.md index d1f60fd0b..13800aeec 100644 --- a/typescript/README.md +++ b/typescript/README.md @@ -11,8 +11,8 @@ The typing is an ongoing process. If anything is still missing, you can add it! ## Compilation -Install [npm](https://www.npmjs.com/get-npm) if you haven't already. -Make sure you are using version ^8 by running `npm -v`. If the version is incorrect, run `npm i -g npm@^8`. +Install [npm](https://www.npmjs.com/get-npm) and node.js if you haven't already. We recommend using a version manager like nvm, which is also referenced in the linked documentation. +Make sure you are using node version 16 by running `nvm use 16` and npm version ^8 by running `npm -v`. If the latter version is incorrect, run `npm i -g npm@^8`. After having installed npm for your platform, open a terminal, and navigate into the `/typescript` folder. Then run: @@ -23,7 +23,7 @@ npm ci to install the project's build tools, and: ``` -npm run build:apps +npm run build ``` -To build all Typescript apps. The last command will generate the `app.js` files containing the transpiled code for the BangleJS. +To build all Typescript apps and widgets. The last command will generate the `app.js` files containing the transpiled code for the BangleJS. diff --git a/typescript/package.json b/typescript/package.json index 4bfb88d27..8cd38ce63 100644 --- a/typescript/package.json +++ b/typescript/package.json @@ -7,7 +7,7 @@ "typescript": "4.5.2" }, "scripts": { - "build:apps": "tsc", + "build": "tsc", "build:types": "tsc ./types/globals.d.ts" } } From ebbbf696701c01af8f31992d2e97862d4fcaa5b4 Mon Sep 17 00:00:00 2001 From: Sebastian Di Luzio Date: Thu, 20 Jan 2022 21:23:17 +0100 Subject: [PATCH 28/80] adjust module target version during build --- apps/banglerun/activity.js | 35 ++++++++++++++++++++--------------- apps/banglerun/app.js | 28 +++++++++++++++------------- apps/banglerun/display.js | 19 +++++++++++++++---- apps/banglerun/gps.js | 23 ++++++++++++++--------- apps/banglerun/hrm.js | 6 +++++- apps/banglerun/log.js | 6 +++++- apps/banglerun/state.js | 6 +++++- apps/banglerun/step.js | 10 +++++++--- typescript/tsconfig.json | 4 ++-- 9 files changed, 88 insertions(+), 49 deletions(-) diff --git a/apps/banglerun/activity.js b/apps/banglerun/activity.js index 818f9cf2a..94512094c 100644 --- a/apps/banglerun/activity.js +++ b/apps/banglerun/activity.js @@ -1,30 +1,35 @@ -import { draw } from './display'; -import { initLog } from './log'; -import { ActivityStatus } from './state'; +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.stopActivity = exports.startActivity = exports.clearActivity = void 0; +const display_1 = require("./display"); +const log_1 = require("./log"); +const state_1 = require("./state"); function startActivity(state) { - if (state.status === ActivityStatus.Stopped) { - initLog(state); + if (state.status === state_1.ActivityStatus.Stopped) { + (0, log_1.initLog)(state); } - if (state.status === ActivityStatus.Running) { - state.status = ActivityStatus.Paused; + if (state.status === state_1.ActivityStatus.Running) { + state.status = state_1.ActivityStatus.Paused; } else { - state.status = ActivityStatus.Running; + state.status = state_1.ActivityStatus.Running; } - draw(state); + (0, display_1.draw)(state); } +exports.startActivity = startActivity; function stopActivity(state) { - if (state.status === ActivityStatus.Paused) { + if (state.status === state_1.ActivityStatus.Paused) { clearActivity(state); } - if (state.status === ActivityStatus.Running) { - state.status = ActivityStatus.Paused; + if (state.status === state_1.ActivityStatus.Running) { + state.status = state_1.ActivityStatus.Paused; } else { - state.status = ActivityStatus.Stopped; + state.status = state_1.ActivityStatus.Stopped; } - draw(state); + (0, display_1.draw)(state); } +exports.stopActivity = stopActivity; function clearActivity(state) { state.duration = 0; state.distance = 0; @@ -32,4 +37,4 @@ function clearActivity(state) { state.steps = 0; state.cadence = 0; } -export { clearActivity, startActivity, stopActivity }; +exports.clearActivity = clearActivity; diff --git a/apps/banglerun/app.js b/apps/banglerun/app.js index af5413cc0..84d03820a 100644 --- a/apps/banglerun/app.js +++ b/apps/banglerun/app.js @@ -1,13 +1,15 @@ -import { startActivity, stopActivity } from './activity'; -import { initDisplay } from './display'; -import { initGps } from './gps'; -import { initHrm } from './hrm'; -import { initState } from './state'; -import { initStep } from './step'; -const appState = initState(); -initGps(appState); -initHrm(appState); -initStep(appState); -initDisplay(appState); -setWatch(() => startActivity(appState), BTN1, { repeat: true, edge: 'falling' }); -setWatch(() => stopActivity(appState), BTN3, { repeat: true, edge: 'falling' }); +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const activity_1 = require("./activity"); +const display_1 = require("./display"); +const gps_1 = require("./gps"); +const hrm_1 = require("./hrm"); +const state_1 = require("./state"); +const step_1 = require("./step"); +const appState = (0, state_1.initState)(); +(0, gps_1.initGps)(appState); +(0, hrm_1.initHrm)(appState); +(0, step_1.initStep)(appState); +(0, display_1.initDisplay)(appState); +setWatch(() => (0, activity_1.startActivity)(appState), BTN1, { repeat: true, edge: 'falling' }); +setWatch(() => (0, activity_1.stopActivity)(appState), BTN3, { repeat: true, edge: 'falling' }); diff --git a/apps/banglerun/display.js b/apps/banglerun/display.js index 2768e8973..648482676 100644 --- a/apps/banglerun/display.js +++ b/apps/banglerun/display.js @@ -1,4 +1,7 @@ -import { ActivityStatus } from './state'; +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.initDisplay = exports.formatTime = exports.formatPace = exports.formatDistance = exports.formatClock = exports.drawValue = exports.drawBackground = exports.drawAll = exports.draw = void 0; +const state_1 = require("./state"); const STATUS_COLORS = { 'STOP': 0xF800, 'PAUSE': 0xFFE0, @@ -14,6 +17,7 @@ function initDisplay(state) { }); drawAll(state); } +exports.initDisplay = initDisplay; function drawBackground() { g.clear(); g.setColor(0xC618); @@ -26,12 +30,14 @@ function drawBackground() { g.drawString('STEPS', 60, 152); g.drawString('CADENCE', 172, 152); } +exports.drawBackground = drawBackground; function drawValue(value, x, y) { g.setColor(0x0000); g.fillRect(x - 60, y, x + 60, y + 30); g.setColor(0xFFFF); g.drawString(value, x, y); } +exports.drawValue = drawValue; function draw(state) { g.setFontVector(30); g.setFontAlign(0, -1, 0); @@ -55,27 +61,31 @@ function draw(state) { g.setColor(0x0000); g.drawString(state.status, 200, 220); g.setFont("6x8").setFontAlign(0, 0, 1).setColor(-1); - if (state.status === ActivityStatus.Paused) { + if (state.status === state_1.ActivityStatus.Paused) { g.drawString("START", 236, 60, 1).drawString(" CLEAR ", 236, 180, 1); } - else if (state.status === ActivityStatus.Running) { + else if (state.status === state_1.ActivityStatus.Running) { g.drawString(" PAUSE ", 236, 60, 1).drawString(" PAUSE ", 236, 180, 1); } else { g.drawString("START", 236, 60, 1).drawString(" ", 236, 180, 1); } } +exports.draw = draw; function drawAll(state) { drawBackground(); draw(state); Bangle.drawWidgets(); } +exports.drawAll = drawAll; function formatClock(date) { return ('0' + date.getHours()).substr(-2) + ':' + ('0' + date.getMinutes()).substr(-2); } +exports.formatClock = formatClock; function formatDistance(meters) { return (meters / 1000).toFixed(2); } +exports.formatDistance = formatDistance; function formatPace(speed) { if (speed < 0.1667) { return `__'__"`; @@ -85,6 +95,7 @@ function formatPace(speed) { const sec = pace % 60; return ('0' + min).substr(-2) + `'` + ('0' + sec).substr(-2) + `"`; } +exports.formatPace = formatPace; function formatTime(time) { const seconds = Math.round(time); const hrs = Math.floor(seconds / 3600); @@ -92,4 +103,4 @@ function formatTime(time) { const sec = seconds % 60; return (hrs ? hrs + ':' : '') + ('0' + min).substr(-2) + `:` + ('0' + sec).substr(-2); } -export { draw, drawAll, drawBackground, drawValue, formatClock, formatDistance, formatPace, formatTime, initDisplay, }; +exports.formatTime = formatTime; diff --git a/apps/banglerun/gps.js b/apps/banglerun/gps.js index d06215cd5..35e0f8769 100644 --- a/apps/banglerun/gps.js +++ b/apps/banglerun/gps.js @@ -1,11 +1,15 @@ -import { draw } from './display'; -import { updateLog } from './log'; -import { ActivityStatus } from './state'; +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.updateGps = exports.readGps = exports.initGps = void 0; +const display_1 = require("./display"); +const log_1 = require("./log"); +const state_1 = require("./state"); const EARTH_RADIUS = 6371008.8; function initGps(state) { Bangle.on('GPS', (gps) => readGps(state, gps)); Bangle.setGPSPower(1); } +exports.initGps = initGps; function readGps(state, gps) { state.lat = gps.lat; state.lon = gps.lon; @@ -15,16 +19,17 @@ function readGps(state, gps) { state.dop = gps.hdop; state.gpsValid = state.fix > 0; updateGps(state); - draw(state); + (0, display_1.draw)(state); /* Only log GPS data every 5 secs if we have a fix and we're running. */ if (state.gpsValid && - state.status === ActivityStatus.Running && + state.status === state_1.ActivityStatus.Running && state.timeSinceLog > 5) { state.timeSinceLog = 0; - updateLog(state); + (0, log_1.updateLog)(state); } } +exports.readGps = readGps; function updateGps(state) { const t = Date.now(); let dt = (t - state.t) / 1000; @@ -32,7 +37,7 @@ function updateGps(state) { dt = 0; state.t = t; state.timeSinceLog += dt; - if (state.status === ActivityStatus.Running) { + if (state.status === state_1.ActivityStatus.Running) { state.duration += dt; } if (!state.gpsValid) { @@ -57,10 +62,10 @@ function updateGps(state) { state.x = x; state.y = y; state.z = z; - if (state.status === ActivityStatus.Running) { + if (state.status === state_1.ActivityStatus.Running) { state.distance += dpMag; state.speed = (state.distance / state.duration) || 0; state.cadence = (60 * state.steps / state.duration) || 0; } } -export { initGps, readGps, updateGps }; +exports.updateGps = updateGps; diff --git a/apps/banglerun/hrm.js b/apps/banglerun/hrm.js index 35804f5e8..c002de2f6 100644 --- a/apps/banglerun/hrm.js +++ b/apps/banglerun/hrm.js @@ -1,7 +1,11 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.updateHrm = exports.initHrm = void 0; function initHrm(state) { Bangle.on('HRM', (hrm) => updateHrm(state, hrm)); Bangle.setHRMPower(1); } +exports.initHrm = initHrm; function updateHrm(state, hrm) { if (hrm.confidence === 0) { return; @@ -12,4 +16,4 @@ function updateHrm(state, hrm) { state.hr += dHr * hrGain; state.hrError += (hrError - state.hrError) * hrGain; } -export { initHrm, updateHrm }; +exports.updateHrm = updateHrm; diff --git a/apps/banglerun/log.js b/apps/banglerun/log.js index b11409de6..ee2af3091 100644 --- a/apps/banglerun/log.js +++ b/apps/banglerun/log.js @@ -1,3 +1,6 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.updateLog = exports.initLog = void 0; function initLog(state) { const datetime = new Date().toISOString().replace(/[-:]/g, ''); const date = datetime.substr(2, 6); @@ -8,6 +11,7 @@ function initLog(state) { state.fileWritten = false; return state; } +exports.initLog = initLog; function updateLog(state) { if (!state.fileWritten) { state.file.write([ @@ -33,4 +37,4 @@ function updateLog(state) { state.steps.toFixed(0), ].join(',') + '\n'); } -export { initLog, updateLog }; +exports.updateLog = updateLog; diff --git a/apps/banglerun/state.js b/apps/banglerun/state.js index 8629d69a7..349ef1954 100644 --- a/apps/banglerun/state.js +++ b/apps/banglerun/state.js @@ -1,9 +1,13 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.initState = exports.ActivityStatus = void 0; var ActivityStatus; (function (ActivityStatus) { ActivityStatus["Stopped"] = "STOP"; ActivityStatus["Paused"] = "PAUSE"; ActivityStatus["Running"] = "RUN"; })(ActivityStatus || (ActivityStatus = {})); +exports.ActivityStatus = ActivityStatus; function initState() { return { fix: NaN, @@ -30,4 +34,4 @@ function initState() { cadence: 0, }; } -export { ActivityStatus, initState }; +exports.initState = initState; diff --git a/apps/banglerun/step.js b/apps/banglerun/step.js index b258a853d..e4acfd66a 100644 --- a/apps/banglerun/step.js +++ b/apps/banglerun/step.js @@ -1,10 +1,14 @@ -import { ActivityStatus } from './state'; +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.updateStep = exports.initStep = void 0; +const state_1 = require("./state"); function initStep(state) { Bangle.on('step', () => updateStep(state)); } +exports.initStep = initStep; function updateStep(state) { - if (state.status === ActivityStatus.Running) { + if (state.status === state_1.ActivityStatus.Running) { state.steps += 1; } } -export { initStep, updateStep }; +exports.updateStep = updateStep; diff --git a/typescript/tsconfig.json b/typescript/tsconfig.json index 7def102b7..d36465a01 100644 --- a/typescript/tsconfig.json +++ b/typescript/tsconfig.json @@ -1,8 +1,8 @@ { "compilerOptions": { - "module": "es2015", + "module": "commonjs", "noImplicitAny": true, - "target": "es2015", + "target": "es6", "allowUnreachableCode": false, "allowUnusedLabels": false, "noImplicitOverride": true, From 2faa870e7e7dd87f44c7ae9162b4f5e889c40d47 Mon Sep 17 00:00:00 2001 From: Sebastian Di Luzio Date: Thu, 20 Jan 2022 21:30:44 +0100 Subject: [PATCH 29/80] adjust banglerun/app.ts to not do some stupid self assign logic --- apps/banglerun/log.js | 5 +--- apps/banglerun/log.ts | 53 +++++++++++++++++++++++-------------------- 2 files changed, 30 insertions(+), 28 deletions(-) diff --git a/apps/banglerun/log.js b/apps/banglerun/log.js index ee2af3091..0cdeaa964 100644 --- a/apps/banglerun/log.js +++ b/apps/banglerun/log.js @@ -6,10 +6,7 @@ function initLog(state) { const date = datetime.substr(2, 6); const time = datetime.substr(9, 6); const filename = `banglerun_${date}_${time}`; - state = state; - state.file = require('Storage').open(filename, 'w'); - state.fileWritten = false; - return state; + return Object.assign(Object.assign({}, state), { file: require('Storage').open(filename, 'w'), fileWritten: false }); } exports.initLog = initLog; function updateLog(state) { diff --git a/apps/banglerun/log.ts b/apps/banglerun/log.ts index 282115e1a..ba1c1f00e 100644 --- a/apps/banglerun/log.ts +++ b/apps/banglerun/log.ts @@ -7,36 +7,41 @@ function initLog(state: AppState): AppStateWithLog { const date = datetime.substr(2, 6); const time = datetime.substr(9, 6); const filename = `banglerun_${date}_${time}`; - state = state; - state.file = require('Storage').open(filename, 'w'); - state.fileWritten = false; - return state; + return { + ...state, + file: require('Storage').open(filename, 'w'), + fileWritten: false, + } as AppStateWithLog; } function updateLog(state: AppStateWithLog): void { if (!state.fileWritten) { - state.file.write([ - 'timestamp', - 'latitude', - 'longitude', - 'altitude', - 'duration', - 'distance', - 'heartrate', - 'steps', - ].join(',') + '\n'); + state.file.write( + [ + 'timestamp', + 'latitude', + 'longitude', + 'altitude', + 'duration', + 'distance', + 'heartrate', + 'steps', + ].join(',') + '\n' + ); state.fileWritten = true; } - state.file.write([ - Date.now().toFixed(0), - state.lat.toFixed(6), - state.lon.toFixed(6), - state.alt.toFixed(2), - state.duration.toFixed(0), - state.distance.toFixed(2), - state.hr.toFixed(0), - state.steps.toFixed(0), - ].join(',') + '\n'); + state.file.write( + [ + Date.now().toFixed(0), + state.lat.toFixed(6), + state.lon.toFixed(6), + state.alt.toFixed(2), + state.duration.toFixed(0), + state.distance.toFixed(2), + state.hr.toFixed(0), + state.steps.toFixed(0), + ].join(',') + '\n' + ); } export { initLog, updateLog }; From df7c92080fd4de54509924f04d7ab80b64cef112 Mon Sep 17 00:00:00 2001 From: Sebastian Di Luzio Date: Thu, 20 Jan 2022 21:34:28 +0100 Subject: [PATCH 30/80] add steps that travis CI does to the github actions pipeline --- .github/workflows/nodejs.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index bb27b367e..08849c073 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -25,3 +25,7 @@ jobs: - name: build all TS apps and widgets working-directory: ./typescript run: npm run build + - name: install testing dependencies + run: npm i + - name: test all apps and widgets + run: npm run test From f869b5373031cbac89b9ec37f8e6573bef125719 Mon Sep 17 00:00:00 2001 From: Sebastian Di Luzio Date: Thu, 20 Jan 2022 21:41:41 +0100 Subject: [PATCH 31/80] move app testing in front of TS build steps to see if that makes any difference --- .github/workflows/nodejs.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 08849c073..234e3d455 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -16,7 +16,11 @@ jobs: uses: actions/setup-node@v1 with: node-version: ${{ matrix.node-version }} - - name: npm ci + - name: install testing dependencies + run: npm i + - name: test all apps and widgets + run: npm run test + - name: install typescript dependencies working-directory: ./typescript run: npm ci - name: build types @@ -24,8 +28,4 @@ jobs: run: npm run build:types - name: build all TS apps and widgets working-directory: ./typescript - run: npm run build - - name: install testing dependencies - run: npm i - - name: test all apps and widgets - run: npm run test + run: npm run build \ No newline at end of file From 455c89cbec9e331d37c7f1566eb989bfd673ca5e Mon Sep 17 00:00:00 2001 From: Sebastian Di Luzio Date: Thu, 20 Jan 2022 21:55:20 +0100 Subject: [PATCH 32/80] add some debugging logs as to why the module cant be found in the pipeline, but locally --- .github/workflows/nodejs.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 234e3d455..166700e2f 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -18,6 +18,12 @@ jobs: node-version: ${{ matrix.node-version }} - name: install testing dependencies run: npm i + - name: list content of folders + run: ls -l + - name: list content of folders 2 + run: ls -l ./core + - name: list content of folders 3 + run: ls -l ./core/lib - name: test all apps and widgets run: npm run test - name: install typescript dependencies From 391fbc20950083eb7a11c4f7c474fe5ae65f623b Mon Sep 17 00:00:00 2001 From: Sebastian Di Luzio Date: Thu, 20 Jan 2022 22:01:34 +0100 Subject: [PATCH 33/80] use checkout v2 and import submodules for github actions --- .github/workflows/nodejs.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 166700e2f..fe438bae1 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -11,7 +11,10 @@ jobs: node-version: [16.x] steps: - - uses: actions/checkout@v1 + - name: Checkout repository and submodules + uses: actions/checkout@v2 + with: + submodules: recursive - name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-node@v1 with: From 016a0c89ea5d0208c02b33c0ff8adff10551a4ac Mon Sep 17 00:00:00 2001 From: Sebastian Di Luzio Date: Thu, 20 Jan 2022 22:03:55 +0100 Subject: [PATCH 34/80] fix indenting in github actions yaml --- .github/workflows/nodejs.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index fe438bae1..42aced6a9 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -12,9 +12,9 @@ jobs: steps: - name: Checkout repository and submodules - uses: actions/checkout@v2 - with: - submodules: recursive + uses: actions/checkout@v2 + with: + submodules: recursive - name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-node@v1 with: From e6d23cbc7e83e9aa61b588c933db21fe7758adee Mon Sep 17 00:00:00 2001 From: Sebastian Di Luzio Date: Thu, 20 Jan 2022 22:05:03 +0100 Subject: [PATCH 35/80] remove unnecessary steps from github actions --- .github/workflows/nodejs.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 42aced6a9..1eb009153 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -21,12 +21,6 @@ jobs: node-version: ${{ matrix.node-version }} - name: install testing dependencies run: npm i - - name: list content of folders - run: ls -l - - name: list content of folders 2 - run: ls -l ./core - - name: list content of folders 3 - run: ls -l ./core/lib - name: test all apps and widgets run: npm run test - name: install typescript dependencies From b81c165209372800410bf63eaa389b5af6061910 Mon Sep 17 00:00:00 2001 From: Andrew Gregory Date: Tue, 8 Feb 2022 22:40:44 +0800 Subject: [PATCH 36/80] Update interface.html --- apps/authentiwatch/interface.html | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/authentiwatch/interface.html b/apps/authentiwatch/interface.html index d2213b819..5ee32fd8e 100644 --- a/apps/authentiwatch/interface.html +++ b/apps/authentiwatch/interface.html @@ -56,6 +56,7 @@ function base32clean(val, nows) { var ret = val.replaceAll(/\s+/g, ' '); ret = ret.replaceAll(/0/g, 'O'); ret = ret.replaceAll(/1/g, 'I'); + ret = ret.replaceAll(/8/g, 'B'); ret = ret.replaceAll(/[^A-Za-z2-7 ]/g, ''); if (nows) { ret = ret.replaceAll(/\s+/g, ''); From 33dc4954c25e537c86176a4887a6746616165069 Mon Sep 17 00:00:00 2001 From: Andrew Gregory Date: Sat, 19 Feb 2022 17:20:09 +0800 Subject: [PATCH 37/80] Update app.js Precalculate overall token height. Have Bangle1 list UI work more like a Pebble. --- apps/authentiwatch/app.js | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/apps/authentiwatch/app.js b/apps/authentiwatch/app.js index 640183230..b2c8f857b 100644 --- a/apps/authentiwatch/app.js +++ b/apps/authentiwatch/app.js @@ -1,5 +1,6 @@ const tokenextraheight = 16; var tokendigitsheight = 30; +var tokenheight = tokendigitsheight + tokenextraheight; // Hash functions const crypto = require("crypto"); const algos = { @@ -198,15 +199,15 @@ function draw() { } if (tokens.length > 0) { var drewcur = false; - var id = Math.floor(state.listy / (tokendigitsheight + tokenextraheight)); - var y = id * (tokendigitsheight + tokenextraheight) + Bangle.appRect.y - state.listy; + var id = Math.floor(state.listy / tokenheight); + var y = id * tokenheight + Bangle.appRect.y - state.listy; while (id < tokens.length && y < Bangle.appRect.y2) { - drawToken(id, {x:Bangle.appRect.x, y:y, w:Bangle.appRect.w, h:(tokendigitsheight + tokenextraheight)}); + drawToken(id, {x:Bangle.appRect.x, y:y, w:Bangle.appRect.w, h:tokenheight}); if (id == state.curtoken && (tokens[id].period <= 0 || state.nextTime != 0)) { drewcur = true; } id += 1; - y += (tokendigitsheight + tokenextraheight); + y += tokenheight; } if (drewcur) { // the current token has been drawn - schedule a redraw @@ -240,18 +241,18 @@ function draw() { function onTouch(zone, e) { if (e) { - var id = Math.floor((state.listy + (e.y - Bangle.appRect.y)) / (tokendigitsheight + tokenextraheight)); + var id = Math.floor((state.listy + (e.y - Bangle.appRect.y)) / tokenheight); if (id == state.curtoken || tokens.length == 0 || id >= tokens.length) { id = -1; } if (state.curtoken != id) { if (id != -1) { - var y = id * (tokendigitsheight + tokenextraheight) - state.listy; + var y = id * tokenheight - state.listy; if (y < 0) { state.listy += y; y = 0; } - y += (tokendigitsheight + tokenextraheight); + y += tokenheight; if (y > Bangle.appRect.h) { state.listy += (y - Bangle.appRect.h); } @@ -268,7 +269,7 @@ function onTouch(zone, e) { function onDrag(e) { if (e.x > g.getWidth() || e.y > g.getHeight()) return; if (e.dx == 0 && e.dy == 0) return; - var newy = Math.min(state.listy - e.dy, tokens.length * (tokendigitsheight + tokenextraheight) - Bangle.appRect.h); + var newy = Math.min(state.listy - e.dy, tokens.length * tokenheight - Bangle.appRect.h); state.listy = Math.max(0, newy); draw(); } @@ -300,8 +301,12 @@ function bangle1Btn(e) { } state.curtoken = Math.max(state.curtoken, 0); state.curtoken = Math.min(state.curtoken, tokens.length - 1); + state.listy = state.curtoken * tokenheight; + state.listy -= (Bangle.appRect.h - tokenheight) / 2; + state.listy = Math.min(state.listy, tokens.length * tokenheight - Bangle.appRect.h); + state.listy = Math.max(state.listy, 0); var fakee = {}; - fakee.y = state.curtoken * (tokendigitsheight + tokenextraheight) - state.listy + Bangle.appRect.y; + fakee.y = state.curtoken * tokenheight - state.listy + Bangle.appRect.y; state.curtoken = -1; state.nextTime = 0; onTouch(0, fakee); From 29432bb9f83aad7cb38b9f3a3feb3620f8d1e205 Mon Sep 17 00:00:00 2001 From: Stergios Mekras Date: Wed, 23 Feb 2022 09:24:33 +0100 Subject: [PATCH 38/80] Add screenshot --- apps/smclock/metadata.json | 1 + apps/smclock/screenshot.png | Bin 0 -> 2845 bytes 2 files changed, 1 insertion(+) create mode 100644 apps/smclock/screenshot.png diff --git a/apps/smclock/metadata.json b/apps/smclock/metadata.json index 1783ca7bf..febbdd01c 100644 --- a/apps/smclock/metadata.json +++ b/apps/smclock/metadata.json @@ -3,6 +3,7 @@ "name":"Monogram Watch Face", "shortName":"MonoClock", "icon":"app.png", + "screenshots": [{"url":"screenshot.png"}], "version":"0.02", "description": "A simple watchface based on my stylised monogram.", "tags":"clock", diff --git a/apps/smclock/screenshot.png b/apps/smclock/screenshot.png new file mode 100644 index 0000000000000000000000000000000000000000..c0e0bd0eed06e2c77e0ad737b1ecd4814a8e4f65 GIT binary patch literal 2845 zcmcgudpHyN8=tk+P{+{b62ho+%%#yO{TQVU%PnDOVr`<1%jR-2R%%KviO_N>(@8mn zvD`aGBXhqVwpdlrj z^iSd0)VdSVJ0Hvnf%0ky4%8UtrJ%xCOL@t&X@MBtb^!lp(1VDjt@sT7`1?~6b+Xs4 zS+pw|j5P4c2gpY~BUzWF&MfGLF_2Iu(EKyGS{%kHqU>bp2gsQ4nxr4|?3m z?h8_x<_;$0V@C-X%Kd6?31dp3byzYU5Jx0@c0iUC{15#G2 zVnpy8543+DACab7rFE?&qefz@fd{d9>C{4sxaacNBH^i6-U)d;{gV_e%mc4O)_wpI zV6{~XL&kvK!1N+5*nrX)ol&`XHJpLY&@3K>zmR;4pKU)KNk>I^ny)%hbaGt?>Ip|g zeF?nOd*gHc5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cqjj89-7XJ56H-@dX|_8?KtXJbx3)6wDn`0N>3E(-gOZrg=-WTLLQgRSc1 zJP$P?=Y>5P)AL1j`Mt^PjL}wE%gl)v7-mvpSBPx*b1qBwT>AnUY;}6N149F+cGQtl zn5gSqo_D(6eIsuJ<%_bx{P3Rzm*hWR`!2#u|E_*hEX$tYz{}}no8vRGj4+1>Jb-qX z^5zqWL&!T*F+GXxq|1CCwW<7J8?Qb>etu4(?=}2hX)KfEPm8VzVutB1X}dkNWG1!w zoJ4kX!gXK8t0o;o3~Pc|-tQfmnrrAx!WD3=k-@IWtBn<#W&)Fnp2Q=<-0D|@VHi>a zAO7?!d=mHIFivRBLUCo=d|xQ4m8?BhJgql=oq$}oH!e|af(;=!Dy3Ct#pcB={*C$Q zT94%W_trkud7dGb9f6(I#Vz|l1NlcQOss=6?cfL@vZYeex9RLNear&sfElkaHlR2{ zEFW!dO9|Wo*v8(AB@<>fW!@#@*-+ZU)o$>5a(MGIt^iB2nK%F`8F9v7a?p@ylpWcI zXfhmTaaTGBfBM^3@5X@pUHIu>N66!L;hXD*ThD=k$a0uJIQd0e1xkmC6*ecBBQXxS z-nf!4W(nM)Y^Zr=9@c>BG?xODd34iX{-TS6JY;Z3lGIaE!WCse4G_x#;r~5kI8AH= YUdx_>rDxQ4@7%ip9M&0AYD0|sC!%XI-v9sr literal 0 HcmV?d00001 From 812c8ba7c1a228ca33eb162b80f7ed85b22acc01 Mon Sep 17 00:00:00 2001 From: Stergios Mekras Date: Fri, 25 Feb 2022 21:54:38 +0100 Subject: [PATCH 39/80] Introduce settings --- apps/smclock/README.md | 18 +++++++ apps/smclock/app.js | 20 ++++--- apps/smclock/metadata.json | 1 + apps/smclock/settings.js | 108 +++++++++++++++++++++++++++++++++++++ 4 files changed, 139 insertions(+), 8 deletions(-) create mode 100644 apps/smclock/settings.js diff --git a/apps/smclock/README.md b/apps/smclock/README.md index 7b5613147..635292d0c 100644 --- a/apps/smclock/README.md +++ b/apps/smclock/README.md @@ -3,3 +3,21 @@ Just a simple watch face for the Banglejs2. It shows battery level in the upper left corner, date information in the upper right, and time information in the bottom. + +![](screenshot.png) + +## Settings + +**Analog Clock:** + +**Human Readable Date:** When the setting is on, the date is shown in a more human-friendly format (e.g. "Oct 2"), otherwise the date is shown in a standard format (e.g. "02/10"). Default is off. + +**Show Week Info:** When the setting is on, the weekday and week number are shown in the upper right box. When the setting is off, the full year is shown instead. Default is off. + +**Vector Font:** When the setting is on, the app uses Espruino's vector font, otherwise it uses the default font. Default is off. + +## Using the app + +Monogram Watch Face can be selected as the default clock or it can be run manually from the launcher. Its settings can be accessed and changed via the relevant menu. + +Tapping on the "Alerts" area will replace the current time display with the time of the most immediate alert. diff --git a/apps/smclock/app.js b/apps/smclock/app.js index 6aff72a46..9b0ec85d0 100644 --- a/apps/smclock/app.js +++ b/apps/smclock/app.js @@ -1,13 +1,17 @@ +const SETTINGSFILE = "smclock.json"; const background = { - width : 176, height : 176, bpp : 3, - transparent : 1, + width : 176, height : 176, bpp : 3, transparent : 1, buffer : require("heatshrink").decompress(atob("/4A/AH4ACUb8H9MkyVJAThB/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/INP/AH4A/AAX8Yz4Afn5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/INI=")) }; - +const monthName = ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]; const weekday = ["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]; -var level = -1; -function ISO8601_week_no(date) { //copied from: https://gist.github.com/IamSilviu/5899269#gistcomment-3035480 +// dynamic variables +var batLevel = -1; +var batColor = [0,0,0]; + +// copied from: https://gist.github.com/IamSilviu/5899269#gistcomment-3035480 +function ISO8601_week_no(date) { var tdt = new Date(date.valueOf()); var dayn = (date.getDay() + 6) % 7; tdt.setDate(tdt.getDate() - dayn + 3); @@ -24,8 +28,8 @@ function d02(value) { } function pollBattery() { - level = E.getBattery(); - return level; + batLevel = E.getBattery(); + return batLevel; } function getBatteryColor(level) { @@ -100,7 +104,7 @@ Bangle.on('lcdPower',on=>{ drawInterval = setInterval(draw, 10000); pollBattery(); - draw(); // draw immediately + draw(); } }); diff --git a/apps/smclock/metadata.json b/apps/smclock/metadata.json index febbdd01c..79d996f2c 100644 --- a/apps/smclock/metadata.json +++ b/apps/smclock/metadata.json @@ -12,6 +12,7 @@ "allow_emulator": true, "storage": [ {"name":"smclock.app.js","url":"app.js"}, + {"name":"smclock.settings.js","url":"settings.js"}, {"name":"smclock.img","url":"app-icon.js","evaluate":true} ] } diff --git a/apps/smclock/settings.js b/apps/smclock/settings.js new file mode 100644 index 000000000..bfc738e19 --- /dev/null +++ b/apps/smclock/settings.js @@ -0,0 +1,108 @@ +// Settings menu for Monogram Watch Face +// Anton Clock settings were used as template + +(function(back) { + var FILE = "smclock.json"; + // Load settings + var settings = Object.assign({ + secondsOnUnlock: false, + }, require('Storage').readJSON(FILE, true) || {}); + + function writeSettings() { + require('Storage').writeJSON(FILE, settings); + } + + // Helper method which uses int-based menu item for set of string values + function stringItems(startvalue, writer, values) { + return { + value: (startvalue === undefined ? 0 : values.indexOf(startvalue)), + format: v => values[v], + min: 0, + max: values.length - 1, + wrap: true, + step: 1, + onchange: v => { + writer(values[v]); + writeSettings(); + } + }; + } + + // Helper method which breaks string set settings down to local settings object + function stringInSettings(name, values) { + return stringItems(settings[name], v => settings[name] = v, values); + } + + var mainmenu = { + "": { + "title": "Monogram Clock" + }, + "< Back": () => back(), + "Seconds...": () => E.showMenu(secmenu), + "Date": stringInSettings("dateOnMain", ["Long", "Short", "ISO8601"]), + "Show Weekday": { + value: (settings.weekDay !== undefined ? settings.weekDay : true), + format: v => v ? "On" : "Off", + onchange: v => { + settings.weekDay = v; + writeSettings(); + } + }, + "Show CalWeek": { + value: (settings.calWeek !== undefined ? settings.calWeek : false), + format: v => v ? "On" : "Off", + onchange: v => { + settings.calWeek = v; + writeSettings(); + } + }, + "Uppercase": { + value: (settings.upperCase !== undefined ? settings.upperCase : true), + format: v => v ? "On" : "Off", + onchange: v => { + settings.upperCase = v; + writeSettings(); + } + }, + "Vector font": { + value: (settings.vectorFont !== undefined ? settings.vectorFont : false), + format: v => v ? "On" : "Off", + onchange: v => { + settings.vectorFont = v; + writeSettings(); + } + }, + }; + + // Submenu + var secmenu = { + "": { + "title": "Show seconds..." + }, + "< Back": () => E.showMenu(mainmenu), + "Show": stringInSettings("secondsMode", ["Never", "Unlocked", "Always"]), + "With \":\"": { + value: (settings.secondsWithColon !== undefined ? settings.secondsWithColon : true), + format: v => v ? "On" : "Off", + onchange: v => { + settings.secondsWithColon = v; + writeSettings(); + } + }, + "Color": { + value: (settings.secondsColoured !== undefined ? settings.secondsColoured : true), + format: v => v ? "On" : "Off", + onchange: v => { + settings.secondsColoured = v; + writeSettings(); + } + }, + "Date": stringInSettings("dateOnSecs", ["Year", "Weekday", "No"]) + }; + + // Actually display the menu + E.showMenu(mainmenu); + +}); + +// end of file From ac29a4f5a54aad523f8cf68047103dd46be1f17a Mon Sep 17 00:00:00 2001 From: Stergios Mekras Date: Sun, 27 Feb 2022 23:22:32 +0100 Subject: [PATCH 40/80] Fix battery color --- apps/smclock/app.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/smclock/app.js b/apps/smclock/app.js index 9b0ec85d0..b900e4d9e 100644 --- a/apps/smclock/app.js +++ b/apps/smclock/app.js @@ -29,13 +29,13 @@ function d02(value) { function pollBattery() { batLevel = E.getBattery(); - return batLevel; } function getBatteryColor(level) { var color; if (level < 0) { - level = pollBattery(); + pollBattery(); + level = batLevel; } if(level>80) { color = [0,0,1]; @@ -54,7 +54,7 @@ function getBatteryColor(level) { function draw() { g.drawImage(background); - const color = getBatteryColor(); + const color = getBatteryColor(batLevel); const bat = d02(E.getBattery()) + "%"; const d = new Date(); const day = d.getDate(); From 52d54c9234d158a27eb9212daf63500d1d03e76d Mon Sep 17 00:00:00 2001 From: Gordon Williams Date: Mon, 28 Feb 2022 13:10:55 +0000 Subject: [PATCH 41/80] Remove BangleRun as it's unmaintained and no longer works nicely with PR #1052 for Typescript support Remove Travis builds as we're now switching to GitHub actions --- .travis.yml | 3 - apps/banglerun/ChangeLog | 13 -- apps/banglerun/activity.js | 40 ------- apps/banglerun/activity.ts | 41 ------- apps/banglerun/app-icon.js | 1 - apps/banglerun/app.js | 15 --- apps/banglerun/app.ts | 20 ---- apps/banglerun/banglerun.png | Bin 10456 -> 0 bytes apps/banglerun/display.js | 106 ----------------- apps/banglerun/display.ts | 123 ------------------- apps/banglerun/gps.js | 71 ----------- apps/banglerun/gps.ts | 90 -------------- apps/banglerun/hrm.js | 19 --- apps/banglerun/hrm.ts | 29 ----- apps/banglerun/interface.html | 217 ---------------------------------- apps/banglerun/log.js | 37 ------ apps/banglerun/log.ts | 47 -------- apps/banglerun/metadata.json | 16 --- apps/banglerun/state.js | 37 ------ apps/banglerun/state.ts | 93 --------------- apps/banglerun/step.js | 14 --- apps/banglerun/step.ts | 15 --- 22 files changed, 1047 deletions(-) delete mode 100644 .travis.yml delete mode 100644 apps/banglerun/ChangeLog delete mode 100644 apps/banglerun/activity.js delete mode 100644 apps/banglerun/activity.ts delete mode 100644 apps/banglerun/app-icon.js delete mode 100644 apps/banglerun/app.js delete mode 100644 apps/banglerun/app.ts delete mode 100644 apps/banglerun/banglerun.png delete mode 100644 apps/banglerun/display.js delete mode 100644 apps/banglerun/display.ts delete mode 100644 apps/banglerun/gps.js delete mode 100644 apps/banglerun/gps.ts delete mode 100644 apps/banglerun/hrm.js delete mode 100644 apps/banglerun/hrm.ts delete mode 100644 apps/banglerun/interface.html delete mode 100644 apps/banglerun/log.js delete mode 100644 apps/banglerun/log.ts delete mode 100644 apps/banglerun/metadata.json delete mode 100644 apps/banglerun/state.js delete mode 100644 apps/banglerun/state.ts delete mode 100644 apps/banglerun/step.js delete mode 100644 apps/banglerun/step.ts diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index f3d0d2159..000000000 --- a/.travis.yml +++ /dev/null @@ -1,3 +0,0 @@ -language: node_js -node_js: - - "node" diff --git a/apps/banglerun/ChangeLog b/apps/banglerun/ChangeLog deleted file mode 100644 index c778588cc..000000000 --- a/apps/banglerun/ChangeLog +++ /dev/null @@ -1,13 +0,0 @@ -0.01: First release -0.02: Bugfix time: Reset minutes to 0 when hitting 60 -0.03: Fix distance >=10 km (fix #529) -0.04: Use offscreen buffer for flickerless updates -0.05: Complete rewrite. New UI, GPS & HRM Kalman filters, activity logging -0.06: Reading HDOP directly from the GPS event (needs Espruino 2v07 or above) -0.07: Fixed GPS update, added guards against NaN values -0.08: Fix issue with GPS coordinates being wrong after the first one -0.09: Another GPS fix (log raw coordinates - not filtered ones) -0.10: Removed kalman filtering to allow distance log to work - Only log data every 5 seconds (not 1 sec) - Don't create a file until the first log entry is ready - Add labels for buttons diff --git a/apps/banglerun/activity.js b/apps/banglerun/activity.js deleted file mode 100644 index 94512094c..000000000 --- a/apps/banglerun/activity.js +++ /dev/null @@ -1,40 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.stopActivity = exports.startActivity = exports.clearActivity = void 0; -const display_1 = require("./display"); -const log_1 = require("./log"); -const state_1 = require("./state"); -function startActivity(state) { - if (state.status === state_1.ActivityStatus.Stopped) { - (0, log_1.initLog)(state); - } - if (state.status === state_1.ActivityStatus.Running) { - state.status = state_1.ActivityStatus.Paused; - } - else { - state.status = state_1.ActivityStatus.Running; - } - (0, display_1.draw)(state); -} -exports.startActivity = startActivity; -function stopActivity(state) { - if (state.status === state_1.ActivityStatus.Paused) { - clearActivity(state); - } - if (state.status === state_1.ActivityStatus.Running) { - state.status = state_1.ActivityStatus.Paused; - } - else { - state.status = state_1.ActivityStatus.Stopped; - } - (0, display_1.draw)(state); -} -exports.stopActivity = stopActivity; -function clearActivity(state) { - state.duration = 0; - state.distance = 0; - state.speed = 0; - state.steps = 0; - state.cadence = 0; -} -exports.clearActivity = clearActivity; diff --git a/apps/banglerun/activity.ts b/apps/banglerun/activity.ts deleted file mode 100644 index c1a01f30b..000000000 --- a/apps/banglerun/activity.ts +++ /dev/null @@ -1,41 +0,0 @@ -import { draw } from './display'; -import { initLog } from './log'; -import { ActivityStatus, AppState } from './state'; - -function startActivity(state: AppState): void { - if (state.status === ActivityStatus.Stopped) { - initLog(state); - } - - if (state.status === ActivityStatus.Running) { - state.status = ActivityStatus.Paused; - } else { - state.status = ActivityStatus.Running; - } - - draw(state); -} - -function stopActivity(state: AppState): void { - if (state.status === ActivityStatus.Paused) { - clearActivity(state); - } - - if (state.status === ActivityStatus.Running) { - state.status = ActivityStatus.Paused; - } else { - state.status = ActivityStatus.Stopped; - } - - draw(state); -} - -function clearActivity(state: AppState): void { - state.duration = 0; - state.distance = 0; - state.speed = 0; - state.steps = 0; - state.cadence = 0; -} - -export { clearActivity, startActivity, stopActivity }; diff --git a/apps/banglerun/app-icon.js b/apps/banglerun/app-icon.js deleted file mode 100644 index 9eeaced6e..000000000 --- a/apps/banglerun/app-icon.js +++ /dev/null @@ -1 +0,0 @@ -require("heatshrink").decompress(atob("mEwwIHEuAEDgP8ApMDAqAXBjAGD/E8AgUcgF8CAX/BgIFBn//wAFCv//8PwAoP///5Aon/8AcB+IFB4AFB8P/34FBgfj/8fwAFB4f+g4cBg/H/w/Cg+HKQcPx4FEh4/CAoMfAocOj4/CKYRwELIIFDLII6BAoZSBLIYeCgP+v4FD/k/GAQFBHgcD/ABBIIX4gIFBSYPwAoUPAog/B8AFEwAFDDQQCBQoQFCZYYFigCKEgFwgAA==")) diff --git a/apps/banglerun/app.js b/apps/banglerun/app.js deleted file mode 100644 index 84d03820a..000000000 --- a/apps/banglerun/app.js +++ /dev/null @@ -1,15 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -const activity_1 = require("./activity"); -const display_1 = require("./display"); -const gps_1 = require("./gps"); -const hrm_1 = require("./hrm"); -const state_1 = require("./state"); -const step_1 = require("./step"); -const appState = (0, state_1.initState)(); -(0, gps_1.initGps)(appState); -(0, hrm_1.initHrm)(appState); -(0, step_1.initStep)(appState); -(0, display_1.initDisplay)(appState); -setWatch(() => (0, activity_1.startActivity)(appState), BTN1, { repeat: true, edge: 'falling' }); -setWatch(() => (0, activity_1.stopActivity)(appState), BTN3, { repeat: true, edge: 'falling' }); diff --git a/apps/banglerun/app.ts b/apps/banglerun/app.ts deleted file mode 100644 index 7093e24e0..000000000 --- a/apps/banglerun/app.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { startActivity, stopActivity } from './activity'; -import { initDisplay } from './display'; -import { initGps } from './gps'; -import { initHrm } from './hrm'; -import { initState } from './state'; -import { initStep } from './step'; - -declare var BTN1: any; -declare var BTN3: any; -declare var setWatch: any; - -const appState = initState(); - -initGps(appState); -initHrm(appState); -initStep(appState); -initDisplay(appState); - -setWatch(() => startActivity(appState), BTN1, { repeat: true, edge: 'falling' }); -setWatch(() => stopActivity(appState), BTN3, { repeat: true, edge: 'falling' }); diff --git a/apps/banglerun/banglerun.png b/apps/banglerun/banglerun.png deleted file mode 100644 index bf2cd8af3ef5f9711d18df1656a03a98283bcc67..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 10456 zcmV;}C@0s6P) zaB^>EX>4U6ba`-PAZ2)IW&i+q+O3>tk{!8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yB{KpYnKa6P)`5>1e@x{2iTR=&0cUhV-ELQDle>}d*NXR`B-t(12#7Oo z)51eUcZtbBLX@P3ITPpW=JrPW+ND(jKO~i#dt1@23uV@wpE@bDF#iC2b#dMc4qXBO O0000 { - state.drawing = on; - if (on) { - drawAll(state); - } - }); - drawAll(state); -} -exports.initDisplay = initDisplay; -function drawBackground() { - g.clear(); - g.setColor(0xC618); - g.setFont('6x8', 2); - g.setFontAlign(0, -1, 0); - g.drawString('DIST (KM)', 60, 32); - g.drawString('TIME', 172, 32); - g.drawString('PACE', 60, 92); - g.drawString('HEART', 172, 92); - g.drawString('STEPS', 60, 152); - g.drawString('CADENCE', 172, 152); -} -exports.drawBackground = drawBackground; -function drawValue(value, x, y) { - g.setColor(0x0000); - g.fillRect(x - 60, y, x + 60, y + 30); - g.setColor(0xFFFF); - g.drawString(value, x, y); -} -exports.drawValue = drawValue; -function draw(state) { - g.setFontVector(30); - g.setFontAlign(0, -1, 0); - drawValue(formatDistance(state.distance), 60, 55); - drawValue(formatTime(state.duration), 172, 55); - drawValue(formatPace(state.speed), 60, 115); - drawValue(state.hr.toFixed(0), 172, 115); - drawValue(state.steps.toFixed(0), 60, 175); - drawValue(state.cadence.toFixed(0), 172, 175); - g.setFont('6x8', 2); - g.setColor(state.gpsValid ? 0x07E0 : 0xF800); - g.fillRect(0, 216, 80, 240); - g.setColor(0x0000); - g.drawString('GPS', 40, 220); - g.setColor(0xFFFF); - g.fillRect(80, 216, 160, 240); - g.setColor(0x0000); - g.drawString(formatClock(new Date()), 120, 220); - g.setColor(STATUS_COLORS[state.status]); - g.fillRect(160, 216, 230, 240); - g.setColor(0x0000); - g.drawString(state.status, 200, 220); - g.setFont("6x8").setFontAlign(0, 0, 1).setColor(-1); - if (state.status === state_1.ActivityStatus.Paused) { - g.drawString("START", 236, 60, 1).drawString(" CLEAR ", 236, 180, 1); - } - else if (state.status === state_1.ActivityStatus.Running) { - g.drawString(" PAUSE ", 236, 60, 1).drawString(" PAUSE ", 236, 180, 1); - } - else { - g.drawString("START", 236, 60, 1).drawString(" ", 236, 180, 1); - } -} -exports.draw = draw; -function drawAll(state) { - drawBackground(); - draw(state); - Bangle.drawWidgets(); -} -exports.drawAll = drawAll; -function formatClock(date) { - return ('0' + date.getHours()).substr(-2) + ':' + ('0' + date.getMinutes()).substr(-2); -} -exports.formatClock = formatClock; -function formatDistance(meters) { - return (meters / 1000).toFixed(2); -} -exports.formatDistance = formatDistance; -function formatPace(speed) { - if (speed < 0.1667) { - return `__'__"`; - } - const pace = Math.round(1000 / speed); - const min = Math.floor(pace / 60); - const sec = pace % 60; - return ('0' + min).substr(-2) + `'` + ('0' + sec).substr(-2) + `"`; -} -exports.formatPace = formatPace; -function formatTime(time) { - const seconds = Math.round(time); - const hrs = Math.floor(seconds / 3600); - const min = Math.floor(seconds / 60) % 60; - const sec = seconds % 60; - return (hrs ? hrs + ':' : '') + ('0' + min).substr(-2) + `:` + ('0' + sec).substr(-2); -} -exports.formatTime = formatTime; diff --git a/apps/banglerun/display.ts b/apps/banglerun/display.ts deleted file mode 100644 index 528890c35..000000000 --- a/apps/banglerun/display.ts +++ /dev/null @@ -1,123 +0,0 @@ -import { ActivityStatus, AppState } from './state'; - -declare var Bangle: any; -declare var g: any; - -const STATUS_COLORS = { - 'STOP': 0xF800, - 'PAUSE': 0xFFE0, - 'RUN': 0x07E0, -} - -function initDisplay(state: AppState): void { - Bangle.loadWidgets(); - Bangle.on('lcdPower', (on: boolean) => { - state.drawing = on; - if (on) { - drawAll(state); - } - }); - drawAll(state); -} - -function drawBackground(): void { - g.clear(); - g.setColor(0xC618); - g.setFont('6x8', 2); - g.setFontAlign(0, -1, 0); - g.drawString('DIST (KM)', 60, 32); - g.drawString('TIME', 172, 32); - g.drawString('PACE', 60, 92); - g.drawString('HEART', 172, 92); - g.drawString('STEPS', 60, 152); - g.drawString('CADENCE', 172, 152); -} - -function drawValue(value: string, x: number, y: number) { - g.setColor(0x0000); - g.fillRect(x - 60, y, x + 60, y + 30); - g.setColor(0xFFFF); - g.drawString(value, x, y); -} - -function draw(state: AppState): void { - g.setFontVector(30); - g.setFontAlign(0, -1, 0); - - drawValue(formatDistance(state.distance), 60, 55); - drawValue(formatTime(state.duration), 172, 55); - drawValue(formatPace(state.speed), 60, 115); - drawValue(state.hr.toFixed(0), 172, 115); - drawValue(state.steps.toFixed(0), 60, 175); - drawValue(state.cadence.toFixed(0), 172, 175); - - g.setFont('6x8', 2); - - g.setColor(state.gpsValid ? 0x07E0 : 0xF800); - g.fillRect(0, 216, 80, 240); - g.setColor(0x0000); - g.drawString('GPS', 40, 220); - - g.setColor(0xFFFF); - g.fillRect(80, 216, 160, 240); - g.setColor(0x0000); - g.drawString(formatClock(new Date()), 120, 220); - - g.setColor(STATUS_COLORS[state.status]); - g.fillRect(160, 216, 230, 240); - g.setColor(0x0000); - g.drawString(state.status, 200, 220); - - g.setFont("6x8").setFontAlign(0,0,1).setColor(-1); - if (state.status === ActivityStatus.Paused) { - g.drawString("START",236,60,1).drawString(" CLEAR ",236,180,1); - } else if (state.status === ActivityStatus.Running) { - g.drawString(" PAUSE ",236,60,1).drawString(" PAUSE ",236,180,1); - } else { - g.drawString("START",236,60,1).drawString(" ",236,180,1); - } -} - -function drawAll(state: AppState) { - drawBackground(); - draw(state); - Bangle.drawWidgets(); -} - -function formatClock(date: Date): string { - return ('0' + date.getHours()).substr(-2) + ':' + ('0' + date.getMinutes()).substr(-2); -} - -function formatDistance(meters: number): string { - return (meters / 1000).toFixed(2); -} - -function formatPace(speed: number): string { - if (speed < 0.1667) { - return `__'__"`; - } - const pace = Math.round(1000 / speed); - const min = Math.floor(pace / 60); - const sec = pace % 60; - return ('0' + min).substr(-2) + `'` + ('0' + sec).substr(-2) + `"`; -} - -function formatTime(time: number): string { - const seconds = Math.round(time); - const hrs = Math.floor(seconds / 3600); - const min = Math.floor(seconds / 60) % 60; - const sec = seconds % 60; - return (hrs ? hrs + ':' : '') + ('0' + min).substr(-2) + `:` + ('0' + sec).substr(-2); -} - -export { - draw, - drawAll, - drawBackground, - drawValue, - formatClock, - formatDistance, - formatPace, - formatTime, - initDisplay, -}; diff --git a/apps/banglerun/gps.js b/apps/banglerun/gps.js deleted file mode 100644 index 35e0f8769..000000000 --- a/apps/banglerun/gps.js +++ /dev/null @@ -1,71 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.updateGps = exports.readGps = exports.initGps = void 0; -const display_1 = require("./display"); -const log_1 = require("./log"); -const state_1 = require("./state"); -const EARTH_RADIUS = 6371008.8; -function initGps(state) { - Bangle.on('GPS', (gps) => readGps(state, gps)); - Bangle.setGPSPower(1); -} -exports.initGps = initGps; -function readGps(state, gps) { - state.lat = gps.lat; - state.lon = gps.lon; - state.alt = gps.alt; - state.vel = gps.speed / 3.6; - state.fix = gps.fix; - state.dop = gps.hdop; - state.gpsValid = state.fix > 0; - updateGps(state); - (0, display_1.draw)(state); - /* Only log GPS data every 5 secs if we - have a fix and we're running. */ - if (state.gpsValid && - state.status === state_1.ActivityStatus.Running && - state.timeSinceLog > 5) { - state.timeSinceLog = 0; - (0, log_1.updateLog)(state); - } -} -exports.readGps = readGps; -function updateGps(state) { - const t = Date.now(); - let dt = (t - state.t) / 1000; - if (!isFinite(dt)) - dt = 0; - state.t = t; - state.timeSinceLog += dt; - if (state.status === state_1.ActivityStatus.Running) { - state.duration += dt; - } - if (!state.gpsValid) { - return; - } - const r = EARTH_RADIUS + state.alt; - const lat = state.lat * Math.PI / 180; - const lon = state.lon * Math.PI / 180; - const x = r * Math.cos(lat) * Math.cos(lon); - const y = r * Math.cos(lat) * Math.sin(lon); - const z = r * Math.sin(lat); - if (!state.x) { - state.x = x; - state.y = y; - state.z = z; - return; - } - const dx = x - state.x; - const dy = y - state.y; - const dz = z - state.z; - const dpMag = Math.sqrt(dx * dx + dy * dy + dz * dz); - state.x = x; - state.y = y; - state.z = z; - if (state.status === state_1.ActivityStatus.Running) { - state.distance += dpMag; - state.speed = (state.distance / state.duration) || 0; - state.cadence = (60 * state.steps / state.duration) || 0; - } -} -exports.updateGps = updateGps; diff --git a/apps/banglerun/gps.ts b/apps/banglerun/gps.ts deleted file mode 100644 index 1886ecfb2..000000000 --- a/apps/banglerun/gps.ts +++ /dev/null @@ -1,90 +0,0 @@ -import { draw } from './display'; -import { updateLog } from './log'; -import { ActivityStatus, AppState } from './state'; - -declare var Bangle: any; - -interface GpsEvent { - lat: number; - lon: number; - alt: number; - speed: number; - hdop: number; - fix: number; -} - -const EARTH_RADIUS = 6371008.8; - -function initGps(state: AppState): void { - Bangle.on('GPS', (gps: GpsEvent) => readGps(state, gps)); - Bangle.setGPSPower(1); -} - -function readGps(state: AppState, gps: GpsEvent): void { - state.lat = gps.lat; - state.lon = gps.lon; - state.alt = gps.alt; - state.vel = gps.speed / 3.6; - state.fix = gps.fix; - state.dop = gps.hdop; - state.gpsValid = state.fix > 0; - - updateGps(state); - draw(state); - - /* Only log GPS data every 5 secs if we - have a fix and we're running. */ - if (state.gpsValid && - state.status === ActivityStatus.Running && - state.timeSinceLog > 5) { - state.timeSinceLog = 0; - updateLog(state); - } -} - -function updateGps(state: AppState): void { - const t = Date.now(); - let dt = (t - state.t) / 1000; - if (!isFinite(dt)) dt=0; - state.t = t; - state.timeSinceLog += dt; - - if (state.status === ActivityStatus.Running) { - state.duration += dt; - } - - if (!state.gpsValid) { - return; - } - - const r = EARTH_RADIUS + state.alt; - const lat = state.lat * Math.PI / 180; - const lon = state.lon * Math.PI / 180; - const x = r * Math.cos(lat) * Math.cos(lon); - const y = r * Math.cos(lat) * Math.sin(lon); - const z = r * Math.sin(lat); - - if (!state.x) { - state.x = x; - state.y = y; - state.z = z; - return; - } - - const dx = x - state.x; - const dy = y - state.y; - const dz = z - state.z; - const dpMag = Math.sqrt(dx * dx + dy * dy + dz * dz); - - state.x = x; - state.y = y; - state.z = z; - - if (state.status === ActivityStatus.Running) { - state.distance += dpMag; - state.speed = (state.distance / state.duration) || 0; - state.cadence = (60 * state.steps / state.duration) || 0; - } -} - -export { initGps, readGps, updateGps }; diff --git a/apps/banglerun/hrm.js b/apps/banglerun/hrm.js deleted file mode 100644 index c002de2f6..000000000 --- a/apps/banglerun/hrm.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.updateHrm = exports.initHrm = void 0; -function initHrm(state) { - Bangle.on('HRM', (hrm) => updateHrm(state, hrm)); - Bangle.setHRMPower(1); -} -exports.initHrm = initHrm; -function updateHrm(state, hrm) { - if (hrm.confidence === 0) { - return; - } - const dHr = hrm.bpm - state.hr; - const hrError = Math.abs(dHr) + 101 - hrm.confidence; - const hrGain = (state.hrError / (state.hrError + hrError)) || 0; - state.hr += dHr * hrGain; - state.hrError += (hrError - state.hrError) * hrGain; -} -exports.updateHrm = updateHrm; diff --git a/apps/banglerun/hrm.ts b/apps/banglerun/hrm.ts deleted file mode 100644 index 08dd237a7..000000000 --- a/apps/banglerun/hrm.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { AppState } from './state'; - -interface HrmData { - bpm: number; - confidence: number; - raw: string; -} - -declare var Bangle: any; - -function initHrm(state: AppState) { - Bangle.on('HRM', (hrm: HrmData) => updateHrm(state, hrm)); - Bangle.setHRMPower(1); -} - -function updateHrm(state: AppState, hrm: HrmData) { - if (hrm.confidence === 0) { - return; - } - - const dHr = hrm.bpm - state.hr; - const hrError = Math.abs(dHr) + 101 - hrm.confidence; - const hrGain = (state.hrError / (state.hrError + hrError)) || 0; - - state.hr += dHr * hrGain; - state.hrError += (hrError - state.hrError) * hrGain; -} - -export { initHrm, updateHrm }; diff --git a/apps/banglerun/interface.html b/apps/banglerun/interface.html deleted file mode 100644 index 6388d3b65..000000000 --- a/apps/banglerun/interface.html +++ /dev/null @@ -1,217 +0,0 @@ - - - - - -
- - - - - diff --git a/apps/banglerun/log.js b/apps/banglerun/log.js deleted file mode 100644 index 0cdeaa964..000000000 --- a/apps/banglerun/log.js +++ /dev/null @@ -1,37 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.updateLog = exports.initLog = void 0; -function initLog(state) { - const datetime = new Date().toISOString().replace(/[-:]/g, ''); - const date = datetime.substr(2, 6); - const time = datetime.substr(9, 6); - const filename = `banglerun_${date}_${time}`; - return Object.assign(Object.assign({}, state), { file: require('Storage').open(filename, 'w'), fileWritten: false }); -} -exports.initLog = initLog; -function updateLog(state) { - if (!state.fileWritten) { - state.file.write([ - 'timestamp', - 'latitude', - 'longitude', - 'altitude', - 'duration', - 'distance', - 'heartrate', - 'steps', - ].join(',') + '\n'); - state.fileWritten = true; - } - state.file.write([ - Date.now().toFixed(0), - state.lat.toFixed(6), - state.lon.toFixed(6), - state.alt.toFixed(2), - state.duration.toFixed(0), - state.distance.toFixed(2), - state.hr.toFixed(0), - state.steps.toFixed(0), - ].join(',') + '\n'); -} -exports.updateLog = updateLog; diff --git a/apps/banglerun/log.ts b/apps/banglerun/log.ts deleted file mode 100644 index ba1c1f00e..000000000 --- a/apps/banglerun/log.ts +++ /dev/null @@ -1,47 +0,0 @@ -import { AppState, AppStateWithLog } from './state'; - -declare var require: any; - -function initLog(state: AppState): AppStateWithLog { - const datetime = new Date().toISOString().replace(/[-:]/g, ''); - const date = datetime.substr(2, 6); - const time = datetime.substr(9, 6); - const filename = `banglerun_${date}_${time}`; - return { - ...state, - file: require('Storage').open(filename, 'w'), - fileWritten: false, - } as AppStateWithLog; -} - -function updateLog(state: AppStateWithLog): void { - if (!state.fileWritten) { - state.file.write( - [ - 'timestamp', - 'latitude', - 'longitude', - 'altitude', - 'duration', - 'distance', - 'heartrate', - 'steps', - ].join(',') + '\n' - ); - state.fileWritten = true; - } - state.file.write( - [ - Date.now().toFixed(0), - state.lat.toFixed(6), - state.lon.toFixed(6), - state.alt.toFixed(2), - state.duration.toFixed(0), - state.distance.toFixed(2), - state.hr.toFixed(0), - state.steps.toFixed(0), - ].join(',') + '\n' - ); -} - -export { initLog, updateLog }; diff --git a/apps/banglerun/metadata.json b/apps/banglerun/metadata.json deleted file mode 100644 index d66441c8d..000000000 --- a/apps/banglerun/metadata.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "id": "banglerun", - "name": "BangleRun", - "shortName": "BangleRun", - "version": "0.10", - "description": "An app for running sessions. Displays info and logs your run for later viewing.", - "icon": "banglerun.png", - "tags": "run,running,fitness,outdoors", - "supports": ["BANGLEJS"], - "interface": "interface.html", - "allow_emulator": false, - "storage": [ - {"name":"banglerun.app.js","url":"app.js"}, - {"name":"banglerun.img","url":"app-icon.js","evaluate":true} - ] -} diff --git a/apps/banglerun/state.js b/apps/banglerun/state.js deleted file mode 100644 index 349ef1954..000000000 --- a/apps/banglerun/state.js +++ /dev/null @@ -1,37 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.initState = exports.ActivityStatus = void 0; -var ActivityStatus; -(function (ActivityStatus) { - ActivityStatus["Stopped"] = "STOP"; - ActivityStatus["Paused"] = "PAUSE"; - ActivityStatus["Running"] = "RUN"; -})(ActivityStatus || (ActivityStatus = {})); -exports.ActivityStatus = ActivityStatus; -function initState() { - return { - fix: NaN, - lat: NaN, - lon: NaN, - alt: NaN, - vel: NaN, - dop: NaN, - gpsValid: false, - x: NaN, - y: NaN, - z: NaN, - t: NaN, - timeSinceLog: 0, - hr: 60, - hrError: 100, - fileWritten: false, - drawing: false, - status: ActivityStatus.Stopped, - duration: 0, - distance: 0, - speed: 0, - steps: 0, - cadence: 0, - }; -} -exports.initState = initState; diff --git a/apps/banglerun/state.ts b/apps/banglerun/state.ts deleted file mode 100644 index 1ba9bca26..000000000 --- a/apps/banglerun/state.ts +++ /dev/null @@ -1,93 +0,0 @@ -enum ActivityStatus { - Stopped = 'STOP', - Paused = 'PAUSE', - Running = 'RUN', -} - -interface BasicAppState { - // GPS NMEA data - fix: number; - lat: number; - lon: number; - alt: number; - vel: number; - dop: number; - gpsValid: boolean; - - // Absolute position data - x: number; - y: number; - z: number; - // Last fix time - t: number; - // Last time we saved log info - timeSinceLog : number; - - // HRM data - hr: number, - hrError: number, - - // Logger data - fileWritten: boolean; - - // Drawing data - drawing: boolean; - - // Activity data - duration: number; - distance: number; - speed: number; - steps: number; - cadence: number; -} - -interface AppStateWithoutLog extends BasicAppState { - status: 'STOP'; -} - -interface AppStateWithLog extends BasicAppState { - file: File; - status: ActivityStatus; -} - -type AppState = AppStateWithLog | AppStateWithoutLog; - -interface File { - read: Function; - write: Function; - erase: Function; -} - -function initState(): AppState { - return { - fix: NaN, - lat: NaN, - lon: NaN, - alt: NaN, - vel: NaN, - dop: NaN, - gpsValid: false, - - x: NaN, - y: NaN, - z: NaN, - t: NaN, - timeSinceLog : 0, - - hr: 60, - hrError: 100, - - fileWritten: false, - - drawing: false, - - status: ActivityStatus.Stopped, - duration: 0, - distance: 0, - speed: 0, - steps: 0, - cadence: 0, - } -} - -export { ActivityStatus, AppState, AppStateWithLog, File, initState }; diff --git a/apps/banglerun/step.js b/apps/banglerun/step.js deleted file mode 100644 index e4acfd66a..000000000 --- a/apps/banglerun/step.js +++ /dev/null @@ -1,14 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.updateStep = exports.initStep = void 0; -const state_1 = require("./state"); -function initStep(state) { - Bangle.on('step', () => updateStep(state)); -} -exports.initStep = initStep; -function updateStep(state) { - if (state.status === state_1.ActivityStatus.Running) { - state.steps += 1; - } -} -exports.updateStep = updateStep; diff --git a/apps/banglerun/step.ts b/apps/banglerun/step.ts deleted file mode 100644 index c7fcb61ea..000000000 --- a/apps/banglerun/step.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { ActivityStatus, AppState } from './state'; - -declare var Bangle: any; - -function initStep(state: AppState) { - Bangle.on('step', () => updateStep(state)); -} - -function updateStep(state: AppState) { - if (state.status === ActivityStatus.Running) { - state.steps += 1; - } -} - -export { initStep, updateStep }; From 955acf2696634490ca200930c02a919d57530dc7 Mon Sep 17 00:00:00 2001 From: Erik Andresen Date: Mon, 28 Feb 2022 22:10:00 +0100 Subject: [PATCH 42/80] gpsautotime: Set Bangle.js 2 compatible --- apps/gpsautotime/ChangeLog | 1 + apps/gpsautotime/metadata.json | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/gpsautotime/ChangeLog b/apps/gpsautotime/ChangeLog index 5560f00bc..2827c9e5c 100644 --- a/apps/gpsautotime/ChangeLog +++ b/apps/gpsautotime/ChangeLog @@ -1 +1,2 @@ 0.01: New App! +0.02: Set Bangle.js 2 compatible diff --git a/apps/gpsautotime/metadata.json b/apps/gpsautotime/metadata.json index a64a45f6d..766961276 100644 --- a/apps/gpsautotime/metadata.json +++ b/apps/gpsautotime/metadata.json @@ -2,12 +2,12 @@ "id": "gpsautotime", "name": "GPS auto time", "shortName": "GPS auto time", - "version": "0.01", + "version": "0.02", "description": "A widget that automatically updates the Bangle.js time to the GPS time whenever there is a valid GPS fix.", "icon": "widget.png", "type": "widget", "tags": "widget,gps", - "supports": ["BANGLEJS"], + "supports": ["BANGLEJS","BANGLEJS2"], "storage": [ {"name":"gpsautotime.wid.js","url":"widget.js"} ] From bc8eecf998a8d380485139ce4016e888b648ffb6 Mon Sep 17 00:00:00 2001 From: Gordon Williams Date: Tue, 1 Mar 2022 08:12:53 +0000 Subject: [PATCH 43/80] fix lint warnings --- .eslintignore | 1 + apps/pooqroman/app.js | 6 ++++-- apps/pooqroman/resourcer.js | 3 ++- apps/pooqround/resourcer.js | 3 ++- apps/speedalt2/app.js | 3 ++- apps/weatherClock/app.js | 1 - 6 files changed, 11 insertions(+), 6 deletions(-) diff --git a/.eslintignore b/.eslintignore index 7bbe41136..fcbea07f9 100644 --- a/.eslintignore +++ b/.eslintignore @@ -2,4 +2,5 @@ apps/animclk/V29.LBM.js apps/banglerun/rollup.config.js apps/schoolCalendar/fullcalendar/main.js apps/authentiwatch/qr_packed.js +apps/qrcode/qr-scanner.umd.min.js *.test.js diff --git a/apps/pooqroman/app.js b/apps/pooqroman/app.js index bed8ef3d2..fcb2437e1 100644 --- a/apps/pooqroman/app.js +++ b/apps/pooqroman/app.js @@ -353,13 +353,15 @@ const events = { let c, p, i, l = from - o, h = to - o; for (i = 0; (c = this.wall[i]).time < l; i++) ; for (; (c = this.wall[i]).time < h; i++) { - if ((p = c.time < t) ? c.past : c.future) + p = c.time < t; + if (p ? c.past : c.future) result = Math.min(result, f(c, new Date(c.time + o), p)); } l += o; h += o; t += o; for (i = 0; (c = this.fixed[i]).time < l; i++) ; for (; (c = this.fixed[i]).time < h; i++) { - if ((p = c.time < t) ? c.past : c.future) + p = c.time < t; + if (p ? c.past : c.future) result = Math.min(f(c, new Date(c.time), p)); } return result; diff --git a/apps/pooqroman/resourcer.js b/apps/pooqroman/resourcer.js index 69365018e..8b95dc834 100644 --- a/apps/pooqroman/resourcer.js +++ b/apps/pooqroman/resourcer.js @@ -60,7 +60,8 @@ const prepFont = (name, data) => { let width = m[2] == '*' ? null : +m[2]; let c = null, o = 0; lines.forEach((line, l) => { - if (m = /^(<*)(=)([*\d]*)(=*)(>*)$/.exec(line) || /^(<*)(-)(.)(-*)(>*)$/.exec(line)) { + m = /^(<*)(=)([*\d]*)(=*)(>*)$/.exec(line) || /^(<*)(-)(.)(-*)(>*)$/.exec(line); + if (m) { const h = m[2] == '='; if (m[1].length > desc || h && m[1].length != desc) throw new Error('Invalid descender height at ' + l); diff --git a/apps/pooqround/resourcer.js b/apps/pooqround/resourcer.js index 17c35a40d..6b969a102 100644 --- a/apps/pooqround/resourcer.js +++ b/apps/pooqround/resourcer.js @@ -60,7 +60,8 @@ const prepFont = (name, data) => { let width = m[2] == '*' ? null : +m[2]; let c = null, o = 0; lines.forEach((line, l) => { - if (m = /^(<*)(=)([*\d]*)(=*)(>*)$/.exec(line) || /^(<*)(-)(.)(-*)(>*)$/.exec(line)) { + m = /^(<*)(=)([*\d]*)(=*)(>*)$/.exec(line) || /^(<*)(-)(.)(-*)(>*)$/.exec(line); + if (m) { const h = m[2] == '='; if (m[1].length > desc || h && m[1].length != desc) throw new Error('Invalid descender height at ' + l); diff --git a/apps/speedalt2/app.js b/apps/speedalt2/app.js index 73fa3bacb..ed16131a4 100644 --- a/apps/speedalt2/app.js +++ b/apps/speedalt2/app.js @@ -179,7 +179,8 @@ var buf = Graphics.createArrayBuffer(240,160,2,{msb:true}); let LED = // LED as minimal and only definition (as instance / singleton) { isOn: false // status on / off, not needed if you don't need to ask for it , set: function(v) { // turn on w/ no arg or truey, else off - g.setColor((this.isOn=(v===undefined||!!v))?1:0,0,0).fillCircle(120,10,10); } + this.isOn = v===undefined||!!v; + g.setColor(this.isOn?1:0,0,0).fillCircle(120,10,10); } , reset: function() { this.set(false); } // turn off , write: function(v) { this.set(v); } // turn on w/ no arg or truey, else off , toggle: function() { this.set( ! this.isOn); } // toggle the LED diff --git a/apps/weatherClock/app.js b/apps/weatherClock/app.js index 1a7f53f05..91d0ab36f 100644 --- a/apps/weatherClock/app.js +++ b/apps/weatherClock/app.js @@ -71,7 +71,6 @@ function chooseIconByCode(code) { case 801: return partSunIcon; default: return cloudIcon; } - break; default: return cloudIcon; } } From 7ce68ff66cd84996d4bef974fe17a407aa8fc460 Mon Sep 17 00:00:00 2001 From: BartS23 <10829389+BartS23@users.noreply.github.com> Date: Sun, 27 Feb 2022 08:35:17 +0100 Subject: [PATCH 44/80] Make links to github absolute otherwise they will not work in the apploader --- apps/run/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/run/README.md b/apps/run/README.md index 17975f92c..5b3bb635a 100644 --- a/apps/run/README.md +++ b/apps/run/README.md @@ -46,8 +46,8 @@ record GPS/HRM/etc data every time you start a run? ## Development -This app uses the [`exstats` module](/modules/exstats.js). When uploaded via the +This app uses the [`exstats` module](https://github.com/espruino/BangleApps/blob/master/modules/exstats.js). When uploaded via the app loader, the module is automatically included in the app's source. However when developing via the IDE the module won't get pulled in by default. -There are some options to fix this easily - please check out the [modules README.md file](/modules/README.md) +There are some options to fix this easily - please check out the [modules README.md file](https://github.com/espruino/BangleApps/blob/master/modules/README.md) From 87cfd379e8c92177c40cfe3df7ba94a872559c6f Mon Sep 17 00:00:00 2001 From: Andrew Gregory Date: Tue, 1 Mar 2022 22:02:13 +0800 Subject: [PATCH 45/80] Update app.js Fix #12 Optimize graphics calls a bit --- apps/authentiwatch/app.js | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/apps/authentiwatch/app.js b/apps/authentiwatch/app.js index b2c8f857b..73b8bdeea 100644 --- a/apps/authentiwatch/app.js +++ b/apps/authentiwatch/app.js @@ -94,6 +94,9 @@ function hotp(d, token, dohmac) { while (ret.length < token.digits) { ret = "0" + ret; } + // add a space after every 3rd or 4th digit + var re = (token.digits % 3 == 0 || (token.digits % 3 >= token.digits % 4 && token.digits % 4 != 0)) ? "" : "."; + ret = ret.replace(new RegExp("(..." + re + ")", "g"), "$1 ").trim(); } catch(err) { ret = notsupported; } @@ -122,15 +125,15 @@ function drawToken(id, r) { lbl = tokens[id].label.substr(0, 10); if (id == state.curtoken) { // current token - g.setColor(g.theme.fgH); - g.setBgColor(g.theme.bgH); - g.setFont("Vector", tokenextraheight); + g.setColor(g.theme.fgH) + .setBgColor(g.theme.bgH) + .setFont("Vector", tokenextraheight) // center just below top line - g.setFontAlign(0, -1, 0); + .setFontAlign(0, -1, 0); adj = y1; } else { - g.setColor(g.theme.fg); - g.setBgColor(g.theme.bg); + g.setColor(g.theme.fg) + .setBgColor(g.theme.bg); sz = tokendigitsheight; do { g.setFont("Vector", sz--); @@ -139,8 +142,8 @@ function drawToken(id, r) { g.setFontAlign(0, 0, 0); adj = (y1 + y2) / 2; } - g.clearRect(x1, y1, x2, y2); - g.drawString(lbl, (x1 + x2) / 2, adj, false); + g.clearRect(x1, y1, x2, y2) + .drawString(lbl, (x1 + x2) / 2, adj, false); if (id == state.curtoken) { if (tokens[id].period > 0) { // timed - draw progress bar @@ -161,10 +164,10 @@ function drawToken(id, r) { g.drawString(state.otp, (x1 + adj + x2) / 2, y1 + tokenextraheight, false); } // shaded lines top and bottom - g.setColor(0.5, 0.5, 0.5); - g.drawLine(x1, y1, x2, y1); - g.drawLine(x1, y2, x2, y2); - g.setClipRect(0, 0, g.getWidth(), g.getHeight()); + g.setColor(0.5, 0.5, 0.5) + .drawLine(x1, y1, x2, y1) + .drawLine(x1, y2, x2, y2) + .setClipRect(0, 0, g.getWidth(), g.getHeight()); } function draw() { @@ -229,9 +232,9 @@ function draw() { state.nexttime = 0; } } else { - g.setFont("Vector", tokendigitsheight); - g.setFontAlign(0, 0, 0); - g.drawString(notokens, Bangle.appRect.x + Bangle.appRect.w / 2, Bangle.appRect.y + Bangle.appRect.h / 2, false); + g.setFont("Vector", tokendigitsheight) + .setFontAlign(0, 0, 0) + .drawString(notokens, Bangle.appRect.x + Bangle.appRect.w / 2, Bangle.appRect.y + Bangle.appRect.h / 2, false); } if (state.drawtimer) { clearTimeout(state.drawtimer); @@ -323,9 +326,9 @@ Bangle.on('touch', onTouch); Bangle.on('drag' , onDrag ); Bangle.on('swipe', onSwipe); if (typeof BTN2 == 'number') { - setWatch(function(){bangle1Btn(-1);}, BTN1, {edge:"rising", debounce:50, repeat:true}); - setWatch(function(){exitApp(); }, BTN2, {edge:"rising", debounce:50, repeat:true}); - setWatch(function(){bangle1Btn( 1);}, BTN3, {edge:"rising", debounce:50, repeat:true}); + setWatch(function(){bangle1Btn(-1);}, BTN1, {edge:"rising" , debounce:50, repeat:true}); + setWatch(function(){exitApp(); }, BTN2, {edge:"falling", debounce:50}); + setWatch(function(){bangle1Btn( 1);}, BTN3, {edge:"rising" , debounce:50, repeat:true}); } Bangle.loadWidgets(); From ad911cdb02d8bd51748b11160a6623eab0bf9565 Mon Sep 17 00:00:00 2001 From: Andrew Gregory Date: Tue, 1 Mar 2022 22:06:49 +0800 Subject: [PATCH 46/80] Update ChangeLog v0.06 --- apps/authentiwatch/ChangeLog | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/authentiwatch/ChangeLog b/apps/authentiwatch/ChangeLog index 7d6f96026..bb2945db4 100644 --- a/apps/authentiwatch/ChangeLog +++ b/apps/authentiwatch/ChangeLog @@ -3,3 +3,4 @@ 0.03: Add "Calculating" placeholder, update JSON save format 0.04: Fix tapping at very bottom of list, exit on inactivity 0.05: Add support for bulk importing and exporting tokens +0.06: Add spaces to codes for improved readability (thanks @BartS23) From 5fc057f943cb7e3a0392a3e64f5119769918f7f8 Mon Sep 17 00:00:00 2001 From: Andrew Gregory Date: Tue, 1 Mar 2022 22:07:23 +0800 Subject: [PATCH 47/80] Update metadata.json v0.06 --- apps/authentiwatch/metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/authentiwatch/metadata.json b/apps/authentiwatch/metadata.json index 676d8da9f..309a47b78 100644 --- a/apps/authentiwatch/metadata.json +++ b/apps/authentiwatch/metadata.json @@ -4,7 +4,7 @@ "shortName": "AuthWatch", "icon": "app.png", "screenshots": [{"url":"screenshot.png"}], - "version": "0.05", + "version": "0.06", "description": "Google Authenticator compatible tool.", "tags": "tool", "interface": "interface.html", From edf8204ab82fdce7a0bfb9199118876c1371e4cf Mon Sep 17 00:00:00 2001 From: Andrew Gregory Date: Tue, 1 Mar 2022 22:13:52 +0800 Subject: [PATCH 48/80] Add files via upload New screenshots --- apps/authentiwatch/screenshot1.png | Bin 0 -> 2708 bytes apps/authentiwatch/screenshot2.png | Bin 0 -> 2914 bytes apps/authentiwatch/screenshot3.png | Bin 0 -> 2656 bytes apps/authentiwatch/screenshot4.png | Bin 0 -> 2951 bytes 4 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 apps/authentiwatch/screenshot1.png create mode 100644 apps/authentiwatch/screenshot2.png create mode 100644 apps/authentiwatch/screenshot3.png create mode 100644 apps/authentiwatch/screenshot4.png diff --git a/apps/authentiwatch/screenshot1.png b/apps/authentiwatch/screenshot1.png new file mode 100644 index 0000000000000000000000000000000000000000..c7ca744b497c2098743be85b15d16878f7196a54 GIT binary patch literal 2708 zc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I*k zJ{hGr40o(Q*{FYfQ7$9atdX1Zdeb1Cy-_f_-Xo}zTt7J>3pBeH3J3MNdn+x4^sDc> rKZT;94ha#*&rezeFWO;m|7lqE{lV(+_~!D#n+aH(+nY6-5EK6c)4k!G literal 0 HcmV?d00001 diff --git a/apps/authentiwatch/screenshot2.png b/apps/authentiwatch/screenshot2.png new file mode 100644 index 0000000000000000000000000000000000000000..8156dd3e8a8070e3b57b93163f8cd44ca5e90e85 GIT binary patch literal 2914 zcmbtW`#;l<_kV4+#oT6cO>CLTb&>o1I`=4&TL@vKmc)9yG(}Y85>rGI-YWOExs!!1 zQtoC}*gMtGTb8?#KKlL(-yhC7kH_zq@7i^<$3u6`KdNz)x_-afx|Zl(vJ;?#o`D$nyt}Z63@p0XS=9($-rPxb zej-W6eN_AP<#PzsU&Z=xBAR~qRmDOqG&3zudfN#ll1Oza*2@Pn5|v_nXIfw6*UZF+)=;jv6^$6!iar5Kxz7+#;f6x6+zPD=@d&O8WgwNifk zei&@xWcETTh_WKM@$sLO2NEKnl8Rk&(#X5`jvx@pLfTEr&&oo3X*wNPE}mT~8w2Dl zgmB7^xa949m8Wq$zDtb}d zYV{`cGjCIv=07{UF!YX)m0<%4xOL5j=*hNTfb@ufjunVmU`3;>$f7R0n&)tQ#2;(u zUkU|c9VpHrJ85#xd7A;$(?lX7XV;KfK4&qY51?;)8PEIbSjQ|(hdPj#Z5$9LuPjUL zEyJe`e0ZI^_+_WyYLH)JSeNKhhkm*4juYU=ciR1=x|{vyc#OGzyjOz8_6=r4+a`nm zAqZpIRhI_#^1-8SkHhD4wn~7=pur^dv)kuyRath*(Or{u2GaesbG}-^AB4=w1M}7A zp7|G^&wMRM+<9(FU&AvGN@ILD%-~xvbEYD;aSDAx60Ae;3C;|f4PI2J!V;W zkz^R*csn>!4cBgBfwEh(V1=typ4rI;3Q+hIJSzjjgyX=JZHxidfIZ$ zA1oxK3(*OAm-pPqNxK~Wh?hn`x($DeP0~Ynw~tfKYZL|d{g#jV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~?Ch^Ev1t~YW?rC1` zt#TlX_U#gMa3|?cm%9;2IQx@qz0Q+(*P5=XN;`=#=tk`(ES~@9+o|f<)g$X_XD=1+ z2^@nBj7k_BNL~-W3;ezgNkjh=TlE!GYxzi1rFG|(yki5p|`@L+q@mTj%qBy%>#vYXa{QJG4de3bEV$}`dO~vnF zA&N}4)t0XS_shWu6r*-PIZdxT9&BP0+IC;|Eu^Jd0YsUSWj$%e$}iey5AqYUZALzH zf*}t=Qas5(+6jeXWqJsT28I~K@a9cGSiaKzm!)*fjw5hPhQEd`N}v39dp$z*x_er< z9QWg*At_i2moybOFSADCw86~elbK)yo4IW~6Aw->0XINV^oG^A&P~V`2@)h|K@R3D zla>XzKl%G4sWO3C97&oPTsIaTM9NAS@4pGHk^KP#h=iM^95vMly>-+_Ebb!it8!){ zzLuXmxTgEslUJ_8qguJ38{1jXKpI>T{6TucQ!B1Rw10>q!4zjtQ`3=Ip$o(}I%UjV Z(A4{6$wZuM;{MYNIM|-BskI8c@jt}ERJ#BG literal 0 HcmV?d00001 diff --git a/apps/authentiwatch/screenshot3.png b/apps/authentiwatch/screenshot3.png new file mode 100644 index 0000000000000000000000000000000000000000..6d14e0b965efa1b522d034bc0fee2f8415a950d5 GIT binary patch literal 2656 zcmai0XIE2+7QOc-KoSr`fFUp;v_Rm|3`GJ2#X>WJ2u=WLp%3B!DmAEtrZ55q&;$_} zrHF+9g7jiW5uy}_{^%J6(UB4q4T1wNGk@THIOnXj&)RG64`=OlvRqvp_MlWy008W9 zay;rLo^}5eLQ>pon-~1V1H9noa2Ti=#C-q&l#0{QL#Gn_R!aViD@axbGwgQBL|? z*{>Hpk)`GZyMPS%luh(fbR18qHNmxO&1BR)le;)Kd9FPo2*NF6s?^+>!1WKk4NH1J ztRRSC*sV4l{Isbyb%N(}xc_bVZ+wqC*4u6H1U2vGm!}$~haR2@Vt(tROw+AMC;wH# z(`>(Ise<_NLQqo?3zBuCc8rd)geP3|vjTGejQpc(o4%)+}F6okB)K^7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B2bw9&9ok_h2l*P;lP79(eJjdrAa)Kt=r zb%erys$6t?(J`}Lt9Cm}t# zEX&|mhn0<_nH3D@EsmTJcs@w#$4$>ts3NN0p}jX!9JAy^`n zPJa7wVcJ#{0XJV(q-(t^OYP~+_qA7LuAuqFMG?46aFS( zP?}wR<-{TGsPB_evOt&1!H`&1A)J@C<)_Q|+JFlaU^xTV*V;JhQL7^F&w%GYCIc6> zl<${75pa`^0sjMC3U@FM;ss5cDA zN?+;+JAS<$F*PmRiIM5p{*ycRX}fvru5~YBAH|3OgS5hyqo$qQcmn|a*v0-sW$`q77sm`EjvqT}^#P7Az3@7IFgh=D)E^C{b{)js@mt$<1GCC) zaKxtgxMHJ;;^Q_zY%Lo-lpZn$Xeis{M5EG9=xDZ!m>2Z zYGjrhUw>Z~kNRhE-yJnGZxl?DZJBkr_+5`)5&n51-e1eorRA+-CFFqJ zJu+`$0cqqEdhOS<%jtQM_^?EO^y$07YG77gscQsV@bT=qu`us`F-a(~w=?u0z!rz4Nr)(y zzS15a{(q=F4PNQ!yJhsvp!n_5&l@r(;t#xq(`b^N^PWWdjxh-msmhdXwKds){~QS5 zu7N92d%A0%ndbWKxpFwdAYm^H|2N$RS>K$zJ$WNLU1ABfq9_-!OfajdFl2T?b>+;- z4E7OoOkIlMnC-6@Z)CI7p)XIw7d0q&y0$Ab{lu+cX|2_UD~xwUB~w@{>AIajqoC&B i@KS%7z6u=Xk?DX?!=o=H8z=WZYry)ny(Pt*aQi=;H)1vb literal 0 HcmV?d00001 From 4a7244601ade976aa077cd2dcdce69201d7834bd Mon Sep 17 00:00:00 2001 From: Andrew Gregory Date: Tue, 1 Mar 2022 22:14:44 +0800 Subject: [PATCH 49/80] Delete screenshot.png Remove obsolete screenshot --- apps/authentiwatch/screenshot.png | Bin 2939 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 apps/authentiwatch/screenshot.png diff --git a/apps/authentiwatch/screenshot.png b/apps/authentiwatch/screenshot.png deleted file m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?tbXgxnzP;(kFPUqMF~WE}okhPN{Dlf$Y9kDj9Na9_8te5lLlCH6wk45x=%VVSm?E zZIEHsmoRIgEE&Rk@%9tc<_5MyHH|6e8%4UzTQy)l_Qfs~B855D^z3ZT#gQk4>s4or z00jdDvy?7+%Th&abGD4t+IUYY8>~~LOVLUOspxA#jv0U){U5@foMLg7^#)(XgtVU< z56h-vPK1H8wN8Ml*`{9ll_3t0db;1KEU%x7eKSC6hfF{a-)cHAtw^$tGA#Df#HC3% zx2F`Z3zl4je1=GYNZE%faYRVB6NyP{ySz43!zEe*@MJrQQ&>;ER9q*Je4pHOo|x=4 zLa?6_0lDquZr*n!0lDONhnwczqW3299%r%x2}o5smLv=NNVGyo&9FTYT~G#5E+he$ zzaF6N1u;jvi;KU-gmQ6@J`j>fSX+2`LqjNn)Cj00B+JFgk8qxA zm0|=czn2}3GpR>yj(k^Na`r+A#~x6L-(<4@a2-%mPR(}3AoYvTq(&l~>+ph{oX From b811d6524b142185f53bb6fc9ebfa109f0c14390 Mon Sep 17 00:00:00 2001 From: Andrew Gregory Date: Tue, 1 Mar 2022 22:16:45 +0800 Subject: [PATCH 50/80] Update metadata.json Add screenshots --- apps/authentiwatch/metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/authentiwatch/metadata.json b/apps/authentiwatch/metadata.json index 309a47b78..b4ed34a12 100644 --- a/apps/authentiwatch/metadata.json +++ b/apps/authentiwatch/metadata.json @@ -3,7 +3,7 @@ "name": "2FA Authenticator", "shortName": "AuthWatch", "icon": "app.png", - "screenshots": [{"url":"screenshot.png"}], + "screenshots": [{"url":"screenshot1.png"},{"url":"screenshot2.png"},{"url":"screenshot3.png"},{"url":"screenshot4.png"}], "version": "0.06", "description": "Google Authenticator compatible tool.", "tags": "tool", From b2ebc7f29efd3aebb663bfa65a9eb7ff1ae1d986 Mon Sep 17 00:00:00 2001 From: Andrew Gregory Date: Tue, 1 Mar 2022 22:18:20 +0800 Subject: [PATCH 51/80] Update README.md Update screenshots --- apps/authentiwatch/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/authentiwatch/README.md b/apps/authentiwatch/README.md index cc25e9604..a957cf93a 100644 --- a/apps/authentiwatch/README.md +++ b/apps/authentiwatch/README.md @@ -33,7 +33,7 @@ Keep those copies safe and secure. * Swipe right to exit to the app launcher. * Swipe left on selected counter token to advance the counter to the next value. -![Screenshot](screenshot.png) +![Screenshot](screenshot1.png) ![Screenshot](screenshot2.png) ![Screenshot](screenshot3.png) ![Screenshot](screenshot4.png) ## Creator From dd906e076f9fbdf382248c493b780245eedc3b93 Mon Sep 17 00:00:00 2001 From: Rarder44 Date: Tue, 1 Mar 2022 19:03:09 +0100 Subject: [PATCH 52/80] added clear for fix the trasparent widget bar if there are no widgets --- apps/dtlaunch/app-b2.js | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/dtlaunch/app-b2.js b/apps/dtlaunch/app-b2.js index 96e562add..35cec3da9 100644 --- a/apps/dtlaunch/app-b2.js +++ b/apps/dtlaunch/app-b2.js @@ -125,5 +125,6 @@ Bangle.on("touch",(_,p)=>{ }); Bangle.loadWidgets(); +g.clear(); Bangle.drawWidgets(); drawPage(0); From ef815f230c7df50d9e4541253866b34aac2cb0bd Mon Sep 17 00:00:00 2001 From: Rarder44 Date: Tue, 1 Mar 2022 19:13:49 +0100 Subject: [PATCH 53/80] added option to exit the launcher with one click --- apps/dtlaunch/app-b2.js | 4 ++++ apps/dtlaunch/settings-b2.js | 11 ++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/apps/dtlaunch/app-b2.js b/apps/dtlaunch/app-b2.js index 35cec3da9..e0f7f825f 100644 --- a/apps/dtlaunch/app-b2.js +++ b/apps/dtlaunch/app-b2.js @@ -6,8 +6,12 @@ var settings = Object.assign({ showClocks: true, showLaunchers: true, direct: false, + oneClickExit:false }, require('Storage').readJSON("dtlaunch.json", true) || {}); +if( settings.oneClickExit) + setWatch(_=> load(), BTN1); + var s = require("Storage"); var apps = s.list(/\.info$/).map(app=>{ var a=s.readJSON(app,1); diff --git a/apps/dtlaunch/settings-b2.js b/apps/dtlaunch/settings-b2.js index 7f667d213..8eca46a7e 100644 --- a/apps/dtlaunch/settings-b2.js +++ b/apps/dtlaunch/settings-b2.js @@ -4,7 +4,8 @@ var settings = Object.assign({ showClocks: true, showLaunchers: true, - direct: false + direct: false, + oneClickExit:false }, require('Storage').readJSON(FILE, true) || {}); function writeSettings() { @@ -37,6 +38,14 @@ settings.direct = v; writeSettings(); } + }, + 'One click exit': { + value: settings.oneClickExit, + format: v => v?"On":"Off", + onchange: v => { + settings.oneClickExit = v; + writeSettings(); + } } }); }) From d476f530a8e728ae5eab18947a706f397a365602 Mon Sep 17 00:00:00 2001 From: Gordon Williams Date: Wed, 2 Mar 2022 08:42:39 +0000 Subject: [PATCH 54/80] fix #1533 --- apps/snek/snek.icon.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/snek/snek.icon.js b/apps/snek/snek.icon.js index b820ffcf7..c9a17eee3 100644 --- a/apps/snek/snek.icon.js +++ b/apps/snek/snek.icon.js @@ -1 +1 @@ -require("heatshrink").decompress(atob("oFA4X/AAOJksvr2rmokYgWqB7sq/2AB5krgYPMgW8ioPc1X9i/oLplVqv+1BdK1OV//q9QPMv4PL1eqy/q1SRK3tVu+AgWCFxP96t+Vhn9qoPLgWr/+//wFBSBEq3/qlW+JwJ/I3eXDQIOBB5OrB5sC3xMD1WAH4+r6xsOtSpKLoYPN1fV1bpKTYf+RJAeDytXFxoPOdQYPNPpkCy1VtQPc6wvO62Vu+CbhfVN4P//+q//uMgwPH9QPH3tqqtpqoABv4wHfoOpBoP/6tVUg7uBFwIvB3xlIB4v+OpJsC1WA1fVQpiGCB52+uzlMB58A31XB5sqy4PNlYPfH50rywPN3++BxgPPgW9V5kCZ4L/HBwmq/tX1APM/4PMBwNVvxuKgW/tP/HxUq1X+1eqFxQPRAAKsLB4KqNAFY=")) +require("heatshrink").decompress(atob("mEwwcBkmSpICZqVECJ+SCJ+UxIRP0lIggRNlckxFICJlKrYGCsmJNBfZsmSpdkyIRL7YRBAwIRLAYQyLNAQRPkoGDCJlLBwQmBAoZ6HBYI4Cy3ZCJVZCITpLymSCIhWMF4IRMlMky3JkTRMAYTjNqREBCJ4DCX5gRD2IRO5MlCKAjQRgOSkslBIRrMUoO2fZVSpdkyQ4BBIWRUJNtBIzpHWYYCCpYRJa4RWDEZQCH0oR0yuyCJ+UCKI1QEaOkCKI1PAYQgMyQDDNBwDBxIRLdgOydgQRKqVJloROyVLthWOpQONAUIA=")) From f0e6190c16550be503b8ab38ae346542b0a7a21d Mon Sep 17 00:00:00 2001 From: Rarder44 Date: Wed, 2 Mar 2022 11:23:18 +0100 Subject: [PATCH 55/80] edit version and changelog --- apps/dtlaunch/ChangeLog | 2 ++ apps/dtlaunch/metadata.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/dtlaunch/ChangeLog b/apps/dtlaunch/ChangeLog index 556472eaa..811784b39 100644 --- a/apps/dtlaunch/ChangeLog +++ b/apps/dtlaunch/ChangeLog @@ -6,3 +6,5 @@ 0.06: Adds settings page (hide clocks or launchers) 0.07: Adds setting for directly launching app on touch for Bangle 2 0.08: Optimize line wrapping for Bangle 2 +0.09: fix the trasparent widget bar if there are no widgets for Bangle 2 +0.10: added "one click exit" setting for Bangle 2 diff --git a/apps/dtlaunch/metadata.json b/apps/dtlaunch/metadata.json index 6cd1dbe73..7a4094e54 100644 --- a/apps/dtlaunch/metadata.json +++ b/apps/dtlaunch/metadata.json @@ -1,7 +1,7 @@ { "id": "dtlaunch", "name": "Desktop Launcher", - "version": "0.08", + "version": "0.10", "description": "Desktop style App Launcher with six (four for Bangle 2) apps per page - fast access if you have lots of apps installed.", "screenshots": [{"url":"shot1.png"},{"url":"shot2.png"},{"url":"shot3.png"}], "icon": "icon.png", From 4150874534ee5830e713d86855726793567b6255 Mon Sep 17 00:00:00 2001 From: Stergios Mekras Date: Wed, 2 Mar 2022 16:34:35 +0100 Subject: [PATCH 56/80] Write settings file --- apps/smclock/settings.js | 117 ++++++++++++++++----------------------- 1 file changed, 47 insertions(+), 70 deletions(-) diff --git a/apps/smclock/settings.js b/apps/smclock/settings.js index bfc738e19..9d747a910 100644 --- a/apps/smclock/settings.js +++ b/apps/smclock/settings.js @@ -1,108 +1,85 @@ -// Settings menu for Monogram Watch Face +// settings menu for Monogram Watch Face // Anton Clock settings were used as template +// helper functions taken from Anton Clock -(function(back) { +(function (back) { var FILE = "smclock.json"; - // Load settings - var settings = Object.assign({ - secondsOnUnlock: false, - }, require('Storage').readJSON(FILE, true) || {}); + // load settings from the file + // assign default values if it doesn't exist + var settings = Object.assign( + { + dateFormat: "short", + showAnalogFace: false, + showWeekInfo: false, + useVectorFont: true, + }, + require("Storage").readJSON(FILE, true) || {} + ); + // write the new settings to the file function writeSettings() { - require('Storage').writeJSON(FILE, settings); + require("Storage").writeJSON(FILE, settings); } - // Helper method which uses int-based menu item for set of string values + // helper method which uses int-based menu item for set of string values function stringItems(startvalue, writer, values) { return { - value: (startvalue === undefined ? 0 : values.indexOf(startvalue)), - format: v => values[v], + value: startvalue === undefined ? 0 : values.indexOf(startvalue), + format: (v) => values[v], min: 0, max: values.length - 1, wrap: true, step: 1, - onchange: v => { + onchange: (v) => { writer(values[v]); writeSettings(); - } + }, }; } - // Helper method which breaks string set settings down to local settings object + // helper method which breaks string set settings down to local settings object function stringInSettings(name, values) { - return stringItems(settings[name], v => settings[name] = v, values); + return stringItems(settings[name], (v) => (settings[name] = v), values); } + // settings menu var mainmenu = { "": { - "title": "Monogram Clock" + title: "Monogram Clock", }, "< Back": () => back(), - "Seconds...": () => E.showMenu(secmenu), - "Date": stringInSettings("dateOnMain", ["Long", "Short", "ISO8601"]), - "Show Weekday": { - value: (settings.weekDay !== undefined ? settings.weekDay : true), - format: v => v ? "On" : "Off", - onchange: v => { - settings.weekDay = v; + "Analog Face": { + value: + settings.showAnalogFace !== undefined ? settings.showAnalogFace : false, + format: (v) => (v ? "On" : "Off"), + onchange: (v) => { + settings.showAnalogFace = v; writeSettings(); - } + }, }, - "Show CalWeek": { - value: (settings.calWeek !== undefined ? settings.calWeek : false), - format: v => v ? "On" : "Off", - onchange: v => { - settings.calWeek = v; + Date: stringInSettings("dateOnMain", ["Long", "Short", "ISO8601"]), + "Week Info": { + value: + settings.showWeekInfo !== undefined ? settings.showWeekInfo : false, + format: (v) => (v ? "On" : "Off"), + onchange: (v) => { + settings.showWeekInfo = v; writeSettings(); - } + }, }, - "Uppercase": { - value: (settings.upperCase !== undefined ? settings.upperCase : true), - format: v => v ? "On" : "Off", - onchange: v => { - settings.upperCase = v; + "Vector Font": { + value: + settings.useVectorFont !== undefined ? settings.useVectorFont : false, + format: (v) => (v ? "On" : "Off"), + onchange: (v) => { + settings.useVectorFont = v; writeSettings(); - } + }, }, - "Vector font": { - value: (settings.vectorFont !== undefined ? settings.vectorFont : false), - format: v => v ? "On" : "Off", - onchange: v => { - settings.vectorFont = v; - writeSettings(); - } - }, - }; - - // Submenu - var secmenu = { - "": { - "title": "Show seconds..." - }, - "< Back": () => E.showMenu(mainmenu), - "Show": stringInSettings("secondsMode", ["Never", "Unlocked", "Always"]), - "With \":\"": { - value: (settings.secondsWithColon !== undefined ? settings.secondsWithColon : true), - format: v => v ? "On" : "Off", - onchange: v => { - settings.secondsWithColon = v; - writeSettings(); - } - }, - "Color": { - value: (settings.secondsColoured !== undefined ? settings.secondsColoured : true), - format: v => v ? "On" : "Off", - onchange: v => { - settings.secondsColoured = v; - writeSettings(); - } - }, - "Date": stringInSettings("dateOnSecs", ["Year", "Weekday", "No"]) }; // Actually display the menu E.showMenu(mainmenu); - }); // end of file From 4ddf8a94fbb36bd663fbc018c5f92c9e0d2e2e8b Mon Sep 17 00:00:00 2001 From: Ronin0000 <89286474+Ronin0000@users.noreply.github.com> Date: Wed, 2 Mar 2022 09:36:11 -0800 Subject: [PATCH 57/80] Update ChangeLog --- apps/smclock/ChangeLog | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/smclock/ChangeLog b/apps/smclock/ChangeLog index b029d805d..77098b0ad 100644 --- a/apps/smclock/ChangeLog +++ b/apps/smclock/ChangeLog @@ -1,2 +1,3 @@ 0.01: Initial version 0.02: Add battery level +0.03: fix battery level displaying From d64f945eff1ecbdc4507dfdcef4c6039cc2f1e75 Mon Sep 17 00:00:00 2001 From: Ronin0000 <89286474+Ronin0000@users.noreply.github.com> Date: Wed, 2 Mar 2022 09:36:31 -0800 Subject: [PATCH 58/80] Update app.js --- apps/smclock/app.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/smclock/app.js b/apps/smclock/app.js index 6aff72a46..84942e0ef 100644 --- a/apps/smclock/app.js +++ b/apps/smclock/app.js @@ -51,7 +51,7 @@ function draw() { g.drawImage(background); const color = getBatteryColor(); - const bat = d02(E.getBattery()) + "%"; + const bat = E.getBattery() + "%"; const d = new Date(); const day = d.getDate(); const month = (d.getMonth() + 1); @@ -78,7 +78,7 @@ function draw() { g.setFont("Vector", 16); g.drawString("Bat:", 12, 22, false); g.setColor(color[0], color[1], color[2]); - g.drawString(bat, 52, 22, false); + g.drawString(bat, 46, 22, false); } g.clear(); From 136cbe28e12b78f4a45b838ecfc3c357784c2d53 Mon Sep 17 00:00:00 2001 From: Ronin0000 <89286474+Ronin0000@users.noreply.github.com> Date: Wed, 2 Mar 2022 09:36:46 -0800 Subject: [PATCH 59/80] Update metadata.json --- apps/smclock/metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/smclock/metadata.json b/apps/smclock/metadata.json index 1783ca7bf..e2fbeace1 100644 --- a/apps/smclock/metadata.json +++ b/apps/smclock/metadata.json @@ -3,7 +3,7 @@ "name":"Monogram Watch Face", "shortName":"MonoClock", "icon":"app.png", - "version":"0.02", + "version":"0.03", "description": "A simple watchface based on my stylised monogram.", "tags":"clock", "readme":"README.md", From 4521873a53e65a51699fc3dbfb9d533690c48ff6 Mon Sep 17 00:00:00 2001 From: hughbarney Date: Wed, 2 Mar 2022 19:21:41 +0000 Subject: [PATCH 60/80] Daisy: added heart rate, update steps on each step --- apps/daisy/ChangeLog | 1 + apps/daisy/README.md | 15 +-- apps/daisy/app.js | 198 ++++++++++++++++++++++++++------------- apps/daisy/metadata.json | 2 +- 4 files changed, 142 insertions(+), 74 deletions(-) diff --git a/apps/daisy/ChangeLog b/apps/daisy/ChangeLog index 4fdf333e4..989704054 100644 --- a/apps/daisy/ChangeLog +++ b/apps/daisy/ChangeLog @@ -1,2 +1,3 @@ 0.01: first release 0.02: added settings menu to change color +0.03: added heart rate which is switched on when cycled to it through up/down touch on rhs diff --git a/apps/daisy/README.md b/apps/daisy/README.md index 3f22f5dd9..12a55ddfd 100644 --- a/apps/daisy/README.md +++ b/apps/daisy/README.md @@ -1,4 +1,4 @@ -# Daisy +# Daisy ![](app.png) *A beautiful digital clock with large ring guage, idle timer and a cyclic information line that includes, day, date, steps, battery, @@ -8,15 +8,20 @@ Written by: [Hugh Barney](https://github.com/hughbarney) For support and discussion please post in the [Bangle JS Forum](http://forum.espruino.com/microcosms/1424/) -* Derived from `The Ring` proof of concept and the [Pastel clock](https://banglejs.com/apps/?q=pastel) +* Derived from [The Ring](https://banglejs.com/apps/?id=thering) proof of concept and the [Pastel clock](https://banglejs.com/apps/?q=pastel) * Includes the [Lazybones](https://banglejs.com/apps/?q=lazybones) Idle warning timer -* Touch the top right/top left to cycle through the info display (Day, Date, Steps, Sunrise, Sunset) +* Touch the top right/top left to cycle through the info display (Day, Date, Steps, Sunrise, Sunset, Heart Rate) +* The heart rate monitor is turned on only when Heart rate is selected and will take a few seconds to settle +* The heart value is displayed in RED if the confidence value is less than 50% +* NOTE: The heart rate monitor of Bangle JS 2 is not very accurate when moving about. +See [#1248](https://github.com/espruino/BangleApps/issues/1248) * Uses mylocation.json from MyLocation app to calculate sunrise and sunset times for your location +* If your Sunrise, Sunset times look odd make sure you have setup your location using +[MyLocation](https://banglejs.com/apps/?id=mylocation) * The screen is updated every minute to save battery power * Uses the [BloggerSansLight](https://www.1001fonts.com/rounded-fonts.html?page=3) font, which if free for commercial use ## Future Development -* Add a heart rate option in the information line that turns on when selected * Use mini icons in the information line rather that text * Add weather icons as per Pastel clock * Add a lock icon to the screen @@ -25,5 +30,3 @@ Forum](http://forum.espruino.com/microcosms/1424/) ![](screenshot_daisy1.png) It is worth looking at the real thing though as the screenshot does not do it justice. -(Though I need to redo this photo at some point) -![](screenshot_daisy2.jpg) diff --git a/apps/daisy/app.js b/apps/daisy/app.js index 2717f94db..01d177a32 100644 --- a/apps/daisy/app.js +++ b/apps/daisy/app.js @@ -14,16 +14,19 @@ let warned = 0; let idle = false; let IDLE_MINUTES = 26; -var pal1; // palette for 0-40% -var pal2; // palette for 50-100% -const infoWidth = 50; -const infoHeight = 14; +let pal1; // palette for 0-40% +let pal2; // palette for 50-100% +const infoLine = (3*h/4) - 6; +const infoWidth = 56; +const infoHeight = 11; var drawingSteps = false; function log_debug(o) { //print(o); } +var hrmImg = require("heatshrink").decompress(atob("i0WgIKHgPh8Ef5/g///44CBz///1///5A4PnBQk///wA4PBA4MDA4MH/+Ah/8gEP4EAjw0GA")); + // https://www.1001fonts.com/rounded-fonts.html?page=3 Graphics.prototype.setFontBloggerSansLight46 = function(scale) { // Actual height 46 (45 - 0) @@ -109,7 +112,8 @@ const infoData = { ID_SR: { calc: () => 'Sunrise: ' + sunRise }, ID_SS: { calc: () => 'Sunset: ' + sunSet }, ID_STEP: { calc: () => 'Steps: ' + getSteps() }, - ID_BATT: { calc: () => 'Battery: ' + E.getBattery() + '%' } + ID_BATT: { calc: () => 'Battery: ' + E.getBattery() + '%' }, + ID_HRM: { calc: () => hrmCurrent } }; const infoList = Object.keys(infoData).sort(); @@ -121,6 +125,9 @@ function nextInfo() { if (idx === infoList.length - 1) infoMode = infoList[0]; else infoMode = infoList[idx + 1]; } + // power HRM on/off accordingly + Bangle.setHRMPower(infoMode == "ID_HRM" ? 1 : 0); + resetHrm(); } function prevInfo() { @@ -129,8 +136,125 @@ function prevInfo() { if (idx === 0) infoMode = infoList[infoList.length - 1]; else infoMode = infoList[idx - 1]; } + // power HRM on/off accordingly + Bangle.setHRMPower(infoMode == "ID_HRM" ? 1 : 0); + resetHrm(); } +function clearInfo() { + g.setColor(g.theme.bg); + //g.setColor(g.theme.fg); + g.fillRect((w/2) - infoWidth, infoLine - infoHeight, (w/2) + infoWidth, infoLine + infoHeight); +} + +function drawInfo() { + clearInfo(); + g.setColor(g.theme.fg); + setSmallFont(); + g.setFontAlign(0,0); + + if (infoMode == "ID_HRM") { + clearInfo(); + g.setColor('#f00'); // red + drawHeartIcon(); + } else { + g.drawString((infoData[infoMode].calc()), w/2, infoLine); + } +} + +function drawHeartIcon() { + g.drawImage(hrmImg, (w/2) - infoHeight - 20, infoLine - infoHeight); +} + +function drawHrm() { + if (idle) return; // dont draw while prompting + var d = new Date(); + clearInfo(); + g.setColor(d.getSeconds()&1 ? '#f00' : g.theme.bg); + drawHeartIcon(); + setSmallFont(); + g.setFontAlign(-1,0); // left + g.setColor(hrmConfidence >= 50 ? g.theme.fg : '#f00'); + g.drawString(hrmCurrent, (w/2) + 10, infoLine); +} + +function draw() { + if (!idle) + drawClock(); + else + drawIdle(); + queueDraw(); +} + +function drawClock() { + var date = new Date(); + var timeStr = require("locale").time(date,1); + var da = date.toString().split(" "); + var time = da[4].substr(0,5); + var hh = da[4].substr(0,2); + var mm = da[4].substr(3,2); + var steps = getSteps(); + var p_steps = Math.round(100*(steps/10000)); + + g.reset(); + g.setColor(g.theme.bg); + g.fillRect(0, 0, w, h); + g.drawImage(getGaugeImage(p_steps), 0, 0); + setLargeFont(); + + g.setColor(settings.fg); + g.setFontAlign(1,0); // right aligned + g.drawString(hh, (w/2) - 1, h/2); + + g.setColor(g.theme.fg); + g.setFontAlign(-1,0); // left aligned + g.drawString(mm, (w/2) + 1, h/2); + + drawInfo(); + + // recalc sunrise / sunset every hour + if (drawCount % 60 == 0) + updateSunRiseSunSet(new Date(), location.lat, location.lon); + drawCount++; +} + +function drawSteps() { + if (drawingSteps) return; + drawingSteps = true; + clearInfo(); + setSmallFont(); + g.setFontAlign(0,0); + g.setColor(g.theme.fg); + g.drawString('Steps ' + getSteps(), w/2, (3*h/4) - 4); + drawingSteps = false; +} + +///////////////// GAUGE images ///////////////////////////////////// + +var hrmCurrent = "--"; +var hrmConfidence = 0; + +function resetHrm() { + hrmCurrent = "--"; + hrmConfidence = 0; + if (infoMode == "ID_HRM") { + clearInfo(); + g.setColor('#f00'); // red + drawHeartIcon(); + } +} + +Bangle.on('HRM', function(hrm) { + hrmCurrent = hrm.bpm; + hrmConfidence = hrm.confidence; + log_debug("HRM=" + hrm.bpm + " (" + hrm.confidence + ")"); + if (infoMode == "ID_HRM" ) drawHrm(); +}); + + +///////////////// GAUGE images ///////////////////////////////////// + + // putting into 1 function like this, rather than individual variables // reduces ram usage from 70%-13% function getGaugeImage(p) { @@ -247,68 +371,6 @@ function getGaugeImage(p) { }; } -function draw() { - if (!idle) - drawClock(); - else - drawIdle(); - queueDraw(); -} - -function drawClock() { - var date = new Date(); - var timeStr = require("locale").time(date,1); - var da = date.toString().split(" "); - var time = da[4].substr(0,5); - var hh = da[4].substr(0,2); - var mm = da[4].substr(3,2); - var steps = getSteps(); - var p_steps = Math.round(100*(steps/10000)); - - g.reset(); - g.setColor(g.theme.bg); - g.fillRect(0, 0, w, h); - g.drawImage(getGaugeImage(p_steps), 0, 0); - setLargeFont(); - - g.setColor(settings.fg); - g.setFontAlign(1,0); // right aligned - g.drawString(hh, (w/2) - 1, h/2); - - g.setColor(g.theme.fg); - g.setFontAlign(-1,0); // left aligned - g.drawString(mm, (w/2) + 1, h/2); - - setSmallFont(); - g.setFontAlign(0,0); // left aligned - g.drawString((infoData[infoMode].calc()), w/2, (3*h/4) - 4); - - // recalc sunrise / sunset every hour - if (drawCount % 60 == 0) - updateSunRiseSunSet(new Date(), location.lat, location.lon); - drawCount++; -} - -function drawSteps() { - if (drawingSteps) return; - drawingSteps = true; - setSmallFont(); - g.setFontAlign(0,0); - var steps = getSteps(); - g.setColor(g.theme.bg); - g.fillRect((w/2) - infoWidth, (3*h/4) - infoHeight, (w/2) + infoWidth, (3*h/4) + infoHeight); - g.setColor(g.theme.fg); - g.drawString('Steps ' + steps, w/2, (3*h/4) - 4); - drawingSteps = false; -} - -/* -Bangle.on('step', s => { - drawSteps(); -}); -*/ - - ///////////////// IDLE TIMER ///////////////////////////////////// function drawIdle() { @@ -392,6 +454,8 @@ Bangle.on('step', s => { } idle = false; warned = 0; + + if (infoMode == "ID_STEP") drawSteps(); }); function checkIdle() { diff --git a/apps/daisy/metadata.json b/apps/daisy/metadata.json index c35bfefa3..695e4a85e 100644 --- a/apps/daisy/metadata.json +++ b/apps/daisy/metadata.json @@ -1,6 +1,6 @@ { "id": "daisy", "name": "Daisy", - "version":"0.02", + "version":"0.03", "dependencies": {"mylocation":"app"}, "description": "A clock based on the Pastel clock with large ring guage for steps", "icon": "app.png", From e124aa91c0b47e041619a0ac288eb3ea408daca8 Mon Sep 17 00:00:00 2001 From: Jeroen Peters Date: Thu, 3 Mar 2022 09:29:47 +0100 Subject: [PATCH 61/80] Dutch translations --- lang/nl_NL.json | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/lang/nl_NL.json b/lang/nl_NL.json index 0a39fefb2..117d4feeb 100644 --- a/lang/nl_NL.json +++ b/lang/nl_NL.json @@ -11,10 +11,10 @@ "Back": "Terug", "Repeat": "Herhalen", "Delete": "Verwijderen", - "ALARM!": "ALARV.", - "Sleep": "Stand-by", + "ALARM!": "ALARM!", + "Sleep": "Standby", "New Timer": "Nieuwe Timer", - "(repeat)": "(herhaling)", + "(repeat)": "(herhaal)", "music": "muziek", "week": "week", "Auto snooze": "Auto snooze", @@ -31,7 +31,7 @@ "minimum": "minimum", "valid period": "geldige periode", "heartrate": "hartslag", - "battery warn": "batterijwaarschuwing", + "battery warn": "batterijwaarsch.", "data": "gegevens", "step length": "staplengte", "min. confidence": "min. vertrouwen", @@ -47,7 +47,7 @@ "Yes\ndefinitely": "Ja\nzeker", "STEPS": "STAPPEN", "Show clocks": "Toon klokken", - "Record Run": "Record run", + "Record Run": "Rondje opnemen", "No Messages": "Geen berichten.", "View Message": "Bekijk bericht", "Piezo": "PiĆ«zo", @@ -63,7 +63,7 @@ "Make Connectable": "Maak Verbindbaar", "Quiet Mode": "Rustige modus", "BLE": "BLE", - "Dark BW": "Donker BW", + "Dark BW": "Donkere modus", "Apps": "Apps", "Programmable": "Programmeerbaar", "Vibration": "Trilling", @@ -82,32 +82,32 @@ "Remove": "Verwijder", "Add Device": "Apparaat toevoegen", "Connect device\nto add to\nwhitelist": "Apparaat aansluiten\ntoe te voegen aan\nwhitelist", - "Wake on Twist": "Wake on Twist", - "Wake on BTN2": "Wake op BTN2", - "Wake on BTN1": "Wake op BTN1", - "Wake on FaceUp": "Wakker worden op FaceUp", + "Wake on Twist": "Aangaan bij draaien", + "Wake on BTN2": "Aangaan bij BTN2", + "Wake on BTN1": "Aangaan bij BTN1", + "Wake on FaceUp": "Aangaan bij FaceUp", "Log": "Log", "Debug Info": "Debug info", - "Wake on BTN3": "Wake op BTN3", - "Flatten Battery": "Batterij plat maken", + "Wake on BTN3": "Aangaan bij BTN3", + "Flatten Battery": "Batterij leegmaken", "Rewrite Settings": "Instellingen herschrijven", - "Compact Storage": "Compacte opslag", - "Utilities": "Nutsbedrijven", + "Compact Storage": "Comprimeer opslag", + "Utilities": "Gereedschap", "Clock Style": "Klok Stijl", "Time Zone": "Tijdzone", - "Twist Timeout": "Time-out draaien", - "Twist Max Y": "Twist Max Y", - "Twist Threshold": "Twist Drempel", - "Wake on Touch": "Wakker worden bij aanraking", - "Compacting...\nTakes approx\n1 minute": "Verdichten...\nDuurt ongeveer\n1 minuut", - "Reset to Defaults": "Terugzetten op standaardwaarden", + "Twist Timeout": "Draaien time-out", + "Twist Max Y": "Draaien Max Y", + "Twist Threshold": "Draaien vanaf", + "Wake on Touch": "Aangaan bij aanraking", + "Compacting...\nTakes approx\n1 minute": "Comprimeren...\nDuurt ongeveer\n1 minuut", + "Reset to Defaults": "Terug naar standaardwaarden", "No Clocks Found": "Geen klokken gevonden", "Month": "Maand", - "Minute": "Minuutje", + "Minute": "Minuut", "Flattening battery - this can take hours.\nLong-press button to cancel": "Batterij leegmaken - dit kan uren duren.\nDruk lang op de knop om te annuleren", "Sleep Phase Alarm": "Slaapfase alarm", "Second": "Tweede", - "Turn Off": "Zet uit.", + "Turn Off": "Uitzetten", "Hour": "Uur", "Storage": "Opslag", "Date": "Datum", @@ -144,7 +144,7 @@ "Hide": "Verberg", "Messages": "Berichten", "Error in settings": "Fout in instellingen", - "BACK": "ACHTER", + "BACK": "TERUG", "Whitelist": "Whitelist", "Set Time": "Tijd instellen", "Disable": "Uitschakelen", @@ -162,7 +162,7 @@ "Loading": "Laden", "Music": "Muziek", "color": "kleur", - "off": "van", + "off": "uit", "Off": "Uit", "Theme": "Thema" }, From 9bf6f1f20b8fd5b83b767aedc3f75634311bf3dc Mon Sep 17 00:00:00 2001 From: Stergios Mekras Date: Thu, 3 Mar 2022 13:36:56 +0100 Subject: [PATCH 62/80] Add testing variables --- apps/smclock/app.js | 107 +++++++++++++++++++++++++++++---------- apps/smclock/settings.js | 28 ++++++++-- 2 files changed, 103 insertions(+), 32 deletions(-) diff --git a/apps/smclock/app.js b/apps/smclock/app.js index b900e4d9e..19044883e 100644 --- a/apps/smclock/app.js +++ b/apps/smclock/app.js @@ -1,30 +1,74 @@ const SETTINGSFILE = "smclock.json"; const background = { - width : 176, height : 176, bpp : 3, transparent : 1, - buffer : require("heatshrink").decompress(atob("/4A/AH4ACUb8H9MkyVJAThB/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/INP/AH4A/AAX8Yz4Afn5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/INI=")) + width: 176, + height: 176, + bpp: 3, + transparent: 1, + buffer: require("heatshrink").decompress( + atob( + "/4A/AH4ACUb8H9MkyVJAThB/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/INP/AH4A/AAX8Yz4Afn5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/IP5B/INI=" + ) + ), }; -const monthName = ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]; -const weekday = ["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]; +const monthName = [ + "Jan", + "Feb", + "Mar", + "Apr", + "May", + "Jun", + "Jul", + "Aug", + "Sep", + "Oct", + "Nov", + "Dec", +]; +const weekday = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]; // dynamic variables var batLevel = -1; -var batColor = [0,0,0]; +var batColor = [0, 0, 0]; + +// settings variables +var dateFormat; +var drawInterval; +var pollInterval; +var showAnalogFace; +var showWeekInfo; +var useVectorFont; + +// load settings +function loadSettings() { + // Helper function default setting + function def(value, def) { + return value !== undefined ? value : def; + } + var settings = require("Storage").readJSON(SETTINGSFILE, true) || {}; + + dateFormat = def(settings.dateFormat, "Short"); + drawInterval = def(settings.drawInterval, 10); + pollInterval = def(settings.pollInterval, 60); + showAnalogFace = def(settings.showAnalogFace, false); + showWeekInfo = def(settings.showWeekInfo, false); + useVectorFont = def(settings.useVectorFont, false); +} // copied from: https://gist.github.com/IamSilviu/5899269#gistcomment-3035480 function ISO8601_week_no(date) { - var tdt = new Date(date.valueOf()); - var dayn = (date.getDay() + 6) % 7; - tdt.setDate(tdt.getDate() - dayn + 3); - var firstThursday = tdt.valueOf(); - tdt.setMonth(0, 1); - if (tdt.getDay() !== 4) { - tdt.setMonth(0, 1 + ((4 - tdt.getDay()) + 7) % 7); - } - return 1 + Math.ceil((firstThursday - tdt) / 604800000); + var tdt = new Date(date.valueOf()); + var dayn = (date.getDay() + 6) % 7; + tdt.setDate(tdt.getDate() - dayn + 3); + var firstThursday = tdt.valueOf(); + tdt.setMonth(0, 1); + if (tdt.getDay() !== 4) { + tdt.setMonth(0, 1 + ((4 - tdt.getDay() + 7) % 7)); + } + return 1 + Math.ceil((firstThursday - tdt) / 604800000); } function d02(value) { - return ('0' + value).substr(-2); + return ("0" + value).substr(-2); } function pollBattery() { @@ -37,16 +81,16 @@ function getBatteryColor(level) { pollBattery(); level = batLevel; } - if(level>80) { - color = [0,0,1]; - } else if(level>60) { - color = [0,1,1]; - } else if(level>40) { - color = [0,1,0]; - } else if(level>20) { - color = [1,1,0]; + if (level > 80) { + color = [0, 0, 1]; + } else if (level > 60) { + color = [0, 1, 1]; + } else if (level > 40) { + color = [0, 1, 0]; + } else if (level > 20) { + color = [1, 1, 0]; } else { - color = [1,0,0]; + color = [1, 0, 0]; } return color; } @@ -58,7 +102,7 @@ function draw() { const bat = d02(E.getBattery()) + "%"; const d = new Date(); const day = d.getDate(); - const month = (d.getMonth() + 1); + const month = d.getMonth() + 1; const week = d02(ISO8601_week_no(d)); const date1 = d02(day) + "/" + d02(month); const date2 = weekday[d.getDay()] + " " + d02(week); @@ -69,7 +113,12 @@ function draw() { g.reset(); g.setColor(0, 0, 0); - g.setFont("Vector", 20); + console.log(useVectorFont, dateFormat); + if (useVectorFont == true && dateFormat == "Short") { + g.setFont("Vector", 20); + } else { + g.setFont("6x8", 2); + } g.drawString(date1, 105, 20, false); g.setFont("Vector", 16); g.drawString(date2, 105, 55, false); @@ -85,6 +134,8 @@ function draw() { g.drawString(bat, 52, 22, false); } +loadSettings(); + g.clear(); pollBattery(); @@ -94,7 +145,7 @@ var batInterval = setInterval(pollBattery, 60000); var drawInterval = setInterval(draw, 10000); // Stop updates when LCD is off, restart when on -Bangle.on('lcdPower',on=>{ +Bangle.on("lcdPower", (on) => { if (batInterval) clearInterval(batInterval); batInterval = undefined; if (drawInterval) clearInterval(drawInterval); @@ -102,7 +153,7 @@ Bangle.on('lcdPower',on=>{ if (on) { batInterval = setInterval(pollBattery, 60000); drawInterval = setInterval(draw, 10000); - + pollBattery(); draw(); } diff --git a/apps/smclock/settings.js b/apps/smclock/settings.js index 9d747a910..22314b764 100644 --- a/apps/smclock/settings.js +++ b/apps/smclock/settings.js @@ -8,10 +8,12 @@ // assign default values if it doesn't exist var settings = Object.assign( { - dateFormat: "short", + dateFormat: "Short", + drawInterval: 10, + pollInterval: 60, showAnalogFace: false, showWeekInfo: false, - useVectorFont: true, + useVectorFont: false, }, require("Storage").readJSON(FILE, true) || {} ); @@ -57,7 +59,21 @@ writeSettings(); }, }, - Date: stringInSettings("dateOnMain", ["Long", "Short", "ISO8601"]), + Date: stringInSettings("dateFormat", ["Long", "Short", "ISO8601"]), + "Draw Interval": { + value: settings.drawInterval, + onchange: (v) => { + settings.drawInterval = v; + writeSettings(); + }, + }, + "Poll Interval": { + value: settings.pollInterval, + onchange: (v) => { + settings.pollInterval = v; + writeSettings(); + }, + }, "Week Info": { value: settings.showWeekInfo !== undefined ? settings.showWeekInfo : false, @@ -72,7 +88,11 @@ settings.useVectorFont !== undefined ? settings.useVectorFont : false, format: (v) => (v ? "On" : "Off"), onchange: (v) => { - settings.useVectorFont = v; + if (v == "On") { + settings.useVectorFont = true; + } else { + settings.useVectorFont = false; + } writeSettings(); }, }, From 3486dc6401ecbe4dd8040e79e5c3657d105674f1 Mon Sep 17 00:00:00 2001 From: Stergios Mekras Date: Thu, 3 Mar 2022 16:38:29 +0100 Subject: [PATCH 63/80] Add true/false values for toggles --- apps/smclock/settings.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/apps/smclock/settings.js b/apps/smclock/settings.js index 22314b764..0fa0340d5 100644 --- a/apps/smclock/settings.js +++ b/apps/smclock/settings.js @@ -55,11 +55,15 @@ settings.showAnalogFace !== undefined ? settings.showAnalogFace : false, format: (v) => (v ? "On" : "Off"), onchange: (v) => { - settings.showAnalogFace = v; + if (v == "On") { + settings.showAnalogFace = true; + } else { + settings.showAnalogFace = false; + } writeSettings(); }, }, - Date: stringInSettings("dateFormat", ["Long", "Short", "ISO8601"]), + Date: stringInSettings("dateFormat", ["Long", "Short"]), "Draw Interval": { value: settings.drawInterval, onchange: (v) => { @@ -79,7 +83,11 @@ settings.showWeekInfo !== undefined ? settings.showWeekInfo : false, format: (v) => (v ? "On" : "Off"), onchange: (v) => { - settings.showWeekInfo = v; + if (v == "On") { + settings.showWeekInfo = true; + } else { + settings.showWeekInfo = false; + } writeSettings(); }, }, From cdb4ed5f16600316abae23878c12087c6daa7c42 Mon Sep 17 00:00:00 2001 From: Stergios Mekras Date: Thu, 3 Mar 2022 16:38:56 +0100 Subject: [PATCH 64/80] Fix battery display when full --- apps/smclock/app.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/apps/smclock/app.js b/apps/smclock/app.js index 19044883e..0294f070b 100644 --- a/apps/smclock/app.js +++ b/apps/smclock/app.js @@ -99,7 +99,7 @@ function draw() { g.drawImage(background); const color = getBatteryColor(batLevel); - const bat = d02(E.getBattery()) + "%"; + const bat; const d = new Date(); const day = d.getDate(); const month = d.getMonth() + 1; @@ -110,6 +110,12 @@ function draw() { const m = d.getMinutes(); const time = d02(h) + ":" + d02(m); + if (E.getBattery() < 100) { + bat = d02(E.getBattery()) + "%" + } else { + bat = E.getBattery() + "%" + } + g.reset(); g.setColor(0, 0, 0); @@ -131,7 +137,11 @@ function draw() { g.setFont("Vector", 16); g.drawString("Bat:", 12, 22, false); g.setColor(color[0], color[1], color[2]); - g.drawString(bat, 52, 22, false); + if (batLevel < 100) { + g.drawString(bat, 52, 22, false); + } else { + g.drawString(bat, 46, 22, false); + } } loadSettings(); From 9abde22f8e1276c74929e378956e067d246bcad3 Mon Sep 17 00:00:00 2001 From: Stergios Mekras Date: Wed, 23 Feb 2022 09:24:33 +0100 Subject: [PATCH 65/80] Add screenshot --- apps/smclock/metadata.json | 5 +++++ apps/smclock/screenshot.png | Bin 0 -> 2845 bytes 2 files changed, 5 insertions(+) create mode 100644 apps/smclock/screenshot.png diff --git a/apps/smclock/metadata.json b/apps/smclock/metadata.json index e2fbeace1..0cbf0b261 100644 --- a/apps/smclock/metadata.json +++ b/apps/smclock/metadata.json @@ -3,7 +3,12 @@ "name":"Monogram Watch Face", "shortName":"MonoClock", "icon":"app.png", +<<<<<<< HEAD "version":"0.03", +======= + "screenshots": [{"url":"screenshot.png"}], + "version":"0.02", +>>>>>>> 29432bb9 (Add screenshot) "description": "A simple watchface based on my stylised monogram.", "tags":"clock", "readme":"README.md", diff --git a/apps/smclock/screenshot.png b/apps/smclock/screenshot.png new file mode 100644 index 0000000000000000000000000000000000000000..c0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QXxS z-nf!4W(nM)Y^Zr=9@c>BG?xODd34iX{-TS6JY;Z3lGIaE!WCse4G_x#;r~5kI8AH= YUdx_>rDxQ4@7%ip9M&0AYD0|sC!%XI-v9sr literal 0 HcmV?d00001 From 4f5fb38d73989c2a6867b61260f9d311b6724b0e Mon Sep 17 00:00:00 2001 From: Stergios Mekras Date: Thu, 3 Mar 2022 19:59:20 +0100 Subject: [PATCH 66/80] Update changelog --- apps/smclock/ChangeLog | 2 ++ 1 file changed, 2 insertions(+) diff --git a/apps/smclock/ChangeLog b/apps/smclock/ChangeLog index b029d805d..ec7e245ac 100644 --- a/apps/smclock/ChangeLog +++ b/apps/smclock/ChangeLog @@ -1,2 +1,4 @@ 0.01: Initial version 0.02: Add battery level +0.03: Fix battery display when full +0.04: Add support for settings \ No newline at end of file From 95884d4df8407f893124001b181231277be708eb Mon Sep 17 00:00:00 2001 From: Stergios Mekras Date: Thu, 3 Mar 2022 20:09:56 +0100 Subject: [PATCH 67/80] Update changelog --- apps/smclock/ChangeLog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/smclock/ChangeLog b/apps/smclock/ChangeLog index ec7e245ac..0300d5ceb 100644 --- a/apps/smclock/ChangeLog +++ b/apps/smclock/ChangeLog @@ -1,4 +1,4 @@ 0.01: Initial version 0.02: Add battery level 0.03: Fix battery display when full -0.04: Add support for settings \ No newline at end of file +0.04: Add support for settings From 7a8f3d9bd985fe65e14f12f62ff2845333dff57b Mon Sep 17 00:00:00 2001 From: Stergios Mekras Date: Thu, 3 Mar 2022 20:12:40 +0100 Subject: [PATCH 68/80] Update metadata file --- apps/smclock/metadata.json | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/apps/smclock/metadata.json b/apps/smclock/metadata.json index 79d996f2c..4a3effe71 100644 --- a/apps/smclock/metadata.json +++ b/apps/smclock/metadata.json @@ -1,18 +1,18 @@ { - "id":"smclock", - "name":"Monogram Watch Face", - "shortName":"MonoClock", - "icon":"app.png", - "screenshots": [{"url":"screenshot.png"}], - "version":"0.02", + "id": "smclock", + "name": "Monogram Watch Face", + "shortName": "MonoClock", + "icon": "app.png", + "screenshots": [{ "url": "screenshot.png" }], + "version": "0.04", "description": "A simple watchface based on my stylised monogram.", - "tags":"clock", - "readme":"README.md", - "supports" : ["BANGLEJS2"], + "tags": "clock", + "readme": "README.md", + "supports": ["BANGLEJS2"], "allow_emulator": true, "storage": [ - {"name":"smclock.app.js","url":"app.js"}, - {"name":"smclock.settings.js","url":"settings.js"}, - {"name":"smclock.img","url":"app-icon.js","evaluate":true} + { "name": "smclock.app.js", "url": "app.js" }, + { "name": "smclock.settings.js", "url": "settings.js" }, + { "name": "smclock.img", "url": "app-icon.js", "evaluate": true } ] } From fd9fb6cba4014ec1cd4f68bb72e7746a452fab21 Mon Sep 17 00:00:00 2001 From: Stergios Mekras Date: Thu, 3 Mar 2022 20:15:32 +0100 Subject: [PATCH 69/80] Fix battery ...again --- apps/smclock/app.js | 8 +++++--- apps/smclock/settings.js | 12 +----------- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/apps/smclock/app.js b/apps/smclock/app.js index 0294f070b..9309cf508 100644 --- a/apps/smclock/app.js +++ b/apps/smclock/app.js @@ -99,7 +99,7 @@ function draw() { g.drawImage(background); const color = getBatteryColor(batLevel); - const bat; + const bat = ""; const d = new Date(); const day = d.getDate(); const month = d.getMonth() + 1; @@ -111,9 +111,9 @@ function draw() { const time = d02(h) + ":" + d02(m); if (E.getBattery() < 100) { - bat = d02(E.getBattery()) + "%" + bat = d02(E.getBattery()) + "%"; } else { - bat = E.getBattery() + "%" + bat = E.getBattery() + "%"; } g.reset(); @@ -146,6 +146,8 @@ function draw() { loadSettings(); +console.log(settings); + g.clear(); pollBattery(); diff --git a/apps/smclock/settings.js b/apps/smclock/settings.js index 0fa0340d5..6ff95c72e 100644 --- a/apps/smclock/settings.js +++ b/apps/smclock/settings.js @@ -6,17 +6,7 @@ var FILE = "smclock.json"; // load settings from the file // assign default values if it doesn't exist - var settings = Object.assign( - { - dateFormat: "Short", - drawInterval: 10, - pollInterval: 60, - showAnalogFace: false, - showWeekInfo: false, - useVectorFont: false, - }, - require("Storage").readJSON(FILE, true) || {} - ); + var settings = Object.assign(require("Storage").readJSON(FILE, true) || {}); // write the new settings to the file function writeSettings() { From 515d1ea229b46007f6da5f649813d6b6b31b8a61 Mon Sep 17 00:00:00 2001 From: Stergios Mekras Date: Thu, 3 Mar 2022 20:17:04 +0100 Subject: [PATCH 70/80] Fix battery ...again --- apps/smclock/app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/smclock/app.js b/apps/smclock/app.js index 9309cf508..7fa5eae77 100644 --- a/apps/smclock/app.js +++ b/apps/smclock/app.js @@ -99,7 +99,7 @@ function draw() { g.drawImage(background); const color = getBatteryColor(batLevel); - const bat = ""; + let bat = ""; const d = new Date(); const day = d.getDate(); const month = d.getMonth() + 1; From 7b91d21bde19c398297ae881e9c34389191642fb Mon Sep 17 00:00:00 2001 From: Stergios Mekras Date: Thu, 3 Mar 2022 21:46:26 +0100 Subject: [PATCH 71/80] Fix settings, hopefully --- apps/smclock/app.js | 20 +++++++++----------- apps/smclock/metadata.json | 3 ++- apps/smclock/settings.js | 14 ++++++++++++-- 3 files changed, 23 insertions(+), 14 deletions(-) diff --git a/apps/smclock/app.js b/apps/smclock/app.js index 7fa5eae77..b417c6976 100644 --- a/apps/smclock/app.js +++ b/apps/smclock/app.js @@ -27,16 +27,16 @@ const monthName = [ const weekday = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]; // dynamic variables -var batLevel = -1; -var batColor = [0, 0, 0]; +let batLevel = -1; +let batColor = [0, 0, 0]; // settings variables -var dateFormat; -var drawInterval; -var pollInterval; -var showAnalogFace; -var showWeekInfo; -var useVectorFont; +let dateFormat; +let drawInterval; +let pollInterval; +let showAnalogFace; +let showWeekInfo; +let useVectorFont; // load settings function loadSettings() { @@ -44,7 +44,7 @@ function loadSettings() { function def(value, def) { return value !== undefined ? value : def; } - var settings = require("Storage").readJSON(SETTINGSFILE, true) || {}; + let settings = require("Storage").readJSON(SETTINGSFILE, true) || {}; dateFormat = def(settings.dateFormat, "Short"); drawInterval = def(settings.drawInterval, 10); @@ -146,8 +146,6 @@ function draw() { loadSettings(); -console.log(settings); - g.clear(); pollBattery(); diff --git a/apps/smclock/metadata.json b/apps/smclock/metadata.json index 4a3effe71..cce18a648 100644 --- a/apps/smclock/metadata.json +++ b/apps/smclock/metadata.json @@ -14,5 +14,6 @@ { "name": "smclock.app.js", "url": "app.js" }, { "name": "smclock.settings.js", "url": "settings.js" }, { "name": "smclock.img", "url": "app-icon.js", "evaluate": true } - ] + ], + "data": [{ "name": "smclock.json" }] } diff --git a/apps/smclock/settings.js b/apps/smclock/settings.js index 6ff95c72e..81c0a0af1 100644 --- a/apps/smclock/settings.js +++ b/apps/smclock/settings.js @@ -3,10 +3,20 @@ // helper functions taken from Anton Clock (function (back) { - var FILE = "smclock.json"; + const FILE = "smclock.json"; // load settings from the file // assign default values if it doesn't exist - var settings = Object.assign(require("Storage").readJSON(FILE, true) || {}); + let settings = Object.assign( + { + dateFormat: "Short", + drawInterval: 10, + pollInterval: 60, + showAnalogFace: false, + showWeekInfo: false, + useVectorFont: false, + }, + require("Storage").readJSON(FILE, true) || {} + ); // write the new settings to the file function writeSettings() { From 57f7d489209a9304076bf88b781d453b903fd3e2 Mon Sep 17 00:00:00 2001 From: Stergios Mekras Date: Thu, 3 Mar 2022 22:23:57 +0100 Subject: [PATCH 72/80] Fix drawInterval --- apps/smclock/app.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/smclock/app.js b/apps/smclock/app.js index b417c6976..223dd053a 100644 --- a/apps/smclock/app.js +++ b/apps/smclock/app.js @@ -152,17 +152,17 @@ pollBattery(); draw(); var batInterval = setInterval(pollBattery, 60000); -var drawInterval = setInterval(draw, 10000); +let actualDrawInterval = setInterval(draw, drawInterval * 1000); // Stop updates when LCD is off, restart when on Bangle.on("lcdPower", (on) => { if (batInterval) clearInterval(batInterval); batInterval = undefined; - if (drawInterval) clearInterval(drawInterval); - drawInterval = undefined; + if (actualDrawInterval) clearInterval(actualDrawInterval); + actualDrawInterval = undefined; if (on) { batInterval = setInterval(pollBattery, 60000); - drawInterval = setInterval(draw, 10000); + actualDrawInterval = setInterval(draw, drawInterval * 1000); pollBattery(); draw(); From 968707d76153151f07ed2414ea27e1f909023b09 Mon Sep 17 00:00:00 2001 From: Stergios Mekras Date: Thu, 3 Mar 2022 23:02:05 +0100 Subject: [PATCH 73/80] Update metajason file --- apps/smclock/metadata.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/smclock/metadata.json b/apps/smclock/metadata.json index cce18a648..cc995d587 100644 --- a/apps/smclock/metadata.json +++ b/apps/smclock/metadata.json @@ -6,9 +6,10 @@ "screenshots": [{ "url": "screenshot.png" }], "version": "0.04", "description": "A simple watchface based on my stylised monogram.", + "type": "clock", "tags": "clock", "readme": "README.md", - "supports": ["BANGLEJS2"], + "supports": ["BANGLEJS", "BANGLEJS2"], "allow_emulator": true, "storage": [ { "name": "smclock.app.js", "url": "app.js" }, From bd8c89b538e86096ab0ae093b55888265215ddfa Mon Sep 17 00:00:00 2001 From: Stergios Mekras Date: Thu, 3 Mar 2022 23:30:34 +0100 Subject: [PATCH 74/80] Fix issue with evaluating arrow output --- apps/smclock/app.js | 26 +++++++++++------------- apps/smclock/settings.js | 43 +++++++++++++++------------------------- 2 files changed, 28 insertions(+), 41 deletions(-) diff --git a/apps/smclock/app.js b/apps/smclock/app.js index 223dd053a..4516ca9e5 100644 --- a/apps/smclock/app.js +++ b/apps/smclock/app.js @@ -27,24 +27,22 @@ const monthName = [ const weekday = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]; // dynamic variables -let batLevel = -1; -let batColor = [0, 0, 0]; +var batLevel = -1; +var batColor = [0, 0, 0]; // settings variables -let dateFormat; -let drawInterval; -let pollInterval; -let showAnalogFace; -let showWeekInfo; -let useVectorFont; +var dateFormat; +var drawInterval; +var pollInterval; +var showAnalogFace; +var showWeekInfo; +var useVectorFont; // load settings function loadSettings() { // Helper function default setting - function def(value, def) { - return value !== undefined ? value : def; - } - let settings = require("Storage").readJSON(SETTINGSFILE, true) || {}; + function def(value, def) {return value !== undefined ? value : def;} + var settings = require("Storage").readJSON(SETTINGSFILE, true) || {}; dateFormat = def(settings.dateFormat, "Short"); drawInterval = def(settings.drawInterval, 10); @@ -99,7 +97,7 @@ function draw() { g.drawImage(background); const color = getBatteryColor(batLevel); - let bat = ""; + var bat = ""; const d = new Date(); const day = d.getDate(); const month = d.getMonth() + 1; @@ -152,7 +150,7 @@ pollBattery(); draw(); var batInterval = setInterval(pollBattery, 60000); -let actualDrawInterval = setInterval(draw, drawInterval * 1000); +var actualDrawInterval = setInterval(draw, drawInterval * 1000); // Stop updates when LCD is off, restart when on Bangle.on("lcdPower", (on) => { diff --git a/apps/smclock/settings.js b/apps/smclock/settings.js index 81c0a0af1..53ff974f3 100644 --- a/apps/smclock/settings.js +++ b/apps/smclock/settings.js @@ -3,36 +3,31 @@ // helper functions taken from Anton Clock (function (back) { - const FILE = "smclock.json"; + var FILE = "smclock.json"; // load settings from the file // assign default values if it doesn't exist - let settings = Object.assign( - { + var settings = Object.assign({ dateFormat: "Short", drawInterval: 10, pollInterval: 60, showAnalogFace: false, showWeekInfo: false, useVectorFont: false, - }, - require("Storage").readJSON(FILE, true) || {} - ); + }, require("Storage").readJSON(FILE, true) || {}); // write the new settings to the file - function writeSettings() { - require("Storage").writeJSON(FILE, settings); - } + function writeSettings() {require("Storage").writeJSON(FILE, settings);} // helper method which uses int-based menu item for set of string values function stringItems(startvalue, writer, values) { return { value: startvalue === undefined ? 0 : values.indexOf(startvalue), - format: (v) => values[v], + format: v => values[v], min: 0, max: values.length - 1, wrap: true, step: 1, - onchange: (v) => { + onchange: v => { writer(values[v]); writeSettings(); }, @@ -46,15 +41,13 @@ // settings menu var mainmenu = { - "": { - title: "Monogram Clock", - }, + "": {title: "Monogram Clock",}, "< Back": () => back(), "Analog Face": { value: settings.showAnalogFace !== undefined ? settings.showAnalogFace : false, - format: (v) => (v ? "On" : "Off"), - onchange: (v) => { + format: v => v ? "On" : "Off", + onchange: v => { if (v == "On") { settings.showAnalogFace = true; } else { @@ -66,14 +59,14 @@ Date: stringInSettings("dateFormat", ["Long", "Short"]), "Draw Interval": { value: settings.drawInterval, - onchange: (v) => { + onchange: v => { settings.drawInterval = v; writeSettings(); }, }, "Poll Interval": { value: settings.pollInterval, - onchange: (v) => { + onchange: v => { settings.pollInterval = v; writeSettings(); }, @@ -81,8 +74,8 @@ "Week Info": { value: settings.showWeekInfo !== undefined ? settings.showWeekInfo : false, - format: (v) => (v ? "On" : "Off"), - onchange: (v) => { + format: v => v ? "On" : "Off", + onchange: v => { if (v == "On") { settings.showWeekInfo = true; } else { @@ -94,13 +87,9 @@ "Vector Font": { value: settings.useVectorFont !== undefined ? settings.useVectorFont : false, - format: (v) => (v ? "On" : "Off"), - onchange: (v) => { - if (v == "On") { - settings.useVectorFont = true; - } else { - settings.useVectorFont = false; - } + format: v => v ? "On" : "Off", + onchange: v => { + settings.useVectorFont = v; writeSettings(); }, }, From 46717acb3c1d764d3e2c4afde869434b442eeff6 Mon Sep 17 00:00:00 2001 From: Stergios Mekras Date: Fri, 4 Mar 2022 00:05:17 +0100 Subject: [PATCH 75/80] Add font support for battery info --- apps/smclock/app.js | 46 +++++++++++++++++++-------------------------- 1 file changed, 19 insertions(+), 27 deletions(-) diff --git a/apps/smclock/app.js b/apps/smclock/app.js index 4516ca9e5..9630bb42e 100644 --- a/apps/smclock/app.js +++ b/apps/smclock/app.js @@ -10,20 +10,7 @@ const background = { ) ), }; -const monthName = [ - "Jan", - "Feb", - "Mar", - "Apr", - "May", - "Jun", - "Jul", - "Aug", - "Sep", - "Oct", - "Nov", - "Dec", -]; +const monthName = ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]; const weekday = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]; // dynamic variables @@ -116,8 +103,23 @@ function draw() { g.reset(); + // draw battery info + g.setColor(1, 1, 1); + if (useVectorFont == true) { + g.setFont("Vector", 16); + g.drawString("Bat:", 12, 22, false); + } else { + g.setFont("4x6", 2); + g.drawString("Bat:", 10, 22, false); + } + g.setColor(color[0], color[1], color[2]); + if (batLevel < 100) { + g.drawString(bat, 52, 22, false); + } else { + g.drawString(bat, 46, 22, false); + } + g.setColor(0, 0, 0); - console.log(useVectorFont, dateFormat); if (useVectorFont == true && dateFormat == "Short") { g.setFont("Vector", 20); } else { @@ -130,16 +132,6 @@ function draw() { g.setColor(1, 1, 1); g.setFont("Vector", 60); g.drawString(time, 10, 108, false); - - g.setColor(1, 1, 1); - g.setFont("Vector", 16); - g.drawString("Bat:", 12, 22, false); - g.setColor(color[0], color[1], color[2]); - if (batLevel < 100) { - g.drawString(bat, 52, 22, false); - } else { - g.drawString(bat, 46, 22, false); - } } loadSettings(); @@ -149,7 +141,7 @@ g.clear(); pollBattery(); draw(); -var batInterval = setInterval(pollBattery, 60000); +var batInterval = setInterval(pollBattery, pollInterval * 1000); var actualDrawInterval = setInterval(draw, drawInterval * 1000); // Stop updates when LCD is off, restart when on @@ -159,7 +151,7 @@ Bangle.on("lcdPower", (on) => { if (actualDrawInterval) clearInterval(actualDrawInterval); actualDrawInterval = undefined; if (on) { - batInterval = setInterval(pollBattery, 60000); + batInterval = setInterval(pollBattery, pollInterval * 1000); actualDrawInterval = setInterval(draw, drawInterval * 1000); pollBattery(); From 9664368caa3f76da80855cb2d67fc7416155d0f0 Mon Sep 17 00:00:00 2001 From: Stergios Mekras Date: Fri, 4 Mar 2022 00:14:20 +0100 Subject: [PATCH 76/80] Add font support for time display --- apps/smclock/app.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/apps/smclock/app.js b/apps/smclock/app.js index 9630bb42e..cb7d2e3e9 100644 --- a/apps/smclock/app.js +++ b/apps/smclock/app.js @@ -129,9 +129,15 @@ function draw() { g.setFont("Vector", 16); g.drawString(date2, 105, 55, false); + // draw time g.setColor(1, 1, 1); - g.setFont("Vector", 60); - g.drawString(time, 10, 108, false); + if (useVectorFont == true) { + g.setFont("Vector", 60); + g.drawString(time, 10, 108, false); + } else { + g.setFont("6x8", 5); + g.drawString(time, 14, 112, false); + } } loadSettings(); From f89579ad6d98973e3daaf34a2a068ebd736c690b Mon Sep 17 00:00:00 2001 From: Stergios Mekras Date: Fri, 4 Mar 2022 00:52:33 +0100 Subject: [PATCH 77/80] Add font support for date and week info --- apps/smclock/app.js | 37 +++++++++++++++++++++++++++++++------ apps/smclock/settings.js | 12 ++---------- 2 files changed, 33 insertions(+), 16 deletions(-) diff --git a/apps/smclock/app.js b/apps/smclock/app.js index cb7d2e3e9..099fcad74 100644 --- a/apps/smclock/app.js +++ b/apps/smclock/app.js @@ -89,8 +89,8 @@ function draw() { const day = d.getDate(); const month = d.getMonth() + 1; const week = d02(ISO8601_week_no(d)); - const date1 = d02(day) + "/" + d02(month); - const date2 = weekday[d.getDay()] + " " + d02(week); + const date1 = ""; + const date2 = ""; const h = d.getHours(); const m = d.getMinutes(); const time = d02(h) + ":" + d02(m); @@ -119,15 +119,40 @@ function draw() { g.drawString(bat, 46, 22, false); } + // draw date info g.setColor(0, 0, 0); - if (useVectorFont == true && dateFormat == "Short") { + if (useVectorFont == true) { g.setFont("Vector", 20); } else { g.setFont("6x8", 2); } - g.drawString(date1, 105, 20, false); - g.setFont("Vector", 16); - g.drawString(date2, 105, 55, false); + if (dateFormat == "Short") { + date1 = d02(day) + "/" + d02(month); + g.drawString(date1, 105, 20, false); + } else { + date1 = monthName[month - 1] + d02(day); + g.drawString(date1, 104, 20, false); + } + + // draw week info + if (showWeekInfo == true) { + date2 = weekday[d.getDay()] + " " + d02(week) + if (useVectorFont == true) { + g.setFont("Vector", 18); + } else { + g.setFont("6x8", 2); + } + g.drawString(date2, 105, 55, false); + } else { + date2 = d.getFullYear(); + if (useVectorFont == true) { + g.setFont("Vector", 22); + g.drawString(date2, 105, 55, false); + } else { + g.setFont("4x6", 3); + g.drawString(date2, 108, 55, false); + } + } // draw time g.setColor(1, 1, 1); diff --git a/apps/smclock/settings.js b/apps/smclock/settings.js index 53ff974f3..a6c7d1b98 100644 --- a/apps/smclock/settings.js +++ b/apps/smclock/settings.js @@ -48,11 +48,7 @@ settings.showAnalogFace !== undefined ? settings.showAnalogFace : false, format: v => v ? "On" : "Off", onchange: v => { - if (v == "On") { - settings.showAnalogFace = true; - } else { - settings.showAnalogFace = false; - } + settings.showAnalogFace = v; writeSettings(); }, }, @@ -76,11 +72,7 @@ settings.showWeekInfo !== undefined ? settings.showWeekInfo : false, format: v => v ? "On" : "Off", onchange: v => { - if (v == "On") { - settings.showWeekInfo = true; - } else { - settings.showWeekInfo = false; - } + settings.showWeekInfo = v; writeSettings(); }, }, From 0a798aa5e7e54403c417783ab11f3bb7b04837da Mon Sep 17 00:00:00 2001 From: Stergios Mekras Date: Fri, 4 Mar 2022 01:03:49 +0100 Subject: [PATCH 78/80] Fix date variables --- apps/smclock/app.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/smclock/app.js b/apps/smclock/app.js index ebc3efde1..44037a7a7 100644 --- a/apps/smclock/app.js +++ b/apps/smclock/app.js @@ -94,8 +94,8 @@ function draw() { const day = d.getDate(); const month = d.getMonth() + 1; const week = d02(ISO8601_week_no(d)); - const date1 = ""; - const date2 = ""; + var date1 = ""; + var date2 = ""; const h = d.getHours(); const m = d.getMinutes(); const time = d02(h) + ":" + d02(m); From 7c46d95119a225302ed6cff17ae08e7e2819de7b Mon Sep 17 00:00:00 2001 From: Stergios Mekras Date: Fri, 4 Mar 2022 01:06:14 +0100 Subject: [PATCH 79/80] Remove unnecessary merge info from changelog and metadata file --- apps/smclock/ChangeLog | 4 ---- apps/smclock/metadata.json | 13 ------------- 2 files changed, 17 deletions(-) diff --git a/apps/smclock/ChangeLog b/apps/smclock/ChangeLog index b09db0145..0300d5ceb 100644 --- a/apps/smclock/ChangeLog +++ b/apps/smclock/ChangeLog @@ -1,8 +1,4 @@ 0.01: Initial version 0.02: Add battery level -<<<<<<< HEAD -0.03: fix battery level displaying -======= 0.03: Fix battery display when full 0.04: Add support for settings ->>>>>>> feature/introduce_settings diff --git a/apps/smclock/metadata.json b/apps/smclock/metadata.json index 5918406d6..cc995d587 100644 --- a/apps/smclock/metadata.json +++ b/apps/smclock/metadata.json @@ -1,23 +1,10 @@ { -<<<<<<< HEAD - "id":"smclock", - "name":"Monogram Watch Face", - "shortName":"MonoClock", - "icon":"app.png", -<<<<<<< HEAD - "version":"0.03", -======= - "screenshots": [{"url":"screenshot.png"}], - "version":"0.02", ->>>>>>> 29432bb9 (Add screenshot) -======= "id": "smclock", "name": "Monogram Watch Face", "shortName": "MonoClock", "icon": "app.png", "screenshots": [{ "url": "screenshot.png" }], "version": "0.04", ->>>>>>> feature/introduce_settings "description": "A simple watchface based on my stylised monogram.", "type": "clock", "tags": "clock", From a4c76e3d3aaad674b35abe2efff809d7db2e612d Mon Sep 17 00:00:00 2001 From: Stergios Mekras Date: Fri, 4 Mar 2022 01:09:11 +0100 Subject: [PATCH 80/80] Remove unnecessary merge info from main app file --- apps/smclock/app.js | 9 --------- 1 file changed, 9 deletions(-) diff --git a/apps/smclock/app.js b/apps/smclock/app.js index 44037a7a7..350c0dd07 100644 --- a/apps/smclock/app.js +++ b/apps/smclock/app.js @@ -83,13 +83,8 @@ function getBatteryColor(level) { function draw() { g.drawImage(background); -<<<<<<< HEAD - const color = getBatteryColor(); - const bat = E.getBattery() + "%"; -======= const color = getBatteryColor(batLevel); var bat = ""; ->>>>>>> feature/introduce_settings const d = new Date(); const day = d.getDate(); const month = d.getMonth() + 1; @@ -118,9 +113,6 @@ function draw() { g.drawString("Bat:", 10, 22, false); } g.setColor(color[0], color[1], color[2]); -<<<<<<< HEAD - g.drawString(bat, 46, 22, false); -======= if (batLevel < 100) { g.drawString(bat, 52, 22, false); } else { @@ -171,7 +163,6 @@ function draw() { g.setFont("6x8", 5); g.drawString(time, 14, 112, false); } ->>>>>>> feature/introduce_settings } loadSettings();