what is the best way to clear the matrix, so that I can print new data on top, without going to a flicker inducing
matrix.fillScreen(0);
?
my code is:
RGBmatrixPanel matrix(A, B, C, CLK, LAT, OE, false);
void setup() {
Time.zone(0);
matrix.begin();
matrix.setTextSize(1); // size 1 == 8 pixels high
// print each letter with a rainbow color
matrix.setTextColor(matrix.Color333(7,0,0));
}
void loop() {
int sec=Time.second();
int min=Time.minute();
int hour=Time.hour();
matrix.setCursor(1, 0); // start at top left, with one pixel of spacin
matrix.print(hour);
matrix.print(":");
matrix.print(min);
matrix.setCursor(8,8);
matrix.print(sec);
matrix.swapBuffers(false);
}
@Julian, @ScruffR is dead on (as usual) regarding the fonts. As for the fillscreen, that is the correct way to reset the screen prior to painting. So in loop(), do a matrix.fillscreen(0) then draw everything you need drawn with the ābottomā layer being the first to draw and so on. Each successive draws will overwrite parts of the previous draws. When youāve drawn everthing, you do the swapBuffers(false) to redraw the screen in its entirety.
And in addition to @peekay123 's tips you may also use double buffering by doing this
RGBmatrixPanel matrix(A, B, C, CLK, LAT, OE, true); // instead of false
This way you do the drawing off āscreenā and only make the new screen visible, once you are done by swapping buffers - as Paul said.
To be able to do double buffering you need enough RAM to store both displays. The Core has usually enough for two 16x32 or one 32x32 panel, unless you do have other code concurently demanding big chunks of RAM too.
As for fillScreen() there are some colors that can be used way faster than others. At the moment Paul only allows the fast memset() approach for black and white, but there are a few other colors possible too.
Actually any color where the low byte sattisfies these criteria:
Plane 0 bits (0 & 1) have to be 0b00 or 0b11
Bits 2, 3 & 4 have to match bits 5, 6 & 7
e.g. 0b10110100 is a valid āmemsetableā color.
The resulting colors may not resemble the color you have in mind when passing in an int color, but an overload for fillScreen that takes an enumed (named) color this might become useful.
At the moment Iām looking if there is a way to speed up fillScreen for any color (e.g. via ASM stosb or something similar).
Thanks for the reminder, @peekay123.
Itās just that I got the impression, that you are the one who has the best insight of the ins and outs of this library.
@ScruffR, I have to agree with you there we are lucky to have @peekay123 and others to help.
I have solved the flicker ( by just doing what you said). my false is now true (in the initial statement / matrix declaration ) and my final swapbuffer is false.
@Julian, @ScruffR you make me blush Truth is, myself and the other Elites do this because of the great members we have in this community. However I end up helping, all I ask is that members pay it forward
@peekay123, @ScruffR, I am just thinking of how I can use my display and to connect up a sensor I seem to be running out of pins. As a way to get round this is there a way to use spark publish to publish a variable, say temperature, from one core and then for another core to ācollectā that variable and display it on the LED matrix?
@Julian, sure you can use Spark.publish() as @peekay123 has pointed out, but may I also ask what sensors youād like to use and how many more pins youād be needing for your idea?
As for my setup I still got D0, D1, A0, A1 and A7 free to use, so I2C sensors or Serial2and three analog inputs would still be possible.
And if required some already used pins could be shifted about.
@ScruffR, in the āfastā version of the library, I have A4 (for 16x32 matrix only) A5, A7, D5, D6 and D7 available. I guess you reworked the whole-port I/O to other pins? I like that you free up the I2C bus so if you feel itās just as fast, it would be great if you did a pull request!
Iāll try to push it to my repo and file a PR on yours, but Iām an utter failure with GitHub. I can just do the minimum and donāt even know if Iām doing it right
Iām pretty certain āmy wayā is at least as quick as yours (although I havenāt measured/proven it - I hope not to be wrong ) and on the 16x32 panel Iād also have A6 free - I do use RX/TX thoā.
Sorry, I havenāt timed it at all, yet. The 20µs were more a optimistic guess and are definetly not worst case, Iād even say they werenāt even average
But I still only have one of those olde 15kg Oscillographs which I didnāt cart down from the atic And at the moment Iām even on a mountain hut holiday.
If I have to be honest - I donāt even completely understand what would happen, if these settings were completely wrong
But since Iām in the middle of sucking in the STM32 ASM manual to see if there might be some other options for tweaking, I didnāt expect that anybody would be interested in this already.
But if youād get round to measuring, Iād love to hear if this actually did bring some measurable improvement - I would be disappointed if it didnāt
@ScruffR, I have a logic analyzer (DSLogic) for measuring the ISR entry-to-exit time. I only have a single 16x32 panel so I will let you know what I discover.
I was going to add a adafruithermocouple breakoutboard MAX31855. Looks like I need these pins
int thermoCLK = A3;
int thermoCS = A2;
int thermoDO = A4;
Could I just reassign the above to A3,A5 and A7, which are the pins I have free?
It might be nice to use a second core to collect the data though because 1) I have an excuse to buy another core, 2) I can have my display remote (at home) from the thermocouple (at work).
Also I donāt have to worry about the libraries playing nicely together.
By the way, merry Christmas, thank you all for your help this year. I look forward to more adventures in electronics next year!
If you want to use the hardware SPI of the Core, you would need to use the pins you said, loosing the speed gain of @peekay123 's or my fast lib, but there is also a very good SoftSPI which allows the use of any other three pins on the Core.
So you could do it - but Iāll promise to tell noone, not to rob you of any excuse to get another Core
Hi @Dave and @peekay123 ! Many thanks for your work on the Adafruit library!
I have an Adafruit 32x32 panel, Iām sure itās connected correctly and the panel works fine but I can only get half the pixels to work, with two dark bands in it, and itās clearly D thatās not working.
Iām essentially just trying to run /display-firmware-32 as-is from here:
but changing the constructor to be
RGBmatrixPanel matrix(A, B, C, D, CLK, LAT, OE, false, 2);
Iām also sure the panel works fine, as it works fine with an Arduino.
My display-firmware-32 was tested on a few 16x32s I had strung together, and I was having problems with that firmware, so itās definitely not ready for use. I ported some chunks as best as I could, but @peekay123 is way better at display firmware than myself :).