Merge pull request #771 from FxIII/master

some fixes/ improvement and a couple of clones
master
Gordon Williams 2021-07-26 09:06:32 +01:00 committed by GitHub
commit b27efe378b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 190 additions and 7 deletions

View File

@ -533,7 +533,7 @@
{ "id": "files",
"name": "App Manager",
"icon": "files.png",
"version":"0.06",
"version":"0.07",
"description": "Show currently installed apps, free space, and allow their deletion from the watch",
"tags": "tool,system,files",
"storage": [
@ -1244,6 +1244,19 @@
{"name":"torch.img","url":"app-icon.js","evaluate":true}
]
},
{ "id": "rtorch",
"name": "Red Torch",
"shortName":"RedTorch",
"icon": "app.png",
"version":"0.01",
"description": "Turns screen RED to help you see in the dark without breaking your night vision. Select from the launcher or press BTN3,BTN1,BTN3,BTN1 quickly to start when in any app that shows widgets",
"tags": "tool,torch",
"storage": [
{"name":"rtorch.app.js","url":"app.js"},
{"name":"rtorch.wid.js","url":"widget.js"},
{"name":"rtorch.img","url":"app-icon.js","evaluate":true}
]
},
{ "id": "wohrm",
"name": "Workout HRM",
"icon": "app.png",
@ -1746,7 +1759,7 @@
"name": "Black Jack game",
"shortName":"Black Jack game",
"icon": "blackjack.png",
"version":"0.01",
"version":"0.02",
"description": "Simple implementation of card game Black Jack",
"tags": "game",
"allow_emulator":true,
@ -2097,6 +2110,20 @@
{ "name": "jbm8b.img", "url": "app-icon.js", "evaluate": true }
]
},
{
"id": "jbm8b_IT",
"name": "Magic 8 Ball Italiano",
"shortName": "Magic 8 Ball IT",
"icon": "app.png",
"description": "La palla predice il futuro",
"tags": "game",
"version": "0.03",
"allow_emulator":true,
"storage": [
{ "name": "jbm8b_IT.app.js", "url": "app.js" },
{ "name": "jbm8b_IT.img", "url": "app-icon.js", "evaluate": true }
]
},
{ "id": "BLEcontroller",
"name": "BLE Customisable Controller with Joystick",
"shortName": "BLE Controller",
@ -2667,7 +2694,7 @@
{ "id": "dtlaunch",
"name": "Desktop Launcher",
"icon": "icon.png",
"version":"0.03",
"version":"0.04",
"description": "Desktop style App Launcher with six apps per page - fast access if you have lots of apps installed.",
"readme": "README.md",
"tags": "tool,system,launcher",

View File

@ -1 +1,2 @@
0.01: New game! BTN4- Hit card, BTN5- Stand
0.01: New game! BTN4- Hit card, BTN5- Stand
0.02: ignore buttons on pauses

View File

@ -18,6 +18,7 @@ const Diamonds = { width : 48, height : 48, bpp : 4,
var deck = [];
var player = {Hand:[]};
var computer = {Hand:[]};
var ctx = {ready:true};
function createDeck() {
var suits = ["Spades", "Hearts", "Diamonds", "Clubs"];
@ -44,6 +45,7 @@ function shuffle(a) {
}
function EndGameMessdage(msg){
ctx.ready = false;
g.drawString(msg, 155, 200);
setTimeout(function(){
startGame();
@ -52,6 +54,7 @@ function EndGameMessdage(msg){
}
function hitMe() {
if (!ctx.ready) return;
player.Hand.push(deck.pop());
renderOnScreen(1);
var playerWeight = calcWeight(player.Hand, 0);
@ -97,6 +100,8 @@ function calcWeight(hand, hideCard) {
}
function stand(){
if (!ctx.ready) return;
ctx.ready = false;
function sleepFor( sleepDuration ){
console.log("Sleeping...");
var now = new Date().getTime();
@ -156,6 +161,7 @@ function renderOnScreen(HideCard) {
function dealHands() {
player.Hand= [];
computer.Hand= [];
ctx.ready = false;
setTimeout(function(){
player.Hand.push(deck.pop());
@ -175,6 +181,7 @@ function dealHands() {
setTimeout(function(){
computer.Hand.push(deck.pop());
renderOnScreen(1);
ctx.ready = true;
}, 2000);
}

View File

@ -1,4 +1,4 @@
0.01: Initial version
0.02: Multiple pages
0.03: cycle thru pages
0.04: reset to clock after 2 mins of inactivity

View File

@ -2,6 +2,20 @@
*
*/
function wdog(handle,timeout){
if(handle !== undefined){
wdog.handle = handle;
wdog.timeout = timeout;
}
if(wdog.timer){
clearTimeout(wdog.timer)
}
wdog.timer = setTimeout(wdog.handle,wdog.timeout)
}
// reset after two minutes of inactivity
wdog(load,120000)
var s = require("Storage");
var apps = s.list(/\.info$/).map(app=>{var a=s.readJSON(app,1);return a&&{name:a.name,type:a.type,icon:a.icon,sortorder:a.sortorder,src:a.src};}).filter(app=>app && (app.type=="app" || app.type=="clock" || !app.type));
apps.sort((a,b)=>{
@ -42,6 +56,7 @@ function drawPage(p){
}
Bangle.on("swipe",(dir)=>{
wdog()
selected = 0;
oldselected=-1;
if (dir<0){
@ -54,6 +69,7 @@ Bangle.on("swipe",(dir)=>{
});
function nextapp(d){
wdog();
oldselected = selected;
selected+=d;
selected = selected<0?5:selected>5?0:selected;

View File

@ -2,4 +2,5 @@
0.03: Add support for data files
0.04: Add functionality to sort apps manually or alphabetically ascending/descending.
0.05: Tweaks to help with memory usage
0.06: Reduce memory usage
0.06: Reduce memory usage
0.07: Allow negative numbers when manual-sorting

View File

@ -180,7 +180,7 @@ function showSortAppsManually() {
appList.reduce((menu, app) => {
menu[app.name] = {
value: app.sortorder || 0,
min: 0,
min: -appList.length,
max: appList.length,
step: 1,
onchange: val => setSortorder(app, val)

1
apps/jbm8b_IT/ChangeLog Normal file
View File

@ -0,0 +1 @@
0.01: Cloning Magic 8 Ball and make it speak italian

View File

@ -0,0 +1 @@
require("heatshrink").decompress(atob("mEwhBC/AGMrq2B1gAEwNWlYthq2s64AKGYIydFpoAEGLUrFqIADqxcXFqhiDFymBFy7GCF1owTRjCSVlYudeiGsF7/XlaNqSKBeP1mBwJxQMBReO1gaEleBMDBLN1hAC1hhBAoIwNCwQAGlZINqxvFGAIXOSBAXQN4hPBC5yQIVBxfBCAgvQSBC+NFAYRDMwJHOF654DqxkBYooALF6+sbIhkEF8Z3CRIWBR6AvXFAzvQF6wnIYQJgNd5AWNdoLoGBBAvPO5pfYH4IvUUwS/GVBzXBYCpHCq2s1mBDwKOWDwRgNPAwVVMCRLCwIABCZ6OJJSAATLxZgRACJeLAAMrFz9WFxiRgRpoADwIub1guQGDmsXhqSfRiL0G1jqkMRYxRwKLUGK2sFryVEq2B1gAEwNWFkIA/AH4A/AH4AQ"))

79
apps/jbm8b_IT/app.js Normal file
View File

@ -0,0 +1,79 @@
const affirmative = [
'È certo.',
'È decisamente\ncosì.',
'Senza alcun\ndubbio.',
'Sì,\nsenza dubbio.',
'Ci puoi\ncontare.',
'Da quanto\nvedo,\nsì.',
'Molto\nprobabilmente.',
'Le prospettive\nsono buone.',
'Sì.',
'I segni\nindicano\ndi sì.'
];
const nonCommittal = [
'È difficile\ndirlo,\nprova di nuovo.',
'Rifai la domanda\npiù tardi.',
'Meglio non\nrisponderti\nadesso.',
'Non posso\npredirlo ora.',
'Concentrati e\nrifai la\ndomanda.'
];
const negative = [
'Non ci\ncontare.',
'La mia\nrisposta\nè no.',
'Le mie\nfonti dicono\ndi no.',
'Le prospettive\nnon sono\nbuone.',
'È molto\ndubbio.'
];
const title = 'Magic 8 Ball';
const answers = [affirmative, nonCommittal, negative];
function getRandomArbitrary(min, max) {
return Math.random() * (max - min) + min;
}
function predict() {
// affirmative, negative or non-committal
let max = answers.length;
const a = Math.floor(getRandomArbitrary(0, max));
// sets max compared to answer category
max = answers[a].length;
const b = Math.floor(getRandomArbitrary(0, max));
// get the answer
const response = answers[a][b];
return response;
}
function draw(msg) {
// console.log(msg);
g.clear();
E.showMessage(msg, title);
}
function reply(button) {
const theButton = (typeof button === 'undefined' || isNaN(button)) ? 1 : button;
const timer = Math.floor(getRandomArbitrary(0, theButton) * 1000);
// Thinking...
draw('...');
setTimeout('draw(predict());', timer);
}
function ask() {
draw('Ponimi una\ndomanda\nSì/No e\ntocca lo\nschermo');
}
g.clear();
Bangle.loadWidgets();
Bangle.drawWidgets();
ask();
// Event Handlers
Bangle.on('touch', (button) => reply(button));
setWatch(ask, BTN1, { repeat: true, edge: "falling" });
setWatch(reply, BTN3, { repeat: true, edge: "falling" });
// Back to launcher
setWatch(Bangle.showLauncher, BTN2, { repeat: false, edge: "falling" });

BIN
apps/jbm8b_IT/app.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

1
apps/rtorch/ChangeLog Normal file
View File

@ -0,0 +1 @@
0.01: Cloning torch and making it red :D

1
apps/rtorch/app-icon.js Normal file
View File

@ -0,0 +1 @@
require("heatshrink").decompress(atob("mEw4UA///oP4gH+t9TCQ1VAAYLpgILunoLK/4LJgf/6oLIh//+oLK/oLIhapBBZEqBYIwDBYu/GAgLE1WvGAgLF1YwEBQcC1WqGAgLGGAgLDhQLBGAdQBYwwCBQgLDGASlFlQLC3/8BYoIBGAXwBQkCFgILC4AuFBYeAFw2v/wLBBQqNCBYOgBQp1B1/qCw5dDFoxdEBQwuBAAOoBQykCHI4uXgZPBFxEP/QuJn5/CFw7DBLpILB9QuHEYP//QuHHYP//wuHKYL0HGAoLJn/8BZMP+ALJgfABRA="))

22
apps/rtorch/app.js Normal file
View File

@ -0,0 +1,22 @@
Bangle.setLCDPower(1);
Bangle.setLCDTimeout(0);
g.reset();
c = 1;
function setColor(delta){
c+=delta;
c = Math.max(c,0);
c = Math.min(c,2);
if (c<1){
g.setColor(c,0,0);
}else{
g.setColor(1,c-1,c-1);
}
g.fillRect(0,0,g.getWidth(),g.getHeight());
}
setColor(0)
// BTN1 light up toward white
// BTN3 light down to red
// BTN2 to reset
setWatch(()=>setColor(0.1), BTN1, { repeat:true, edge:"rising", debounce: 50 });
setWatch(()=>load(), BTN2);
setWatch(()=>setColor(-0.1), BTN3, { repeat:true, edge:"rising", debounce: 50 });

BIN
apps/rtorch/app.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

26
apps/rtorch/widget.js Normal file
View File

@ -0,0 +1,26 @@
(function() {
var clickTimes = [];
var clickPattern = "";
var TAPS = 4; // number of taps
var PERIOD = 1; // seconds
// we don't actually create/draw a widget here at all...
Bangle.on("lcdPower",function(on) {
// First click (that turns LCD on) isn't given to
// setWatch, so handle it here
if (!on) return;
clickTimes=[getTime()];
clickPattern="x";
});
function tap(e,c) {
clickPattern = clickPattern.substr(-3)+c;
while (clickTimes.length>=TAPS) clickTimes.shift();
clickTimes.push(e.time);
var clickPeriod = e.time-clickTimes[0];
if (clickPeriod<PERIOD && clickPattern.match(/.131/)) {
load("rtorch.app.js");
}
}
setWatch(function(e) { tap(e,"1"); }, BTN1, {repeat:true, edge:"rising"});
setWatch(function(e) { tap(e,"3"); }, BTN3, {repeat:true, edge:"rising"});
})();