implement gif pros
This commit is contained in:
parent
330f6b5f4b
commit
b5fa4a8331
BIN
RELENTLESS/gif-pros@2.1.1.zip
Normal file
BIN
RELENTLESS/gif-pros@2.1.1.zip
Normal file
Binary file not shown.
59
RELENTLESS/include/gif-pros/gifclass.hpp
Normal file
59
RELENTLESS/include/gif-pros/gifclass.hpp
Normal file
@ -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);
|
||||||
|
|
||||||
|
};
|
||||||
58
RELENTLESS/include/gif-pros/gifdec.h
Normal file
58
RELENTLESS/include/gif-pros/gifdec.h
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
#ifndef GIFDEC_H
|
||||||
|
#define GIFDEC_H
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#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 */
|
||||||
@ -27,6 +27,23 @@
|
|||||||
"user_files": [],
|
"user_files": [],
|
||||||
"version": "0.4.7"
|
"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": {
|
"kernel": {
|
||||||
"location": "C:\\Users\\cjans\\AppData\\Roaming\\PROS\\templates\\kernel@3.8.0",
|
"location": "C:\\Users\\cjans\\AppData\\Roaming\\PROS\\templates\\kernel@3.8.0",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user