Kotlin Dasung253 Client Library

What is it?
This is a KMM (Kotlin Multiplatform Module) library which allows a Kotlin project to interact with a Dasung 253 monitor via its USB port.
This module abstracts away the UART commands which the monitor understands and provides simpler classes and functions for manipulating it.
It is based on reference code from Dasung.
It uses the jSerialComm and USB Serial For Android libraries under the hood.
Supported platforms
Example
val monitor = D253SerialPortList().getMonitors().first()
val params = port.getParameters()
println("Threshold: ${params.threshold}")
println("Light: ${params.light}")
println("Speed: ${params.speed}")
println("Frontlight: ")
println()
println()
API Documentation
Javadoc can be found here.
Setup
The setup instructions below assume that you're building a gradle project, with a TOML file for dependency management and KTS files for gradle scripts.
The instructions should still work for other setups with minor changes.
- Add jitpack to your repositories (only necessary for Android targets):
dependencyResolutionManagement {
repositories {
maven(url = "https://jitpack.io")
}
}
- Add the library definition and version to your TOML file (if you use one):
[versions]
d253 = "1.0.1"
[libraries]
d253-library-core = { module = "dev.mcarr.d253:library", version.ref = "d253" }
d253-library-jvm = { module = "dev.mcarr.d253:library-jvm", version.ref = "d253" }
d253-library-android = { module = "dev.mcarr.d253:library-android", version.ref = "d253" }
- Add the dependency to your app's build.gradle.kts file for any platforms you want to support:
kotlin {
sourceSets {
val commonMain by getting {
dependencies {
implementation(libs.d253.library.core)
}
}
val jvmMain by getting {
dependencies {
implementation(libs.d253.library.jvm)
}
}
val androidMain by getting {
dependencies {
implementation(libs.d253.library.android)
}
}
}
}
TODO
-
implement the monitor detection function and logic
-
add support for other platforms
-
list required java version
-
more docs