Adjustments for 2x1 Neopixel display
This commit is contained in:
parent
4e4ba0d0e4
commit
288a363618
@ -7,8 +7,10 @@
|
|||||||
#define SCREEN_HEIGHT 64
|
#define SCREEN_HEIGHT 64
|
||||||
#define OLED_RESET -1
|
#define OLED_RESET -1
|
||||||
#define SCREEN_ADDRESS 0x3C
|
#define SCREEN_ADDRESS 0x3C
|
||||||
#define PIN_NEOPIXEL 2
|
#define PIN_NEOPIXEL 6
|
||||||
#define NUM_PIXELS 64
|
#define NEOPIXELS_X 16
|
||||||
|
#define NEOPIXELS_Y 8
|
||||||
|
#define NUM_PIXELS 64*2 // 8x8 LEDs in 2 panels
|
||||||
|
|
||||||
UIManager ui;
|
UIManager ui;
|
||||||
|
|
||||||
@ -332,7 +334,9 @@ uint32_t UIManager::getNoteColor(int note, bool dim) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int UIManager::getPixelIndex(int x, int y) {
|
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,
|
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++) {
|
for(int s=0; s<NUM_STEPS; s++) {
|
||||||
if (s >= numSteps) continue;
|
if (s >= numSteps) continue;
|
||||||
|
|
||||||
int row = t * 2 + (s / 8);
|
int row = t * 2 + (s / NUM_STEPS);
|
||||||
int col = s % 8;
|
int col = s % NUM_STEPS;
|
||||||
|
|
||||||
uint32_t color = 0;
|
uint32_t color = 0;
|
||||||
int note = sequence[t][s].note;
|
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++) {
|
for (int s = 0; s < NUM_STEPS; s++) {
|
||||||
if (s >= numSteps) continue;
|
if (s >= numSteps) continue;
|
||||||
|
|
||||||
int x = s % 8;
|
int x = s % NUM_STEPS;
|
||||||
int yBase = (s / 8) * 4;
|
int yBase = (s / NUM_STEPS) * 2;
|
||||||
uint32_t color = 0, dimColor = 0;
|
uint32_t color = 0, dimColor = 0;
|
||||||
bool isCursorHere = (isPlaying && s == playbackStep);
|
bool isCursorHere = (isPlaying && s == playbackStep);
|
||||||
if (trackSequence[s].note != -1) {
|
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);
|
uint32_t cursorColor = pixels.Color(0, 0, 50);
|
||||||
if (isPlaying) {
|
if (isPlaying) {
|
||||||
cursorColor = pixels.Color(0, 50, 0);
|
cursorColor = pixels.Color(0, 50, 0);
|
||||||
if (songModeEnabled && s >= 8) {
|
if (songModeEnabled && s >= NUM_STEPS) {
|
||||||
int repeats = min(songRepeatsRemaining, 8);
|
int repeats = min(songRepeatsRemaining, NUM_STEPS);
|
||||||
if (x >= (8 - repeats)) cursorColor = (songRepeatsRemaining == 1 && x == 7 && (millis()/250)%2) ? pixels.Color(255, 200, 0) : pixels.Color(100, 220, 40);
|
if (x >= (NUM_STEPS - repeats)) cursorColor = (songRepeatsRemaining == 1 && x == 7 && (millis()/250)%2) ? pixels.Color(255, 200, 0) : pixels.Color(100, 220, 40);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -30,7 +30,6 @@ public:
|
|||||||
private:
|
private:
|
||||||
Adafruit_SSD1306 display;
|
Adafruit_SSD1306 display;
|
||||||
Adafruit_NeoPixel pixels;
|
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,
|
void drawMenu(int selection, UIState currentState, int midiChannel, int tempo, const char* flavourName,
|
||||||
int queuedTheme, int currentThemeIndex,
|
int queuedTheme, int currentThemeIndex,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user