elpaso 15 Posted August 28, 2013 Share Posted August 28, 2013 A quick port to Energia of the famous LedControl library for Arduino. Download: https://github.com/elpaso/ledcontrol-energia Original library: http://playground.arduino.cc/Main/LedControl Enjoy! energia and bluehash 2 Quote Link to post Share on other sites
elpaso 15 Posted August 28, 2013 Author Share Posted August 28, 2013 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: Energia LedControl di apasotti, su Flickr 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); } Quote Link to post Share on other sites
bluehash 1,581 Posted August 28, 2013 Share Posted August 28, 2013 @@elpaso Thank you for sharing! Quote Link to post Share on other sites
energia 485 Posted August 29, 2013 Share Posted August 29, 2013 Thanks for sharing! What were the changes you had to make? Quote Link to post Share on other sites
elpaso 15 Posted August 29, 2013 Author Share Posted August 29, 2013 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. Quote Link to post Share on other sites
energia 485 Posted August 30, 2013 Share Posted August 30, 2013 We ran across this issue a while back. I will have to look into this. Quote Link to post Share on other sites
Amalinda 0 Posted September 12, 2013 Share Posted September 12, 2013 are these libraries compatible with CCS? Quote Link to post Share on other sites
elpaso 15 Posted September 12, 2013 Author Share Posted September 12, 2013 are these libraries compatible with CCS? No idea sorry, I only use free software. Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.