Jump to content

using ugfx with arduino


crteensy

Recommended Posts

I see arduino is now supported as an OS, but how are we supposed to use it? As far as I can tell it's not possible to add ugfx (in its current form) as an arduino library. Has anyone done this, or even packaged it in an arduino-friendly form?

Link to comment
Share on other sites

Other people have avoided the wierd and wonderful arduino build system and have created makefile based builds for their arduino project into which ugfx fits natively.

It is possible though to use ugfx as a standard arduino library (that is how I did it for my project) however the bits of glue and documentation on it is not yet ready for the main repository. The arduino library structure is a bit strange the way it determines dependencies etc and so there was a fair amount of kludging involved.

The basic process is to create a library called ugfx, then create a subdirectory within the library called ugfx that contains the real ugfx repository. Into the top level library directory create a ugfx.c and a ugfx.h and of course a config.h suitable for your project.

In ugfx.c then #include all the relevant source files from the real repository subdirectory.

In ugfx.h just #include the real ugfx.h from the real ugfx subdirectory.

There are a few additional bits to making it work, the details of which I can't remember without firing the project up again But the above should get you most of the way there.

When I get more time I will look at what is required to put the necessary bits into the master repository and write a wiki article on how to use it. Unfortunately that will not be in the next couple of weeks as I just have too much on currently.

Link to comment
Share on other sites

In ugfx.c then #include all the relevant source files from the real repository subdirectory.

In ugfx.h just #include the real ugfx.h from the real ugfx subdirectory.

Regarding including all source files in a single one: Doesn't that result in one huge compilation unit for ugfx and cause optimization problems?

I already tried wrapping gfx.h in ugfx.h so that arduino can find the library header, but didn't get any further because I couldn't think of a convenient way to guide arduino to gfxconf.h.

Link to comment
Share on other sites

The gfxconf.h must be put in the library directory due to the include path arduino uses when it is compiling the library.

With regard to it making one big file which "reduces optimisation", it actually increases optimisation as it increases the size of the compilation unit. Gcc link optimizer is also almost never used anyway due to bugs in the optimizer.

This combining of source files is what the arduino build platform seems to do anyway for libraries - it combines all the source in the directory and then compiles it as a single unit.

Link to comment
Share on other sites

  • 1 month later...

I don't know if you noticed but I recently made this http://forum.ugfx.org/viewtopic.php?f=9&t=228 change.

This should make incorporating ugfx as an arduino library MUCH simpler. When I get more time I will spend some more time on getting the arduino library tested and in the main repository.

Note I also found and fixed an issue with the scheduler which should improve stability of ports like this.

Link to comment
Share on other sites

  • 2 years later...
1 hour ago, inmarket said:

Arduino is now well supported using the single file make mechanism. There is a wiki article on the best way to use it across multiple Arduino projects.

Thanks. It's definitely nowhere on the main Wiki page (I did check!), but searching for "Arduino" inside the Wiki leads to what looks like an actual manual: https://wiki.ugfx.io/index.php/Teensy

Seems a bit convoluted, though. The project-specific library part.

Link to comment
Share on other sites

The method described in the wiki is not the only way of doing it, it is just a good way if you are intending to use uGFX in multiple projects with different hardware/configurations.

If you look in the board/arduino directory (I think) of uGFX there is described the most basic way of doing it.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...