pi-codey
v0.1.5
Published
Pi extension and onboard blueprint controller for Makeblock Codey Rocky reactions.
Downloads
743
Maintainers
Readme
pi-codey
Pi extension + onboard controller for Makeblock Codey Rocky reactions.
pi-codey lets Pi trigger expressive Codey Rocky reactions over USB serial. Codey runs a small onboard Python program; Pi only sends tiny trigger messages such as think, success, or error. Synthetic beep notes are avoided; built-in Codey wave/melody files are used where configured.
Install
Install from npm as a Pi package:
pi install npm:pi-codeyRestart Pi, then detect and set the Codey serial port:
/codey detect --useFlash the onboard Codey program:
/codey installRun a quick check:
/codey testUpdate later with:
pi update npm:pi-codeyBasic commands
/codey status # show current settings
/codey detect # show likely Codey serial port
/codey detect --use # detect and set active port
/codey port COM3 # set port manually
/codey install # flash onboard program
/codey test # hello → think → success → idle
/codey success # trigger a blueprint
/codey bored
/codey idle
/codey play ready # play a built-in Codey sound
/codey play prompt toneAuto reaction profiles
/codey silent # manual reactions only
/codey min # startup, thinking, errors, success, shutdown
/codey mid # min + tool start/success reactions
/codey max # broader expression palette across tool eventsLong form also works:
/codey profile minWhen automatic reactions are enabled, Codey also triggers bored once if an agent turn runs longer than 30 seconds.
Blueprints
ack, hello, ready, think, curious, notify, success,
celebrate, wow, laugh, warn, error, angry, sad,
sleepy, bored, dizzy, screaming, fear, thank_you, bye, idleManual trigger:
/codey <blueprint>Sensor reactions
The onboard program can react locally, even when Pi is not sending a command:
shake → dizzy
loud sound → screaming
lift/airborne → fear
put down again → thank_youThese thresholds are configurable; see Configuration. If sensor behavior needs tuning, run diagnostics:
/codey sensors # record 15 seconds
/codey sensors 30 # record 30 secondsThis temporarily uploads a diagnostic program and writes readings to:
.pi/codey-sensors-last.txtRestore pi-codey afterwards:
/codey installConfiguration
Create a project-local config:
mkdir -p .pi
cp codey.config.example.json .pi/codey.config.jsonEdit .pi/codey.config.json, then re-flash:
/codey installCommon options:
{
"movement": false,
"movementSpeed": 0.55,
"sounds": true,
"blueprints": {
"success": { "sound": "yummy", "movement": false },
"bored": { "sound": "sigh", "movement": false }
},
"sensors": {
"enabled": true,
"sound": { "enabled": true, "threshold": 15 },
"lift": {
"enabled": true,
"useFloorIr": true,
"floorIrThreshold": 20,
"floorIrStableThreshold": 60
}
}
}Config lookup order:
.pi/codey.config.jsonin the current Pi projectcodey.config.jsonin the current project/repocodey.config.jsonin the package root, mainly for local development
Useful config keys:
movement: enable/disable Rocky wheel/body movementmovementSpeed: movement speed multiplier from0to1sounds: enable/disable built-in wave playbackblueprints.<name>.sound: replace a blueprint sound, e.g."score","level up", ornullblueprints.<name>.movement: override movement per blueprintsensors.*.threshold/ cooldown keys: tune sensor reactions
Built-in sounds
Play directly with /codey play <name>.
hello, hi, bye, yeah, wow, laugh,
hum, sad, sigh, annoyed, angry,
surprised, yummy, curious, embarrassed,
ready, sprint, sleepy, meow, start,
switch, beeps, buzzing, exhaust, explosion,
gotcha, hurt, jump, laser, level up,
low energy, metal clash, prompt tone, right,
wrong, ring, score, shot, step_1,
step_2, wake, warningShell tools
After installing from npm, the package also provides:
pi-codey detect
pi-codey-flash --port COM3From a checkout you can run helpers directly:
python tools/trigger_codey.py success --port COM3
python tools/trigger_codey.py sound --value "ready" --port COM3
python tools/flash_codey.py generated/codey_blueprints.py --port COM3Development
Use a local package install while developing:
pi install /path/to/pi-codeyDo not also copy the extension into .pi/extensions/; that loads a second copy and causes duplicate tool/command conflicts.
Useful commands:
npm run packcheck
npm publishEnvironment
PI_CODEY_PORT=COM3 # default serial port
PI_CODEY_AUTO=0 # start with automatic reactions disabled
PI_CODEY_ENABLED=0 # disable extension on startup
PI_CODEY_ROOT=/path # package root override for developmentNotes
- Codey must be connected over USB and visible as a serial port.
- Normal operation does not require the mBlock app.
/codey sensorstemporarily overwrites the onboard program; run/codey installafterwards.
