Adjustments for 2x1 Neopixel display

This commit is contained in:
Dejvino 2026-03-04 22:38:11 +01:00
parent 4e4ba0d0e4
commit 288a363618
3 changed files with 15 additions and 12 deletions

View File

@ -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<NUM_STEPS; s++) {
if (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);
}
}

View File

@ -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,

View File

@ -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