ILI9341(new)SPI library for Due supporting DMA transfer(Uno, Mega,.. compatible)

MarekB:
Not a mac user so I guess I won't help you with absolute paths on mac. Should it not start with something like /Users/... (macos - How to tell full path of file on Mac? - Super User)

If the compiler has issues finding fonts then just put them in the same directory as your .ino (or maybe putting them in the same folder as ili9341_due.h will work too). Personally I am using Visual Studio with Visual Micro addon. Maybe somebody can chime in on how to fix those paths.

Ok thanks i'm gonna try that right now...

One more question, I have a challenge for you guys. Since i'm not getting through maybe some one out there could give me a clue.

I have a rotary encoder left right and press. defined in my sketch as the following :

int RotaryEntryLeft = 24; // Rotary Potentiometer Left Turn
int RotaryEntryPress = 26; // Rotary Potentiometer Press Button
int RotaryEntryRight = 28; // Rotary Potentiometer Right Turn

That will be used to browse in menu by rotating left right, select by short press, enter by double press and on/off by long press.

Now my problem is the following I do not know how to figure out. When the Due is powered there will be " Off Line! " printed on the screen, and I have managed to make the tat backlight to fade in and out so that the print visualy disapear. Fine but the long press on the button to enter the main program how can i do that.. PLEASE NEED HELP :slight_smile:

Thanks in advance k

K4hn:
Hey MarekB

I've got the same issue on my mac for the font :frowning: , I've included the correct path but still getting the same error message. Can you help?

To ALL MAC USERS when you point the path for the Arial_bold_14.h in exemple: #include "fonts\Arial_bold_14.h"
and getting this following error:

fonts\Arial_bold_14.h: No such file or directory
compilation terminated."

you must know that this little sign " \ " is proper to WINDOW USERS, MAC doesn't even have it on his keyboard so simply change it to "/ " and you're done :)...

I uploaded a new version v0.94.000 which adds AVR compatibility so the library can now also be used on Uno, Mega, Pro Mini, Nano and alike.

Btw. that is a 3.3V Pro Mini, do not attempt to connect a 5V version like that.

THX MarekB for the update.

Three ways can be selected in order to drop the logical voltage from 5 V to 3.3 V:

  1. Wiring on a TFT-MEGA shield like ElecFreaks V2.2

  1. Put one voltage divider on pin CS, pin D/C, pin RESET, pin MOSI and pin SCK

  2. Wiring on a level shifter like CD4050

MarekB:
Load an image as a background yes, but have a moving object over it...well, you would have to do some partial repaints of the background image. So if your object is moved to a different location, its previous region has to be repainted with a portion of the background image. Considering the image would be on an SD card, I am not sure how fast you could repaint a region. I'd say you're much better off with a plain color background.

Ok.

What I was thinking of was something like the attached pict and having the needle moving over it

You could draw it all with the libs drawing functions (arcs, lines, circles) and use gText to draw all the text (if you can find the right fonts). If I am not mistaken you should not reproduce the Dolby logo (trademark). But generally speaking, I think the easiest is to use the font editor which is included in the lib's tools folder (you have to use it anyway if you want to generate custom fonts) and draw the logo there. Then print it on the screen with gText's drawString.
One of the disadvantages is that all the lines, curves, text won't be antialiased. You can achieve antialiasing only by using an image. Not sure how big the resulting image will be, but maybe you could fit it in Due's flash/program memory (a big byte array) and draw an image from it (instead of having it on an SD card). I think the refresh rate (draw image, draw needle, erase needle, draw image, draw needle,...) might be acceptable then.

MarekB:
You could draw it all with the libs drawing functions (arcs, lines, circles) and use gText to draw all the text (if you can find the right fonts). If I am not mistaken you should not reproduce the Dolby logo (trademark). But generally speaking, I think the easiest is to use the font editor which is included in the lib's tools folder (you have to use it anyway if you want to generate custom fonts) and draw the logo there. Then print it on the screen with gText's drawString.
One of the disadvantages is that all the lines, curves, text won't be antialiased. You can achieve antialiasing only by using an image. Not sure how big the resulting image will be, but maybe you could fit it in Due's flash/program memory (a big byte array) and draw an image from it (instead of having it on an SD card). I think the refresh rate (draw image, draw needle, erase needle, draw image, draw needle,...) might be acceptable then.

Hi and thanks for your response.

Yeah for the db logo I know, the pict was for exemple.
Ok then I'll dig this way,

and yet again an other challenge.

Is it possible to create a loop in void setup ().
Let me explain my self.

I got make the screen rotate when my prototype will be rotated from 0° then 90° with a mercure sensor.

here is the sketch I came to:

#include <ILI_SdSpi.h>
#include <ILI_SdFatConfig.h>
#include <ILI9341_due_gText.h>
#include <ILI9341_due.h>

#define TFT_DC 9
#define TFT_CS 10

int ledPin = 7;
int MercurSensor;

ILI9341_due tft = ILI9341_due(TFT_CS, TFT_DC);

void setup() {

MercurSensor = 22;

pinMode(MercurSensor, INPUT);

Serial.begin(115200);
tft.begin();

if(digitalRead(MercurSensor) == HIGH)
{
tft.setRotation(iliRotation270);

tft.setCursor(0, 0);
tft.fillScreen(ILI9341_BLACK);
tft.setTextColor(ILI9341_WHITE);
tft.setTextSize(3);
tft.println("Hello World!");

}

{
if(digitalRead(MercurSensor) == LOW)

tft.setRotation(iliRotation180);

tft.setCursor(0, 0);
tft.fillScreen(ILI9341_BLACK);
tft.setTextColor(ILI9341_WHITE);
tft.setTextSize(3);
tft.println("Hello World!");
}

}

void loop() {

}

But the issue is I will also have a long pressed on/off button to make the main program run and go back to the hello world , and this with the rotation setup. but it only rotates if i reset the board because it's in void setup (). When in void loop() it rotates but screen flickers and the word doubles, how can I manage the long press for run and go back to initial state, can you help me out with this.

The buttons are a bit off topic for this thread and I am not sure what functionality are you trying to achieve anyway.
As for the flickering, when the orientation changes, you should call fillScreen to clear the screen, then setRotation and then print the "Hello World" text. And all of that should happen only once per each rotation. If you're clearing the screen and printing out the text on each loop then it will flicker.

ok, thanks for your assistance :wink:

hello .
I have arduino mega and ili 9340 .
i declared :

#include <SPI.h>
#include <ILI_SdSpi.h>
#include <ILI_SdFatConfig.h>
#include <ILI9341_due_gText.h>
#include <ILI9341_due.h>

i used pin and cb4050 :
#define _sclk 52
#define _miso 51
#define _mosi 50
#define _rst 48
#define _dc 49
#define _cd 53
But I have not image display; just backlight.
MarekB you possible help me ?

Attach the full source code.

Edit:
You have MISO and MOSI pins switched. MISO is 50, MOSI is 51. If switching them won't work post your full source code.

ok I will look the problem in late week and back test.

it is good .
i switched mosi and miso ; and add rst for synthax ;
ILI9341_due tft = ILI9341_due(_cs, _dc, _rst);
thanks you marekb!

Hi Marek,

this is Mike from Germany - and old C programmer, mostly working on embedded stuff until the late 90's, now lately playing around with Arduino and IoT's -

after searching around, i found your fantastic DUE enabled ILI9341 library, which i'm currently using in an datalogger - first of all, let me thank you for all the efforts you've put into this library and the speed it has gained through your work.

i'm currently facing some problems of handling additional fonts, like 7-Segment numbers, i tried to convert a standard ttf font using the font creator mentioned in the font files, which are found in the \font diectory of the lib.
Can you give me some direction, on how to integrate an external font - like ttf, of fonts from other graphic libs like Hennings UTFT fonts.

Any help or explanation will be highly apreciated.
And please keep up your excellent work

kind regards, Mike

Hi Mike,

you can create custom fonts from .ttf fonts. Here's a quick guide:

  1. Open GLCD Font Creator 2
  2. From the menu select File->New Font
  3. Select the Font, Size and Style you want to import in the Import Font group
  4. Set the Start Index, that's the index from the character map. The first character (space) starts at index 32. The numbers start at index 48, upper-case characters at index 65, etc.
  5. Set the Char Count, that's the number of characters starting at the Start Index you want to have in your character set. So e.g. if you just need the numbers, set the Start Index to 48 and Char Count to 10. That will give you numbers 0-9 in your set.
  6. Set the Font Name. I advice to use maximum of 8 characters, no spaces.
  7. Click OK
  8. From the menu select Export->Export Font
  9. Provide a file name. I advice to use maximum of 8 characters, no spaces and the same name as in step 6. I think you'd have to use 8.3 DOS style file names in your include (so something like #include "MyFont~1.h") if the file name would be over 8 chars. So keep it simple and don't use more than 8 chars :slight_smile: Also add ".h" to your file name so you do not have to add it afterwards.
  10. When you click Save, the app starts to export, if you do not see the file immediately, just wait for it :slight_smile:
  11. Copy the .h file where your sketch is (or wherever you can find it)
  12. Add an include in your sketch, #include "name_from_step_9.h"
  13. Define an instance of ILI9341_due_gText in your sketch, call .setFont(name_from_step_6) on the instance and .drawString to render the text (have a look at gTextHelloWorld example sketch)

spectre59390:
it is good .
i switched mosi and miso ; and add rst for synthax ;
ILI9341_due tft = ILI9341_due(_cs, _dc, _rst);
thanks you marekb!

Glad that it worked for you :slight_smile: I usually add the reset pin as well.

TFT: ILI9341 2.8" touch

Seven segment font
Size: 100 px

Sev3.h

PD: THX MarekB

Hi Marek,

Many thanks for your comprehensive help and information,
it took me only five minutes with your perfect tutorial to create some nice fonts in different sizes from TTF files - its just that easy to do with your conversion tool -

Now this library is by far, the fastest and most flexible i've ever used with the Due !
i'm deeply impressed what can be done with SPI and DMA to the 2.2inch Display - will now get me some of the new 2.8inch touch displays to improve readability

Just out of curiosity, have you already thought about including the touch controller in the lib as well - or is there any other touch lib which can be included - if i can be of help sponsoring you a display or two - just let me know - i'd love to give something back for your preciuos work !

keep up your great work,
kind regards, Mike

TFTLCDCyg:
TFT: ILI9341 2.8" touch

Seven segment font
Size: 100 px

Sev3.h

PD: THX MarekB

this looks great - if this was made for me - let me express my honest thanks to you for your efforts - maybe you can link the TTF file as well, so one can resize the font to the required size.

thanks for the post and your help,
kind regards, Mike

@Mike:

thanks :slight_smile:
In regards to the touch thing. I haven't tried it yet but I presume the UTouch library should work.
Btw. you can find many free fonts on the likes of 1001 free fonts or Dafont. They have that digital font TFTLCDCyg used as well (or similar to it).

And thanks for the offer, what I would really need is to send you my two small kids for at least a month so I can get some development time after work. Let me know if and when that suits you :wink:

@TFTLCDCyg

that 2.8inch looks good, I didn't even know they existed. Will buy one (or better two). Do you know of any other cheapish SPI display but with a higher resolution (like 640x480)?