Adafruit mfGFX discussion

EL Wire/Tape/Panels, LEDs, pixels and strips, LCDs and TFTs, etc products from Adafruit

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
User avatar
Exander
 
Posts: 3
Joined: Mon Dec 22, 2014 10:01 am

Re: Adafruit mfGFX discussion

Post by Exander »

Hi guys,

I succed to have it working with arduino uno and arduino leaonardo, but now I need more power, compiling for teensy 3.1 or arduino due gives the same error:

Adafruit_mfGFX\fonts.cpp:1353:1: error: too many initializers for 'const FontDescriptor'

Any advice?

Regards,
Exander

User avatar
tigers
 
Posts: 16
Joined: Fri Oct 31, 2014 6:11 pm

Re: Adafruit mfGFX discussion

Post by tigers »

Which version of the library are you using? The last one posted has been modified to work with Arduino, but I doubt that it'd work with the Teensy.
Instead, the original library, that you'll find in pkourany's Github was developed specifically for the Teensy and should work with that.
So be careful on the version.

Also, you may think of using a MEGA.

User avatar
Exander
 
Posts: 3
Joined: Mon Dec 22, 2014 10:01 am

Re: Adafruit mfGFX discussion

Post by Exander »

Ok,
I figured it out, and I hope this can be useful to other users too.
The original library compiles and work ok for Arduino Due and Teensy, the latest one is ok for 8 Bit AVR.

User avatar
pkourany
 
Posts: 51
Joined: Wed Nov 27, 2013 12:57 pm

Re: Adafruit mfGFX discussion

Post by pkourany »

I should be able to merge everything into a single arduino/teensy (etc) library. Hopefully over the holidays :)

User avatar
Exander
 
Posts: 3
Joined: Mon Dec 22, 2014 10:01 am

Re: Adafruit mfGFX discussion

Post by Exander »

Since almost all Adafruits LCD come with a SD card slot it will be nice if the library could load the fonts from there...

User avatar
pkourany
 
Posts: 51
Joined: Wed Nov 27, 2013 12:57 pm

Re: Adafruit mfGFX discussion

Post by pkourany »

Extander, the font bitmap would need to be loaded in RAM since fetching the bitmaps on the fly via SPI would be too slow. Using a processor with more flash is the best approach (eg, Mega256, Teensy 3, Due).

User avatar
SpyChar
 
Posts: 5
Joined: Tue Dec 23, 2014 9:06 pm

Re: Adafruit mfGFX discussion

Post by SpyChar »

Howdy! I have a 1.27" adafruit OLED hooked up to UNO. This is the test code I'm trying to run

Code: Select all

void setup(void) {
  Serial.begin(9600);
  Serial.print("hello!");
  tft.begin();
}

void loop() {
	tft.print("lol");
}
The is a problem though. When running using Adafruit_GFX.h it just fills the screen with text as it should. But when I change library to Adafruit_mfGFX.h, UNO just keeps resetting itself(I'm assuming so, because it prints "hello!" to the serial monitor over and over again) and the screen remains empty. Maby there just is something I don't understand about using this library.

User avatar
pkourany
 
Posts: 51
Joined: Wed Nov 27, 2013 12:57 pm

Re: Adafruit mfGFX discussion

Post by pkourany »

SpyCar, which display are you using and did you modify the driver's library to use the mfGFX library instead of GFX?

User avatar
SpyChar
 
Posts: 5
Joined: Tue Dec 23, 2014 9:06 pm

Re: Adafruit mfGFX discussion

Post by SpyChar »

This is my display
https://www.adafruit.com/products/1673
Ad by modifying the library, do You mean changing this line:

Code: Select all

#include <Adafruit_GFX.h>
to this?

Code: Select all

#include <Adafruit_mfGFX.h>
If so then yes, I did modify it.
EDIT.
Okay, that wasn't what U meant. I just modified the library and this is what I get:
http://youtu.be/mFpYGAQd_4M just a colorful noise

User avatar
pkourany
 
Posts: 51
Joined: Wed Nov 27, 2013 12:57 pm

Re: Adafruit mfGFX discussion

Post by pkourany »

SpyCar, in Adafruit_SSD1351.cpp you need to make the change to "Adafruit_mfGFX.h: and comment out the line:

Code: Select all

"#include "glcdfont.c"
. In YOUR app, you also need to have

Code: Select all

#include "Adafruit_mfGFX.h"
Make sure you have the latest mfGFX library I posted also.

User avatar
SpyChar
 
Posts: 5
Joined: Tue Dec 23, 2014 9:06 pm

Re: Adafruit mfGFX discussion

Post by SpyChar »

I commented out glcdfont line and now I got this
http://youtu.be/CoSe8owJ0Rc
When I remove everything from loop function it just stays that way, without resetting constantly.
I have this https://github.com/pkourany/Arduino_Ada ... FX_Library library

EDIT
I deleted all the libraries, and set everything up once again. It seems to be working for now. Weird xD

neltnerb
 
Posts: 18
Joined: Sun Jun 24, 2012 12:08 am

Re: Adafruit mfGFX discussion

Post by neltnerb »

Hi,

To reply to others, I have gotten this to work with an Arduino UNO and a HX8357 (320x480) display.

I managed to generate a custom font from a size 8 font as described, as well as a size 24 font for making it look good at larger font sizes.

There were a few things I ran into, that others may find helpful. First, if you make a new font you need to change the type on the bitmaps to unsigned char instead of uint_8. Additionally, for both the bitmaps and the parameters you must add the PROGMEM label as shown by the other cases. I also added the #ifdef blocks to avoid filling up my program memory, I would recommend others do the same.

Obviously, use fontSize(1) or else they'll be enormous!

Thanks for the great work on this, I can't imagine I'd have been able to do this without this library. I've attached my versions of the code in case anyone else wants to use the same larger font.
Attachments
fonts.h
(1.66 KiB) Downloaded 139 times
fonts.cpp
(107.68 KiB) Downloaded 140 times
Adafruit_mfGFX.cpp
(14.62 KiB) Downloaded 118 times

User avatar
pkourany
 
Posts: 51
Joined: Wed Nov 27, 2013 12:57 pm

Re: Adafruit mfGFX discussion

Post by pkourany »

neltnerb, super glad you found the library useful! At some point, I may poke Adafruit to look at it and possibly add it to their github or update their GFX to the new mfGFX. :)

neltnerb
 
Posts: 18
Joined: Sun Jun 24, 2012 12:08 am

Re: Adafruit mfGFX discussion

Post by neltnerb »

Hi,

I am struggling with creating a fixed width font. What I'd like is basically a large version fixed width font so that I can update a smaller portion of the display specifically.

Background:

I want to have a display that prints a label for a value, and then use a rotary encoder to change the value which will update on the LCD. I'm finding that the time it takes to have the library print the full string of "Label: <value>" takes ridiculously long, hundreds of milliseconds, so I want to place the cursor at the start of <value> and only update the changing text.

I also think that fixed width fonts look better, but that's just a preference.

Can I simply update the FontDescriptor so that the widths are all the same? That seems unwise. I can't figure out how to do it with the font creator software, and so I was trying with http://www.mikroe.com/glcd-font-creator/

However, that output doesn't generate the FontDescriptor code, and I have no idea if the actual font content is correct to match the code assumptions.

User avatar
pkourany
 
Posts: 51
Joined: Wed Nov 27, 2013 12:57 pm

Re: Adafruit mfGFX discussion

Post by pkourany »

netlnerb, I too like fixed width fonts for some things. Creating one for mfGFX is not too difficult. Take a look at how GLCDFONT is defined in fonts.cpp. Each row of the Bitmaps[] array is a character, in RowMajor and MSB first format. In other words, each byte defines a row of the character from top to bottom (bottom being blank for spacing) and the byte's MSB is the left-most dot of the row. If you stack the bytes vertically and convert them to binary, you will "see" the character.

As for the fontDescriptors[] array, there is an entry for each character, with the width defined first, then the height (including the spacer) and then the character index of the character row in the Bitmaps[] array. Since GLCDFONT is an 5x8 font with all 256 characters defined, the fontDescriptors[] entries always start with 5,8 and the index increments by 8 for each entry.

So, to create fixed width font, you need an app that generates RowMajor output. Unfortunately, glcd font creator produces ColumnMajor output. I am searching for a font generator, besides TheDotFactory that does. :)

Locked
Please be positive and constructive with your questions and comments.

Return to “Glowy things (LCD, LED, TFT, EL) purchased at Adafruit”