RGB Pixel Clock Kit (Maker Faire 2016)

I’m interested in taking a look at that dual animation code you have created just so I know I can do this if desired :slight_smile:

@RWB, the small fonts are rendered independently of the mfGFX library. So if you want other fonts, you need to enable them in mfGFX and use them there. I am considering creating a new version of the pong clock using the latest Adafruit GFX library and adapt the code for a 64x32 panel. Using @ScruffR’s multi animation code, it would be possible to have four days of animated forecasts on such a panel. The life clock on a bigger panel is cool to watch and the word clock could use bigger fonts. I have considered doing a 64x64 panel using a “folded” 128x32 configuration but I need a long panel-to-panel cable to connect the top-right corner panel to the bottom left corner panel. The code needed to do the “folding” to simulate a 64x64 panel is straight forward. Now all I need is time!

I’m using a single 64x32 size panel but have another identical panel here not being used.

I think your dead on about all the upgrades you mention and that they would be improvements. I also agree that messing with this sure does eat up time quickly :smile:

I do want to increase the font size of the Word Clock.

So could I just copy the additional font layout and usage that you did in the Sharp Memory LCD library you created for me in the past? Is that the same method I need to use here also?

@RWB, yes and no. The resolution of the RGB panel is much lower than the Sharp LCD so you have to consider that. The idea with going with the new Adafruit GFX library is that it has a small tiny font available along with several others. The bad part is the font generator for it only runs on (some) linux systems.

@Peekay123 I know the Fonts I used for the Memory LCD’s wouldn’t work due to fewer pixels on the LED display.

Is your mfGFX library on the IDE library list a suitable replacement for the GFX library you used on in the Pong Clock Library?

The RGBPixelClock library already uses the mfGFX library!

Sure you can

2 Likes

That's what I thought.

So this function should allow me to switch to a new font using the mfGFX library, Right?

//Default font is ARIAL_8, uncomment line below to set to different font
display.setFont(TIMESNR_8);
//display.setFont(TEST);

I just need to use the DotFactory program to create and test different fonts right?

I don't understand why you would want to use Adafruits new library when your mfGFX library works just as good, plus the DotFactory software runs on windows which you have written a user guide for already.

I just didn't see any calls to change the font in your Pong Clock code so wasn't sure it was possible and didn't find the setFont() function until looking at the Sharp Color LCD library tonight.

Hopefully, that function is all that is needed to add new fonts to this LCD screen.

The Big Scrolling display with a 20ms refresh delay is as you say "Buttery Smooth", it looks nice.

1 Like

No specific reason, mostly just to have it available. I was very disappointed in the Linux-only font tool which really sucks anyway.

BTW, I believe version 0.8.0-rc.1 (or maybe even 0.7.0?) will have a "fast" attachInterrup() function available which will reduce interrupt latency making the RGB panel refresh faster. I tested the new functionality with the RGBMatrixPanel library but didn't do any timing yet. However, since the new function allows a direct hook into the interrupt vector table, it is faster by default! :slight_smile:

1 Like

Faster is better! At slower scrolling speeds it looks a tad choppy compared to the quicker refresh times for some reason, maybe it’s my code, I just run quicker scrolling speeds.

Do you have any pre-written code that randomly set’s each pixel on the LED display? I’m wondering what that would look like if I played it between screen changes. I’m not sure what the best way to code that would be?

Just set each pixel to a random RGB value with a for loop and then call the display matrix command?

@peekay123

I tried using the setFont function with no success.

void screen1() {
    // Clear background
   matrix.fillScreen(0);
   // Draw big scrolly text on top
   matrix.setTextSize(1);
   matrix.setFont(CENTURY_8);
   matrix.setTextColor(matrix.ColorHSV(hue, 255, 255, true));
   matrix.setCursor(11, 7);
   matrix.print("BitCoin");
   matrix.setCursor(5, 17);
   matrix.print("$");
   matrix.print(BitCoinSpotPrice);

When I try to use Display.setFont(); it says:

Which makes sense because we did not set the name of the link to the library the same as you did in the Sharp Color Display Library as shown below.

If I change the display.setFont() to Matrix.setFont() it will compile without issues but the font that shows up on the LED Matrix panel does not change.

Am I on the right track in thinking changing the fonts shoud be as easy as using the setFont() function?

@RWB, I’ll post an example of using mfGFX fonts in the morning to show you what to do. :slight_smile:

1 Like

AWESOME!

I was looking more into how others have done this with the Adafruit library trying to get a better understanding of how it’s done but kinda gave up for the moment :slight_smile: I’m happy to see this message from you.

The family has been watching the outside real feel temp scroll across the screen for the last few days where it’s been between -13 and 10F outside. :snowman: It know it’s even colder up there!

1 Like

@RWB, here is a 32x64 example that scrolls a message across the panel from right to left, with “bouncing balls” in the backgroung, using a fixed message with the TimesNewRoman 8 font from the mfGFX library. You can substitute your own font for testing. Note that I scale the font after setting it so you may want to remove that if the font is large.

You’ll notice I have some Time code in there which I will be using to display date and time. I didn’t get to doing that yet. Note that I compiled this example with the latest CLI and firmware version. All library files were copied to a single directory for compiling. You need this for the Adafruit_mfGFX library so you can modify fonts.h. :slight_smile:

// scrolltext demo for Adafruit RGBmatrixPanel library.
// Demonstrates double-buffered animation on our 16x32 RGB LED matrix:
// http://www.adafruit.com/products/420

// Written by Limor Fried/Ladyada & Phil Burgess/PaintYourDragon
// for Adafruit Industries.
// BSD license, all text above must be included in any redistribution.

#include "Adafruit_mfGFX.h"   // Core graphics library
#include "RGBmatrixPanel.h" // Hardware-specific library
#include "math.h"

SYSTEM_THREAD(ENABLED);

// Modify for version of RGBShieldMatrix that you have
// HINT: Maker Faire 2016 Kit and later have shield version 4 (3 prior to that)
//
// NOTE: Version 4 of the RGBMatrix Shield only works with Photon and Electron (not Core)
#define RGBSHIELDVERSION		4

/** Define RGB matrix panel GPIO pins **/
#if (RGBSHIELDVERSION == 4)		// Newest shield with SD socket onboard
	#warning "new shield"
	#define CLK	D6
	#define OE	D7
	#define LAT	TX
	#define A  	A0
	#define B  	A1
	#define C  	A2
	#define D	RX
#else
	#warning "old shield"
	#define CLK	D6
	#define OE 	D7
	#define LAT	A4
	#define A  	A0
	#define B  	A1
	#define C  	A2
	#define D	A3
#endif
/****************************************/


// Last parameter = 'true' enables double-buffering, for flicker-free,
// buttery smooth animation.  Note that NOTHING WILL SHOW ON THE DISPLAY
// until the first call to swapBuffers().  This is normal.
//RGBmatrixPanel matrix(A, B, C, D, CLK, LAT, OE, true, 128);
RGBmatrixPanel matrix(A, B, C, D, CLK, LAT, OE, true, 64);


const char str[] = "Adafruit 32x64 RGB LED Matrix";
int	textX = matrix.width();
int	textMin = sizeof(str) * -12;
int	hue = 0;

int8_t ball[3][4] = {
	{  3,  0,  1,  1 }, // Initial X,Y pos & velocity for 3 bouncy balls
	{ 17, 15,  1, -1 },
	{ 27,  4, -1,  1 }
};

static const uint16_t ballcolor[3] = {
	0x0080, // Green=1
	0x0002, // Blue=1
	0x1000  // Red=1
};

unsigned long scrolldelay = 0;
bool daylightSavings;



bool IsDST(int dayOfMonth, int month, int dayOfWeek)
{
	if (month < 3 || month > 11) {
		return false;
	}
	if (month > 3 && month < 11) {
		return true;
	}
	int previousSunday = dayOfMonth - (dayOfWeek - 1);
	if (month == 3) {
		return previousSunday >= 8;
	}
	return previousSunday <= 0;
}



void setup() {
	matrix.begin();
	matrix.setTextWrap(false); // Allow text to run off right edge
	matrix.setFont(TIMESNR_8);
	matrix.setTextSize(3);		// Scale font to fit full height since 8pt font is small

  while (!Time.isValid()) {		//Wait for valid time from cloud
	  delay(10);
  }

  daylightSavings = IsDST(Time.day(), Time.month(), Time.weekday());
  Time.zone(daylightSavings? -4 : -5);

}

void loop() {
	byte i;
	static int indx = 0;

	if (millis() - scrolldelay >= 75) {		// Slow down the animation
		scrolldelay = millis();

		// Clear background
		matrix.fillScreen(0);

		// Bounce three balls around
		for(i=0; i<3; i++) {
			// Draw 'ball'
			matrix.fillCircle(ball[i][0], ball[i][1], 5, ballcolor[i]);
			// Update X, Y position
			ball[i][0] += ball[i][2];
			ball[i][1] += ball[i][3];
			// Bounce off edges
			if((ball[i][0] == 0) || (ball[i][0] == (matrix.width() - 1)))
			ball[i][2] *= -1;
			if((ball[i][1] == 0) || (ball[i][1] == (matrix.height() - 1)))
			ball[i][3] *= -1;
		}

		// Draw big scrolly text on top
		matrix.setTextColor(matrix.ColorHSV(hue, 255, 255, true));
		matrix.setCursor(textX, 1);
		matrix.print(str);

		// Move text left (w/wrap), increase hue
		if((--textX) < textMin) {
			textX = matrix.width();
		}

		hue += 7;
		if(hue >= 1536) hue -= 1536;

		// Update display
		matrix.swapBuffers(false);
	}
}
2 Likes

I tried your code but using the Online Build IDE which is what I have been using the whole time but it will not change the font it’s using no matter what I choose.

Are you saying compiling via CLI is how it has to be done for this to work?

The code compiles just fine as it did originally and I’m using the same matrix.setFont(TIMESNR_8); function code that you are calling so the only difference I see based on what you’re telling me is that you’re using the CLI to compile while I’m using the Online Build IDE to compile? Should that make a difference?

@RWB, without pulling the in the mfGFX library files, you won't be able to change the fonts.h file to enable the TIMESNR_8 font:

//Font selection for compiling - comment out or uncomment definitions as required
//NOTE: GLCDFONT is default font and always included
//#define TIMESNEWROMAN8
//#define CENTURYGOTHIC8
//#define ARIAL8
//#define COMICSANSMS8
//#define TESTFONT

You won't get a compile error but the font won't work! This is why I use the CLI. Like I said:

Ahh, That makes sense. I see the problem now :slight_smile:

I should be good now. I’ll report back soon as I get this working.

Thank you!

1 Like

Threw all the files for my project into a single folder and compiled with the Desktop IDE and I am able to change the fonts with my custom code.

Pretty easy, the thing that was causing problems for me was failing to uncomment the individual font define lines as shown below.

You can certainly tell a difference between the fonts on the higher resolution 64x32 displays.

I have a second 64x32 display, what's the best way to add it if I want to make the screen wider for more scrolling text vs. just taller?

@peekay123 First I have seen the tight pitch 64x64 single boards so figured I would share this for you and others to use with your Matrix LED Breakout if you are still selling them.

2 Likes

@RWB, I saw that just the other day myself! The RGBMatrixPanel library can’t drive a 64x64 display but it could drive a 32x128 display “folded” to appear like a 64x64 display. All I need is to modify the library and get a long “corner-to-corner” connector which is another story.

In the meantime, I have the sandgrain animation working on a 32x64 display and would like to get something similar to the Adafruit logo thing going. I just need the time!