a bunch of gif stuff

This commit is contained in:
ary 2023-11-02 10:03:01 -04:00
parent 418b1fde1a
commit 8f9207d6c6
10 changed files with 564 additions and 356 deletions

Binary file not shown.

View File

@ -77,4 +77,6 @@
#include "pros/link.hpp"
#endif
#include "asset.h"
#endif // _PROS_API_H_

View File

@ -0,0 +1,88 @@
#pragma once
#ifndef _ASSET_H_
#define _ASSET_H_
#include "api.h"
#ifdef __cplusplus
extern "C" {
#endif
#ifndef V5_API_H_
typedef struct __attribute__((__packed__)) _v5_image {
uint16_t width;
uint16_t height;
uint32_t *data;
uint32_t *p;
} v5_image;
uint32_t vexImageBmpRead(const uint8_t *ibuf, v5_image *oBuf, uint32_t maxw, uint32_t maxh);
uint32_t vexImagePngRead(const uint8_t *ibuf, v5_image *oBuf, uint32_t maxw, uint32_t maxh, uint32_t ibuflen);
void vexDisplayCopyRect(int32_t x1, int32_t y1, int32_t x2, int32_t y2, uint32_t *pSrc, int32_t srcStride);
#endif
typedef struct __attribute__((__packed__)) _asset {
uint8_t *buf;
size_t size;
} asset;
#ifdef __cplusplus
}
#endif
#ifdef __cplusplus
#define ASSET(x) \
extern "C" { \
extern uint8_t _binary_static_##x##_start[], _binary_static_##x##_size[]; \
static asset x = {_binary_static_##x##_start, (size_t)_binary_static_##x##_size}; \
}
#else
#define ASSET(x) \
extern uint8_t _binary_static_##x##_start[], _binary_static_##x##_size[]; \
static asset x = {_binary_static_##x##_start, (size_t)_binary_static_##x##_size};
#endif
#define DECODE_PNG(var, asset, width, height) \
var.data = new uint32_t[width * height]; \
vexImagePngRead(asset.buf, &var, width, height, asset.size);
#define DECODE_BMP(var, asset, width, height) \
var.data = new uint32_t[width * height]; \
vexImageBmpRead(asset.buf, &var, width, height);
static void draw_image(int x, int y, v5_image *image) {
int x2 = x + image->width - 1;
int y2 = y + image->height - 1;
vexDisplayCopyRect(x, y, x2, y2, image->data, x2 - x + 1);
}
static void draw_image(lv_obj_t *canvas, int x, int y, v5_image *image) {
int start_x = x;
int start_y = y;
for (int i = 0; i < image->height; i++) {
for (int j = 0; j < image->width; j++) {
lv_color_t c = lv_color_hex(image->data[i * image->width + j]);
lv_color_t d = lv_canvas_get_px(canvas, start_x + j, start_y + i);
float a_float = c.alpha / 2.55 / 100;
float a_m_float = 1 - a_float;
d.red = d.red * a_m_float + c.red * a_float;
d.green = d.green * a_m_float + c.green * a_float;
d.blue = d.blue * a_m_float + c.blue * a_float;
lv_canvas_set_px(canvas, start_x + j, start_y + i, d);
}
}
}
#endif // _ASSET_H_

View File

@ -35,12 +35,11 @@
#define PROS_USE_LITERALS
#include "api.h"
#include "lemlib/api.hpp"
#include "arylib/api.hpp"
/**
* You should add more #includes here
*/
#include "okapi/api.hpp"
//#include "okapi/api.hpp"
//#include "pros/api_legacy.h"
/**

View File

@ -27,6 +27,142 @@
"user_files": [],
"version": "0.4.7"
},
"gif-pros-asset": {
"location": "C:\\Users\\cjans\\AppData\\Roaming\\PROS\\templates\\gif-pros-asset@1.0.1",
"metadata": {
"origin": "local"
},
"name": "gif-pros-asset",
"py/object": "pros.conductor.templates.local_template.LocalTemplate",
"supported_kernels": "^3.8.0",
"system_files": [
"include\\display\\lv_core\\lv_style.h",
"include\\pros\\optical.h",
"include\\pros\\llemu.hpp",
"include\\display\\lv_conf.h",
"include\\display\\lv_misc\\lv_templ.h",
"include\\display\\lv_objx\\lv_canvas.h",
"include\\display\\lvgl.h",
"include\\display\\lv_objx\\lv_lmeter.h",
"include\\display\\lv_misc\\lv_font.h",
"include\\display\\lv_objx\\lv_slider.h",
"include\\pros\\serial.hpp",
"include\\display\\lv_draw\\lv_draw_vbasic.h",
"include\\api.h",
"include\\display\\lv_core\\lv_group.h",
"include\\display\\lv_objx\\lv_spinbox.h",
"include\\display\\lv_draw\\lv_draw_triangle.h",
"include\\display\\lv_hal\\lv_hal_tick.h",
"include\\display\\lv_objx\\lv_calendar.h",
"include\\pros\\ext_adi.h",
"include\\display\\lv_draw\\lv_draw_rbasic.h",
"include\\display\\lv_draw\\lv_draw_arc.h",
"include\\display\\lv_objx\\lv_mbox.h",
"include\\display\\lv_objx\\lv_btn.h",
"include\\pros\\rtos.hpp",
"include\\display\\lv_version.h",
"include\\pros\\rtos.h",
"include\\gif-pros\\gifclass.hpp",
"include\\pros\\gps.hpp",
"include\\display\\lv_draw\\lv_draw_rect.h",
"include\\display\\lv_objx\\lv_label.h",
"include\\display\\lv_objx\\lv_preload.h",
"include\\display\\lv_themes\\lv_theme_default.h",
"include\\display\\lv_misc\\lv_ufs.h",
"include\\pros\\colors.h",
"include\\display\\lv_objx\\lv_win.h",
"include\\display\\lv_objx\\lv_gauge.h",
"include\\pros\\rotation.h",
"include\\display\\lv_themes\\lv_theme_zen.h",
"include\\display\\lv_themes\\lv_theme.h",
"include\\display\\lv_draw\\lv_draw_label.h",
"include\\display\\lv_objx\\lv_kb.h",
"include\\display\\lv_core\\lv_obj.h",
"include\\display\\lv_objx\\lv_line.h",
"include\\pros\\vision.h",
"include\\pros\\screen.hpp",
"include\\display\\lv_themes\\lv_theme_nemo.h",
"include\\display\\lv_core\\lv_refr.h",
"include\\display\\lv_objx\\lv_btnm.h",
"include\\display\\lv_objx\\lv_led.h",
"include\\display\\lv_draw\\lv_draw.h",
"include\\pros\\distance.h",
"include\\display\\lv_objx\\lv_arc.h",
"include\\display\\lv_misc\\lv_color.h",
"include\\display\\lv_misc\\lv_math.h",
"include\\display\\lv_objx\\lv_cont.h",
"include\\display\\lv_objx\\lv_objx_templ.h",
"include\\display\\lv_objx\\lv_imgbtn.h",
"include\\display\\lv_misc\\lv_mem.h",
"include\\gif-pros\\gifdec.h",
"include\\display\\lv_objx\\lv_bar.h",
"include\\display\\lv_fonts\\lv_font_builtin.h",
"include\\pros\\misc.h",
"include\\pros\\gps.h",
"include\\display\\lv_objx\\lv_roller.h",
"include\\pros\\apix.h",
"include\\display\\lv_themes\\lv_theme_templ.h",
"include\\pros\\imu.hpp",
"include\\display\\lv_misc\\lv_gc.h",
"include\\display\\lv_misc\\lv_txt.h",
"include\\display\\lv_core\\lv_lang.h",
"include\\display\\lv_objx\\lv_ddlist.h",
"include\\display\\lv_objx\\lv_table.h",
"include\\display\\lv_themes\\lv_theme_mono.h",
"include\\display\\lv_objx\\lv_list.h",
"include\\display\\lv_themes\\lv_theme_material.h",
"include\\pros\\rotation.hpp",
"include\\asset.h",
"include\\pros\\colors.hpp",
"include\\display\\lv_objx\\lv_cb.h",
"include\\display\\lv_misc\\lv_symbol_def.h",
"include\\display\\lv_objx\\lv_page.h",
"include\\display\\lv_core\\lv_indev.h",
"include\\pros\\vision.hpp",
"include\\pros\\api_legacy.h",
"include\\main.h",
"include\\pros\\adi.h",
"include\\display\\lv_misc\\lv_anim.h",
"firmware\\gif-pros-asset.a",
"include\\pros\\screen.h",
"include\\display\\lv_hal\\lv_hal_indev.h",
"include\\display\\lv_themes\\lv_theme_night.h",
"include\\display\\lv_draw\\lv_draw_img.h",
"include\\display\\lv_misc\\lv_log.h",
"include\\pros\\optical.hpp",
"include\\pros\\imu.h",
"include\\pros\\distance.hpp",
"include\\display\\lv_conf_checker.h",
"include\\pros\\motors.h",
"include\\pros\\llemu.h",
"include\\display\\lv_misc\\lv_area.h",
"include\\display\\lv_objx\\lv_sw.h",
"include\\pros\\link.h",
"include\\display\\lv_misc\\lv_task.h",
"include\\display\\lv_draw\\lv_draw_line.h",
"include\\pros\\link.hpp",
"include\\display\\lv_hal\\lv_hal_disp.h",
"include\\pros\\adi.hpp",
"include\\display\\lv_core\\lv_vdb.h",
"include\\pros\\serial.h",
"include\\display\\lv_objx\\lv_chart.h",
"include\\display\\lv_hal\\lv_hal.h",
"include\\display\\lv_objx\\lv_tileview.h",
"include\\display\\lv_themes\\lv_theme_alien.h",
"include\\pros\\error.h",
"include\\display\\lv_misc\\lv_ll.h",
"include\\display\\lv_objx\\lv_img.h",
"include\\display\\lv_objx\\lv_tabview.h",
"include\\pros\\misc.hpp",
"include\\display\\lv_objx\\lv_ta.h",
"include\\pros\\motors.hpp",
"include\\display\\lv_misc\\lv_circ.h",
"include\\display\\lv_misc\\lv_fs.h"
],
"target": "v5",
"user_files": [],
"version": "1.0.1"
},
"kernel": {
"location": "C:\\Users\\cjans\\AppData\\Roaming\\PROS\\templates\\kernel@3.8.0",
"metadata": {
@ -333,8 +469,8 @@
},
"upload_options": {
"description": "the scrim bot!",
"slot": 1,
"icon": "planet"
"icon": "planet",
"slot": 1
}
}
}

Binary file not shown.

Binary file not shown.

View File

@ -27,23 +27,6 @@
"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": {