This repository has been archived by the owner on May 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Install gif-pros and update programming skills
- Loading branch information
1 parent
6c60863
commit f2b3788
Showing
7 changed files
with
159 additions
and
28 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters