NEW Adafruit_mfGFX multifont library


#21

Hey peekay123,
I’ve been trying to flash your library with the demo application onto spark core, sadly withouth success. I’m using a 128x128 memory lcd with the breakout board by kuzyatech.
The board seams to have problems connecting my access point after flashing the demo code. It starts blinking green, and turns red after a while. It has no problems with other(simpler?) code.
Any suggestions on what could cause this problems or how I could debug the core?


#22

@Sepal, the larger 128x128 display requires a larger memory buffer and may exceed the Spark limit. I will test later and let you know what I find. Are you using the web IDE?


#23

Yeah, it uses 2KB so i thought the Spark Core with its 20KB of RAM should handle it, but apparently the basic firmware uses most of that.
I just tried it out again removing all fonts but the GLCDFont, using the spark cli and spark build, but the result is the same.
This are the stats from Spark Build:

In a nutshell:
Flash used     82116 / 110592     74.3 %
RAM used       17344 / 20480      84.7 %

#24

@Segal, all the fonts are stored in flash. The only determining factor is the pixel size of the display. I am about to test it with my display. Stay tuned! :wink:

UPDATE: I can confirm that with the latest Core firmware version, a 128x128 display causes an out-of-RAM error. In the current Sprint, RAM usage will be reduced.


#25

I have posted the Adafruit_mfGFX library to the IDE. I will be posting Adafruit display drivers adapted for this library in the coming days. :smile:


#26

Thanks for posting this library to IDE.

I had a project where I had added a cut/paste version so I thought I’d swap over to library instead. It works except I am not sure how to include selected fonts now. Previously I had set the #defines in fonts.h but can’t do that now. I saw the "defines for the other fonts are defaulted off, so I tried adding the #defines in main app before the #include "Adafruit_mfGFX/Adafruit_mfGFX.h"
but that doesn’t seem to work as I still end up with GLCDFONT for any setFont call. I wasn’t really expecting that to work but I’m not sure if there is any where to put project level defines.


#27

@bobtidey, this is a pet peeve of mine right now - you can’t modify the library files once you pull them into an app!! @Dave, we need to be able to do this!!!

So, at this point, there is no way to change those #defines to add the fonts. So I have two options I think. One is to add all the fonts by default (not optimal). The second is to require the user to create a “fontselect.h” file as part of their app, to which they would copy those #defines and edit as required. Any thoughts?


#28

Yes. I think the fontselect.h option is best for now until one can ‘fork’ a library. It is much nicer to create a little header than have to cut/paste the whole code in to get access to this functionality.

I guess this could sort of be generalised to have a generic header that could be put into any library. If the IDE included an empty version last on the search list then a user can then put any overrides into his own version.


#29

ping for @jgoggins - option to fork the library into a project?


#30

Thanks for the ping @Dave, yea, we want to support this capability.

I brainstormed on this a bunch this evening to find the fastest, simplest path to make library forking possible and cooked it into a rough spec. I’m hoping to refine this a bit with @Dick, will ping this thread or folks individually when we have a better grasp on how we’ll approach this.

Off the bat, I know I want a solution that leans on GitHub as much as possible for the forking, committing, merging, pushing, and pull requests. I also know the solution needs to facilitate rapid refinement and tweaking of an existing published library.


#31

@jgoggins, the sooner the better IMO :wink:

@bobtidey, I really don’t want to change the library works knowing library editing is coming (SOON, RIGHT JOE!). In the meantime, I strongly recommend using Spark CLI for locally compiling your code. Personally, that is what I use 80% of the time. I put all the files I need in one directory and compile that directory and voila! :smile:


#32

peekay123
a Question on the refresh()
How does this work with updating the information on the display? Example, if you just want to write sequential numbers to the same position on the screen like a counter, 1,2,3,4…etc and send a refresh() between each one it doesnt seem to do anything as the numbers just overwrite each other with the old number still visible.
It seems the only way is to clear the screen completely each time which causes the blink mentioned by RWB.
This is a pain especially if you have some static text on the screen and just want to update a single character, the whole screen blinks.
I tried another library by Astuder sharpmemLCDTxt Library which is very simple and that implementation doesnt blink the screen. Problem is that library doesnt allow you to change sizes and position where you want to print.

Any insight would be appreciated.


#33

@MagicTech, this is a classic problem with graphic displays. That is, text is actually displayed as pixels, just like any other display “entity”. There are different ways of refreshing text or any graphical element on a screen:

  1. Redraw the same item/text in the background color to “erase” the item. Then, draw the new item and repeat. For the Sharp display that would be white or black.

  2. For text, you can print spaces first then the text but the mfGFX library uses variable width text so the number of spaces you need may vary.

  3. Draw a filled rectangle using the background color. The size and position is chosen to overwrite the (longest) text area (in your case). Then, print your text as you normally would

I prefer using #3 for text since I don’t have to store the previous text I printed. I use #1 for cases where a specific element on the screen is being redrawn like a needle on a meter for example. A filled rectangle could not do the job in that situation. Hope that helps! :smile:


#34

Thank you
That makes sense. Still get the blink but at least its limited to the numeric that changes.


#35

I have a request. I am using a colour LCD display 128*160. I have tried your library - I ended up having to paste your code into the original GFX library to get it to work (overwriting all of the original text)… and that’s fine - the text works including looking at text in different sizes.

Of course when expanded the font looks awful as it is all blocky. SO I followed your instructions to try adding a larger font - 20pt using The Dot Factory (v 0.1.4) I followed the instructions to the letter - but it simply doesn’t work. The font was a 7-segment font - and at one point I saw 1 seven segment character appear on the LCD screen followed by rubbish so it kind of recognised the information.

I’m using an ATMEGA 1284 so no shortage of room. It would help immensely if someone could supply a paste in larger font I could try - so I can figure out where my problem is - all the fonts in your demo library are all 8pt.

If it helps for pasting my email address is pete@scargill.org


#36

This is more for the Spark Core platform so I’m not sure if we have resources to help do that.

Maybe the Arduino platform or the original library contributor are better alternatives? :slight_smile:


#37

Thanks for that - as it happens - I’d tried 20pt… with no joy - I moved to 16pt - and it works -(multiples of 8??)… Thanks anyway.


#38

Hi
I’ve spent the day getting this working on Arduino - successfully I may add. Great stuff.

Arial 8pt looks good - but Arial 12pt doubles in thickness. Also for large LCD fonts I tried a couple and they don’t look so good.

Could you save a little research… for (a) small and (b) LARGE - as in clock display large - or your image on this page of LCD font… which are the best fonts to convert for clean output?


#39

A quick point - there’s a reference to deleting all comments in the descriptors - to save compile issues. That takes time. You only need to eliminate one - for reasons only the language designer’s mother must know, you can’t put a backslash at the end of a comment (so much for everything after // being a comment - so between upper case and lower case in the font descriptors - just replace \ with the word “backslash” or remove it.


#40

Backslash at line-end might mean “continue on next line”. Appearantly in your compiler this takes precedence over the comment. Could be according standards…