Open billbrach opened 3 months ago
FOUND THE PROBLEM !! Something in these 3 lines screws things up. I commented them out and it works correctly.
FastLED.setDither(false); FastLED.setCorrection(TypicalLEDStrip); FastLED.setMaxPowerInVoltsAndMilliamps(5, MILLI_AMPS);
Please CLOSE this issue.
I have taken your "7-Segment-Clock.ino" sketch and gutted out everything not necessary to display a number on a 5 X 5 LED matrix. I built 25 bit long numbers, to match the layout of the 5 X 5 LED matrix I bought off of Aliexpress. The problem is I cannot change the color in the displayNumber() routine. In the middle of loop(), try changing the CRGB colr line to something w/o Red. You don't necessarily need a 5 X 5 matrix to test this, any WS2812B strip should work, it just won't display the numbers correctly.
I think the problem is in this line, which I don't fully understand: LEDs[i + startindex] = ((numbers[number] & 1 << i) == 1 << i) ? color : alternateColor;
Hopefully it is just a stupid mistake on my part !! THANKS !!
Here is my code:
// CODE START // Demo code for a 5 X 5 WS2812B matrix, purchased from Aliexpress
// Based on the code here: https://github.com/leonvandenbeukel/7-Segment-Digital-Clock-V2/tree/master/7-Segment-Clock // but with all non-essential code removed so as to have demo code that only displays the digits 0 thru 9 on a 5x5 matrix
// 5X5 LED matrix from Aliexpress /* "as the ox plows" coded rows and columns
include
include
define NUM_LEDS 25 // 86 // Total of 86 LED's
define DATA_PIN D6 // Change this if you are using another type of ESP board than a WeMos D1 Mini
define MILLI_AMPS 1000 //2400
CRGB LEDs[NUM_LEDS];
define NUM_CLRS 5
uint32_t color[] = {CRGB::Red, CRGB::Green, CRGB::Blue, CRGB::Orange, CRGB::White};
// Settings byte brightness = 1; // 0 to 255 CRGB alternateColor = CRGB::Black;
/* For this sketch, the segments are ordered as so. 3 WS2812 LED's per segment in SEQUENTIAL ORDER - wjb
// Each of these long's are 21 bits long. 3 LED's per segment times 7 segments = 21 // They also are written backwards, meaning the 1st segment is the last 3 bits in the long. // Looking at the ZERO will confirm this, with seg 7, the center segment, being all zeros //long numbers[] = { // 0b000111111111111111111, // [0] 0 // 0b000111000000000000111, // [1] 1 // 0b111111111000111111000, // [2] 2 // 0b111111111000000111111, // [3] 3 // 0b111111000111000000111, // [4] 4 // 0b111000111111000111111, // [5] 5 // 0b111000111111111111111, // [6] 6 // 0b000111111000000000111, // [7] 7 // 0b111111111111111111111, // [8] 8 // 0b111111111111000111111, // [9] 9 // 0b000000000000000000000, // [10] off // 0b111111111111000000000, // [11] degrees symbol // 0b000000111111111111000, // [12] C(elsius) // 0b111000111111111000000, // [13] F(ahrenheit) //};
// I built this array for the numbers 0 to 9, using 25 bit longs, for the 5X5 matrix arrays I bought off Aliexpress - wjb // 2222221111111111 // 5432109876543210987654321 long numbers[] = { 0b0000011111100011000111111, // [0] 0 0b0000000001111111000100000, // [1] 1 0b0000011101101011010111101, // [2] 2 0b0000011111101011010110101, // [3] 3 0b0000011111001000010000111, // [4] 4 0b0000010111101011010110111, // [5] 5 0b0000000111101001010111111, // [6] 6 0b0000011111000011000000011, // [7] 7 0b0000011111101011010111111, // [0] 8 0b0000011111001011010000111 // [9] 9 };
int td = 1000; // time delay
void setup() { Serial.begin(115200); Serial.println(); Serial.println(); Serial.println(FILE); // show sketch name in the Serial Monitor.
FastLED.addLeds<WS2812B, DATA_PIN, GRB>(LEDs, NUM_LEDS); // GRB order on the LED's is typical for WS2812B LED's FastLED.setDither(false); FastLED.setCorrection(TypicalLEDStrip); FastLED.setMaxPowerInVoltsAndMilliamps(5, MILLI_AMPS); fill_solid(LEDs, NUM_LEDS, CRGB::Black); // turn off all LED's FastLED.show(); }
void loop() {
// loop thru all the numbers defined in the array for (int i = 0; i <= 9; i++) {
} }
void displayNumber(byte number, byte segment, CRGB color) { /*
12 13 14
11 15 10 16 42 __ _9 17 20 19 18
65 44 43 21 _8 _0 _7 _1 _6 _2 __ _5 _4 _3
*/
// FIX NEEDED HERE - to correct for the actual # of LED's per segment, as opposed to just 21 - wjb // segment from left to right: 3, 2, 1, 0 byte startindex = 0; switch (segment) { case 0: startindex = 0; break; case 1: startindex = 21; break; case 2: startindex = 44; break; case 3: startindex = 65; break;
}
//for (byte i=0; i<21; i++){ for (byte i=0; i<NUM_LEDS; i++) {
yield(); LEDs[i + startindex] = ((numbers[number] & 1 << i) == 1 << i) ? color : alternateColor; } } // CODE END