pi-keyboard 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/features/keyboard.feature +2 -2
- package/package.json +1 -1
- package/src/driver.ts +24 -2
- package/src/types.ts +10 -8
|
@@ -58,8 +58,8 @@ Feature: Pi Keyboard Lighting Indicator
|
|
|
58
58
|
Given a user has submitted a prompt or the agent is executing a turn
|
|
59
59
|
When the agent starts thinking or executing tools
|
|
60
60
|
Then the keyboard state machine updates to "thinking"
|
|
61
|
-
And the
|
|
62
|
-
And the
|
|
61
|
+
And the transition is buffered with a gentle intermediate ramp to avoid abrupt visual changes
|
|
62
|
+
And the keyboard lighting is set to softened oceanic blue breathing
|
|
63
63
|
And the update is applied with --no-save in memory
|
|
64
64
|
|
|
65
65
|
Scenario: Pi transitions to need approval state with yellow blinking light
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-keyboard",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Dynamic VIA/QMK keyboard RGB lighting indicator reflecting Pi states (idle, thinking, unread, need-approval, error)",
|
|
5
5
|
"author": "Frad LEE <fradser@gmail.com>",
|
|
6
6
|
"license": "MIT",
|
package/src/driver.ts
CHANGED
|
@@ -22,7 +22,7 @@ export function resolveCliPath(customPath?: string): string {
|
|
|
22
22
|
|
|
23
23
|
const standardPaths = [
|
|
24
24
|
join(homedir(), ".local", "bin", "via-rgb"),
|
|
25
|
-
"/opt/homebrew/bin
|
|
25
|
+
"/opt/homebrew/bin", "via-rgb",
|
|
26
26
|
"/usr/local/bin/via-rgb",
|
|
27
27
|
];
|
|
28
28
|
|
|
@@ -42,6 +42,8 @@ export interface HardwareApplyResult {
|
|
|
42
42
|
error?: string;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
+
const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
46
|
+
|
|
45
47
|
export async function applyKeyboardState(
|
|
46
48
|
state: KeyboardState,
|
|
47
49
|
config: KeyboardConfig,
|
|
@@ -71,7 +73,27 @@ export async function applyKeyboardState(
|
|
|
71
73
|
|
|
72
74
|
const task = async (): Promise<HardwareApplyResult> => {
|
|
73
75
|
try {
|
|
74
|
-
//
|
|
76
|
+
// If state specifies smooth ramp (e.g. thinking blue), apply a gentle buffered transition
|
|
77
|
+
if (def.smoothRamp) {
|
|
78
|
+
const intermediateSat = Math.round(def.sat * 0.6);
|
|
79
|
+
const intermediateBrightness = Math.round(targetBrightness * 0.9);
|
|
80
|
+
const rampArgs = [
|
|
81
|
+
...baseArgs,
|
|
82
|
+
"set",
|
|
83
|
+
"-b",
|
|
84
|
+
String(intermediateBrightness),
|
|
85
|
+
"-e",
|
|
86
|
+
String(def.effect),
|
|
87
|
+
"-s",
|
|
88
|
+
"100",
|
|
89
|
+
"-c",
|
|
90
|
+
`${def.hue} ${intermediateSat}`,
|
|
91
|
+
];
|
|
92
|
+
await execFileAsync(cli, rampArgs, { timeout: 3000 });
|
|
93
|
+
await sleep(150); // 150ms graceful transition buffer
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// Set final color, effect, speed, brightness in memory
|
|
75
97
|
const setArgs = [
|
|
76
98
|
...baseArgs,
|
|
77
99
|
"set",
|
package/src/types.ts
CHANGED
|
@@ -20,6 +20,7 @@ export interface KeyboardStateDefinition {
|
|
|
20
20
|
brightness: number;
|
|
21
21
|
pattern: KeyboardPattern;
|
|
22
22
|
blinkCount?: number;
|
|
23
|
+
smoothRamp?: boolean;
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
export interface KeyboardConfig {
|
|
@@ -45,7 +46,7 @@ export const KEYBOARD_STATE_DEFINITIONS: Record<KeyboardState, KeyboardStateDefi
|
|
|
45
46
|
hue: 0,
|
|
46
47
|
sat: 0, // White
|
|
47
48
|
effect: 2, // Breathing
|
|
48
|
-
speed:
|
|
49
|
+
speed: 90,
|
|
49
50
|
brightness: 180,
|
|
50
51
|
pattern: "breathing",
|
|
51
52
|
},
|
|
@@ -54,22 +55,23 @@ export const KEYBOARD_STATE_DEFINITIONS: Record<KeyboardState, KeyboardStateDefi
|
|
|
54
55
|
label: "Green Breathing (Unread Chat)",
|
|
55
56
|
labelZh: "绿色 呼吸灯 (未读消息)",
|
|
56
57
|
hue: 85, // Green
|
|
57
|
-
sat:
|
|
58
|
+
sat: 240,
|
|
58
59
|
effect: 2, // Breathing
|
|
59
|
-
speed:
|
|
60
|
-
brightness:
|
|
60
|
+
speed: 130,
|
|
61
|
+
brightness: 210,
|
|
61
62
|
pattern: "breathing",
|
|
62
63
|
},
|
|
63
64
|
thinking: {
|
|
64
65
|
state: "thinking",
|
|
65
66
|
label: "Blue Breathing (Thinking)",
|
|
66
67
|
labelZh: "蓝色 呼吸灯 (正在思考/执行)",
|
|
67
|
-
hue:
|
|
68
|
-
sat:
|
|
68
|
+
hue: 165, // Calm oceanic blue (softened from harsh 170)
|
|
69
|
+
sat: 210, // Softened saturation (non-glaring)
|
|
69
70
|
effect: 2, // Breathing
|
|
70
|
-
speed: 200
|
|
71
|
-
brightness:
|
|
71
|
+
speed: 120, // Calmed, gentle cadence (softened from 200)
|
|
72
|
+
brightness: 195, // Balanced ambient level (smooth from 180)
|
|
72
73
|
pattern: "breathing",
|
|
74
|
+
smoothRamp: true,
|
|
73
75
|
},
|
|
74
76
|
need_approval: {
|
|
75
77
|
state: "need_approval",
|