I copied over main.cpp and gifdec.c from the first version and it works, except the GIF doesn’t display. It says “render” and counts up, but it does not display a GIF.

EDIT: The gif I downloaded from you wasn’t working at all, and mine was too big. It works now, thanks @jpearman. How would I go about porting it to PROS?

@jpearman I tried copying the files to PROS and I got these errors in the header files

Compiling src/comp_controlled_code/opcontrol.cpp [WARNINGS]
In file included from src/comp_controlled_code/opcontrol.cpp:11:0:
./include/gifclass.h: In static member function 'static int vex::Gif::render(void*)':
./include/gifclass.h:33:29: error: 'vexSystemTimeGet' was not declared in this scope
               int32_t now = vexSystemTimeGet();
./include/gifclass.h:42:15: error: 'vexDisplayCopyRect' was not declared in this scope
               vexDisplayCopyRect( instance->_sx, instance->_sy, ex, ey, (uint32_t *)instance->_buffer, gif->width);
./include/gifclass.h:49:17: error: 'this_thread' has not been declared

Is there any way to fix this @theol0403 ?

so it is, must be a bug in VEXcode export

v5code-project-gifdemo_1 (1).zip (853.2 KB)

well, sure, you have to rewrite everything for PROS, those are functions in the VEXcode API you will need to replace.

How would I do that, and where would I find the documentation for it?

There will not be any instructions on how to do this but the PROS documentation is here.

This will be quite difficult and require a good understanding of how PROS and LVGL works, perhaps you need to start with something simpler.

Then how can I get a gif to display in PROS?

I have it working with VEXcode here

The class I wrote has a static function called render, this is where all the work happens after the gif image has been opened and memory allocated etc.

The render function more or less does this (in pseudo code)

while( the gif animation wants to keep looping )
    while( there is a new gif frame available ) {
        note the time so we can have accurate gif frame delays
        render the frame
        copy the frame to the display
        delay for the amount of time the gif frame specified

    rewind the gif animation back to the beginning

so you will need a PROS task that does something similar.
you will need to figure out how to copy the frame into the lvgl display buffer.

and you will probably need some help from a PROS expert to do all this.

I’m gonna try what @hotel said on discord and try to display it frame-by-frame. It’s only 37 frames so I should be good.

No, James’s solution is objectively better. You should try to use that if you can.

I thought I was doing that?

The solution James posted does sort of have you play frame by frame, but instead of extracting all the frames you need and needing to keep track of 37 separate files (which was what I suggested in discord before having read this thread), you can leverage the gif decoder library to perform said extraction for you at runtime.

Can you help me with that in a PM maybe? I would need help, like James said, but I don’t want to clutter up the forums.

After a while of trying to help @Sylvie do this on his own, it appears this is currently too ambitious of a project for him to do on his own.

I decided to just do the porting myself, as I have seen other people want this functionality for PROS.
I do not have a V5 Brain, so I am unable to test it.
It is unlikely I will have nailed it on the first try.
My largest concern is that I was not able to implement an equivalent of Brain.render, so I am not sure if the GIF will even begin executing.

Anyways, here is the repository with some install instructions.


I will give it a go tomorrow if I have time.
Brain.render is a wrapper for a C function, however, even if we were to use that it’s probably not going to play nicely with lvgl.

vexDisplayCopyRect( instance->_sx, instance->_sy, ex, ey, (uint32_t *)instance->_buffer, gif->width);

is also going to bypass lvgl, not sure if we can find an lvgl equivalent for that, I did see a canvas object but that may not be in the lvgl version PROS is using.

LVGL also uses the vexDisplayCopyRect function:

Didn’t you say here that LVGL won’t interfere with the display unless actively showing something?

I don’t understand what the purpose of Brain.render() is, or how LVGL does the equivalent, which is probably where I will need help.

Btw, there is discussion to decouple LVGL from the PROS kernel, which will allow users to completely uninstall LVGL. This won’t be implemented anytime soon though.

1 Like

Brain.render() is used to run the V5 graphics in a double buffered mode, that is, we draw everything into a back buffer and then copy to the screen buffer during screen vertical sync. It can reduce/remove flicker when the whole display is being constantly updated, it may not be necessary here.


It runs

Awesome, thanks for testing.
Now to implement it with the LVGL canvas so that it works with LVGL :thinking:.
I got the LVGL emulator set up so I can test.
But having a bit of trouble finding what I should do.
Maybe I have to register a custom decoder or something,

probably something like

lv_canvas_copy_buf(canvas, buffer_to_copy, x, y, width, height)

copy the raw gif frame to the canvas.