diff --git a/build.gradle.kts b/build.gradle.kts index e9c96d1..aa49cef 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -28,7 +28,7 @@ dependencies { api("com.diozero:diozero-core:$DIOZERO_VER") // for adhoc testing - testImplementation("com.diozero:diozero-provider-remote:$DIOZERO_VER") + implementation("com.diozero:diozero-provider-remote:$DIOZERO_VER") testImplementation("com.diozero:diozero-provider-mock:$DIOZERO_VER") testImplementation("io.kotest:kotest-runner-junit5:5.5.5") diff --git a/src/main/kotlin/crackers/kobots/devices/lighting/PixelBuf.kt b/src/main/kotlin/crackers/kobots/devices/lighting/PixelBuf.kt index 6c5f800..ad7298c 100644 --- a/src/main/kotlin/crackers/kobots/devices/lighting/PixelBuf.kt +++ b/src/main/kotlin/crackers/kobots/devices/lighting/PixelBuf.kt @@ -69,17 +69,10 @@ abstract class PixelBuf( get() = _brightness set(b) { if (b < 0f || b > 1f) throw IllegalArgumentException("'brightness' is out of range (0.0-1.0)") - val delta = b - _brightness - _brightness = b - - // adjust brightness of existing values - for (i in 0 until effectiveSize) { - if (dotstarMode && (i + 1) % 4 == 0) continue - val index = i + bufferOffset - val item = pixelBuffer[index].toUByte().toFloat() - val adjusted = (item * delta).roundToInt() - pixelBuffer[index] = (item + adjusted).toInt().toByte() - } + val currentAutoWrite = _autoWrite + _autoWrite = false + currentColors.clone().forEachIndexed { i, c -> set(i, PixelColor(c.color, c.white, b)) } + _autoWrite = currentAutoWrite if (_autoWrite) show() }