Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Changelog

All notable changes to this project will be documented in this file.

## [0.0.4] - 2026-08-11

- Fix voice control (J key) repeating the last recognition result in `picarx_control.py`
- Add J-key ack protocol: device returns `1` on receipt (ack), then `0` when the action completes, so the App clears the pending command and repeated identical commands (e.g. consecutive "forward") trigger again
- Edge-triggered voice command execution (empty/None -> command)

## [0.0.2] - 2020-06-12

- New Release
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@
- set(key='A_region', value=None)
send value

## Voice control (J key)

In `picarx_control.py`, the J key uses an ack protocol with the App:

1. Device receives a voice command (`J`) → sends `J: 1` (ack, action in progress)
2. Device executes the action (~0.3s, adjustable via `ack_ts` threshold)
3. Device sends `J: 0` (action done) → App clears the pending command

This prevents the last voice command from repeating forever and allows repeated identical commands to trigger again (edge-triggered).



Quick Links:
Expand Down
20 changes: 14 additions & 6 deletions examples/picarx_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from robot_hat import utils, Music
from vilib import Vilib
import os
import time
from time import sleep

utils.reset_mcu()
Expand Down Expand Up @@ -85,6 +86,7 @@ def main():
Vilib.camera_start(vflip=False,hflip=False)
Vilib.display(local=False, web=True)
speak = None
ack_ts = 0
while True:
# sleep(0.2)

Expand All @@ -101,12 +103,18 @@ def main():
# sc.set("L", [0,distance])
sc.set("F", distance)

# if sc.get('J') == True:
# horn()

# print(sc.get('J'), type(sc.get('J')), speak)
if sc.get('J') != None:
speak=sc.get('J')
# ---- J-key voice protocol: receive → ack(1) → execute → done(0, App clears) ----
j = sc.get('J')
if j not in (None, ''): # voice command present
if j != speak: # edge-trigger: only run on new command (repeat allowed)
speak = j
sc.set("J", 1) # ① ack: tell App we're handling it
ack_ts = time.time()
else:
if speak is not None and time.time() - ack_ts > 0.3: # ② ack(1) sent long enough for App to receive
sc.set("J", 0) # ③ done: App clears the send value
speak = None # ④ reset, ready for next command
# ----
if speak == "forward":
px.forward(speed)
elif speak == "backward":
Expand Down
2 changes: 1 addition & 1 deletion sunfounder_controller/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.0.2"
__version__ = "0.0.4"