achimdoebler / UGUI

µGUI - Open Source GUI module for embedded systems
Other
1.2k stars 415 forks source link

Adafruit_GFX + Adafruit_ILI9341 + uGUI not work #24

Open Tungsteno74 opened 7 years ago

Tungsteno74 commented 7 years ago

Hello guys!

First of all many tanks to @achimdoebler , this is a very time saver library!

The only big problem (in my case) is that i'm trying to use it together with Arduino Adafruit_GFX and a modified version of Adafruit_ILI9341 libraries but, after compiling and uploading on my Arduino Uno with 2.4 tft lcd shield (8bit bus and 18bit colors) , what appears is a randomly colored pixels on the screen.

All examples on the Adafruit libraries work well so, i think i'm doing something wrong with the implementation of the uGUI lib.

My code is as following: In my EXAMPLE i modified the ugui_config.h and i've included all relevant code in guitest.ino. Then, in the UGUI.h file i replaced #include <system.h> with #include <Arduino.h>.

Someone has already tried to run the library with Arduino? In that case you could post your implementation code?

Many thanks.

sealj553 commented 7 years ago

Hi, I'm in a similar situation. I'm using an arduino project with a STM32f103 (STMduino) using an ILI9341 with the Adafruit library.

I think your problem may be due to the different pixel formats. uGUI uses RGB888 while the adafruit library uses RGB565. In your pixel setting function, you need to convert to the correct pixel format. Here's my function:

void SetPixel(UG_S16 x, UG_S16 y, UG_COLOR c) {
  tft.drawPixel(x, y, 
        (((c >> 19) & 0x1f) << 11) |
        (((c >> 10) & 0x3f) <<  6) |
        (((c >>  3) & 0x1f)));
}

With this conversion, my colors are correct, but I cannot get any windows to display correctly.

rtwfroody commented 6 years ago

FWIW, was also trying to get this to work. I can get UGUI to correctly display a window with a textbox in it, but only if I tell it the resolution is smaller than it really easy (eg. 300x200 instead of 320x240). If I tell it the actual resolution, then my program crashes shortly after UG_Update() is called. It feels like memory corruption somewhere, but I can't figure out what might be going on.

When I pass the 300x200 and register a driver for FILL_FRAME, my window is drawn (faster), but the textbox doesn't show up and the program appears to crash there.

My hardware is the Adafruit Feather Huzzah, along with the ILI9341-based 2.4" Touchscreen Feather Wing.