Merge pull request #55 from ra100/feature/Pomodoro-update

Feature/pomodoro update
pull/57/head
Gordon Williams 2019-11-27 09:04:16 +00:00 committed by GitHub
commit 091979038d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 56 additions and 31 deletions

View File

@ -504,16 +504,16 @@
]
},
{
"id": "promodo",
"name":"Promodoro",
"icon":"promodoro.png",
"description": "A simple promodoro timer.",
"tags": "promodoro,cooking,tools",
"id": "pomodo",
"name":"Pomodoro",
"icon":"pomodoro.png",
"description": "A simple pomodoro timer.",
"tags": "pomodoro,cooking,tools",
"type": "app",
"storage": [
{"name": "+promodo","url": "promodoro.json"},
{"name": "-promodo","url": "promodoro.js"},
{"name": "*promodo","url": "promodoro-icon.js","evaluate": true}
{"name": "+pomodo","url": "pomodoro.json"},
{"name": "-pomodo","url": "pomodoro.js"},
{"name": "*pomodo","url": "pomodoro-icon.js","evaluate": true}
]
},
{ "id": "blobclk",
@ -528,4 +528,4 @@
{"name":"*blobclk","url":"clock-blob-icon.js","evaluate":true}
]
}
]
]

9
apps/pomodo/CHANGELOG.md Normal file
View File

@ -0,0 +1,9 @@
# Changelog
## 2019-11-27
- [Feature] App now saves the last interval value
- [Feature] Add option to increase/decrease time by 1 minute using screen
buttons (BTN4 and BTN5)
- [Bugfix] Fixed newlines in message
- [Chore] Renamed to Pomodoro

View File

@ -1,3 +1,5 @@
const storage = require("Storage");
const DEFAULT_TIME = 1500; // 25m
const TIME_BREAK = 300;
const STATES = {
@ -14,21 +16,12 @@ class State {
this.next = null;
}
goNext () {
if (this.next) {
this.next.run();
}
}
setNext (next) {
this.next = next;
}
setButtons () {
setWatch(() => { console.log('BTN1') }, BTN1, { repeat: true });
setWatch(() => { console.log('BTN2') }, BTN2, { repeat: true });
setWatch(() => { console.log('BTN3') }, BTN3, { repeat: true });
}
setButtons () {}
clear () {
clearWatch();
g.clear();
@ -54,10 +47,14 @@ class State {
}
class InitState extends State {
constructor () {
constructor (time) {
super(STATES.INIT);
this.timeCounter = DEFAULT_TIME;
this.timeCounter = parseInt(storage.read(".pomodo") || DEFAULT_TIME, 10);
}
saveTime () {
storage.write('.pomodo', '' + this.timeCounter);
}
setButtons () {
@ -80,6 +77,25 @@ class InitState extends State {
}, BTN3, { repeat: true });
setWatch(() => {
if (this.timeCounter - 60 > 0) {
this.timeCounter -= 60;
this.draw();
}
}, BTN4, { repeat: true });
setWatch(() => {
if (this.timeCounter + 60 > 3599) {
this.timeCounter = 3599;
} else {
this.timeCounter += 60;
}
this.draw();
}, BTN5, { repeat: true });
setWatch(() => {
this.saveTime();
const startedState = new StartedState(this.timeCounter);
this.setNext(startedState);
@ -90,7 +106,7 @@ class InitState extends State {
draw () {
g.clear();
g.setFontAlign(0, 0); // center font
g.setFont("Vector", 50); // vector font, 80px
g.setFont("Vector", 50); // vector font, 80px
drawCounter(this.timeCounter);
}
}
@ -99,7 +115,7 @@ class StartedState extends State {
constructor (timeCounter) {
super(STATES.STARTED);
this.timeCounter = timeCounter || DEFAULT_TIME;
this.timeCounter = timeCounter;
}
draw () {
@ -174,7 +190,7 @@ class DoneState extends State {
g.setFont("Vector", 45);
g.setFontAlign(-1, -1);
g.drawString('You \\nare \\na \\nhero!', 50, 40);
g.drawString('You\nare\na\nhero!', 50, 40);
}
init () {
@ -237,4 +253,4 @@ function init () {
initState.go();
}
init();
init();

View File

@ -0,0 +1,5 @@
{
"name":"Pomodoro","type":"app",
"icon":"*pomodo",
"src":"-pomodo"
}

View File

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

@ -1,5 +0,0 @@
{
"name":"Promodoro","type":"app",
"icon":"*promodo",
"src":"-promodo"
}