Skip to content

Commit

Permalink
Merge branch 'espruino:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
jabituyaben authored Oct 20, 2023
2 parents 0745533 + 503516e commit 14ede8b
Show file tree
Hide file tree
Showing 13 changed files with 370 additions and 139 deletions.
4 changes: 2 additions & 2 deletions apps/calendar/settings.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
(function (back) {
var FILE = "calendar.json";
const HOLIDAY_FILE = "calendar.days.json";
var settings = require('Storage').readJSON(FILE, true) || {};
var settings = require('Storage').readJSON(FILE, 1) || {};
if (settings.ndColors === undefined)
if (process.env.HWVERSION == 2) {
settings.ndColors = true;
} else {
settings.ndColors = false;
}
const holidays = require("Storage").readJSON(HOLIDAY_FILE,1).sort((a,b) => new Date(a.date) - new Date(b.date)) || [];
const holidays = (require("Storage").readJSON(HOLIDAY_FILE,1)||[]).sort((a,b) => new Date(a.date) - new Date(b.date)) || [];

function writeSettings() {
require('Storage').writeJSON(FILE, settings);
Expand Down
3 changes: 2 additions & 1 deletion apps/fwupdate/custom.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
<a href="https://www.espruino.com/Bangle.js#firmware-updates" target="_blank">see the Bangle.js 1 instructions</a></b></p>
</div>
<ul>
<p>Your current firmware version is <span id="fw-version" style="font-weight:bold">unknown</span> and DFU is <span id="boot-version" style="font-weight:bold">unknown</span></p>
<p>Your current firmware version is <span id="fw-version" style="font-weight:bold">unknown</span> and DFU is <span id="boot-version" style="font-weight:bold">unknown</span>.
The DFU (bootloader) rarely changes, so it does not have to be the same version as your main firmware.</p>
</ul>
<div id="fw-ok" style="display:none">
<p id="fw-old-bootloader-msg">If you have an early (KickStarter or developer) Bangle.js device and still have the old 2v10.x DFU, the Firmware Update
Expand Down
1 change: 1 addition & 0 deletions apps/grocery/ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
0.02: Refactor code to store grocery list in separate file
0.03: Sort selected items to bottom and enable Widgets
0.04: Add settings to edit list on device
0.05: Drop app customiser as it is redundant with download interface
24 changes: 15 additions & 9 deletions apps/grocery/app.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
var filename = 'grocery_list.json';
var settings = require("Storage").readJSON(filename,1)|| { products: [] };
{
const filename = 'grocery_list.json';
const settings = require("Storage").readJSON(filename,1)|| { products: [] };
let menu;

function updateSettings() {
const updateSettings = function() {
require("Storage").writeJSON(filename, settings);
Bangle.buzz();
}
};

function twoChat(n){
const twoChat = function(n) {
if(n<10) return '0'+n;
return ''+n;
}
};

function sortMenu() {
const sortMenu = function() {
mainMenu.sort((a,b) => {
const byValue = a.value-b.value;
return byValue !== 0 ? byValue : a.index-b.index;
});
if (menu) {
menu.draw();
}
}
};

const mainMenu = settings.products.map((p,i) => ({
title: twoChat(p.quantity)+' '+p.name,
Expand All @@ -35,9 +36,14 @@ const mainMenu = settings.products.map((p,i) => ({
}));
sortMenu();

mainMenu[''] = { 'title': 'Grocery list' };
mainMenu[''] = {
'title': 'Grocery list',
remove: () => {
},
};
mainMenu['< Back'] = ()=>{load();};

Bangle.loadWidgets();
menu = E.showMenu(mainMenu);
Bangle.drawWidgets();
}
116 changes: 0 additions & 116 deletions apps/grocery/grocery.html

This file was deleted.

3 changes: 1 addition & 2 deletions apps/grocery/interface.html
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ <h4>Add a new product</h4>
// remove window
Util.hideModal();

settings = JSON.parse(data || "{products: []}");
settings = JSON.parse(data || '{"products": []}');
products = settings.products;
renderProducts();
});
Expand All @@ -89,7 +89,6 @@ <h4>Add a new product</h4>
function save(){
settings.products = products;
Util.showModal("Saving...");
localStorage.setItem('grocery-product-list',JSON.stringify(products));
Util.writeStorage("grocery_list.json", JSON.stringify(settings), () => {
Util.hideModal();
});
Expand Down
3 changes: 1 addition & 2 deletions apps/grocery/metadata.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
{
"id": "grocery",
"name": "Grocery",
"version": "0.04",
"version": "0.05",
"description": "Simple grocery (shopping) list - Display a list of product and track if you already put them in your cart.",
"icon": "grocery.png",
"type": "app",
"tags": "tool,shopping,list",
"supports": ["BANGLEJS", "BANGLEJS2"],
"custom": "grocery.html",
"interface": "interface.html",
"allow_emulator": true,
"dependencies": {"textinput":"type"},
Expand Down
2 changes: 1 addition & 1 deletion apps/grocery/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
/*LANG*/"Edit List": () => editlist(),
/*LANG*/"Add item": () => {
settings.products.push({
"name":/*LANG*/"New item",
"name":/*LANG*/"New",
"quantity":1,
"ok":false
});
Expand Down
1 change: 1 addition & 0 deletions apps/widminbate/ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
0.03: Do not clear outside of widget bar
0.04: Fork `widminbat`->`widminbate`. Only use the system theme foreground
colour.
0.05: Fix broken fork which removed the `update` function
2 changes: 1 addition & 1 deletion apps/widminbate/metadata.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{ "id": "widminbate",
"name": "Extra Minimal Battery",
"shortName":"ExtraMinBat",
"version":"0.04",
"version":"0.05",
"description": "An extra minimal (only use system theme foreground colour) version of the battery widget that only appears if the battery is running low (below 30%)",
"icon": "widget.png",
"type": "widget",
Expand Down
11 changes: 6 additions & 5 deletions apps/widminbate/widget.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(()=>{
function getWidth() {
{
let getWidth = function() {
return E.getBattery() <= 30 || Bangle.isCharging() ? 40 : 0;
}
};
WIDGETS.minbate={area:"tr",width:getWidth(),draw:function() {
if(this.width < 40) return;
var s = 39;
Expand All @@ -12,6 +12,7 @@
clearRect(x,y,x+s,y+23).
setColor(g.theme.fg).fillRect(x,y+2,x+s-4,y+21).clearRect(x+2,y+4,x+s-6,y+19).fillRect(x+s-3,y+10,x+s,y+14).//border
fillRect(x+4,y+6,x+4+barWidth,y+17);//indicator bar
},update: function() {
var newWidth = getWidth();
if(newWidth != this.width) {
this.width = newWidth;
Expand All @@ -22,7 +23,7 @@
}};
setInterval(()=>{
var widget = WIDGETS.minbate;
if(widget) {widget.update();}
if(widget) widget.update();
}, 10*60*1000);
Bangle.on('charging', () => WIDGETS.minbate.update());
})();
}
Loading

0 comments on commit 14ede8b

Please sign in to comment.