Skip to content

woodemi/notepad-example-android

Repository files navigation

English | 简体中文

notepad-example-android

Example for notepad-android-sdk

Usage

  • Scan notepad
  • Connect notepad
  • Claim notepad
  • Sync notepen pointer
  • Import offline memo
  • Get notepad info
  • Upgrade firmware

Scan notepad

val notepadScanner = NotepadScanner(context)
notepadScanner.callback = object : NotepadScanner.Callback {
    override fun onScanResult(result: NotepadScanResult) {
        println("onScanResult $result")
    }
}

notepadScanner.startScan()
// ...
notepadScanner.stopScan()

Connect notepad

Connect to result, received from NotepadScanner.Callback#onScanResult

Parameter authToken is optional. [0x00, 0x00, 0x00, 0x01] will be use if missing

NotepadConnector.callback = object : NotepadConnectorCallback {
    override fun onConnectionStateChange(notepadClient: NotepadClient, state: ConnectionState) {
        println("onConnectionStateChange $state")
    }
    // ...
}

val authToken = null
NotepadConnector.connect(context, result, authToken)
// ...
NotepadConnector.disconnect()

Claim notepad

Claim with authToken, the parameter of NotepadConnector#connect

notepadClient.claimAuth({
    println("claimAuth complete")
}, {
    println("claimAuth error $it")
})
// ...
notepadClient.disclaimAuth({
    println("disclaimAuth complete")
}, {
    println("disclaimAuth error $it")
})

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

notepadClient.setMode(NotepadMode.Sync, {
    println("setMode complete")
}) {
    println("setMode error $it")
}

NotepadClient.Callback#handlePointer

Receive NotePenPointers in NotepadMode.Sync

notepadClient.callback = object : NotepadClient.Callback {
    override fun handlePointer(list: List<NotePenPointer>) {
        println("handlePointer ${list.size}")
    }
    // ...
}

Import offline memo

memos are saved during NotepadMode.Common. memo consists of NotePenPointers with positive pressure & accurate timestamp.

memos are saved in a FIFO queue. Usually we collect summary and loop to import each memo.

Collect summary

NotepadClient#getMemoSummary

Get memos' count, used space, .etc

notepadClient.getMemoSummary({
    println("getMemoSummary success $it")
}) {
    println("getMemoSummary error $it")
}

Import a single memo

NotepadClient#getMemoInfo

Get the first memo's info from the FIFO queue

notepadClient.getMemoInfo({
    println("getMemoInfo success $it")
}) {
    println("getMemoInfo error $it")
}

NotepadClient#importMemo

Import the first memo from the FIFO queue

notepadClient.importMemo({
    println("importMemo progress $it")
}, {
    println("importMemo success $it")
}) {
    println("importMemo error $it")
}

NotepadClient#deleteMemo

Delete the first memo from the FIFO queue

notepadClient.deleteMemo({
    println("deleteMemo complete")
}) {
    println("deleteMemo error $it")
}

Get notepad info

Paint Size

println("W: ${notepadClient.width}, H: ${notepadClient.height}")

Device Name

notepadClient.getDeviceName({
    println("getDeviceName success $it")
}) {
    println("getDeviceName error $it")
}

notepadClient.setDeviceName("name", {
    println("setDeviceName complete")
}) {
    println("setDeviceName error $it")
}

Battery Info

notepadClient.getBatteryInfo({
    println("getBatteryInfo success $it")
}) {
    println("getBatteryInfo error $it")
}

Device Date

notepadClient.getDeviceDate({
    println("getDeviceDate success $it")
}) {
    println("getDeviceDate error $it")
}

notepadClient.setDeviceDate(timestamp, {
    println("setDeviceDate complete")
}) {
    println("setDeviceDate error $it")
}

Auto-Lock Time

notepadClient.getAutoLockTime({
    println("getAutoLockTime success $it")
}) {
    println("getAutoLockTime error $it")
}

notepadClient.setAutoLockTime(duration, {
    println("setAutoLockTime complete")
}) {
    println("setAutoLockTime error $it")
}

Upgrade firmware

Upgrade notepad firmware with *.srec file

notepadClient.upgrade("path", version, {
    println("upgrade progress $it")
}, {
    println("upgrade complete")
}, {
    println("upgrade error $it")
})

About

Example for notepad-android-sdk

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •