https://github.com/zabackary/open-chess-clock
An open source chess clock using an HD44780-compatible LCD and some buttons
https://github.com/zabackary/open-chess-clock
chess chess-clock embedded frontend rust web webserial
Last synced: 2 months ago
JSON representation
An open source chess clock using an HD44780-compatible LCD and some buttons
- Host: GitHub
- URL: https://github.com/zabackary/open-chess-clock
- Owner: zabackary
- License: apache-2.0
- Created: 2023-10-30T22:50:24.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-10-05T11:16:52.000Z (8 months ago)
- Last Synced: 2025-01-24T09:25:29.682Z (4 months ago)
- Topics: chess, chess-clock, embedded, frontend, rust, web, webserial
- Language: Rust
- Homepage: https://zabackary.github.io/open-chess-clock/
- Size: 250 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
# OpenChessClock
A simple chess clock for the _Arduino Uno_ (specifically the r3, though it
probably doesn't matter) that, since it uses `embedded-hal`, can easily be
adapted for other platforms. Basically, it has an up/P1 button, a down/P2
button, and a start/stop/select button for configuration.> [!NOTE]
> On my Arduino Uno r3, there is about a half-second drift per minute of
> runtime compared to my computer clock.OpenChessClock even has a web interface for when you want the time to be even
bigger! Find out more in [`/www`](/www). It connects to the clock over WebSerial
and shows the time, or can operate independently if needed. Screenshots are
below.## Pictures and Screenshots

## Instructions for use (after set-up)
How do I use this chess clock?
1. Boot the chess clock by plugging it in. It should show a version number and a
splash screen.
2. Select the time using the UP and DOWN buttons. Press START to move the cursor
from the P1 minute/hour selector to the P1 second selector, etc.
3. On the screen saying `P1/P2 to begin`, press the button corresponding to the
player who will play first. For example, if P1 is White, they should press
their button.
4. When players are done with their turn, they should push their button.
Continuing from the previous example, when White makes their move, they
should press the P1 button.
5. If the game needs to be paused at any time, press the START button. To
unpause, press the the P1 or P2 buttons depending on who is going next with
the same schematics as the start screen.
6. When the game is over (the buzzer will sound one long beep if it's
connected), press START to go back to the time selection screen.## States
State diagram
```
.----------------.
| |
v | UP/DN
┌--------┐ ┌----------┐ ST ┌-----------┐ ST ┌-------┐
| Splash | --> | Time set | --> | Countdown | --> | Pause |
└--------┘ └----------┘ └-----------┘ └-------┘
^ ^ | (finish) | ST
| | | |
| `---------------|---------------'
| |
| v
| ST ┌------------┐
`---------- | Win screen |
└------------┘
```Time set ([`time_set.rs`](./src/time_set.rs)):
```
P1 Set time P2
0:00:00 0:00:00
```Pause ([`pause.rs`](./src/pause.rs)):
```
P1 >Paused< P2
0:00:00 0:00:00
```Top line alternates between `P1 Paused P2`, `START to restart`, and
`P1/P2 to resume `.Countdown ([`countdown.rs`](./src/countdown.rs)):
```
[P1] << P2
0:00:00 0:00:00
```Finish ([`finish.rs`](./src/finish.rs))
```
[P1] Time's up!
0:00:00 0:00:05
```or
```
Time's up! [P2]
0:00:05 0:00:00
```## Hardware connections
1. **LCD**
LCD RS => Arduino d7 (register select)
LCD EN => Arduino d8 (enable)
LCD d4 => Arduino d9
LCD d5 => Arduino d10
LCD d6 => Arduino d11
LCD d7 => Arduino d12
The LCD backlight cathode and anode should be connected, and the contrast
should be set to an appropriate amount using a pot. Of course, make sure the
LCD has 5V power (unlike me, who attached it to 2.7V and spent an hour trying
to fix it).
2. **Buttons**
Down button => Arduino d2 & GND (also functions as P1 button)
Start button => Arduino d3 & GND
Up button => Arduino d4 & GND (also functions as P2 button)
3. **Buzzer** (optional)
Buzzer anode => Arduino d6## Build Instructions
1. Install prerequisites as described in the [`avr-hal` README] (`avr-gcc`,
`avr-libc`, `avrdude`, [`ravedude`]).2. Run `cargo build` to build the firmware.
3. Run `cargo run` to flash the firmware to a connected board. If `ravedude`
fails to detect your board, check its documentation at
.4. `ravedude` will open a console session after flashing where you can interact
with the UART console of your board.[`avr-hal` README]: https://github.com/Rahix/avr-hal#readme
[`ravedude`]: https://crates.io/crates/ravedude## License
Licensed under either of
- Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or
)
- MIT license ([LICENSE-MIT](LICENSE-MIT) or
)at your option.
## Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in the work by you, as defined in the Apache-2.0 license, shall be
dual licensed as above, without any additional terms or conditions.