dgtusb 0.0.1+3 dgtusb: ^0.0.1+3 copied to clipboard
A new Flutter package which allow you to easily connect your DGT Chess Board and lets you communicate with it
dgtusb #
The dgtusb flutter package allows you to quickly get you dgt-usb-board connected to your Android application.
Getting Started #
Add dependencies to pubspec.yaml
dependencies:
dgtusb: ^0.0.1
usb_serial: ^0.2.4
include the package
import 'package:dgtusb/dgtusb.dart';
import 'package:usb_serial/usb_serial.dart';
add compileOptions to android\app\build.gradle
android {
...
compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
}
...
}
you can do optional more steps to allow usb related features, for that please take a look at the package we depend on: usb_serial.
Connect to a connected board and listen to its events:
List<UsbDevice> devices = await UsbSerial.listDevices();
List<UsbDevice> dgtDevices = devices.where((d) => d.vid == 1115).toList();
if (dgtDevices.length > 0) {
// connect to board and initialize
DGTBoard nBoard = new DGTBoard(await dgtDevices[0].create());
await nBoard.init();
print("DGTBoard connected - SerialNumber: " + nBoard.getSerialNumber() + " Version: " + nBoard.getVersion());
// listen to update stream
nBoard.getBoardDetailedUpdateStream().listen((update) {
print(update.getNotation());
});
// set board to update mode
nBoard.setBoardToUpdateMode();
}
In action #
To get a quick look, it is used in the follwoing project, which is not open source yet.
Updates soon #
sorry for the lack of information, i will soon:
- update this readme
- add an example
- add some tests maybe
- make it crossplatform compatible (currently it depends on usb_serial package which makes it android exclusive. Linux, OSX and Windows should be possible aswell)