-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Re-added pokertimer not as a submodule
- Loading branch information
Showing
9 changed files
with
199 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
0.0.1: Packaged app | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright © 2024 Keith Irwin | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Poker Timer | ||
|
||
A blinds timer for poker. Don't know what that means? See [Wikipedia: Blind (poker)](https://en.wikipedia.org/wiki/Blind_(poker)) and [Wikipedia: Texas hold 'em](https://en.wikipedia.org/wiki/Texas_hold_%27em). | ||
|
||
The blinds are hardcoded and go up every ten minutes: | ||
|
||
- 1, 2 | ||
- 2, 4 | ||
- 4, 8 | ||
- 5, 10 | ||
- 10, 20 | ||
- 20, 40 | ||
- 40, 80 | ||
|
||
... and so on, doubling each round. | ||
|
||
## Usage | ||
|
||
The timer will start as soon as you open the app. Time left in the round is on the top of the screen, currnt small and big blinds are shown below. After ten minutes, it will vibrate and flash and show the new blind. Then it starts over. | ||
|
||
## Controls | ||
|
||
- **Pause/Resume:** Press the button | ||
- **Exit:** hold down the button. | ||
|
||
## Requests | ||
|
||
[Contact Keith Irwin](https://www.ki9.us/contact/) | ||
|
||
## Creator | ||
|
||
[Keith Irwin](https://www.ki9.us) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Roadmap | ||
|
||
## Bugs | ||
|
||
- Unlock before vibrate/flash | ||
|
||
## Improvements | ||
|
||
- Screenshots in README | ||
- Start app paused | ||
- Indicate when paused | ||
- 20-second warning | ||
|
||
## Long-term projects | ||
|
||
- Set settings | ||
- Better graphics |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
const BLIND_INTERVAL = 600; // 10 minutes | ||
const BLINDSUP_ALERT_DURATION = 5000; // 30 seconds | ||
|
||
// Convert seconds to mm:ss | ||
const secondsToMinutes = (s) => { | ||
const mm = Math.floor(s/60); | ||
const ss = s - mm * 60; | ||
return `${mm}:${String(ss).padStart(2,'0')}`; | ||
}; | ||
|
||
// Format screen | ||
const fmtDark = () => { | ||
g.clear(); | ||
g.setFontAlign(0,0); | ||
g.setBgColor(0,0.5,0); | ||
g.setColor(1,1,1); | ||
}; | ||
const fmtLight = () => { | ||
g.clear(); | ||
g.setFontAlign(0,0); | ||
g.setBgColor(0.5,1,0.5); | ||
g.setColor(0,0,0); | ||
}; | ||
|
||
// Start/stop/pause/resume timer | ||
const startTimer = () => { | ||
timer_running = true; tick(); | ||
timer = setInterval(tick, 1000); | ||
}; | ||
const stopTimer = () => { | ||
clearInterval(timer); | ||
timer_running = false; | ||
}; | ||
const pauseResume = () => { | ||
if (timer_running) stopTimer(); | ||
else startTimer(); | ||
}; | ||
|
||
// Calculate blinds for a round | ||
const getBlinds = (i) => { | ||
let small; | ||
if (i===0) small = 1; | ||
else if (i===1) small = 2; | ||
else if (i===2) small = 4; | ||
else small = 5*(Math.pow(2,(i-3))); | ||
return [small, small*2]; | ||
}; | ||
|
||
// Sound the alarm | ||
const blindsUp = () => { | ||
// Display message | ||
const showMessage = () => { | ||
g.clear(); | ||
g.setFont('Vector',34); | ||
g.drawString('Blinds Up!', | ||
g.getWidth()/2, g.getHeight()/3); | ||
g.setFont('Vector',40); | ||
g.drawString(`${blinds[0]}/${blinds[1]}`, | ||
g.getWidth()/2, g.getHeight()*2/3); | ||
}; | ||
stopTimer(); | ||
// Increase blinds | ||
b++; | ||
// TODO: Kill program between round 25 and 26 | ||
blinds = getBlinds(b); | ||
console.log(`Blinds for round ${b} are ${blinds[0]} / ${blinds[1]}`); | ||
// Buzz and light up every second | ||
const buzzInterval = setInterval(() => { | ||
Bangle.buzz(); | ||
Bangle.setLCDPower(1); | ||
}, 1000); | ||
// Invert colors every second | ||
fmtLight(); showMessage(); let dark = false; | ||
const flashInterval = setInterval(() => { | ||
if (dark) { | ||
fmtLight(); | ||
dark = false; | ||
} else { | ||
fmtDark(); | ||
dark = true; | ||
} showMessage(); | ||
}, 500); | ||
// Restart timer | ||
setTimeout(() => { | ||
fmtDark(); tick(); | ||
clearInterval(buzzInterval); | ||
clearInterval(flashInterval); | ||
time_left = BLIND_INTERVAL + 1; | ||
startTimer(); | ||
}, BLINDSUP_ALERT_DURATION); | ||
}; | ||
|
||
// Tick every second | ||
const tick = () => { | ||
if (!timer_running) return; | ||
time_left--; | ||
if (time_left<=0) blindsUp(); | ||
else { | ||
g.clear(); | ||
g.setFont('Vector',40); | ||
g.drawString( | ||
secondsToMinutes(time_left), | ||
g.getWidth()/2, g.getHeight()/3); | ||
g.drawString( | ||
`${blinds[0]}/${blinds[1]}`, | ||
g.getWidth()/2, g.getHeight()*2/3); | ||
} | ||
return; | ||
}; | ||
|
||
// button listener | ||
Bangle.setUI({ | ||
mode: 'custom', | ||
btn: pauseResume, | ||
}); | ||
|
||
// RUNTIME | ||
fmtDark(); | ||
let time_left = BLIND_INTERVAL + 1; | ||
let b = 0; | ||
let blinds = getBlinds(b); | ||
let timer_running = true; | ||
let timer = setInterval(tick, 1000); | ||
tick(); |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
Check failure on line 1 in apps/pokertimer/metadata.json GitHub Actions / build
|
||
"id": "pokertimer", | ||
"name": "Poker Timer", | ||
"shortName":"Poker Timer", | ||
"readme":"README.md", | ||
"icon": "app.png", | ||
"version":"0.0.1", | ||
"description": "A blinds timer for use with Texas Hold 'Em", | ||
"tags": "poker", | ||
"supports": ["BANGLEJS2"], | ||
"storage": [ | ||
{"name":"timer.app.js","url":"app.js"}, | ||
{"name":"timer.img","url":"app-icon.js","evaluate":true} | ||
] | ||
} |