Fix offset tick labels: wrap indices with modulo, show LED 0 position
Some checks failed
Validate / validate (push) Failing after 8s

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-08 05:01:07 +03:00
parent c34f10f7de
commit 36ace0c563

View File

@@ -1197,6 +1197,8 @@ function renderCalibrationCanvas() {
const segments = buildSegments(calibration);
if (segments.length === 0) return;
const totalLeds = calibration.leds_top + calibration.leds_right + calibration.leds_bottom + calibration.leds_left;
// Edge bar geometry (matches CSS: corner zones 56px × 36px fixed)
const cw = 56;
const ch = 36;
@@ -1233,11 +1235,17 @@ function renderCalibrationCanvas() {
const count = seg.led_count;
if (count === 0) return;
// Show only first and last LED index per edge
// Show only first and last LED index per edge, plus LED 0 if offset > 0
const labelsToShow = new Set();
labelsToShow.add(0);
if (count > 1) labelsToShow.add(count - 1);
// Add LED 0 tick on the edge where it wraps
if (offset > 0 && totalLeds > 0) {
const zeroPos = (totalLeds - seg.led_start % totalLeds) % totalLeds;
if (zeroPos < count) labelsToShow.add(zeroPos);
}
// Tick styling
const tickLen = 5;
ctx.strokeStyle = 'rgba(255, 255, 255, 0.4)';
@@ -1248,7 +1256,7 @@ function renderCalibrationCanvas() {
labelsToShow.forEach(i => {
const fraction = count > 1 ? i / (count - 1) : 0.5;
const displayFraction = seg.reverse ? (1 - fraction) : fraction;
const ledIndex = seg.led_start + i;
const ledIndex = totalLeds > 0 ? (seg.led_start + i) % totalLeds : seg.led_start + i;
if (geo.horizontal) {
const tx = geo.x1 + displayFraction * (geo.x2 - geo.x1);