I attempted to define a matrix across a neopixel 4 digit 7-segment display I made and then made a demo to basically scroll a horizontal then vertical line across the matrix as a test. It sort of works in that I see pixels lighting up left to right then top to bottom but they aren't in a perfect line. Am I doing anything obvious wrong? I triple checked my remap function and didn't see any errors.
Here is a video showing my PCB and what I'm seeing: https://imgur.com/a/d6oy3uL
The code that produces that is below, any thought on what might be happening?
#include <Adafruit_GFX.h>
#include <FastLED_NeoMatrix.h>
#include <FastLED.h>
#define PIN 18
#define BRIGHTNESS 10
#define mw 25
#define mh 9
#define NUMMATRIX (mw*mh)
CRGB leds[NUMMATRIX];
// Define matrix width and height.
FastLED_NeoMatrix *matrix = new FastLED_NeoMatrix(leds, mw, mh,
NEO_MATRIX_TOP + NEO_MATRIX_LEFT +
NEO_MATRIX_ROWS + NEO_MATRIX_PROGRESSIVE);
// This could also be defined as matrix->color(255,0,0) but those defines
// are meant to work for adafruit_gfx backends that are lacking color()
#define LED_BLACK 0
#define LED_RED_VERYLOW (3 << 11)
#define LED_RED_LOW (7 << 11)
#define LED_RED_MEDIUM (15 << 11)
#define LED_RED_HIGH (31 << 11)
#define LED_GREEN_VERYLOW (1 << 5)
#define LED_GREEN_LOW (15 << 5)
#define LED_GREEN_MEDIUM (31 << 5)
#define LED_GREEN_HIGH (63 << 5)
// .0 .1 .2 .3 .4 .5 .6 .7 .8 .9 10 11.12 13 14 15 16 17 18 19 20 21 22 23 24
// 0 .. .1 .2 .3 .. .. .. 22 23 24 .. .. .. .. .. 43 44 45 .. .. .. 64 65 66 ..
// 1 18 .. .. .. .4 .. 39 .. .. .. 25 .. .. .. 60 .. .. .. 46 .. 81 .. .. .. 67
// 2 17 .. .. .. .5 .. 38 .. .. .. 26 .. 85 .. 59 .. .. .. 47 .. 80 .. .. .. 68
// 3 16 .. .. .. .6 .. 37 .. .. .. 27 .. .. .. 58 .. .. .. 48 .. 79 .. .. .. 69
// 4 .. 19 20 21 .. .. .. 40 41 42 .. .. .. .. .. 61 62 63 .. .. .. 82 83 84 ..
// 5 15 .. .. .. .7 .. 36 .. .. .. 28 .. .. .. 57 .. .. .. 49 .. 78 .. .. .. 70
// 6 14 .. .. .. .8 .. 35 .. .. .. 29 .. 86 .. 56 .. .. .. 50 .. 77 .. .. .. 71
// 7 13 .. .. .. .9 .. 34 .. .. .. 30 .. .. .. 55 .. .. .. 51 .. 76 .. .. .. 72
// 8 .. 12 11 10 .. .. .. 33 32 31 .. .. .. .. .. 54 53 52 .. .. .. 75 74 73 ..
uint16_t myRemapFn(uint16_t x, uint16_t y) {
switch(y){
case 0:
switch(x){
case 1: return 1;
case 2: return 2;
case 3: return 3;
case 7: return 22;
case 8: return 23;
case 9: return 24;
case 15: return 43;
case 16: return 44;
case 17: return 45;
case 21: return 64;
case 22: return 65;
case 23: return 66;
default: return 87;
}
case 1:
switch(x){
case 0: return 18;
case 4: return 4;
case 6: return 39;
case 10: return 25;
case 14: return 60;
case 18: return 46;
case 20: return 81;
case 24: return 67;
default: return 87;
}
case 2:
switch(x){
case 0: return 17;
case 4: return 5;
case 6: return 38;
case 10: return 26;
case 12: return 85;
case 14: return 59;
case 18: return 47;
case 20: return 80;
case 24: return 68;
default: return 87;
}
case 3:
switch(x){
case 0: return 16;
case 4: return 6;
case 6: return 37;
case 10: return 27;
case 14: return 58;
case 18: return 48;
case 20: return 79;
case 24: return 69;
default: return 87;
}
case 4:
switch(x){
case 1: return 19;
case 2: return 20;
case 3: return 21;
case 7: return 40;
case 8: return 41;
case 9: return 42;
case 15: return 61;
case 16: return 62;
case 17: return 63;
case 21: return 82;
case 22: return 83;
case 23: return 84;
default: return 87;
}
case 5:
switch(x){
case 0: return 15;
case 4: return 7;
case 6: return 36;
case 10: return 28;
case 14: return 57;
case 18: return 49;
case 20: return 78;
case 24: return 70;
default: return 87;
}
case 6:
switch(x){
case 0: return 14;
case 4: return 8;
case 6: return 35;
case 10: return 29;
case 12: return 86;
case 14: return 56;
case 18: return 50;
case 20: return 77;
case 24: return 71;
default: return 87;
}
case 7:
switch(x){
case 0: return 13;
case 4: return 9;
case 6: return 34;
case 10: return 30;
case 14: return 55;
case 18: return 51;
case 20: return 76;
case 24: return 72;
default: return 87;
}
case 8:
switch(x){
case 1: return 12;
case 2: return 11;
case 3: return 10;
case 7: return 33;
case 8: return 32;
case 9: return 31;
case 15: return 54;
case 16: return 53;
case 17: return 52;
case 21: return 75;
case 22: return 74;
case 23: return 73;
default: return 87;
}
}
}
void scrolling_line(){
for (uint8_t i = 0;i<mw;i++){
matrix->clear();
matrix->drawLine(i,0,i,mh,LED_RED_HIGH);
matrix->show();
delay(500);
}
for (uint8_t i = 0;i<mh;i++){
matrix->clear();
matrix->drawLine(0,i,mw,i,LED_GREEN_HIGH);
matrix->show();
delay(500);
}
}
void setup() {
// put your setup code here, to run once:
// Time for serial port to work?
delay(1000);
Serial.begin(115200);
Serial.print("Init on pin: ");
Serial.println(PIN);
Serial.print("Matrix Size: ");
Serial.print(mw);
Serial.print(" ");
Serial.print(mh);
Serial.print(" ");
Serial.println(NUMMATRIX);
FastLED.addLeds<NEOPIXEL,PIN>( leds, NUMMATRIX ).setCorrection(TypicalLEDStrip);
Serial.print("Setup serial: ");
Serial.println(NUMMATRIX);
matrix->begin();
matrix->setTextWrap(false);
matrix->setBrightness(BRIGHTNESS);
matrix->setRemapFunction(myRemapFn);
}
void loop() {
// put your main code here, to run repeatedly:
scrolling_line();
}
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4