Jump to content

Recommended Posts

I admit I've been reading the library posting instructions after posting the library, some more details:

 

I tested the library only on my LP with 2553 and I did not test a 7-segments but only the 8x8 matrix.

 

Here is a picture of the running library:

 

9616341704_42e554e322_n.jpg

 

 

The example code:

/**
* Led Matrix test
*/


#include <LedControl.h>

#define DATA_PIN    P1_3        // data for AS1106
#define CLOCK_PIN   P1_4        // clock for AS1106
#define LOAD_PIN    P1_5        // load CS for AS1106

// LedControl(int dataPin, int clkPin, int csPin, int numDevices=1);
LedControl lc=LedControl(DATA_PIN, CLOCK_PIN, LOAD_PIN, 1);

unsigned long delaytime=100;


void setup() {

  pinMode(RED_LED,OUTPUT);
  pinMode(DATA_PIN,OUTPUT);
  pinMode(CLOCK_PIN,OUTPUT);
  pinMode(LOAD_PIN,OUTPUT);
  digitalWrite(LOAD_PIN,HIGH);
  digitalWrite(RED_LED, HIGH);
  delay(1000);
  digitalWrite(RED_LED, LOW);

  lc.init();
  lc.shutdown(0,false);
  lc.setIntensity(0,10);
  lc.clearDisplay(0);

}

void loop() {
  
  digitalWrite(RED_LED, HIGH);
  lc.clearDisplay(0);
  for (int r=0; r<8; r++){
    for (int c=0; c<8; c++){
        lc.setLed(0,r,c,true);
        delay(100);
    }
  }
  digitalWrite(RED_LED, LOW);
  lc.clearDisplay(0);
  lc.setColumn(0, 1, B01010101);
        delay(1000);
  lc.setColumn(0, 3, B01010101);
        delay(1000);
  lc.setRow(0, 1, B01010101);
        delay(1000);
  lc.setRow(0, 3, B01010101);
        delay(1000);

  delay(10);
  
}

Share this post


Link to post
Share on other sites

Thanks for sharing! What were the changes you had to make?

 

 

Even if it took me a few hours before I saw the light (from the matrix, I mean), the changes at the end were trivial.

 

The original library, does the AS110* MAX72* initialization in the class constructor, this happens before the setup function starts.

 

to make this library compatible with LP I had to move the chip initialization to a separate "init" function that you now have to call from "setup":

 

Original library code:


// Chip initialization happens in the constructor
LedControl lc=LedControl(DATA_PIN, CLOCK_PIN, LOAD_PIN, 1);

void setup() {

  lc.shutdown(0,false);
  lc.setIntensity(0,10);
  lc.clearDisplay(0);

}

MSP430 compatible code:

?LedControl lc=LedControl(DATA_PIN, CLOCK_PIN, LOAD_PIN, 1);

void setup() {
  // This is now mandatory, chip initialization happens here:
  lc.init();
  lc.shutdown(0,false);
  lc.setIntensity(0,10);
  lc.clearDisplay(0);

}

I  did not have time to dig into the Energia code and I don't know why it happens, I suspect that the MSP430 initialization is done just before setup function call, whatever you do in the class constructor is lost/overwritten by that initialization code.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×