diff --git a/RELENTLESS/gif-pros@2.1.1.zip b/RELENTLESS/gif-pros@2.1.1.zip new file mode 100644 index 0000000..66a088c Binary files /dev/null and b/RELENTLESS/gif-pros@2.1.1.zip differ diff --git a/RELENTLESS/include/gif-pros/gifclass.hpp b/RELENTLESS/include/gif-pros/gifclass.hpp new file mode 100644 index 0000000..09ecf27 --- /dev/null +++ b/RELENTLESS/include/gif-pros/gifclass.hpp @@ -0,0 +1,59 @@ +#pragma once +#include "main.h" +#include "gifdec.h" + +/** + * MIT License + * Copyright (c) 2019 Theo Lemay + * https://github.com/theol0403/gif-pros + */ + +class Gif { + +public: + + /** + * Construct the Gif class + * @param fname the gif filename on the SD card (prefixed with /usd/) + * @param parent the LVGL parent object + */ + Gif(const char* fname, lv_obj_t* parent); + + /** + * Destructs and cleans the Gif class + */ + ~Gif(); + + /** + * Deletes GIF and frees all allocated memory + */ + void clean(); + +private: + + gd_GIF* _gif = nullptr; // gif decoder object + void* _gifmem = nullptr; // gif file loaded from SD into memory + uint8_t* _buffer = nullptr; // decoder frame buffer + + lv_color_t* _cbuf = nullptr; // canvas buffer + lv_obj_t* _canvas = nullptr; // canvas object + + pros::task_t _task = nullptr; // render task + + /** + * Cleans and frees all allocated memory + */ + void _cleanup(); + + /** + * Render cycle, blocks until loop count exceeds gif loop count flag (if any) + */ + void _render(); + + /** + * Calls _render() + * @param arg Gif* + */ + static void _render_task(void* arg); + +}; \ No newline at end of file diff --git a/RELENTLESS/include/gif-pros/gifdec.h b/RELENTLESS/include/gif-pros/gifdec.h new file mode 100644 index 0000000..293801e --- /dev/null +++ b/RELENTLESS/include/gif-pros/gifdec.h @@ -0,0 +1,58 @@ +#ifndef GIFDEC_H +#define GIFDEC_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define BYTES_PER_PIXEL 4 + +typedef struct gd_Palette { + int size; + uint8_t colors[0x100 * 3]; +} gd_Palette; + +typedef struct gd_GCE { + uint16_t delay; + uint8_t tindex; + uint8_t disposal; + int input; + int transparency; +} gd_GCE; + +typedef struct gd_GIF { + FILE *fp; + off_t anim_start; + uint16_t width, height; + uint16_t depth; + uint16_t loop_count; + gd_GCE gce; + gd_Palette *palette; + gd_Palette lct, gct; + void (*plain_text)( + struct gd_GIF *gif, uint16_t tx, uint16_t ty, + uint16_t tw, uint16_t th, uint8_t cw, uint8_t ch, + uint8_t fg, uint8_t bg + ); + void (*comment)(struct gd_GIF *gif); + void (*application)(struct gd_GIF *gif, char id[8], char auth[3]); + uint16_t fx, fy, fw, fh; + uint8_t bgindex; + uint8_t *canvas, *frame; +} gd_GIF; + +gd_GIF *gd_open_gif(FILE *fp); +int gd_get_frame(gd_GIF *gif); +void gd_render_frame(gd_GIF *gif, uint8_t *buffer); +void gd_rewind(gd_GIF *gif); +void gd_close_gif(gd_GIF *gif); + +#ifdef __cplusplus +} +#endif + +#endif /* GIFDEC_H */ diff --git a/RELENTLESS/project.pros b/RELENTLESS/project.pros index acd6567..4bdcf75 100644 --- a/RELENTLESS/project.pros +++ b/RELENTLESS/project.pros @@ -27,6 +27,23 @@ "user_files": [], "version": "0.4.7" }, + "gif-pros": { + "location": "C:\\Users\\cjans\\AppData\\Roaming\\PROS\\templates\\gif-pros@2.1.1", + "metadata": { + "origin": "local" + }, + "name": "gif-pros", + "py/object": "pros.conductor.templates.local_template.LocalTemplate", + "supported_kernels": "^3.2.0", + "system_files": [ + "include\\gif-pros\\gifdec.h", + "firmware\\gif-pros.a", + "include\\gif-pros\\gifclass.hpp" + ], + "target": "v5", + "user_files": [], + "version": "2.1.1" + }, "kernel": { "location": "C:\\Users\\cjans\\AppData\\Roaming\\PROS\\templates\\kernel@3.8.0", "metadata": {