From a96f378c9c697606166bfa8ae6f731b10e400a6e Mon Sep 17 00:00:00 2001 From: Bas Grolleman Date: Sun, 24 May 2026 13:20:36 +0200 Subject: [PATCH] Add triple-tap lights-off and fix LED pin to D5 - Triple tap turns off LEDs; any subsequent tap or hold resumes the current show - Change LED_DATA_PIN default from 6 to 5 across config, docs, and wiring diagram - Fix Makefile upload to pass --input-dir so it uses the pre-built binary Co-Authored-By: Claude Sonnet 4.6 --- DETAILS.md | 9 +++++---- Makefile | 2 +- README.md | 12 +++++++----- arduino/cosplay_lights/config.h | 3 ++- arduino/cosplay_lights/cosplay_lights.ino | 6 ++++++ 5 files changed, 21 insertions(+), 11 deletions(-) diff --git a/DETAILS.md b/DETAILS.md index ff107fe..9cfe0d8 100644 --- a/DETAILS.md +++ b/DETAILS.md @@ -43,6 +43,7 @@ Button handling uses the [OneButton](https://github.com/mathertel/OneButton) lib - **Single tap** → next show - **Double tap** → previous show +- **Triple tap** → lights off; any subsequent tap or hold resumes the current show - **Long press** → reset to show 0 The key timing values (configured via `setClickMs` and `setPressMs`): @@ -104,12 +105,12 @@ Edit `config.h`: // WS2812B (default) #define LED_TYPE WS2812B #define COLOR_ORDER GRB -#define LED_DATA_PIN 6 +#define LED_DATA_PIN 5 // APA102 / Dotstar (two-wire) // #define LED_TYPE APA102 // #define COLOR_ORDER BGR -// #define LED_DATA_PIN 6 +// #define LED_DATA_PIN 5 // #define LED_CLOCK_PIN 7 ``` @@ -129,8 +130,8 @@ static CRGB leds_a[NUM_LEDS]; static CRGB leds_b[NUM_LEDS]; void leds_begin() { - FastLED.addLeds(leds_a, NUM_LEDS); - FastLED.addLeds(leds_b, NUM_LEDS); + FastLED.addLeds(leds_a, NUM_LEDS); + FastLED.addLeds(leds_b, NUM_LEDS); FastLED.setBrightness(MAX_BRIGHTNESS); FastLED.clear(true); } diff --git a/Makefile b/Makefile index 9134f22..3125d4f 100644 --- a/Makefile +++ b/Makefile @@ -44,7 +44,7 @@ upload: shows build echo ""; \ exit 1; \ fi - arduino-cli upload --fqbn $(FQBN) --port $(PORT) $(SKETCH) + arduino-cli upload --fqbn $(FQBN) --port $(PORT) --input-dir $(BUILD_DIR) $(SKETCH) @echo "" @echo " Uploaded to $(PORT). The show starts immediately." diff --git a/README.md b/README.md index 8f439e8..80920ab 100644 --- a/README.md +++ b/README.md @@ -26,10 +26,11 @@ SPDX-License-Identifier: BSD-2-Clause ### LED strip ``` -Arduino WS2812B strip -─────── ───────────── -GND ──────────────────── GND -D6 ──── [470Ω] ──────── DIN (data in) +Arduino WS2812B strip wire colors +─────── ────────────────────────── +5V ──────────────────── red (VCC) +GND ──────────────────── white (GND) +D5 ──── [470Ω] ──────── green (DIN — data in) ``` Power the strip separately — see the power warning below. @@ -51,6 +52,7 @@ Uses the internal pull-up resistor. No external resistor needed. Pin 2 can be ch |-------|--------| | 1 tap | Next show | | 2 taps | Previous show | +| 3 taps | Lights off (any tap or hold resumes) | | Hold (~0.8s) | Reset to show 0 (blue breath) | ### Power warning — read this @@ -80,7 +82,7 @@ Arduino IDE: **Sketch → Include Library → Manage Libraries**, then install b ### 2. Configure your hardware Edit `arduino/cosplay_lights/config.h`: -- `LED_DATA_PIN` — pin connected to the strip's DIN (default: 6) +- `LED_DATA_PIN` — pin connected to the strip's DIN (default: 5) - `BUTTON_PIN` — pin the button is wired to (default: 2) - `NUM_LEDS` — total LED count on your strip (default: 60) - `MAX_BRIGHTNESS` — global brightness cap (default: 150) diff --git a/arduino/cosplay_lights/config.h b/arduino/cosplay_lights/config.h index 4a30058..40a26cc 100644 --- a/arduino/cosplay_lights/config.h +++ b/arduino/cosplay_lights/config.h @@ -18,7 +18,7 @@ // -- Wiring -------------------------------------------------- // Pin on the Arduino connected to the strip's DIN (data-in). -#define LED_DATA_PIN 6 +#define LED_DATA_PIN 5 // Clock pin — only needed for APA102/SK9822 strips. // #define LED_CLOCK_PIN 7 @@ -37,6 +37,7 @@ // Uses INPUT_PULLUP — no external resistor needed. // 1 tap → next show // 2 taps → previous show +// 3 taps → lights off (any tap/hold resumes) // hold → reset to show 0 (blue breath) #define BUTTON_PIN 2 diff --git a/arduino/cosplay_lights/cosplay_lights.ino b/arduino/cosplay_lights/cosplay_lights.ino index 6235a69..7993a79 100644 --- a/arduino/cosplay_lights/cosplay_lights.ino +++ b/arduino/cosplay_lights/cosplay_lights.ino @@ -5,6 +5,7 @@ * A single button navigates between shows: * 1 tap — next show * 2 taps — previous show + * 3 taps — lights off (any tap or hold resumes) * hold — reset to show 0 (blue breath) * * To add or update shows: @@ -28,8 +29,10 @@ static ShowDef s_show; // PROGMEM cache for the active sh static uint16_t s_step_index = 0; static uint32_t s_step_start = 0; static CRGB s_from_color = CRGB::Black; +static bool s_lights_off = false; static void load_show(uint8_t index) { + s_lights_off = false; s_show_index = index; s_show = read_show_def(&SHOWS[index]); s_step_index = 0; @@ -76,6 +79,7 @@ void setup() { s_button.setPressMs(800); s_button.attachClick([]() { load_show((s_show_index + 1) % SHOW_COUNT); }); s_button.attachDoubleClick([]() { load_show((s_show_index + SHOW_COUNT - 1) % SHOW_COUNT); }); + s_button.attachMultiClick([]() { if (s_button.getNumberClicks() == 3) { s_lights_off = true; leds_apply_color(CRGB::Black); leds_show(); } }); s_button.attachLongPressStart([]() { load_show(0); }); } @@ -87,6 +91,8 @@ void loop() { if (now - s_last_frame < 16) return; s_last_frame = now; + if (s_lights_off) return; + Step step = read_step(&s_show.steps[s_step_index]); CRGB to = CRGB(step.r, step.g, step.b); uint8_t t8 = step_progress(step, now);