-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implementing first version of twinkly matrix display which contains s…
…tripes with colors from the rest of the stage - just for testing performance
- Loading branch information
Showing
10 changed files
with
189 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 25 additions & 1 deletion
26
...x/src/main/kotlin/de/visualdigits/kotlin/klanglicht/model/twinkly/TwinklyConfiguration.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,30 @@ | ||
package de.visualdigits.kotlin.klanglicht.model.twinkly | ||
|
||
import de.visualdigits.kotlin.twinkly.model.device.xled.DeviceOrigin | ||
import de.visualdigits.kotlin.twinkly.model.device.xled.XLedDevice | ||
import de.visualdigits.kotlin.twinkly.model.device.xled.XledArray | ||
|
||
class TwinklyConfiguration( | ||
val name: String, | ||
val deviceOrigin: String, | ||
val gain: Float, | ||
val array: Array<Array<XledDeviceConfiguration>> | ||
) | ||
) { | ||
|
||
val xledArray: XledArray | ||
|
||
init { | ||
xledArray = XledArray( | ||
deviceOrigin = DeviceOrigin.valueOf(deviceOrigin), | ||
xLedDevices = array.map { column -> | ||
column.map { config -> | ||
XLedDevice( | ||
host = config.ipAddress, | ||
width = config.width, | ||
height = config.height | ||
) | ||
}.toTypedArray() | ||
}.toTypedArray() | ||
) | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
...-dmx/src/main/kotlin/de/visualdigits/kotlin/klanglicht/model/twinkly/XledFrameFadeable.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package de.visualdigits.kotlin.klanglicht.model.twinkly | ||
|
||
import de.visualdigits.kotlin.klanglicht.model.color.RGBColor | ||
import de.visualdigits.kotlin.klanglicht.model.parameter.Fadeable | ||
import de.visualdigits.kotlin.klanglicht.model.preferences.Preferences | ||
import de.visualdigits.kotlin.twinkly.model.playable.XledFrame | ||
import de.visualdigits.kotlin.twinkly.model.color.RGBColor as TwinklyRGBColor | ||
|
||
class XledFrameFadeable( | ||
private val deviceId: String, | ||
private var xledFrame: XledFrame, | ||
private var deviceGain: Float | ||
) : Fadeable<XledFrameFadeable> { | ||
|
||
override fun getTurnOn(): Boolean = true | ||
|
||
override fun getId(): String = deviceId | ||
|
||
override fun getGain(): Float = deviceGain | ||
|
||
override fun setGain(gain: Float) { | ||
this.deviceGain = gain | ||
} | ||
|
||
override fun getRgbColor(): RGBColor { | ||
val twinklyColor = xledFrame[0, 0].toRGB() | ||
return RGBColor(twinklyColor.red, twinklyColor.green, twinklyColor.blue) | ||
} | ||
|
||
override fun setRgbColor(rgbColor: RGBColor) { | ||
xledFrame.setColor(TwinklyRGBColor(rgbColor.red, rgbColor.green, rgbColor.blue)) | ||
} | ||
|
||
override fun write(preferences: Preferences, write: Boolean, transitionDuration: Long) { | ||
val twinklyDevice = preferences.twinklyMap[deviceId] | ||
if (twinklyDevice != null) { | ||
val xledArray = twinklyDevice.xledArray | ||
xledArray.setBrightness(deviceGain) | ||
xledFrame.play(xledArray) | ||
} | ||
} | ||
|
||
override fun fade(other: Any, factor: Double): XledFrameFadeable { | ||
return if (other is XledFrameFadeable) { | ||
val xledFrame1 = xledFrame.fade(other.xledFrame, factor) | ||
XledFrameFadeable(deviceId, xledFrame1, deviceGain) | ||
} else { | ||
throw IllegalArgumentException("Cannot not fade another type") | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.