Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
J
jensen
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Skye Yu
jensen
Commits
0ee097e4
Commit
0ee097e4
authored
Dec 15, 2025
by
martin hou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 增加按键测试指令
parent
9a27099e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
4 deletions
+36
-4
jensen.d.ts
jensen.d.ts
+3
-0
index.tsx
src/index.tsx
+24
-2
jensen.js
src/utils/jensen.js
+9
-2
No files found.
jensen.d.ts
View file @
0ee097e4
...
...
@@ -330,6 +330,9 @@ declare class Jensen {
// 获取WebUSB超时时间
getWebUSBTimeout
:
(
seconds
?:
number
)
=>
Promise
<
{
timeout
:
number
}
>
;
// 发送按键消息
sendKeyCode
:
(
mode
:
number
,
keyCode
:
number
,
seconds
?:
number
)
=>
Promise
<
ReturnStruct
[
'common'
]
>
;
dump
:
(
void
);
}
...
...
src/index.tsx
View file @
0ee097e4
...
...
@@ -31,7 +31,10 @@ export function Home() {
const
liveTimeoutRef
=
useRef
<
number
|
null
>
(
null
);
const
sendTimeoutRef
=
useRef
<
number
|
null
>
(
null
);
const
liveIntervalRef
=
useRef
<
number
>
(
liveDelay
);
const
[
mute
,
setMute
]
=
useState
<
boolean
>
(
false
);
const
muteRef
=
useRef
<
boolean
>
(
false
);
// 保存最新的静音状态供定时回调使用
useEffect
(()
=>
{
liveIntervalRef
.
current
=
liveDelay
;
},
[
liveDelay
]);
useEffect
(()
=>
{
muteRef
.
current
=
mute
;
},
[
mute
]);
mgr
.
onconnectionstatechanged
((
state
,
dinfo
)
=>
{
console
.
log
(
'onconnectionstatechanged'
,
state
,
dinfo
);
...
...
@@ -535,10 +538,10 @@ export function Home() {
const
scheduleLiveTick
=
async
()
=>
{
let
jensen
=
getJensen
();
if
(
jensen
==
null
)
return
;
let
live
=
await
jensen
.
getRealtime
(
1
,
false
,
1
);
let
live
=
await
jensen
.
getRealtime
(
1
,
muteRef
.
current
,
1
);
// 若无数据直接调度下一次
if
(
live
?.
data
==
null
)
return
;
setLiveStates
(
'live: '
+
live
.
data
.
length
+
' rest: '
+
live
.
rest
+
' muted: '
+
live
.
muted
);
setLiveStates
(
'live: '
+
live
.
data
.
length
+
' rest: '
+
live
.
rest
+
' muted: '
+
live
.
muted
+
' == '
+
muteRef
.
current
);
// 仅计算,不保留引用;如需录音导出再使用 blocksRef.current.push(live.data.slice(8))
// blocksRef.current.push(live.data.slice(8));
const
[
rms1
,
rms2
,
mono16k
]
=
rms
(
live
.
data
);
...
...
@@ -706,6 +709,21 @@ export function Home() {
URL
.
revokeObjectURL
(
url
);
}
const
muteControl
=
async
()
=>
{
setMute
((
prev
)
=>
{
const
next
=
!
prev
;
muteRef
.
current
=
next
;
// 立即同步给定时回调
return
next
;
});
}
const
sendKey
=
async
(
mode
:
number
,
keyCode
:
number
)
=>
{
let
jensen
=
getJensen
();
if
(
jensen
==
null
)
return
;
let
rst
=
await
jensen
.
sendKeyCode
(
mode
,
keyCode
,
5
);
Logger
.
info
(
'jensen'
,
'live'
,
'Send Key: '
+
JSON
.
stringify
(
rst
));
}
return
(
<>
<
div
className=
"btn-container"
style=
{
{
display
:
'flex'
,
flexDirection
:
'row'
,
gap
:
'16px'
,
padding
:
'16px'
,
alignItems
:
'center'
,
flexWrap
:
'wrap'
}
}
>
...
...
@@ -738,6 +756,10 @@ export function Home() {
<
button
onClick=
{
getSettings
}
>
Get Settings
</
button
>
<
button
onClick=
{
startLive
}
>
Start Live
</
button
>
<
button
onClick=
{
stopLive
}
>
Stop Live
</
button
>
<
button
onClick=
{
muteControl
}
>
{
mute
?
'Muted'
:
'Unmuted'
}
</
button
>
<
button
onClick=
{
()
=>
sendKey
(
0x01
,
0x04
)
}
>
Mute (Click)
</
button
>
<
button
onClick=
{
()
=>
sendKey
(
0x02
,
0x03
)
}
>
Record (Long Click)
</
button
>
<
button
onClick=
{
()
=>
sendKey
(
0x03
,
0x05
)
}
>
Playback (Dbl Press)
</
button
>
<
span
style=
{
{
marginLeft
:
'8px'
}
}
>
Interval(ms):
</
span
>
<
input
type=
"number"
...
...
src/utils/jensen.js
View file @
0ee097e4
...
...
@@ -31,6 +31,7 @@ const GET_BATTERY_STATUS = 0x1004;
const
REALTIME_READ_SETTING
=
0x20
;
const
REALTIME_CONTROL
=
0x21
;
const
REALTIME_TRANSFER
=
0x22
;
const
SEND_KEY_CODE
=
0x1c
;
const
BLUETOOTH_SCAN
=
0x1001
;
const
BLUETOOTH_CMD
=
0x1002
;
...
...
@@ -816,6 +817,11 @@ Jensen.prototype.getWebUSBTimeout = async function (seconds)
return
this
.
send
(
new
Command
(
READ_WEBUSB_TIMEOUT
),
seconds
);
};
Jensen
.
prototype
.
sendKeyCode
=
async
function
(
mode
,
keyCode
,
seconds
)
{
return
this
.
send
(
new
Command
(
SEND_KEY_CODE
).
body
([
mode
&
0xff
,
keyCode
&
0xff
]),
seconds
);
};
Jensen
.
prototype
.
listFiles
=
async
function
()
{
let
tag
=
'filelist-'
+
this
.
serialNumber
;
if
(
this
[
tag
]
!=
null
)
return
null
;
...
...
@@ -1339,12 +1345,12 @@ Jensen.prototype.pauseRealtime = async function (seconds) {
Jensen
.
prototype
.
stopRealtime
=
async
function
(
seconds
)
{
return
this
.
send
(
new
Command
(
REALTIME_CONTROL
).
body
([
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
]),
seconds
);
};
Jensen
.
prototype
.
getRealtime
=
async
function
(
frames
,
mute
,
seconds
)
{
Jensen
.
prototype
.
getRealtime
=
async
function
(
frames
,
seconds
)
{
let
a
=
(
frames
>>
24
)
&
0xff
;
let
b
=
(
frames
>>
16
)
&
0xff
;
let
c
=
(
frames
>>
8
)
&
0xff
;
let
d
=
(
frames
>>
0
)
&
0xff
;
return
this
.
send
(
new
Command
(
REALTIME_TRANSFER
).
body
([
a
,
b
,
c
,
d
,
0x00
,
0x00
,
0x00
,
mute
?
0x01
:
0x00
]),
seconds
);
return
this
.
send
(
new
Command
(
REALTIME_TRANSFER
).
body
([
a
,
b
,
c
,
d
]),
seconds
);
};
Jensen
.
prototype
.
requestToneUpdate
=
async
function
(
signature
,
size
,
seconds
)
{
let
data
=
[];
...
...
@@ -1647,6 +1653,7 @@ Jensen.registerHandler(GET_FILE_BLOCK, commonMessageParser);
Jensen
.
registerHandler
(
TEST_SN_WRITE
,
commonMessageParser
);
Jensen
.
registerHandler
(
SCHEDULE_INFO
,
commonMessageParser
);
Jensen
.
registerHandler
(
BLUETOOTH_CMD
,
commonMessageParser
);
Jensen
.
registerHandler
(
SEND_KEY_CODE
,
commonMessageParser
);
Jensen
.
registerHandler
(
REQUEST_TONE_UPDATE
,
(
msg
)
=>
{
let
rst
=
msg
.
body
[
0
];
let
txt
=
'success'
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment