Skip to content

woodemi/notepad-core-js

This branch is 1 commit ahead of master.

Folders and files

NameName
Last commit message
Last commit date
May 31, 2020
May 31, 2020
May 30, 2020
May 10, 2020
May 16, 2020
May 10, 2020
May 30, 2020
May 11, 2020
May 30, 2020
May 30, 2020
May 30, 2020
May 29, 2020
Dec 6, 2022
May 30, 2020

Repository files navigation

English | 简体中文

notepad_core

Flutter plugin for connect & operate on smart notepad

Usage

  • Scan notepad
  • Connect notepad
  • Sync notepen pointer

Scan notepad

Web

let device = notepadConnector.requestDevice();
console.log(`requestDevice ${device}`);

Mini-program on Wechat

let scanResultReceiver = function (scanResult) {
  console.log(`onScanResult ${scanResult}`);
};
notepadConnector.onScanResult(scanResultReceiver);

notepadConnector.startScan();
// ...
notepadConnector.stopScan();

notepadConnector.offScanResult(scanResultReceiver);

Connect notepad

Connect to device requested from notepadConnector.requestDevice()

or scanResult received from notepadConnector.onScanResult

let connectionChangeHandler = function (notepadClient, connectionState) {
  console.log(`onConnectionChange ${notepadClient}, ${connectionState}`);
};
notepadConnector.onConnectionChange(connectionChangeHandler);

notepadConnector.connect(obj); // obj = device/scanResult
// ...
notepadConnector.disconnect();

notepadConnector.offConnectionChange(connectionChangeHandler);

Sync notepen pointer

NotepadClient#setMode

  • NotepadMode.Common

    Notepad saves only NotePenPointer with positive pressure & accurate timestamp, into offline memo

  • NotepadMode.Sync

    Notepad notify every NotePenPointer, positive or not, without timestamp, to connected mobile device

Notepad is always NotepadMode.Common (connected or disconnected), unless setMode after connected

await _notepadClient.setMode(NotepadMode.Sync);
console.log("setMode complete");

NotepadClient#onSyncPointerReceive

Receive NotePenPointers in NotepadMode.Sync

let syncPointerReceiver = function (pointers) {
  console.log(`onSyncPointerReceive ${pointers.length}`);
};

_notepadClient.onSyncPointerReceive(syncPointerReceiver);
// ...
_notepadClient.offSyncPointerReceive(syncPointerReceiver);