Files
lucky-cat/components/platform/src/lcd_direct_assets.c
T

401 lines
12 KiB
C

#include "lcd_direct_assets.h"
#include <string.h>
#define LCD_ASSET_BASE_PATH "/littlefs/lcd/"
static const lcd_direct_image_t s_default_image = {
.path = LCD_ASSET_BASE_PATH "buyunqian1.png",
};
static const lcd_direct_image_t s_basic_face_frames[] = {
{
.path = LCD_ASSET_BASE_PATH "jichubiaoqing0.png",
},
{
.path = LCD_ASSET_BASE_PATH "jichubiaoqing1.png",
},
{
.path = LCD_ASSET_BASE_PATH "jichubiaoqing2.png",
},
};
static const lcd_direct_image_t s_listening_frames[] = {
{.path = LCD_ASSET_BASE_PATH "listening0.png"},
{.path = LCD_ASSET_BASE_PATH "listening1.png"},
{.path = LCD_ASSET_BASE_PATH "listening2.png"},
};
static const lcd_direct_image_t s_muyu_frames[] = {
{
.path = LCD_ASSET_BASE_PATH "muyu0.png",
},
{
.path = LCD_ASSET_BASE_PATH "muyu1.png",
},
{
.path = LCD_ASSET_BASE_PATH "muyu2.png",
},
};
static const lcd_direct_image_t s_chouqian_qianzhi_frames[] = {
{
.path = LCD_ASSET_BASE_PATH "chouqian_qianzhi0.png",
},
{
.path = LCD_ASSET_BASE_PATH "chouqian_qianzhi1.png",
},
{
.path = LCD_ASSET_BASE_PATH "chouqian_qianzhi2.png",
},
};
static const lcd_direct_image_t s_chouqian_buyun_frames[] = {
{
.path = LCD_ASSET_BASE_PATH "chouqian_buyun0.png",
},
{
.path = LCD_ASSET_BASE_PATH "chouqian_buyun1.png",
},
{
.path = LCD_ASSET_BASE_PATH "chouqian_buyun2.png",
},
};
static const lcd_direct_image_t s_chouqian_heping_frames[] = {
{
.path = LCD_ASSET_BASE_PATH "chouqian_heping0.png",
},
{
.path = LCD_ASSET_BASE_PATH "chouqian_heping1.png",
},
{
.path = LCD_ASSET_BASE_PATH "chouqian_heping2.png",
},
};
static const lcd_direct_image_t s_chouqian_shangshang_frames[] = {
{
.path = LCD_ASSET_BASE_PATH "chouqian_shangshang0.png",
},
{
.path = LCD_ASSET_BASE_PATH "chouqian_shangshang1.png",
},
{
.path = LCD_ASSET_BASE_PATH "chouqian_shangshang2.png",
},
};
static const lcd_direct_image_t s_chouqian_xiaoji_frames[] = {
{
.path = LCD_ASSET_BASE_PATH "chouqian_xiaoji0.png",
},
{
.path = LCD_ASSET_BASE_PATH "chouqian_xiaoji1.png",
},
{
.path = LCD_ASSET_BASE_PATH "chouqian_xiaoji2.png",
},
};
static const lcd_direct_image_t s_chouqian_zhongshang_frames[] = {
{
.path = LCD_ASSET_BASE_PATH "chouqian_zhongshang0.png",
},
{
.path = LCD_ASSET_BASE_PATH "chouqian_zhongshang1.png",
},
{
.path = LCD_ASSET_BASE_PATH "chouqian_zhongshang2.png",
},
};
static const lcd_direct_image_t s_qianzhiwuxing_frames[] = {
{
.path = LCD_ASSET_BASE_PATH "qianzhiwuxing0.png",
},
};
static const lcd_direct_image_t s_shui_frames[] = {
{
.path = LCD_ASSET_BASE_PATH "shui0.png",
},
{
.path = LCD_ASSET_BASE_PATH "shui1.png",
},
};
static const lcd_direct_image_t s_mu_frames[] = {
{
.path = LCD_ASSET_BASE_PATH "mu0.png",
},
{
.path = LCD_ASSET_BASE_PATH "mu1.png",
},
};
static const lcd_direct_image_t s_huo_frames[] = {
{
.path = LCD_ASSET_BASE_PATH "huo0.png",
},
{
.path = LCD_ASSET_BASE_PATH "huo1.png",
},
};
static const lcd_direct_image_t s_tu_frames[] = {
{
.path = LCD_ASSET_BASE_PATH "tu0.png",
},
{
.path = LCD_ASSET_BASE_PATH "tu1.png",
},
};
static const lcd_direct_image_t s_jin_frames[] = {
{
.path = LCD_ASSET_BASE_PATH "jin0.png",
},
{
.path = LCD_ASSET_BASE_PATH "jin1.png",
},
};
static const lcd_direct_image_t s_spin_frames[] = {
{.path = LCD_ASSET_BASE_PATH "spin0.png"},
};
static const lcd_direct_image_t s_south_frames[] = {
{.path = LCD_ASSET_BASE_PATH "south0.png"},
};
static const lcd_direct_image_t s_southwest_frames[] = {
{.path = LCD_ASSET_BASE_PATH "southwest0.png"},
};
static const lcd_direct_image_t s_west_frames[] = {
{.path = LCD_ASSET_BASE_PATH "west0.png"},
};
static const lcd_direct_image_t s_northwest_frames[] = {
{.path = LCD_ASSET_BASE_PATH "northwest0.png"},
};
static const lcd_direct_image_t s_north_frames[] = {
{.path = LCD_ASSET_BASE_PATH "north0.png"},
};
static const lcd_direct_image_t s_northeast_frames[] = {
{.path = LCD_ASSET_BASE_PATH "northeast0.png"},
};
static const lcd_direct_image_t s_east_frames[] = {
{.path = LCD_ASSET_BASE_PATH "east0.png"},
};
static const lcd_direct_image_t s_southeast_frames[] = {
{.path = LCD_ASSET_BASE_PATH "southeast0.png"},
};
static const lcd_direct_icon_t s_wuxing_icons[] = {
{
.path = LCD_ASSET_BASE_PATH "icon_shui0.png",
},
{
.path = LCD_ASSET_BASE_PATH "icon_mu0.png",
},
{
.path = LCD_ASSET_BASE_PATH "icon_huo0.png",
},
{
.path = LCD_ASSET_BASE_PATH "icon_tu0.png",
},
{
.path = LCD_ASSET_BASE_PATH "icon_jin0.png",
},
};
static const lcd_direct_image_t *lcd_direct_frame_from_array(const lcd_direct_image_t *frames,
size_t frame_count,
uint8_t frame_index)
{
if (frame_index >= frame_count) {
return NULL;
}
return &frames[frame_index];
}
const lcd_direct_image_t *lcd_direct_default_image(void)
{
return &s_default_image;
}
const lcd_direct_image_t *lcd_direct_asset_frame(const char *asset_dir, uint8_t frame_index)
{
if (asset_dir == NULL) {
return NULL;
}
if (strcmp(asset_dir, "jichubiaoqing") == 0) {
return lcd_direct_frame_from_array(s_basic_face_frames,
sizeof(s_basic_face_frames) / sizeof(s_basic_face_frames[0]),
frame_index);
}
if (strcmp(asset_dir, "listening") == 0) {
return lcd_direct_frame_from_array(s_listening_frames,
sizeof(s_listening_frames) / sizeof(s_listening_frames[0]),
frame_index);
}
if (strcmp(asset_dir, "muyu") == 0) {
return lcd_direct_frame_from_array(s_muyu_frames,
sizeof(s_muyu_frames) / sizeof(s_muyu_frames[0]),
frame_index);
}
if (strcmp(asset_dir, "chouqian_qianzhi") == 0) {
return lcd_direct_frame_from_array(s_chouqian_qianzhi_frames,
sizeof(s_chouqian_qianzhi_frames) / sizeof(s_chouqian_qianzhi_frames[0]),
frame_index);
}
if (strcmp(asset_dir, "chouqian_buyun") == 0) {
return lcd_direct_frame_from_array(s_chouqian_buyun_frames,
sizeof(s_chouqian_buyun_frames) / sizeof(s_chouqian_buyun_frames[0]),
frame_index);
}
if (strcmp(asset_dir, "chouqian_heping") == 0) {
return lcd_direct_frame_from_array(s_chouqian_heping_frames,
sizeof(s_chouqian_heping_frames) / sizeof(s_chouqian_heping_frames[0]),
frame_index);
}
if (strcmp(asset_dir, "chouqian_shangshang") == 0) {
return lcd_direct_frame_from_array(s_chouqian_shangshang_frames,
sizeof(s_chouqian_shangshang_frames) / sizeof(s_chouqian_shangshang_frames[0]),
frame_index);
}
if (strcmp(asset_dir, "chouqian_xiaoji") == 0) {
return lcd_direct_frame_from_array(s_chouqian_xiaoji_frames,
sizeof(s_chouqian_xiaoji_frames) / sizeof(s_chouqian_xiaoji_frames[0]),
frame_index);
}
if (strcmp(asset_dir, "chouqian_zhongshang") == 0) {
return lcd_direct_frame_from_array(s_chouqian_zhongshang_frames,
sizeof(s_chouqian_zhongshang_frames) / sizeof(s_chouqian_zhongshang_frames[0]),
frame_index);
}
if (strcmp(asset_dir, "qianzhiwuxing") == 0) {
return lcd_direct_frame_from_array(s_qianzhiwuxing_frames,
sizeof(s_qianzhiwuxing_frames) / sizeof(s_qianzhiwuxing_frames[0]),
frame_index);
}
if (strcmp(asset_dir, "shui") == 0) {
return lcd_direct_frame_from_array(s_shui_frames,
sizeof(s_shui_frames) / sizeof(s_shui_frames[0]),
frame_index);
}
if (strcmp(asset_dir, "mu") == 0) {
return lcd_direct_frame_from_array(s_mu_frames,
sizeof(s_mu_frames) / sizeof(s_mu_frames[0]),
frame_index);
}
if (strcmp(asset_dir, "huo") == 0) {
return lcd_direct_frame_from_array(s_huo_frames,
sizeof(s_huo_frames) / sizeof(s_huo_frames[0]),
frame_index);
}
if (strcmp(asset_dir, "tu") == 0) {
return lcd_direct_frame_from_array(s_tu_frames,
sizeof(s_tu_frames) / sizeof(s_tu_frames[0]),
frame_index);
}
if (strcmp(asset_dir, "jin") == 0) {
return lcd_direct_frame_from_array(s_jin_frames,
sizeof(s_jin_frames) / sizeof(s_jin_frames[0]),
frame_index);
}
if (strcmp(asset_dir, "spin") == 0) {
return lcd_direct_frame_from_array(s_spin_frames,
sizeof(s_spin_frames) / sizeof(s_spin_frames[0]),
frame_index);
}
if (strcmp(asset_dir, "south") == 0) {
return lcd_direct_frame_from_array(s_south_frames,
sizeof(s_south_frames) / sizeof(s_south_frames[0]),
frame_index);
}
if (strcmp(asset_dir, "southwest") == 0) {
return lcd_direct_frame_from_array(s_southwest_frames,
sizeof(s_southwest_frames) / sizeof(s_southwest_frames[0]),
frame_index);
}
if (strcmp(asset_dir, "west") == 0) {
return lcd_direct_frame_from_array(s_west_frames,
sizeof(s_west_frames) / sizeof(s_west_frames[0]),
frame_index);
}
if (strcmp(asset_dir, "northwest") == 0) {
return lcd_direct_frame_from_array(s_northwest_frames,
sizeof(s_northwest_frames) / sizeof(s_northwest_frames[0]),
frame_index);
}
if (strcmp(asset_dir, "north") == 0) {
return lcd_direct_frame_from_array(s_north_frames,
sizeof(s_north_frames) / sizeof(s_north_frames[0]),
frame_index);
}
if (strcmp(asset_dir, "northeast") == 0) {
return lcd_direct_frame_from_array(s_northeast_frames,
sizeof(s_northeast_frames) / sizeof(s_northeast_frames[0]),
frame_index);
}
if (strcmp(asset_dir, "east") == 0) {
return lcd_direct_frame_from_array(s_east_frames,
sizeof(s_east_frames) / sizeof(s_east_frames[0]),
frame_index);
}
if (strcmp(asset_dir, "southeast") == 0) {
return lcd_direct_frame_from_array(s_southeast_frames,
sizeof(s_southeast_frames) / sizeof(s_southeast_frames[0]),
frame_index);
}
return NULL;
}
const lcd_direct_icon_t *lcd_direct_icon(uint16_t icon_id)
{
if (icon_id >= (sizeof(s_wuxing_icons) / sizeof(s_wuxing_icons[0]))) {
return NULL;
}
return &s_wuxing_icons[icon_id];
}
const lcd_direct_icon_draw_t *lcd_direct_default_icon_sequence(size_t *out_count)
{
if (out_count != NULL) {
*out_count = 0;
}
return NULL;
}