Repository navigation
Feat/kawaii eyes - #108
Feat/kawaii eyes#108blakelton wants to merge 12 commits into
Conversation
Add `eyes_style=kawaii`: round eyes with sparkle highlights, a small mouth between them, and dithered blush under the outer corners. - Parametric face renderer (eye shape, lids, happy crescents, mouth, blush, twinkles) so every feature eases between moods; springs give eye size, smiles and mouth opening a little overshoot - Shape swaps that cannot morph (> <, x x, hearts) happen behind a blink - Idle personality: mostly smiles, with occasional grins, winks, excitement, and rare heart eyes - Each animation maps to a mood; talking opens the mouth with speech loudness from /play - Classic pose, glances and blinks still drive position and openness - Renderer and animator are Arduino-free and covered by native tests - Register the style id, Config select option, API docs and web UI API page
The kawaii mouth only moved with /play audio, so a plain `POST /anim talking` showed a still smile while the head and arms moved. Each syllable now opens the mouth into an "ah", "ee" or "o" shape and then returns to a small resting smile. With audio, loudness sets how far it opens and each syllable onset picks a new shape. Without audio, it babbles in short phrases with pauses. Also, from the review: - split mood.* into expression, animator, idle, speech and compose modules, with shared helpers in util.h - name every tuning value; idle accent odds and vowel shapes are tables with compile-time checks - break up drawRoundEye, drawMouth, drawKawaii and the animator's shape-swap blink to cut cognitive complexity - remove the static scratch buffer from render(); the eyes now clear their own gap around the blush, so render() keeps no state - rename test_kawaii_face to test_kawaii and add tests for vowel shapes, babble rhythm, millis wrap, audio follow and render purity - document kawaii in the dead and talking rows of docs/api.md - add kawaii/README.md with the module layout and tuning guide Every mood except talking renders pixel-identical to before.
The welcome clip clipped with kawaii eyes. Audio clips and eye drawing share loop(): each pass feeds 23 ms of audio, and the refactor's two-pass blush gap made a welcome frame (Excited at the welcome pose) cost about 2.45 M instructions on the C3. With the ~12 ms OLED push, that overran the budget. - Draw each eye once; blush picks its dots against the finished eyes before drawing any, so render() still keeps no state - Draw eyes, lids, carve, sparkle holes and > < / x x strokes as per-row runs: only edge pixels are tested in float, with the exact original test, so output is unchanged - Precompute blush and heart terms per row or column, hoist loop bounds, skip the mouth wobble when there is none - Cache the animator's easing weights per frame time A welcome frame now takes about 510 k instructions (1.15 M before the refactor). Every mood renders pixel-identical. The frame budget is documented in kawaii/README.md.
The scripted blinks in the welcome and attention eye modes had their easing upside down: blinkT runs 0 → 1 → 0 across the window, and open = ease(blinkT) snapped the eyes shut at the start, opened them in the middle, shut them again, and snapped them open at the end. At 33 ms frames the 100 ms welcome blink after "Hello, human" showed as shut → open → half shut → open, a visible flicker (most obvious with round kawaii eyes). Use ease(1 - blinkT) so each window is one blink: open at the edges, closed in the middle.
A round kawaii eye squashed to a couple of pixels drew as a flat bar, which reads as a glitch rather than a blink. Draw the closed "‿" lid line once the eye is flatter than 0.22 of its width radius, compared with the width because scripted blinks squash the pose height itself. Only the deepest blink frames change.
The dark sparkle holes read as pupils on the robot, so make them real pupils: a dark disc that looks where the eye choreography points (the task or the human, down at the keyboard while typing, up while thinking), with a white catch-light inside it that cannot be mistaken for a second pupil. - Gaze comes from the shared eye-mode glances; moods add their own pupil size and look (small when surprised or angry, big and looking down when sad) - The pupil keeps a rim of eye around it: when a lid, tilt, smile or blink leaves no room where it looks, it slides toward the middle, then shrinks, so the eye outline never notches - Gaze eases quickly, like a saccade - Tests cover the catch-light, gaze direction, the rim under lids and smiles, and no pupil in a full ^ ^ smile
Replace the dark sparkle holes, which read as small pupils, with big dark pupils that look where the robot is looking, and white catch-lights inside them (a round light and two dots) that cannot be mistaken for a pupil. - Gaze follows the shared eye-mode glances (the task or the human, up while thinking); moods set pupil size and their own look - Pupils keep one size: lids, smiles and blinks cover them like eyelids, a 2 px rim always stays white, and centers snap to whole pixels so a moving pupil never changes shape - Typing reads code: a few lines word by word, then a dart to another spot, instead of following classic's typing jitter - Thinking follows its glances halfway, for a calmer look aside - Gaze glides (150 ms); catch-lights no longer pulse - Discs centered on pixels precompute their rows: a welcome frame drops to ~420 k instructions on the C3 - Tests cover gaze, constant pupil size, the rim under lids and smiles, and the code-reading gaze
Working modes held one face the whole time. Give typing, reading and thinking the same personality idle has: mostly the working face, with a short accent now and then before settling back. - Typing: focused, with a pleased smile, a quick grin, or a wink; the eyes keep reading code through the accents - Reading: absorbed, with a pleased read or an "ooh, interesting" - Thinking: pondering, with an "aha!" (wide eyes looking up, glints, a hop, an open smile) - Accents come more often the longer work has gone well: the gap shrinks over ~90 s without an error, abort or dead, and resets on one - Generalize the idle director into MoodDirector with one personality table per activity; idle behaves as before - Add Pleased and Aha moods - Tests: working modes stay mostly on their base face with only their own accents, and going well brings more accents
…bell The kawaii mouth now says the words of every stock voice clip in sync, and the bell gets a celebration instead of squashed surprised eyes. Spoken lines (keyed to each stock clip's loudness envelope): - welcome: "Hello, human. What are we building today?" - attention: "Psst... human... you might want to take a look." - error: "Uh-oh. Human, we have a problem." - abort: "Fine. I didn't want to finish it anyway." - dead: "Insufficient resources... shutting doooowwwnnn" Keyframes close the lips on p, b, m, t, d and k and hold pauses shut; tracks lead the audio by 40 ms. While a clip plays, the face uses the talking rest mouth. One Line table holds every track and its stock cue times; a custom clip with its own .cue gets syllable babble instead. Bell (ring): an eager wind-up, a burst of joy the moment bell.wav starts, bliss while it rings (^ ^ squeezed shut, blush, open smile, a delighted shiver), then a dreamy afterglow. The ring no longer squashes the eyes; without a bell clip the ding comes after 1.5 s. Adds Bliss and Afterglow moods and a quiver (shiver) parameter.
The bell's delighted shiver was hidden behind squeezed-shut eyes and stopped abruptly, and the wind-up before the ding had little to say. - Wind-up: eager, then suspense builds over 0.8 s and holds until the strike: eyes narrow onto the bell, the mouth holds its breath, and a nervous tremble grows - Bliss keeps the eyes open (soft happy eyes, big sparkling pupils), so the shiver shows for as long as bell.wav plays - When the ring ends, the shiver winds down over 500 ms, smaller and slower (14 Hz to 3 Hz), while the face blends into the afterglow - The shiver's phase now advances in the animator, so its speed can change without a jump - BellCelebration returns the face itself; Expression gains a blend() helper and quiverHz; adds a Suspense mood
…hake The bell's shake moved the whole eye, trembled through the wind-up, and ran for the full clip, including its silent tail. Rework the celebration around the ding. - Only the pupils shake, starting on the ding and following the stock bell.wav loudness (measured every 10 ms): hardest and fastest on the strike, fading and slowing to the last of the ring at ~1.4 s - Wind-up is a deep breath that deepens until the strike: the face rises, eyes widen, pupils tighten, cheeks flush, and the mouth draws in a growing "o"; the ding lets it out as an excited yell - Stars burst from the outer sides of the eyes on the ding and swirl off-screen, with trails that shorten as the bell fades - Adds the Yell mood, a breath "rise", per-eye pupil shake, and face sparks; the busiest bell frame is ~550 k instructions on the C3 - Docs: kawaii summaries, the lip-sync paragraph, the pose exceptions, and the frame budget brought up to date
The post-upload hook runs `pio run -t uploadfs` as a child process, which does not inherit --upload-port. With more than one serial device plugged in, the filesystem upload auto-detected another port and failed after the firmware had flashed fine. Pass the port the firmware upload used ($UPLOAD_PORT, given or auto-detected) on to uploadfs.
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
|
Hope you love it! |
What
Adds a new OLED eye style,
eyes_style=kawaii: round eyes with big pupils, a small talking mouth, and blush. It is opt-in, and the default staysclassic. This supersedes #107, which I opened too early and closed.The face
> <,x x, hearts) swap behind a quick blink.deadflicker and sleep.Per animation
typing/reading/thinkingwelcome,attention,error,abort,dead.cuegets syllable babble insteadtalking/playloudness with vowel shapes, or babbles without audioringCode
src/display/eyes/styles/kawaii/as plain C++ with no Arduino dependencies, and builds in thenativeenv.styles/kawaii.cppis the only firmware glue.kawaii/README.md.loop()as the eyes. The renderer works in per-row runs with pixel-centered discs. On an emulated C3, the busiest frame while a clip plays costs ~550 k instructions; the README documents the 600 k budget.registry.cpp,eye_style_ids.cpp(settings validation and its test), the Config dropdown,docs/api.md, and the web UI API page.Two small fixes outside kawaii, in their own commits
fix(anim)—8b60ab0. The scripted blinks in the welcome and attention eye modes had their easing upside down: the eye snapped shut, opened, shut, then snapped open. Each window is now one blink. This changes classic, dots, and cover slightly at those two moments.fix(scripts)—3885522. The post-upload LittleFS hook did not pass--upload-port, so with several serial devices plugged in it uploaded to the wrong one.Happy to split either fix into its own PR if you prefer.
No HTTP routes, pins, NVS layout, or servo behavior change.
eyes_stylegains one accepted value, so nothing breaks.Checks
type(scope): summarytype!:plus aBREAKING CHANGE:footer (N/A: additive only)pio run(no warnings) andpio test -e native(133/133; the newtest_kawaiisuite covers rendering, easing, moods, lip sync, gaze, and the bell)ui/src/views/ApiReference.tsx) +docs/api.mdupdated for the neweyes_stylevalue;npm test --prefix uiandnpm run lint --prefix uipasskawaiiadded to validation and its test; no rawaccess_tokenin logs.env, tokens, or Wi-Fi passwords in logs or screenshotsSummary by CodeRabbit