Add frame rate limit setting
Lets the frame rate be capped at 30, 15 or 10 fps to find out whether the occasional random-colour flashes on single keys depend on the update rate. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
c38d8de942
commit
9ff5b99fa0
2 files changed
+15
-1
No files matched your search
@@ -17,6 +17,7 @@ LightingMode:readonly
|
||||
forcedColor:readonly
|
||||
lowFPS:readonly
|
||||
keyTest:readonly
|
||||
frameLimit:readonly
|
||||
*/
|
||||
export function ControllableParameters() {
|
||||
return [
|
||||
@@ -24,6 +25,7 @@ export function ControllableParameters() {
|
||||
{property:"LightingMode", group:"lighting", label:"Lighting Mode", description: "Determines where the device's RGB comes from. Canvas will pull from the active Effect, while Forced will override it to a specific color", type:"combobox", values:["Canvas", "Forced"], default:"Canvas"},
|
||||
{property:"forcedColor", group:"lighting", label:"Forced Color", description: "The color used when 'Forced' Lighting Mode is enabled", min:"0", max:"360", type:"color", default:"#009bde"},
|
||||
{property:"lowFPS", group:"lighting", label:"Low frame-rate mode", description: "Sends smaller packets with pauses in between, can improve stability", type:"boolean", default:false},
|
||||
{property:"frameLimit", group:"lighting", label:"Frame rate limit", description: "Maximum frames per second sent to the keyboard", type:"combobox", values:["Unlimited", "30", "15", "10"], default:"Unlimited"},
|
||||
{property:"keyTest", group:"lighting", label:"Key test", description: "Sweeps a white line across the keys to check the LED map", type:"combobox", values:["Off", "Column sweep", "Row sweep"], default:"Off"},
|
||||
];
|
||||
}
|
||||
@@ -67,7 +69,18 @@ export function Initialize() {
|
||||
device.setControllableLeds(vLedNames, vLedPositions);
|
||||
}
|
||||
|
||||
let lastFrameTime = 0;
|
||||
|
||||
export function Render() {
|
||||
// The keyboard falls back to its own effect after about a second without frames,
|
||||
// so the lowest limit (10 fps) still keeps it under plugin control
|
||||
const now = Date.now();
|
||||
|
||||
if (frameLimit !== "Unlimited" && now - lastFrameTime < 1000 / parseInt(frameLimit)) {
|
||||
return;
|
||||
}
|
||||
|
||||
lastFrameTime = now;
|
||||
sendColors();
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user