Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Matrix style" and running text #1

Open
georg90 opened this issue Feb 17, 2015 · 6 comments
Open

"Matrix style" and running text #1

georg90 opened this issue Feb 17, 2015 · 6 comments

Comments

@georg90
Copy link

georg90 commented Feb 17, 2015

Any ideas on supporting a "Matrix" style (from the movies)?

I edited your code a little to be able to run without a DCF77, getting an ACK on remote commands and setting the time with the remote.
Also I like to get a Matrix style display and "running text".

I found this for Matrix style operation:

// Matrix Mode defines
#define MATRIX_MIN_LENGTH 3
#define MATRIX_UPDATE_INTERVAL 250
long int lastMillis = 0;
long int currentMillis;
word matrixBegin = 0;
short matrixLength = 99;

void showMatrix() {
   currentMillis = millis();
      if (currentMillis - lastMillis > MATRIX_UPDATE_INTERVAL) {
        lastMillis  = currentMillis;

        if(matrixLength >= MATRIX_MIN_LENGTH && random(1,100) > 60) {
          matrixBegin = random(0b0000000000000000, 0b1010011010100000);
          matrixBegin &= random(0b0000000000000000, 0b1010011010100000);
          matrixBegin &= 0b1111111111100000; // remove corner LEDs
          matrixLength = 0;
        }
        matrixLength++;
        // move old line 1 line down
        for(int i = 10; i >= 1; i--) {
          matrix[i] = matrix[i-1]; 
        }
        // set new top line
        matrix[0] = matrixBegin;
      }
      needsUpdateFromRtc = true;
      break;
}

Any idea how to edit this to fit the numbering with your setup?

If anybody is interested I can upload the code soon..

@bagges
Copy link
Owner

bagges commented Feb 17, 2015

I have some code for the "matrix" style on my hdd. I will search for it and commit it to an experimental branch.

@georg90
Copy link
Author

georg90 commented Feb 17, 2015

Sounds Great - I thought something like this has to be implemented already ;-)

@bagges
Copy link
Owner

bagges commented Feb 19, 2015

Here is the code I found on my hdd. I think this is not even finished but should be a good starting point. Unfortunately I do not have the time to integrate it :-/. If you add this feature, I would appreciate a pull request :-)

#include "FastLED.h"

#define NUM_LEDS 114
#define DATA_PIN 6
CRGB leds[NUM_LEDS] = {CRGB::Red};

void setup() { 
    FastLED.addLeds<WS2812B, DATA_PIN, GRB>(leds, NUM_LEDS);
    Serial.begin(9600);
}


uint8_t shiftInCols[11] = {0,0,0,5,0,0,0,3,0,0,8};
uint16_t matrixCols[11] = {0,0,0,0,0,0,0,0,0,0,0};

void refreshMatrix() {

    Serial.println("refresh()");


    for(char i=0; i<11; i++) {

        matrixCols[i] <<= 1;

        if(shiftInCols[i] > 0) {
            matrixCols[i] |= 1;
            shiftInCols[i]--;
        }
        else {

            if(random(0,6) == 0) {
                shiftInCols[i] = random(3,7);
                //matrixCols[i] |= 1;
            }
        }
    }
}


uint8_t posToNum(uint8_t col, uint8_t row) {

    uint8_t ret = 0;
    row = 9 - row;

    if((col & 1) != 0) {
        // gerade spalten
        ret += (9 - row);
    } else { 
        ret += row;
    }

    ret += (10*col);
    return ret;
} 


void prepareBuffer() {

    Serial.println("prepare()");

    for(char col=0; col<11; col++) {
        for(char row=0; row<10; row++) {

            const uint16_t mask = (1 << row);
            uint8_t num = posToNum(col, row);

            if(num >= NUM_LEDS) {
                num = 0;
            }
            if((matrixCols[col] & mask) != 0) {
                leds[num] = CRGB::Green;
            }
            else {
                leds[num] = CRGB::Black;
            }

        }
    }
}


void loop() { 
  Serial.println("loop");
  refreshMatrix();

  prepareBuffer();

  FastLED.show();
  delay(200);
}

@georg90
Copy link
Author

georg90 commented Feb 27, 2015

thanks for the snippet! I'll post my results once I get started

@georg90
Copy link
Author

georg90 commented Mar 7, 2015

this will work without customizing - just edit it to run into the main sketch and you're done.

@Macci0
Copy link

Macci0 commented Jun 20, 2016

Hi Georg,
i'm interested on your Code. Can you share it please? Thanks a lot for your Help.

I edited your code a little to be able to run without a DCF77, getting an ACK on remote commands and setting the time with the remote.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants