GithubHelp home page GithubHelp logo

mono424 / dgtdriver Goto Github PK

View Code? Open in Web Editor NEW
6.0 3.0 0.0 129 KB

A DGTDriver for Dart & Flutter

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

License: MIT License

Kotlin 0.27% Ruby 2.97% Swift 0.89% Objective-C 0.08% Dart 95.78%

dgtdriver's Introduction

dgtdriver

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

preview

Getting Started with dgtdriver + usb_serial

Add dependencies to pubspec.yaml

dependencies:
	dgtdriver: ^0.0.1
	usb_serial: ^0.2.4

include the package

import 'package:dgtdriver/dgtdriver.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();
    UsbPort usbDevice = await dgtDevices[0].create();
    await usbDevice.open();

    DGTCommunicationClient client = DGTCommunicationClient(usbDevice.write);
    usbDevice.inputStream.listen(client.handleReceive);
    
    if (dgtDevices.length > 0) {
      // connect to board and initialize
      DGTBoard nBoard = new DGTBoard();
      await nBoard.init(client);
      print("DGTBoard connected - SerialNumber: " +
          nBoard.getSerialNumber() +
          " Version: " +
          nBoard.getVersion());

      // set connected board
      setState(() {
        connectedBoard = nBoard;
      });

      // 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)

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.