From 111e97a945d5a44b1762447c4585128f36ef3b01 Mon Sep 17 00:00:00 2001 From: Ondrej Date: Tue, 16 Apr 2024 10:00:15 +0200 Subject: [PATCH 1/2] Minimal Windows setup --- zeapp/badge/build.gradle.kts | 21 +++++++++++++++++++ .../berlindroid/zekompanion/BadgeManager.kt | 17 +++++++++++++++ .../de/berlindroid/zekompanion/Platform.kt | 3 +++ .../zekompanion/desktop/ui/NameBadgeEditor.kt | 2 ++ 4 files changed, 43 insertions(+) create mode 100644 zeapp/badge/src/windowsMain/kotlin/de/berlindroid/zekompanion/BadgeManager.kt create mode 100644 zeapp/badge/src/windowsMain/kotlin/de/berlindroid/zekompanion/Platform.kt diff --git a/zeapp/badge/build.gradle.kts b/zeapp/badge/build.gradle.kts index ec460c43..fae0957c 100644 --- a/zeapp/badge/build.gradle.kts +++ b/zeapp/badge/build.gradle.kts @@ -41,6 +41,15 @@ kotlin { } } + os.startsWith("Windows") -> + jvm("windows") { + withJavaEnabled + + jvmToolchain { + languageVersion.set(JavaLanguageVersion.of(17)) + } + } + else -> throw StopActionException("Your operating system is not supported at this time: '${os}'.") } @@ -88,6 +97,18 @@ kotlin { } } } + + os.startsWith("Windows") -> { + val windowsMain by getting { + dependencies { + implementation(libs.jSerialComm) + } + + sourceSets { + dependsOn(sourceSets.getAt("jvmMain")) + } + } + } } } } diff --git a/zeapp/badge/src/windowsMain/kotlin/de/berlindroid/zekompanion/BadgeManager.kt b/zeapp/badge/src/windowsMain/kotlin/de/berlindroid/zekompanion/BadgeManager.kt new file mode 100644 index 00000000..92999f27 --- /dev/null +++ b/zeapp/badge/src/windowsMain/kotlin/de/berlindroid/zekompanion/BadgeManager.kt @@ -0,0 +1,17 @@ +package de.berlindroid.zekompanion + +import com.fazecast.jSerialComm.SerialPort + + +actual typealias Environment = Any + +actual fun buildBadgeManager(environment: Environment): BadgeManager = object : JvmBadgeManager() { + override fun getBadger2040s() = SerialPort.getCommPorts() + .filter { + println(it.systemPortName) + true + // return the first serial comm device, can't find it by descriptive name +// it.descriptivePortName.contains("Badger") + } + .toList() +} diff --git a/zeapp/badge/src/windowsMain/kotlin/de/berlindroid/zekompanion/Platform.kt b/zeapp/badge/src/windowsMain/kotlin/de/berlindroid/zekompanion/Platform.kt new file mode 100644 index 00000000..2ace3615 --- /dev/null +++ b/zeapp/badge/src/windowsMain/kotlin/de/berlindroid/zekompanion/Platform.kt @@ -0,0 +1,3 @@ +package de.berlindroid.zekompanion + +actual fun getPlatform(): String = "Windows 🪟" diff --git a/zeapp/desktop/src/main/kotlin/de/berlindroid/zekompanion/desktop/ui/NameBadgeEditor.kt b/zeapp/desktop/src/main/kotlin/de/berlindroid/zekompanion/desktop/ui/NameBadgeEditor.kt index bdd704d2..9f649853 100644 --- a/zeapp/desktop/src/main/kotlin/de/berlindroid/zekompanion/desktop/ui/NameBadgeEditor.kt +++ b/zeapp/desktop/src/main/kotlin/de/berlindroid/zekompanion/desktop/ui/NameBadgeEditor.kt @@ -31,6 +31,8 @@ import androidx.compose.ui.unit.IntSize import androidx.compose.ui.unit.TextUnit import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp +import de.berlindroid.zekompanion.BADGE_HEIGHT +import de.berlindroid.zekompanion.BADGE_WIDTH import de.berlindroid.zekompanion.desktop.State import kotlin.math.max From f9a3941350af8ffe92fe386bed0bfcac5b4d6891 Mon Sep 17 00:00:00 2001 From: Ondrej Date: Sat, 20 Apr 2024 14:30:45 +0200 Subject: [PATCH 2/2] Update badge manager device filter --- .../kotlin/de/berlindroid/zekompanion/BadgeManager.kt | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/zeapp/badge/src/windowsMain/kotlin/de/berlindroid/zekompanion/BadgeManager.kt b/zeapp/badge/src/windowsMain/kotlin/de/berlindroid/zekompanion/BadgeManager.kt index 92999f27..320694fc 100644 --- a/zeapp/badge/src/windowsMain/kotlin/de/berlindroid/zekompanion/BadgeManager.kt +++ b/zeapp/badge/src/windowsMain/kotlin/de/berlindroid/zekompanion/BadgeManager.kt @@ -8,10 +8,8 @@ actual typealias Environment = Any actual fun buildBadgeManager(environment: Environment): BadgeManager = object : JvmBadgeManager() { override fun getBadger2040s() = SerialPort.getCommPorts() .filter { - println(it.systemPortName) - true - // return the first serial comm device, can't find it by descriptive name -// it.descriptivePortName.contains("Badger") + // Device doesn't show any better descriptive name on Windows, this should be good enough + it.portDescription.contains("CircuitPython") } .toList() }