From 288a363618e832e03a27a46bd0bd9424e79f1f41 Mon Sep 17 00:00:00 2001 From: Dejvino Date: Wed, 4 Mar 2026 22:38:11 +0100 Subject: [PATCH] Adjustments for 2x1 Neopixel display --- UIManager.cpp | 24 ++++++++++++++---------- UIManager.h | 1 - config.h | 2 +- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/UIManager.cpp b/UIManager.cpp index e446554..ffeaacb 100644 --- a/UIManager.cpp +++ b/UIManager.cpp @@ -7,8 +7,10 @@ #define SCREEN_HEIGHT 64 #define OLED_RESET -1 #define SCREEN_ADDRESS 0x3C -#define PIN_NEOPIXEL 2 -#define NUM_PIXELS 64 +#define PIN_NEOPIXEL 6 +#define NEOPIXELS_X 16 +#define NEOPIXELS_Y 8 +#define NUM_PIXELS 64*2 // 8x8 LEDs in 2 panels UIManager ui; @@ -332,7 +334,9 @@ uint32_t UIManager::getNoteColor(int note, bool dim) { } int UIManager::getPixelIndex(int x, int y) { - return y * 8 + x; + // [i] Here you can adjust the mapping from "logical" pixel coordinates + // to your physical NeoPixel layout. It depends on how you connected it. + return NEOPIXELS_Y * x + (NEOPIXELS_Y - 1 - y); } void UIManager::updateLeds(const Step sequence[][NUM_STEPS], int playbackStep, bool isPlaying, @@ -352,8 +356,8 @@ void UIManager::updateLeds(const Step sequence[][NUM_STEPS], int playbackStep, b for(int s=0; s= numSteps) continue; - int row = t * 2 + (s / 8); - int col = s % 8; + int row = t * 2 + (s / NUM_STEPS); + int col = s % NUM_STEPS; uint32_t color = 0; int note = sequence[t][s].note; @@ -379,8 +383,8 @@ void UIManager::updateLeds(const Step sequence[][NUM_STEPS], int playbackStep, b for (int s = 0; s < NUM_STEPS; s++) { if (s >= numSteps) continue; - int x = s % 8; - int yBase = (s / 8) * 4; + int x = s % NUM_STEPS; + int yBase = (s / NUM_STEPS) * 2; uint32_t color = 0, dimColor = 0; bool isCursorHere = (isPlaying && s == playbackStep); if (trackSequence[s].note != -1) { @@ -397,9 +401,9 @@ void UIManager::updateLeds(const Step sequence[][NUM_STEPS], int playbackStep, b uint32_t cursorColor = pixels.Color(0, 0, 50); if (isPlaying) { cursorColor = pixels.Color(0, 50, 0); - if (songModeEnabled && s >= 8) { - int repeats = min(songRepeatsRemaining, 8); - if (x >= (8 - repeats)) cursorColor = (songRepeatsRemaining == 1 && x == 7 && (millis()/250)%2) ? pixels.Color(255, 200, 0) : pixels.Color(100, 220, 40); + if (songModeEnabled && s >= NUM_STEPS) { + int repeats = min(songRepeatsRemaining, NUM_STEPS); + if (x >= (NUM_STEPS - repeats)) cursorColor = (songRepeatsRemaining == 1 && x == 7 && (millis()/250)%2) ? pixels.Color(255, 200, 0) : pixels.Color(100, 220, 40); } } diff --git a/UIManager.h b/UIManager.h index f6643d1..f1fa112 100644 --- a/UIManager.h +++ b/UIManager.h @@ -30,7 +30,6 @@ public: private: Adafruit_SSD1306 display; Adafruit_NeoPixel pixels; - uint32_t leds_buffer[8][8]; // For piano roll void drawMenu(int selection, UIState currentState, int midiChannel, int tempo, const char* flavourName, int queuedTheme, int currentThemeIndex, diff --git a/config.h b/config.h index 5c091ae..3112d4e 100644 --- a/config.h +++ b/config.h @@ -16,7 +16,7 @@ #define ENC_SW 14 // --- TRACKER DATA --- -#define NUM_STEPS 8 +#define NUM_STEPS 16 #define NUM_TRACKS 4 #define MIDI_DEBUG