Git Product home page Git Product logo

Comments (59)

8bitbunny avatar 8bitbunny commented on May 23, 2024 1

awesome that it's going to be ported! no worries on time, do everything at your tempo, will donate some money for the awesome support :)

and for the teensy 3 not as far as i know.. ^^;

from lvgl.

ajaybhargav avatar ajaybhargav commented on May 23, 2024 1

I have been working on Arduino recently to add support for a new platform that I am making. And lot of code that I write is in C. Arduino core is actually mix bag of C and C++ sources so I am not sure why compiler is throwing errors. It may be the way you are including the files in your project/sketch.

from lvgl.

8bitbunny avatar 8bitbunny commented on May 23, 2024 1

Okay, will change all files and try again upcoming week and tell you the result

from lvgl.

kisvegabor avatar kisvegabor commented on May 23, 2024 1

I've checked the files, tried to compile and saw multiple type of issues. On next week I'll try to solve them!

from lvgl.

kisvegabor avatar kisvegabor commented on May 23, 2024

Have you added the project's root path to the include paths?

Can you copy here a few from the error messages?

from lvgl.

8bitbunny avatar 8bitbunny commented on May 23, 2024

well, arduino is set up differently, and i don't know how to do that on arduino ide.
so i copied everything to the sketch folder, with adding the needed includes in the sketch file.

then i came across alot of "file not found" (due to root include paths), fixed those manually, but then i got "undefined reference to" errors, so i had to include every .c file in my sketch too, and now i get even more errors saying this:


C:\Users\Admin\AppData\Local\Temp\arduino_build_78852\sketch\lvgl/lv_objx/lv_bar.c: In function 'lv_obj_t* lv_bar_create(lv_obj_t*, lv_obj_t*)':

C:\Users\Admin\AppData\Local\Temp\arduino_build_78852\sketch\lvgl/lv_objx/lv_bar.c:62:42: error: invalid conversion from 'void*' to 'lv_bar_ext_t*' [-fpermissive]

lv_bar_ext_t * ext = lv_obj_alloc_ext(new_bar, sizeof(lv_bar_ext_t));

why not simply make everything easy to integrate in arduino too? :P

from lvgl.

8bitbunny avatar 8bitbunny commented on May 23, 2024

note that this is with the application framework enabled

from lvgl.

kisvegabor avatar kisvegabor commented on May 23, 2024

Hm. Please attache the whole compile log as a txt file.

from lvgl.

8bitbunny avatar 8bitbunny commented on May 23, 2024

okay, i set compiler warnings to "all" so beware of a HUGE list of errors, here's the list: https://pastebin.com/dJZmD2rp

from lvgl.

kisvegabor avatar kisvegabor commented on May 23, 2024

It seems like compiiler threat the source files as cpp files instead of c. Have you changes the file extensions to .cpp from .c?

from lvgl.

8bitbunny avatar 8bitbunny commented on May 23, 2024

the arduino ide does that by default i think, and i cant find a way on how to disable that, and i leaved the file extentions at their default ones ( .h, .c )

from lvgl.

kisvegabor avatar kisvegabor commented on May 23, 2024

I googled on it and found that it a limitation of the Arduino IDE. I have never used Arduino so far but others say there are problems when you begin to use things outside of Arduino. Therefore they recommend to work with an other IDE.

https://stackoverflow.com/questions/7803416/can-the-arduino-ide-be-used-to-develop-plain-old-c-programs

Here is a description about a C compatible IDE:
https://spin.atomicobject.com/2011/10/15/taking-the-training-wheels-off-the-arduino/

from lvgl.

8bitbunny avatar 8bitbunny commented on May 23, 2024

i see, so that basically means i need to port the entire device support package to another IDE... (the teensy 3.x support package in my case, which will be a pain)

and i was so hopeful that lvgl could work relatively easy on arduino.. :'(

from lvgl.

8bitbunny avatar 8bitbunny commented on May 23, 2024

just a question, will it ever be ported to arduino? or not?

from lvgl.

kisvegabor avatar kisvegabor commented on May 23, 2024

Yes, I'm planning to port it to Arduino (and make the required updates) but I will have time for it only a few month later... :(

Teensy 3 doesn't support other IDE/compiler then Arduino?

from lvgl.

ajaybhargav avatar ajaybhargav commented on May 23, 2024

You can create a wrapper class around lvgl to make it arduino compatible, converting whole project to c++ will be a big job.

from lvgl.

8bitbunny avatar 8bitbunny commented on May 23, 2024

never did that kind of coding before, so i wouldn't know how to do that tbh ^^;

from lvgl.

kisvegabor avatar kisvegabor commented on May 23, 2024

I don't know Arduino, but I suppose that regardless to the wrappers the Arduino compiler has to compile the code. The wrappers helps you only when you use the functions, don't they?

from lvgl.

kisvegabor avatar kisvegabor commented on May 23, 2024

Good news! Thanks for that!

from lvgl.

kisvegabor avatar kisvegabor commented on May 23, 2024

I've downloaded the Arduino IDE and tried to setup an example dummy library. The first thing I faced that I had to modify the .h files:
at the begginig
#ifdef __cplusplus
extern "C" {
#endif

at the end
#ifdef __cplusplus
} // extern "C"
#endif

If you have time for that can you try it?

Also to not waste time I recommend you to try the PC simulator. It is a very good to know the LittevGL and also your code can be copied to an embedded environment later. Here is a guide about the PC simulator: http://www.gl.littlev.hu/pc-simulator

from lvgl.

8bitbunny avatar 8bitbunny commented on May 23, 2024

you mean at every .h file? that's gonna take some time.

and i will try the pc emulator :)

from lvgl.

8bitbunny avatar 8bitbunny commented on May 23, 2024

also, regarding the pc simulator, why not make a single visual studio project? if needed i can give you a project that's exactly doing that :)

from lvgl.

kisvegabor avatar kisvegabor commented on May 23, 2024

Yes, I mean all .h files... :(

Visual studio project: I've chosen Eclipse CDT because it is cross platform. Please create an issue in proj_pc repository to continue the discussion about Visual Studio there.

from lvgl.

8bitbunny avatar 8bitbunny commented on May 23, 2024

i midified all the .h files, and now getting "undefined reference to lv_init()" and the same errors with other functions.

looks like i need to include the dedicated .c files as well in each .h file? :O

from lvgl.

kisvegabor avatar kisvegabor commented on May 23, 2024

Thank you for the effort to modify the files.

Please, send me the lvgl, misc and hal folders and I will check/try them.

from lvgl.

8bitbunny avatar 8bitbunny commented on May 23, 2024

attached is the arduino folder including ili9341 and touch libraries for the adafruit 2.8" tft ( https://www.adafruit.com/product/1651 ) with a teensy 3.1 (i used teensyduino 1.36 & arduino 1.8.1)

the whole zip needs to be extracted in my documents/Arduino
Arduino.zip

from lvgl.

kisvegabor avatar kisvegabor commented on May 23, 2024

Firstly I have tried to port the misc library and I've succeeded! It was required to solve several issues because of the limitations in the Arduino IDE but I was able to compile it! Please try it and if it is working for
you too I will make the LittlevGL as well.

Arduino_misc.zip

from lvgl.

8bitbunny avatar 8bitbunny commented on May 23, 2024

it compiles, but it doesn't go past the misc_init(); function on a teensy 3.2 (fastest, with lto, 96mhz), aka a system halt is thrown.

this is the sketch:

#include <hal.h>
#include <misc.h>

extern "C" char* sbrk(int incr);

int FreeRam() {
  char top;
  return &top - reinterpret_cast<char*>(sbrk(0));
}


void setup() {
  delay(1000);
  Serial.println("Start");
  // put your setup code here, to run once:
  delay(100);
  Serial.print("Misc init..");
  misc_init(); //doesn't get past here
  Serial.println(" Done!");
  Serial.print("Free RAM:");
  Serial.println(FreeRam());
}

void loop() {
  // put your main code here, to run repeatedly:
}

from lvgl.

kisvegabor avatar kisvegabor commented on May 23, 2024

In misc_conf.h disable the IDLE module. USE_IDLE 0

from lvgl.

8bitbunny avatar 8bitbunny commented on May 23, 2024

ok, it goes past the misc_init() now, but the ram usage didn't increase, as i see this on the serial monitor:

Start
Free RAM:44035
Misc init.. Done!
Free RAM:44035

from lvgl.

kisvegabor avatar kisvegabor commented on May 23, 2024

It's good if the RAM usage is not growing after init. All the variables are already allocated regardless to calling misc_init. Try not to #include <misc.h> and not call misc_init(). It should decrease the RAM usage.

Other question: Have you ever tried this Eclipse based IDE for Arduino? http://www.baeyens.it/eclipse/
To be hones I'm not so happy with the current solution because (just to mention one thing) I have to use relative include paths which makes the project messy.

from lvgl.

8bitbunny avatar 8bitbunny commented on May 23, 2024

never tried that IDE, so would have to try first.

from lvgl.

8bitbunny avatar 8bitbunny commented on May 23, 2024

well, this is funny, i tried to use a display driver with the hal files (disp.c + disp.h)
i got multiple errors, and now i am trying to write a bare bone driver in the disp files themselves.

still lots of errors, seems like littlevgl doesn't like cpp class usage in the code? (like spisettings class to adjust spi sleep, mode and such with one call)

this is quite dramatic on my side right now ^^;

error log output:


In file included from C:\Users\Ramon\Documents\Arduino\libraries\hal\src\disp\disp.c:12:0:

C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SPI/SPI.h:308:1: error: unknown type name 'class'
 class SPISettings {
 ^

C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SPI/SPI.h:308:19: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
 class SPISettings {
                   ^

C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SPI/SPI.h:406:1: error: unknown type name 'class'
 class SPIClass {

from lvgl.

kisvegabor avatar kisvegabor commented on May 23, 2024

The lvgl is still not modified like misc it won't work with Arduino now.

Please, give a try to suggested the Eclipse IDE. It seems very difficult to handle such a complex project like a GUI in Arduino IDE.

from lvgl.

kisvegabor avatar kisvegabor commented on May 23, 2024

Here is guide about how to add the Teensy board to this Eclipse IDE:
https://trippylighting.com/teensy-arduino-ect/arduino-eclipse-plugin/arduino-eclipse-ide-2-4-arduino-1-6-3-teensyduino-1-22-mac-windows-installation/

from lvgl.

kisvegabor avatar kisvegabor commented on May 23, 2024

Hi! Have you tried the Eclipse baded IDE? If yes what are your experiences?

from lvgl.

8bitbunny avatar 8bitbunny commented on May 23, 2024

from lvgl.

8bitbunny avatar 8bitbunny commented on May 23, 2024

Sorry, I can't find the motivation to move to a different IDE, seems I am too hooked on the Arduino IDE.. ^^;

Maaaybe will try to in the future.
I'm leaving it up to you to close the issue, or simply post updates regarding Arduino IDE support on this thread.
Offtopic: right now I am having the urge to make my own GUI library for the Arduino IDE again.

from lvgl.

kisvegabor avatar kisvegabor commented on May 23, 2024

Sad to hear this. Unfortunately the Arduino IDE compatibility could mean a step back for me because the lack of project properties.

If later you decide to use this library I can offer the already mentioned (Sloeber) Eclipse IDE.

Anyway, thank you for the contribution so far!

from lvgl.

8bitbunny avatar 8bitbunny commented on May 23, 2024

i installed the sloebel ide, imported the teensy core, and get errors in the teensy core with spiclass (which i need for using the SPI bus.)

this is really frustrating..

from lvgl.

kisvegabor avatar kisvegabor commented on May 23, 2024

Hi,

It is good to here that you have tried that IDE.

Were you able to solve the issue meanwhile?

from lvgl.

8bitbunny avatar 8bitbunny commented on May 23, 2024

Sadly not :(

from lvgl.

kisvegabor avatar kisvegabor commented on May 23, 2024

Hi Ramon,

Good news for Arduino! In the upcoming v5.0 release I modified the architecture the graphics library and now it is compatible with the default Arduino IDE. I was able to easily compile it with Teensy 3.6.

I cannot test it because I don't have Teensy hardware, but I hope you can do the testing! :) You need to write a disp_fill and disp_map function (see below)

Here is the library:
lvgl_arduino_lib.zip

An this is my sketch:

#include <lvgl.h>

void hal_init(void)
{
    /*Initialize the display*/
    lv_disp_drv_t disp_drv;
    disp_drv.fill = NULL;  /*function to fill an area:          void fill(int32_t x1, int32_t y1, int32_t x2, int32_t y2, lv_color_t color) */
    disp_drv.map = NULL;   /*function copy pixels to an area:   void map(int32_t x1, int32_t y1, int32_t x2, int32_t y2, lv_color_t *color_p) */
    disp_drv.copy = NULL;  /*ignored*/
    lv_disp_register(&disp_drv);

    /*Initialize the graphics library's tick*/
    /*In a Timer call lv_tich_handler() in every milliseconds*/
}

void setup() {
  lv_init();

  hal_init();

  lv_obj_t *label = lv_label_create(lv_scr_act(), NULL);
  lv_label_set_text(label, "Hello Arduino!");
  lv_obj_align(label, NULL, LV_ALIGN_CENTER, 0, 0);

}

void loop() {
  // put your main code here, to run repeatedly:

}

from lvgl.

8bitbunny avatar 8bitbunny commented on May 23, 2024

awesome, altho i see a problem, the arduino IDE has a macro called map, which is used in LV_HAL_DISP.H

from lvgl.

8bitbunny avatar 8bitbunny commented on May 23, 2024

hmm... i get errors when assigning my own function to the null pointers:

error: expected primary-expression before 'x1'
     disp_drv.map = disp_map(int32_t x1, int32_t y1, int32_t x2, int32_t y2, lv_color_t *color_p);

from lvgl.

kisvegabor avatar kisvegabor commented on May 23, 2024

I updated the library to not use 'map' name.
lvgl_ardion_lib2.zip

    /*Initialize the display*/
    lv_disp_drv_t disp_drv;
    disp_drv.fill_fp = NULL;  /*function to fill an area:          void fill(int32_t x1, int32_t y1, int32_t x2, int32_t y2, lv_color_t color) */
    disp_drv.map_fp = NULL;   /*function copy pixels to an area:   void map(int32_t x1, int32_t y1, int32_t x2, int32_t y2, lv_color_t *color_p) */
    disp_drv.blend_fp = NULL;  /*ignored*/
    lv_disp_register(&disp_drv);

You get the error because you have to initialize it like this:disp_drv.map_fp = disp_map So write onyl the function name.

from lvgl.

8bitbunny avatar 8bitbunny commented on May 23, 2024

ok, didn't know that

now i get this error(?)
error: 'lv_disp_drv_t {aka struct _disp_drv_t}' has no member named 'fill'

nevermind me, was being dumb

from lvgl.

kisvegabor avatar kisvegabor commented on May 23, 2024

Look the previous code example! To be consistent with map_fp I renamed fill to fill_fp

from lvgl.

8bitbunny avatar 8bitbunny commented on May 23, 2024

yeah, i figured it out, i am pretty sleepy right now

got it to compile, going to test soon

from lvgl.

8bitbunny avatar 8bitbunny commented on May 23, 2024

it compiled, but doesn't work with my ili9341, while it does work when i call the tft driver library (the non lvgl) functions directly, so it must be something inside of lvgl that refuses to run.

btw, i am running a tick timer for the lvgl as documented

edit: if usefull, my main arduino file


#include <lvgl.h>
#include <ILI9341_t3.h>
#include <SPI.h>

ILI9341_t3 tft = ILI9341_t3(9,10);

static IntervalTimer tick;

void fill_area(int32_t x1, int32_t y1, int32_t x2, int32_t y2, lv_color_t color) {
  uint16_t c = tft.color565(color.red, color.green, color.blue);
  tft.fillRect(x1,y1,x2,y2,c);
}
void disp_map(int32_t x1, int32_t y1, int32_t x2, int32_t y2, const lv_color_t *color_p) {
  uint16_t c;
  for (int y = y1; y < y2; y++) {
    for (int x = x1; x < x2; x++) {
      c = tft.color565(color_p->red, color_p->green, color_p->blue);
      tft.fillRect(x,y,x+1,y+1, c);
    }
  }
}

void hal_init(void) {
  /*Initialize the display*/
  lv_disp_drv_t disp_drv;
  disp_drv.fill_fp = fill_area;  /*function to fill an area:          void fill(int32_t x1, int32_t y1, int32_t x2, int32_t y2, lv_color_t color) */
  disp_drv.map_fp = disp_map;   /*function copy pixels to an area:   void map(int32_t x1, int32_t y1, int32_t x2, int32_t y2, lv_color_t *color_p) */
  lv_disp_register(&disp_drv);

  /*Initialize the graphics library's tick*/
  tft.begin();
  tft.setRotation(0);
  tft.fillRect(0,0,240,320,0x0000);
  delay(300);
  /*In a Timer call lv_tich_handler() in every milliseconds*/
}

void setup() {
  lv_init();
  delay(50);
  hal_init();
  tft.fillRect(0,0,240,320,0xffff);
  tick.begin(lv_tick_handler,1000);
  lv_obj_t *label = lv_label_create(lv_scr_act(), NULL);
  lv_label_set_text(label, "Hello!");
  lv_obj_align(label, NULL, LV_ALIGN_CENTER, 0, 0);
}

void loop() {
  // put your main code here, to run repeatedly:
  delay(1);
}

from lvgl.

8bitbunny avatar 8bitbunny commented on May 23, 2024

Just thinking out loud now: the teensy support package runs as multi thread within each yield call (which happens alot!)
This might be a problem with the lvgl scheduler to prevent it from executing?
Also, the MCU doesn't freeze up, I can draw in the loop what and whenever I want.

Also note that the lvgl doesn't just give no output on the screen, but also no change on the SPI bus to which the screen is connected to.

Yes I have configured the lvgl config file for correct screen resolution, also reduced buffer to 10 lines to fit on my teensy 3.2

from lvgl.

kisvegabor avatar kisvegabor commented on May 23, 2024

Oh sorry, I forget to add lv_task_handler() to the loop... You can also add a few millisecond delay after it and/or call your applicaton's functions.

from lvgl.

8bitbunny avatar 8bitbunny commented on May 23, 2024

it works, lvgl clears the screen to black, but.... no text is displayed :P

from lvgl.

kisvegabor avatar kisvegabor commented on May 23, 2024

Please show me your disp_map function.

from lvgl.

8bitbunny avatar 8bitbunny commented on May 23, 2024

void disp_map(int32_t x1, int32_t y1, int32_t x2, int32_t y2, const lv_color_t *color_p) {
  uint16_t c;
  tft.setAddrWindow(x1,y1,x2,y2);
  for (int y = y1; y <= y2; y++) {
    for (int x = x1; x <= x2; x++) {
      c = tft.color565(color_p->red, color_p->green, color_p->blue);
      tft.drawPixel(x,y,c);
    }
  }
}

from lvgl.

kisvegabor avatar kisvegabor commented on May 23, 2024

It seems you forget to increment color_p :)

c = tft.color565(color_p->red, color_p->green, color_p->blue);
tft.drawPixel(x,y,c);
color_p++;

from lvgl.

8bitbunny avatar 8bitbunny commented on May 23, 2024

this proves how newb i am with lvgl xD
thanks! it works as should, not i can dive into optimizing my disp_map function, as it is kinda slow.

issue can be closed :)

from lvgl.

kisvegabor avatar kisvegabor commented on May 23, 2024

Awesome ^^

Please keep in mind the dev-5.0 is under development and some changes may still happen until it is released.

from lvgl.

Pablo2048 avatar Pablo2048 commented on May 23, 2024

@ramonschepers Instead of .drawPixel try to use .pushColor - this may speed things up... ;-)

from lvgl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.