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
this_thread::sleep_for(delay);
^~~~~~~~~~~
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.
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.
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.
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.
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.
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.
Awesome, thanks for testing.
Now to implement it with the LVGL canvas so that it works with LVGL .
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,