ktgpio

GPIO on a Raspberry Pi with Kotlin/Native

License

License

Categories

Categories

Data
GroupId

GroupId

io.ktgp
ArtifactId

ArtifactId

core-metadata
Last Version

Last Version

0.0.6
Release Date

Release Date

Type

Type

pom.sha512
Description

Description

ktgpio
GPIO on a Raspberry Pi with Kotlin/Native
Project URL

Project URL

https://ktgp.io/
Source Code Management

Source Code Management

https://github.com/ktgpio/ktgpio/tree/main

Download core-metadata

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

build

GPIO on a Raspberry Pi with Kotlin/Native

Getting started

Supported targets

ktgpio only supports arm64 and armhf linux targets. It was tested and is confirmed to work on Raspberry Pi OS armhf and Raspberry Pi OS arm64.

For the list of supported hosts refer to Kotlin/Native release notes.

Target preparation

ktgpio is dynamically linked with libgpiod and libi2c. If your target is running Raspberry Pi OS or any other Debian-like system install them by running

apt-get install libgpiod2 libi2c0 

Using template repository

The easiest way to get started is creating repository from ktgpio-samples template. Please note that build configuration there only supports linux_arm32_hfp and linux_arm64 Raspberry Pi OS targets. If you are targeting different OS, make sure you're providing correct libgpiod and libi2c libraries to the build. Refer to build.gradle.kts and native-libs.gradle.kts in the template repository for examples, and to the next section for details.

Starting from scratch

Here is a minimal build.gradle.kts example:

plugins {
  kotlin("multiplatform") version "1.4.30"
}

repositories {
  mavenCentral()
}

kotlin {
  val native = linuxArm32Hfp("native")

  sourceSets {
    val commonMain by getting {
      dependencies {
        implementation("io.ktgp:core:0.0.6")
        implementation(kotlin("stdlib"))
      }
    }
  }

  configure(listOf(native)) {
    binaries.executable()
  }
}

Applications using ktgpio should be dynamically linked against libgpiod and libi2c. Make sure .so files for your target architecture are visible to the linker. If you are cross-compiling, you can manually copy them from your target machine and specify path to them using linkerOpts property of a NativeBinary:

binaries.all {
  linkerOpts.add("-Llibs/")
}
io.ktgp

Versions

Version
0.0.6