Home › Evil Mad Scientist Forums › LED Matrix Kits › Peggy 2 Code help
- This topic has 4 replies, 2 voices, and was last updated 10 years, 5 months ago by Windell Oskay.
-
AuthorPosts
-
August 2, 2014 at 10:22 am #20383rcj10Participant
I am working on a project to display server data to a Peggy 2.1 I have. I have python code on the servers collecting data and telnetting to a cc3000 shield running on a Uno that then will eventually I2C the values to the display. I am getting stuck on the display. This is at generating changing char strings to update the display. Right now to simplify things they are static and I am just jumping from one to another. it will run for five minutes then crash. If I reduce the update time it will crash in less time. This tells me I have some sort of overrun error after so many updated frames. Any advise would be gladly be accepted. Thanks,
rick/* Simple example code for Peggy 2.0, using the Peggy2 and PeggyWriter libraries*/#include <Peggy2.h>#include <PeggyWriter.h>Peggy2 frame1; // Make a frame buffer object, called frame1PeggyWriter myWriter1; // Make a PeggyWriter objectPeggyWriter myWriter2; // Make a PeggyWriter objectPeggyWriter myWriter3; // Make a PeggyWriter objectPeggyScroller comp1; // Make a PeggyScroller objectPeggyScroller comp2;PeggyScroller comp3;char scrollerSelect = 1;char* data1 = ” TEST 1 “;char* data2 = ” TEST 2 “;char* data3 = ” TEST 3 “;int j = 0;char mF1;char mF2;char mF3;int k = 0;int l = 0;String s1, s2, s3;void setup(){frame1.HardwareInit();comp2.init(&frame1, &myWriter1, 7, data2);comp3.init(&frame1, &myWriter2, 14, data3);comp1.init(&frame1, &myWriter3, 1, data1);}void loop(){long delayCount = 0;mF1 = comp1.scrollLeft();mF2 = comp2.scrollLeft();mF3 = comp3.scrollLeft();// Refresh Peggy lots of times while we kill time.// switch messages if one has completed.if (mF1 == 0){data1 = ” COMP 1 ? “;comp1.init(&frame1, &myWriter1, 1, data1);}if (mF2 == 0){data2 = ” COMP 2 ? “;comp2.init(&frame1, &myWriter2, 7, data2);}if (mF3 == 0){data3 = ” COMP 3 ? “;comp3.init(&frame1, &myWriter3, 14, data3);}while (delayCount < 150){frame1.RefreshAll(1);delayMicroseconds(50);delayCount++;}delayCount = 0;}- This topic was modified 6 years, 8 months ago by Windell Oskay.
August 2, 2014 at 5:07 pm #21945Windell OskayKeymasterCan you please say exactly what is is that is “crashing” and by what mechanism? I wouldn’t expect either an Uno or a Peggy 2 to be able to “crash,” so I’m a bit confused.
Separately, the “PeggyWriter” is a useful example, but it *is* a user-contributed example that we do not have much experience using. In a quick look, it appears that the example codes for PeggyWriter use a single instance of PeggyWriter, but multiple instances of PeggyScroller. You might consider trying that approach, to see if it works better.August 23, 2014 at 11:03 pm #21946rcj10ParticipantSorry for not getting back to you quicker. I was having password issues.
The display will stop scrolling. The display will drop the frame rate to half or more.I am guessing the ram is filling up?August 23, 2014 at 11:13 pm #21947rcj10ParticipantWhen trying the one Writer approach it seems to last longer:
/* Simple example code for Peggy 2.0, using the Peggy2 and PeggyWriter libraries*/#include <Peggy2.h>#include <PeggyWriter.h>Peggy2 frame1; // Make a frame buffer object, called frame1PeggyWriter myWriter1; // Make a PeggyWriter objectPeggyScroller comp1; // Make a PeggyScroller objectPeggyScroller comp2;PeggyScroller comp3;char scrollerSelect = 1;char* data1= ” TEST 1 “;char* data2 = ” TEST 2 “;char* data3 = ” TEST 3 “;int delayCount = 0;int j = 0;char mF1;char mF2;int n = 0;char mF3;int a=1; //declaring integerchar b[2]; //declaring character arrayString str; //declaring string//int k = 0;//int l = 0;//String s1, s2, s3;void setup(){frame1.HardwareInit();comp2.init(&frame1, &myWriter1, 7, data2);comp3.init(&frame1, &myWriter1, 14, data3);comp1.init(&frame1, &myWriter1, 1, data1);}void loop(){long delayCount = 0;mF1 = comp1.scrollLeft();mF2 = comp2.scrollLeft();mF3 = comp3.scrollLeft();// Refresh Peggy lots of times while we kill time.// switch messages if one has completed.if (mF1 == 0){n=n+1;//str=String(n); //converting integer into a string//str.toCharArray(data1,1); //passing the value of the string to the character arraydata1 = ” Comp 1 ? “;comp1.init(&frame1, &myWriter1, 1, data1);}if (mF2 == 0){data2 = ” COMP 2 ? “;comp2.init(&frame1, &myWriter1, 7, data2);}if (mF3 == 0){data3 = ” COMP 3 ? “;comp3.init(&frame1, &myWriter1, 14, data3);}while (delayCount < 50){frame1.RefreshAll(1);delayMicroseconds(10);delayCount++;}delayCount = 0;}August 25, 2014 at 12:21 pm #21948Windell OskayKeymasterIt looks like using the “init” command multiple times may be the issue. It allocates new memory each time that it is called, with malloc.
That shouldn’t be an issue (and isn’t unless called in a loop!), but there doesn’t appear to be any process for freeing up the memory that is allocated. You might be able to add a command to free up the memory: http://www.gnu.org/software/libc/manual/html_node/Freeing-after-Malloc.html -
AuthorPosts
- You must be logged in to reply to this topic.