Merge pull request #32 from danielvanpaass/feature-hold-last-frame

led was turning off on backdrop/images
This commit is contained in:
haumlab authored and GitHub committed 2026-05-17 12:31:44 +01:00
commit 199479c0c9
1 file changed
+23
@@ -45,6 +45,9 @@ public final class HyperionScreenEncoder extends HyperionScreenEncoderBase {
private int mBorderX; private int mBorderX;
private int mBorderY; private int mBorderY;
private int mFrameCount; private int mFrameCount;
private byte[] mLastFrame;
private int mLastFrameWidth;
private int mLastFrameHeight;
private final Runnable mCaptureRunnable = new Runnable() { private final Runnable mCaptureRunnable = new Runnable() {
@Override @Override
@@ -155,6 +158,10 @@ public final class HyperionScreenEncoder extends HyperionScreenEncoderBase {
img = mImageReader.acquireLatestImage(); img = mImageReader.acquireLatestImage();
if (img != null) { if (img != null) {
processImage(img); processImage(img);
} else if (mLastFrame != null) {
// Screen content hasn't changed — no new frame was produced by the VirtualDisplay.
// Resend the last frame so Hyperion doesn't time out the priority channel and turn off the LEDs.
mListener.sendFrame(mLastFrame, mLastFrameWidth, mLastFrameHeight);
} }
} catch (Exception e) { } catch (Exception e) {
if (DEBUG) Log.w(TAG, "Capture error", e); if (DEBUG) Log.w(TAG, "Capture error", e);
@@ -210,6 +217,13 @@ public final class HyperionScreenEncoder extends HyperionScreenEncoderBase {
if (effWidth <= 0 || effHeight <= 0) return; if (effWidth <= 0 || effHeight <= 0) return;
final byte[] rgb = extractRgb(buffer, width, height, rowStride, pixelStride, bx, by, effWidth, effHeight); final byte[] rgb = extractRgb(buffer, width, height, rowStride, pixelStride, bx, by, effWidth, effHeight);
final int frameSize = effWidth * effHeight * BYTES_PER_PIXEL_RGB;
if (mLastFrame == null || mLastFrame.length != frameSize) {
mLastFrame = new byte[frameSize];
}
System.arraycopy(rgb, 0, mLastFrame, 0, frameSize);
mLastFrameWidth = effWidth;
mLastFrameHeight = effHeight;
mListener.sendFrame(rgb, effWidth, effHeight); mListener.sendFrame(rgb, effWidth, effHeight);
} }
@@ -307,6 +321,12 @@ public final class HyperionScreenEncoder extends HyperionScreenEncoderBase {
mAvgColorResult[0] = (byte) (r / count); mAvgColorResult[0] = (byte) (r / count);
mAvgColorResult[1] = (byte) (g / count); mAvgColorResult[1] = (byte) (g / count);
mAvgColorResult[2] = (byte) (b / count); mAvgColorResult[2] = (byte) (b / count);
if (mLastFrame == null || mLastFrame.length != 3) {
mLastFrame = new byte[3];
}
System.arraycopy(mAvgColorResult, 0, mLastFrame, 0, 3);
mLastFrameWidth = 1;
mLastFrameHeight = 1;
mListener.sendFrame(mAvgColorResult, 1, 1); mListener.sendFrame(mAvgColorResult, 1, 1);
} }
} }
@@ -334,6 +354,9 @@ public final class HyperionScreenEncoder extends HyperionScreenEncoderBase {
mRgbBuffer = null; mRgbBuffer = null;
mRowBuffer = null; mRowBuffer = null;
mLastFrame = null;
mLastFrameWidth = 0;
mLastFrameHeight = 0;
mBorderX = 0; mBorderX = 0;
mBorderY = 0; mBorderY = 0;
mFrameCount = 0; mFrameCount = 0;