Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Standalone Raspberry Pi app #55

Merged
merged 13 commits into from
Sep 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,24 @@ Just some Processing sketches. Source code for visuals we use at [Soul Ex Machin

![](demo-gif.gif)

The project is divided into 3 modules, `:core` module cointains the core stuff like audio processing, tools, remote control handlers, extensions, etc. Then there are two application modules - the `:playground` and `:visuals` module.
The project is divided into multiple modules.

The `:playground` module serves as, well... playground. You can quickly create a new sketch and play around. I'm using the [Koin](https://insert-koin.io/) DI framework, so you can inject here whatever is defined in the `CoreModule`. Have a look around.
The `:core` module contains the core stuff like audio processing, tools, remote control handlers, extensions, etc.

The `:playground` module serves as, well... playground. Used to quickly create a new sketch and play around. I'm using the [Koin](https://insert-koin.io/) DI framework, so you can inject here whatever is defined in the `CoreModule`. Have a look around.

The `:visuals` module is meant to be used in live environment at the parties. There is an abstraction layer in form of `Mixer` and `Layer`s, which allows me to blend multiple scenes together. Also, have a look around, proceed at your own risk, ignore `legacy` package 😅 (I like to change things, API is generally unstable).

The `:raspberrypi` module contains standalone RPi application that can be distributed using the [Application Gradle plugin](https://docs.gradle.org/current/userguide/application_plugin.html).

## How to build

This project depends on local [Processing 4](https://processing.org) installation, so go ahead and install it if you haven't already. Then create a `local.properties` file in project's root directory and configure the core library and contributed libraries' paths:

```
processing.core.jars=/path/to/your/processing/libraries/dir
processing.core.natives=/path/to/your/processing/libraries/dir/<os-architecture>
processing.core.jars=/path/to/core/processing/libraries
processing.core.natives=/path/to/core/processing/libraries/<os-architecture>
processing.core.natives.rpi=/path/to/core/processing/libraries/<os-architecture>
processing.libs.jars=/path/to/core/processing/libraries
```

Expand All @@ -26,8 +31,11 @@ On macOS it might look like this:
```
processing.core.jars=/Applications/Processing.app/Contents/Java/core/library
processing.core.natives=/Applications/Processing.app/Contents/Java/core/library/macos-x86_64
processing.core.natives.rpi=/Applications/Processing.app/Contents/Java/core/library/linux-aarch64
processing.libs.jars=/Users/matsem/Documents/Processing/libraries
```
Note the difference between `processing.core.natives` and `processing.core.natives.rpi`.
The Raspberry Pi libs have to be configured if you wish to use the `:raspberrypi` module.

The Gradle buildscript will look for Processing dependencies at these two paths. Dependencies are defined in CommonDependencies gradle plugin. Open it up, and you can notice that this project depends on some 3rd party libraries, which need to be installed at `processing.libs.jars` path. Open your Processing library manager (Sketch > Import Library > Add library) and install whatever libraries are specified in the `build.gradle` file.

Expand All @@ -49,6 +57,11 @@ val processingLibs = listOf(
)
```


### :raspberrypi module
The Raspberry Pi app can be installed using `./gradlew raspberrypi:installDist` task and zipped using `./gradlew raspberrypi:distZip` task.
See the [Application Plugin](https://docs.gradle.org/current/userguide/application_plugin.html) docs for more info.

## How to run

You can run the project with Gradle `run` task. Be sure to include the `--sketch-path` argument so sketches can properly resolve the data folder containing resources needed by some Sketches.
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/ProjectSettings.kt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
object ProjectSettings {
const val version = "2.1.0"
const val version = "2.2.0"
const val group = "dev.matsem"
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ internal fun Project.configureCommonDependencies() {
fileTree(
mapOf(
"dir" to "$processingLibsDir/$libName/library",
"include" to listOf("*.jar")
"include" to listOf("*.jar", "shader/*.glsl")
)
)
)
Expand Down
5 changes: 5 additions & 0 deletions data/images/semlogo_bottom.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions data/images/semlogo_top.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions raspberrypi/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
build/
out/
*.log
50 changes: 50 additions & 0 deletions raspberrypi/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import java.util.*

plugins {
kotlin("jvm")
application
}

apply<dev.matsem.astral.CommonDependencies>()

application {
val props = Properties().apply {
load(file("${rootDir}/local.properties").inputStream())
}
val nativesDir = props["processing.core.natives.rpi"]

mainClass.set("dev.matsem.astral.raspberrypi.RaspberryApp")
applicationDefaultJvmArgs = listOf(
"-Djava.library.path=$nativesDir"
)
applicationName = "visuals"
}

repositories {
mavenCentral()
jcenter()
}

dependencies {
implementation(project(":core"))
}

group = ProjectSettings.group
version = ProjectSettings.version

tasks {
compileKotlin {
kotlinOptions.jvmTarget = "11"
}
compileTestKotlin {
kotlinOptions.jvmTarget = "11"
}
}

tasks.getByName<Zip>("distZip") {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}

tasks.getByName<Sync>("installDist") {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
Binary file not shown.
5 changes: 5 additions & 0 deletions raspberrypi/src/dist/images/semlogo_bottom.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions raspberrypi/src/dist/images/semlogo_top.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions raspberrypi/src/dist/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh

mkdir lib/shader
mv lib/*.glsl lib/shader/
mv images/ bin/images
mv fonts/ bin/fonts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package dev.matsem.astral.raspberrypi

import dev.matsem.astral.core.di.coreModule
import dev.matsem.astral.raspberrypi.sketches.NeonLogo
import org.koin.core.KoinComponent
import org.koin.core.context.startKoin
import org.koin.core.inject
import org.koin.core.logger.Level
import processing.core.PApplet

class RaspberryApp : KoinComponent {

companion object {
@JvmStatic
fun main(args: Array<String>) {
RaspberryApp().run(args)
}
}

private val sketch: PApplet by inject()

/**
* Launches PApplet with specified arguments. Be sure to include --sketch-path argument for proper data
* folder resolution (dir containing your Processing data folder),
* @see https://processing.github.io/processing-javadocs/core/
*/
fun run(processingArgs: Array<String>) {
startKoin {
printLogger(Level.ERROR)
modules(coreModule + raspberryModule { NeonLogo() })
}

PApplet.runSketch(processingArgs + arrayOf("RaspberryVisuals"), sketch)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package dev.matsem.astral.raspberrypi

import org.koin.dsl.bind
import org.koin.dsl.module
import processing.core.PApplet

fun raspberryModule(providePApplet: () -> PApplet) = module {
single { providePApplet() } bind PApplet::class
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package dev.matsem.astral.raspberrypi.sketches

import dev.matsem.astral.core.tools.extensions.colorModeHsb
import org.koin.core.KoinComponent
import processing.core.PApplet
import processing.core.PConstants

class Blank : PApplet(), KoinComponent {

override fun settings() {
size(420, 420, PConstants.P2D)
}

override fun setup() {
colorModeHsb()
}

override fun draw() {
background(0f, 100f, 100f)
}
}
Loading