From 5f3c518089c780cc224499cea950f8ce2d25bab2 Mon Sep 17 00:00:00 2001 From: Me Here Date: Fri, 5 Jun 2026 21:26:17 -0500 Subject: [PATCH] pm-kit: pendulum swing as a single degrees knob (PEND_SWING_DEG=120) Make the swing arc one source of truth in degrees, driving both the screen graphic (exactly) and the physical arm (mapped through STEPPER_STEPS_PER_REV). Set to 120 deg end-to-end. PEND_THETA now derives from it; STEPPER_ARC = steps_per_rev * deg/360. Graphic geometry verified on-screen at 120 deg. Co-Authored-By: Claude Opus 4.8 (1M context) --- pico-cp/app.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pico-cp/app.py b/pico-cp/app.py index cd088b8..ebe7274 100644 --- a/pico-cp/app.py +++ b/pico-cp/app.py @@ -68,7 +68,9 @@ JOY_INVERT_Y = False JOY_DEADZONE = 9000 # Pendulum stepper (optional): a 4-input unipolar motor (e.g. ULN2003) swung in time with the beat. STEPPER_ENABLED = True # set False if no motor is wired (the pins just stay free) -STEPPER_ARC = 120 # half-steps for one end-to-end swing (= one beat). Tune to your arm's travel. +PEND_SWING_DEG = 120 # total swing arc, end-to-end, in degrees - drives BOTH the screen graphic and the arm +STEPPER_STEPS_PER_REV = 4096 # your motor's half-steps per full 360 turn (28BYJ-48 half-step ~4096); maps deg -> steps +STEPPER_ARC = round(STEPPER_STEPS_PER_REV * PEND_SWING_DEG / 360.0) # half-steps for one end-to-end swing STEPPER_MAX_RATE = 900 # max half-steps/sec the motor can follow; auto-shrinks the arc at fast tempi # ----- pins (fixed by the EP-0172 board) ----- @@ -168,7 +170,7 @@ MIN_LOG_SEC = 5 # don't log plays shorter t PEND_PX = WIDTH // 2 # pivot x (screen centre) PEND_PY = HEIGHT - 16 # pivot y (near the bottom edge) PEND_LEN = 140 # arm length (px) -PEND_THETA = 0.66 # half-swing angle in radians (~38 deg) +PEND_THETA = math.radians(PEND_SWING_DEG) / 2.0 # half-swing angle (radians), derived from PEND_SWING_DEG PAD_DIM = (0x10161E, 0x0A3A52, 0x4A3010, 0x2A1D4A) # idle pad: mute / normal / accent / ghost PAD_LIT = (0x39414D, 0x0AB3F7, 0xFF9B2E, 0x967BFF) # playhead pad: mute / normal / accent / ghost C_GRID = 0x1A2330 # faint vertical beat gridlines (beats line up across lanes)