Skip to content

Instantly share code, notes, and snippets.

@layomia
Created March 18, 2026 23:28
Show Gist options
  • Select an option

  • Save layomia/b92cf4ea6437aa35a07050e496e52d2a to your computer and use it in GitHub Desktop.

Select an option

Save layomia/b92cf4ea6437aa35a07050e496e52d2a to your computer and use it in GitHub Desktop.
Me:
I’m building a mood lamp with CPX. I want a hand swipe gesture to control it. Right swipe should turn it on, left swipe should turn it off, and I want swipe velocity to determine which mood gets activated. Can you help me define gesture rules and mood-state mapping?
AI:
Yes. A clean way to structure this is:
1. Gesture rules
Right swipe = activate lamp and select mood
Left swipe = clear current mood / turn lamp off
Ignore very small or ambiguous motion to avoid accidental triggers
2. Velocity-based mood mapping
You could divide swipe speed into 4 bands:
Slow swipe → Calm
Medium-slow swipe → Reflective
Medium-fast swipe → Energetic
Fast swipe → Overstimulated / Intense
This makes the interaction feel expressive without requiring multiple buttons.
Me:
I want the mood to be legible through both text and lighting. How should the output behave?
AI:
Map each mood to both a text-light state and a frame-light state:
Calm
Text lights: steady, soft glow
Frame lights: low intensity, cool or muted tone
Reflective
Text lights: gentle pulse
Frame lights: medium-low intensity, balanced tone
Energetic
Text lights: brighter, quicker pulse
Frame lights: higher intensity, saturated tone
Overstimulated / Intense
Text lights: rapid pulse or flicker
Frame lights: highest intensity, high-contrast tone
Me:
How do I keep it from feeling random?
AI:
Three rules will help:
Use clear velocity thresholds
Give immediate feedback after the swipe
Keep left swipe always consistent as reset/off
So the user learns:
direction chooses action
speed chooses mood
lighting confirms the state
Me:
What are some example thresholds?
AI:
Example mapping:
0–25% velocity = Calm
26–50% = Reflective
51–75% = Energetic
76–100% = Intense
You may need to tune these after testing, since gesture sensing can be noisy.
Me:
Anything I should watch out for?
AI:
Yes:
accidental triggers from weak hand movement
difficulty distinguishing adjacent speed bands
users not understanding whether direction or speed mattered more
A good fallback is to make the speed bands visually distinct enough that even imperfect sensing still feels intentional.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment