Giter Site home page Giter Site logo

mono424 / dgtusb Goto Github PK

View Code? Open in Web Editor NEW
3.0 3.0 0.0 118 KB

A Flutter Library to communicate with a DGT USB Board

Home Page: https://pub.dev/packages/dgtusb

License: MIT License

Dart 94.36% Kotlin 0.36% Ruby 3.98% Swift 1.19% Objective-C 0.11%

dgtusb's Introduction

dgtusb

The dgtusb flutter package allows you to quickly get you dgt-usb-board connected to your Android application.

preview

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.

https://khad.im/p/white-pawn

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)

dgtusb's People

Contributors

mono424 avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.