dgtchess

Node.js driver for DGT electronic chess boards

npm install dgtchess
2 downloads in the last day
5 downloads in the last week
7 downloads in the last month

dgtchess

An event-driven node.js driver for the electronic DGT chess board.

Install via npm:

npm install dgtchess

Status

This project is still under heavy development. Currently only the boards connected via USB are supported and no clock commands are implemented yet. The module uses only the UPDATE BOARD modus and instead of moves only changes are triggered through the 'data' event.

Usage

var DGT = require('..');
var board = new DGT.Board('/dev/ttyUSB0');

board.on('ready', function() {
  console.log('Serial No:', board.serialNo);
  console.log('Version:', board.versionNo);
  console.log('-----');
});

board.on('data', function(data) {
  console.log('Field:', data.field);
  console.log('Piece:', data.piece);
  console.log('-----');
});

board.on('move', function(move) {
  console.log('Move:', move);
  console.log('-----');
});

This might result in the following output:

Serial No: 12345
Version: 1.7
   +------------------------+
 8 | .  .  .  .  .  .  .  . |
 7 | .  .  .  .  .  .  .  . |
 6 | .  .  .  .  .  .  .  . |
 5 | .  .  .  .  .  k  .  . |
 4 | .  .  R  .  .  .  .  . |
 3 | .  .  .  .  .  K  .  . |
 2 | .  .  .  .  .  .  .  . |
 1 | .  .  .  .  .  .  .  . |
   +------------------------+
     a  b  c  d  e  f  g  h

-----
Field: c4
Piece: EMPTY
-----
Field: c5
Piece: WROOK
-----
Move: { color: 'w',
  from: 'c4',
  to: 'c5',
  flags: 'n',
  piece: 'r',
  san: 'Rc5+' }
-----
Field: f5
Piece: EMPTY
-----
Field: e6
Piece: BKING
-----
Move: { color: 'b',
  from: 'f5',
  to: 'e6',
  flags: 'n',
  piece: 'k',
  san: 'Ke6' }
-----

Events

'ready'

The 'ready' event is fired once the basic data (i.e. version and serial number) are read from the board.

'data'

Once something on the board has been changed, i.e. a move gets (re)moved, this event gets triggered. The passed object has the properties field and piece.

Background

The protocol for communicating with the electronic chess boards is well documented by DGT in their developer section. There you can find the DGT Electronic Board Protocol Description (version 20120309) which is the base for this node.js implementation.

Licence

This project stands under the MIT Licence, see LICENCE.md for details.

npm loves you