add misc as submodule
This commit is contained in:
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
[submodule "misc"]
|
||||
path = misc
|
||||
url = ./misc/
|
||||
@@ -13,11 +13,11 @@
|
||||
#include "lv_draw.h"
|
||||
#include "lv_draw_rbasic.h"
|
||||
#include "lv_draw_vbasic.h"
|
||||
#include "misc/gfx/text.h"
|
||||
#include "misc/gfx/circ.h"
|
||||
#include "misc/fs/fsint.h"
|
||||
#include "misc/math/math_base.h"
|
||||
#include "misc/fs/ufs/ufs.h"
|
||||
#include "lvgl/misc/gfx/text.h"
|
||||
#include "lvgl/misc/gfx/circ.h"
|
||||
#include "lvgl/misc/fs/fsint.h"
|
||||
#include "lvgl/misc/math/math_base.h"
|
||||
#include "lvgl/misc/fs/ufs/ufs.h"
|
||||
#include "../lv_objx/lv_img.h"
|
||||
|
||||
/*********************
|
||||
|
||||
@@ -14,7 +14,7 @@ extern "C" {
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "misc_conf.h"
|
||||
#include "misc/gfx/text.h"
|
||||
#include "lvgl/misc/gfx/text.h"
|
||||
#include "../lv_obj/lv_style.h"
|
||||
|
||||
/*********************
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "../lv_hal/lv_hal_disp.h"
|
||||
#include "lv_draw_rbasic.h"
|
||||
#include "lv_conf.h"
|
||||
#include "misc/gfx/font.h"
|
||||
#include "lvgl/misc/gfx/font.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
|
||||
@@ -13,9 +13,9 @@ extern "C" {
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "misc/gfx/color.h"
|
||||
#include "misc/gfx/area.h"
|
||||
#include "misc/gfx/font.h"
|
||||
#include "lvgl/misc/gfx/color.h"
|
||||
#include "lvgl/misc/gfx/area.h"
|
||||
#include "lvgl/misc/gfx/font.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
|
||||
@@ -10,9 +10,9 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "../lv_hal/lv_hal_disp.h"
|
||||
#include "misc/gfx/area.h"
|
||||
#include "misc/gfx/font.h"
|
||||
#include "misc/gfx/color.h"
|
||||
#include "lvgl/misc/gfx/area.h"
|
||||
#include "lvgl/misc/gfx/font.h"
|
||||
#include "lvgl/misc/gfx/color.h"
|
||||
|
||||
#if LV_VDB_SIZE != 0
|
||||
|
||||
|
||||
@@ -17,9 +17,9 @@ extern "C" {
|
||||
|
||||
#if LV_VDB_SIZE != 0
|
||||
|
||||
#include "misc/gfx/color.h"
|
||||
#include "misc/gfx/area.h"
|
||||
#include "misc/gfx/font.h"
|
||||
#include "lvgl/misc/gfx/color.h"
|
||||
#include "lvgl/misc/gfx/area.h"
|
||||
#include "lvgl/misc/gfx/font.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include "../lv_hal/lv_hal_disp.h"
|
||||
#include "misc/mem/dyn_mem.h"
|
||||
#include "lvgl/misc/mem/dyn_mem.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
|
||||
@@ -18,7 +18,7 @@ extern "C" {
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "lv_hal.h"
|
||||
#include "misc/gfx/color.h"
|
||||
#include "lvgl/misc/gfx/color.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "../lv_hal/lv_hal_indev.h"
|
||||
#include "misc/mem/linked_list.h"
|
||||
#include "lvgl/misc/mem/linked_list.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
|
||||
@@ -18,7 +18,7 @@ extern "C" {
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include "lv_hal.h"
|
||||
#include "misc/gfx/area.h"
|
||||
#include "lvgl/misc/gfx/area.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
|
||||
@@ -11,8 +11,8 @@
|
||||
|
||||
#include "../lv_hal/lv_hal_tick.h"
|
||||
#include "../lv_obj/lv_group.h"
|
||||
#include "misc/os/ptask.h"
|
||||
#include "misc/math/math_base.h"
|
||||
#include "lvgl/misc/os/ptask.h"
|
||||
#include "lvgl/misc/math/math_base.h"
|
||||
#include "../lv_draw/lv_draw_rbasic.h"
|
||||
#include "lv_obj.h"
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#include "../lv_draw/lv_draw_rbasic.h"
|
||||
#include "lv_refr.h"
|
||||
#include "lv_group.h"
|
||||
#include "misc/gfx/anim.h"
|
||||
#include "lvgl/misc/gfx/anim.h"
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
@@ -60,6 +60,9 @@ static ll_dsc_t scr_ll; /*Linked list of screens*/
|
||||
*/
|
||||
void lv_init(void)
|
||||
{
|
||||
/*Initialize misc. library. (Protected against re-initialization)*/
|
||||
misc_init();
|
||||
|
||||
/*Clear the screen*/
|
||||
area_t scr_area;
|
||||
area_set(&scr_area, 0, 0, LV_HOR_RES, LV_VER_RES);
|
||||
|
||||
@@ -16,10 +16,10 @@ extern "C" {
|
||||
#include "lv_conf.h"
|
||||
#include <stddef.h>
|
||||
#include <stdbool.h>
|
||||
#include "misc/gfx/area.h"
|
||||
#include "misc/mem/dyn_mem.h"
|
||||
#include "misc/mem/linked_list.h"
|
||||
#include "misc/gfx/color.h"
|
||||
#include "lvgl/misc/gfx/area.h"
|
||||
#include "lvgl/misc/mem/dyn_mem.h"
|
||||
#include "lvgl/misc/mem/linked_list.h"
|
||||
#include "lvgl/misc/gfx/color.h"
|
||||
#include "lv_style.h"
|
||||
|
||||
/*********************
|
||||
|
||||
@@ -11,8 +11,8 @@
|
||||
#include <stddef.h>
|
||||
#include "lv_refr.h"
|
||||
#include "lv_vdb.h"
|
||||
#include "misc/os/ptask.h"
|
||||
#include "misc/mem/fifo.h"
|
||||
#include "lvgl/misc/os/ptask.h"
|
||||
#include "lvgl/misc/mem/fifo.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "lv_conf.h"
|
||||
#include "lv_style.h"
|
||||
#include "lv_obj.h"
|
||||
#include "misc/mem/dyn_mem.h"
|
||||
#include "lvgl/misc/mem/dyn_mem.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
|
||||
@@ -14,10 +14,10 @@ extern "C" {
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include <stdbool.h>
|
||||
#include "misc/gfx/color.h"
|
||||
#include "misc/gfx/area.h"
|
||||
#include "misc/gfx/font.h"
|
||||
#include "misc/gfx/anim.h"
|
||||
#include "lvgl/misc/gfx/color.h"
|
||||
#include "lvgl/misc/gfx/area.h"
|
||||
#include "lvgl/misc/gfx/font.h"
|
||||
#include "lvgl/misc/gfx/anim.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
|
||||
@@ -17,8 +17,8 @@ extern "C" {
|
||||
|
||||
#if LV_VDB_SIZE != 0
|
||||
|
||||
#include "misc/gfx/color.h"
|
||||
#include "misc/gfx/area.h"
|
||||
#include "lvgl/misc/gfx/color.h"
|
||||
#include "lvgl/misc/gfx/area.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#include "lv_bar.h"
|
||||
#include "../lv_draw/lv_draw.h"
|
||||
#include "../lv_themes/lv_theme.h"
|
||||
#include "misc/gfx/anim.h"
|
||||
#include "lvgl/misc/gfx/anim.h"
|
||||
#include <stdio.h>
|
||||
|
||||
/*********************
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
#include "../lv_obj/lv_group.h"
|
||||
#include "../lv_draw/lv_draw.h"
|
||||
#include "../lv_themes/lv_theme.h"
|
||||
#include "misc/gfx/area.h"
|
||||
#include "misc/gfx/color.h"
|
||||
#include "lvgl/misc/gfx/area.h"
|
||||
#include "lvgl/misc/gfx/color.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#include "../lv_draw/lv_draw.h"
|
||||
#include "../lv_obj/lv_refr.h"
|
||||
#include "../lv_themes/lv_theme.h"
|
||||
#include "misc/gfx/text.h"
|
||||
#include "lvgl/misc/gfx/text.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
@@ -384,9 +384,12 @@ static bool lv_btnm_design(lv_obj_t * btnm, const area_t * mask, lv_design_mode_
|
||||
lv_style_t * btn_style;
|
||||
|
||||
area_t area_btnm;
|
||||
lv_obj_get_coords(btnm, &area_btnm);
|
||||
|
||||
area_t area_tmp;
|
||||
cord_t btn_w;
|
||||
cord_t btn_h;
|
||||
bool border_mod = false;
|
||||
|
||||
uint16_t btn_i = 0;
|
||||
uint16_t txt_i = 0;
|
||||
@@ -397,8 +400,6 @@ static bool lv_btnm_design(lv_obj_t * btnm, const area_t * mask, lv_design_mode_
|
||||
/*Skip hidden buttons*/
|
||||
if(button_is_hidden(ext->map_p[txt_i])) continue;
|
||||
|
||||
lv_obj_get_coords(btnm, &area_btnm);
|
||||
|
||||
area_cpy(&area_tmp, &ext->button_areas[btn_i]);
|
||||
area_tmp.x1 += area_btnm.x1;
|
||||
area_tmp.y1 += area_btnm.y1;
|
||||
@@ -414,7 +415,22 @@ static bool lv_btnm_design(lv_obj_t * btnm, const area_t * mask, lv_design_mode_
|
||||
else if(btn_i == ext->btn_id_pr && btn_i != ext->btn_id_tgl) btn_style = lv_btnm_get_style(btnm, LV_BTNM_STYLE_BTN_PR);
|
||||
else if(btn_i != ext->btn_id_pr && btn_i == ext->btn_id_tgl) btn_style = lv_btnm_get_style(btnm, LV_BTNM_STYLE_BTN_TGL_REL);
|
||||
else if(btn_i == ext->btn_id_pr && btn_i == ext->btn_id_tgl) btn_style = lv_btnm_get_style(btnm, LV_BTNM_STYLE_BTN_TGL_PR);
|
||||
lv_draw_rect(&area_tmp, mask, btn_style);
|
||||
|
||||
/*On the right buttons clear the border if only right borders are drawn*/
|
||||
if(ext->map_p[txt_i + 1][0] == '\0' || ext->map_p[txt_i + 1][0] == '\n') {
|
||||
if(btn_style->body.border.part == LV_BORDER_RIGHT) {
|
||||
btn_style->body.border.part = LV_BORDER_NONE;
|
||||
border_mod = true;
|
||||
}
|
||||
}
|
||||
|
||||
lv_draw_rect(&area_tmp, mask, btn_style);
|
||||
|
||||
if(border_mod) {
|
||||
border_mod = false;
|
||||
btn_style->body.border.part = LV_BORDER_RIGHT;
|
||||
}
|
||||
|
||||
|
||||
/*Calculate the size of the text*/
|
||||
const font_t * font = btn_style->text.font;
|
||||
|
||||
@@ -18,10 +18,10 @@
|
||||
#include "../lv_draw/lv_draw.h"
|
||||
#include "../lv_draw/lv_draw_vbasic.h"
|
||||
#include "../lv_themes/lv_theme.h"
|
||||
#include "misc/gfx/area.h"
|
||||
#include "lvgl/misc/gfx/area.h"
|
||||
|
||||
#include "misc/gfx/color.h"
|
||||
#include "misc/math/math_base.h"
|
||||
#include "lvgl/misc/gfx/color.h"
|
||||
#include "lvgl/misc/math/math_base.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
#include "../lv_obj/lv_group.h"
|
||||
#include "../lv_obj/lv_indev.h"
|
||||
#include "../lv_themes/lv_theme.h"
|
||||
#include "misc/gfx/fonts/symbol_def.h"
|
||||
#include "misc/gfx/anim.h"
|
||||
#include "lvgl/misc/gfx/fonts/symbol_def.h"
|
||||
#include "lvgl/misc/gfx/anim.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
|
||||
@@ -13,9 +13,9 @@
|
||||
#include "lv_gauge.h"
|
||||
#include "../lv_draw/lv_draw.h"
|
||||
#include "../lv_themes/lv_theme.h"
|
||||
#include "misc/gfx/text.h"
|
||||
#include "misc/math/trigo.h"
|
||||
#include "misc/math/math_base.h"
|
||||
#include "lvgl/misc/gfx/text.h"
|
||||
#include "lvgl/misc/math/trigo.h"
|
||||
#include "lvgl/misc/math/math_base.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
@@ -13,9 +13,9 @@
|
||||
#include "lv_img.h"
|
||||
#include "../lv_draw/lv_draw.h"
|
||||
#include "../lv_themes/lv_theme.h"
|
||||
#include "misc/fs/fsint.h"
|
||||
#include "misc/fs/ufs/ufs.h"
|
||||
#include "misc/gfx/text.h"
|
||||
#include "lvgl/misc/fs/fsint.h"
|
||||
#include "lvgl/misc/fs/ufs/ufs.h"
|
||||
#include "lvgl/misc/gfx/text.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
|
||||
@@ -18,7 +18,7 @@ extern "C" {
|
||||
#if USE_LV_IMG != 0 && USE_FSINT != 0
|
||||
|
||||
#include "../lv_obj/lv_obj.h"
|
||||
#include "misc/fs/fsint.h"
|
||||
#include "lvgl/misc/fs/fsint.h"
|
||||
|
||||
#ifndef LV_IMG_ENABLE_SYMBOLS
|
||||
#define LV_IMG_ENABLE_SYMBOLS 0
|
||||
@@ -26,7 +26,7 @@ extern "C" {
|
||||
|
||||
#if LV_IMG_ENABLE_SYMBOLS != 0
|
||||
#include "lv_label.h"
|
||||
#include "misc/gfx/fonts/symbol_def.h"
|
||||
#include "lvgl/misc/gfx/fonts/symbol_def.h"
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
|
||||
@@ -13,11 +13,11 @@
|
||||
#include "../lv_obj/lv_obj.h"
|
||||
#include "../lv_obj/lv_group.h"
|
||||
#include "../lv_draw/lv_draw.h"
|
||||
#include "misc/gfx/color.h"
|
||||
#include "misc/gfx/text.h"
|
||||
#include "misc/math/math_base.h"
|
||||
#include "misc/gfx/text.h"
|
||||
#include "misc/gfx/anim.h"
|
||||
#include "lvgl/misc/gfx/color.h"
|
||||
#include "lvgl/misc/gfx/text.h"
|
||||
#include "lvgl/misc/math/math_base.h"
|
||||
#include "lvgl/misc/gfx/text.h"
|
||||
#include "lvgl/misc/gfx/anim.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
|
||||
@@ -17,9 +17,9 @@ extern "C" {
|
||||
#if USE_LV_LABEL != 0
|
||||
|
||||
#include "../lv_obj/lv_obj.h"
|
||||
#include "misc/gfx/font.h"
|
||||
#include "misc/gfx/text.h"
|
||||
#include "misc/gfx/fonts/symbol_def.h"
|
||||
#include "lvgl/misc/gfx/font.h"
|
||||
#include "lvgl/misc/gfx/text.h"
|
||||
#include "lvgl/misc/gfx/fonts/symbol_def.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#if USE_LV_LINE != 0
|
||||
#include "lv_line.h"
|
||||
#include "../lv_draw/lv_draw.h"
|
||||
#include "misc/math/math_base.h"
|
||||
#include "lvgl/misc/math/math_base.h"
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
#include "lv_list.h"
|
||||
#include "../lv_obj/lv_group.h"
|
||||
#include "../lv_themes/lv_theme.h"
|
||||
#include "misc/gfx/anim.h"
|
||||
#include "misc/math/math_base.h"
|
||||
#include "lvgl/misc/gfx/anim.h"
|
||||
#include "lvgl/misc/math/math_base.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include "../lv_draw/lv_draw.h"
|
||||
#include "../lv_themes/lv_theme.h"
|
||||
#include "../lv_obj/lv_group.h"
|
||||
#include "misc/math/trigo.h"
|
||||
#include "lvgl/misc/math/trigo.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
#include "lv_mbox.h"
|
||||
#include "../lv_obj/lv_group.h"
|
||||
#include "../lv_themes/lv_theme.h"
|
||||
#include "misc/gfx/anim.h"
|
||||
#include "misc/math/math_base.h"
|
||||
#include "lvgl/misc/gfx/anim.h"
|
||||
#include "lvgl/misc/math/math_base.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
|
||||
@@ -9,13 +9,13 @@
|
||||
#include "lv_conf.h"
|
||||
#if USE_LV_PAGE != 0
|
||||
|
||||
#include "misc/math/math_base.h"
|
||||
#include "lvgl/misc/math/math_base.h"
|
||||
#include "../lv_obj/lv_group.h"
|
||||
#include "../lv_objx/lv_page.h"
|
||||
#include "../lv_draw/lv_draw.h"
|
||||
#include "../lv_themes/lv_theme.h"
|
||||
#include "../lv_obj/lv_refr.h"
|
||||
#include "misc/gfx/anim.h"
|
||||
#include "lvgl/misc/gfx/anim.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
|
||||
@@ -226,6 +226,7 @@ static bool lv_roller_design(lv_obj_t * roller, const area_t * mask, lv_design_m
|
||||
lv_style_t new_style;
|
||||
lv_style_copy(&new_style, style);
|
||||
new_style.text.color = sel_style->text.color;
|
||||
new_style.text.opa = sel_style->text.opa;
|
||||
lv_draw_label(&ext->ddlist.label->coords, &mask_sel, &new_style, lv_label_get_text(ext->ddlist.label), TXT_FLAG_CENTER, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include "../lv_obj/lv_group.h"
|
||||
#include "../lv_draw/lv_draw.h"
|
||||
#include "../lv_themes/lv_theme.h"
|
||||
#include "misc/math/math_base.h"
|
||||
#include "lvgl/misc/math/math_base.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
|
||||
@@ -14,9 +14,9 @@
|
||||
#include "../lv_obj/lv_group.h"
|
||||
#include "../lv_draw/lv_draw.h"
|
||||
#include "../lv_themes/lv_theme.h"
|
||||
#include "misc/gfx/anim.h"
|
||||
#include "misc/gfx/text.h"
|
||||
#include "misc/math/math_base.h"
|
||||
#include "lvgl/misc/gfx/anim.h"
|
||||
#include "lvgl/misc/gfx/text.h"
|
||||
#include "lvgl/misc/math/math_base.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include "lv_tabview.h"
|
||||
#include "lv_btnm.h"
|
||||
#include "../lv_themes/lv_theme.h"
|
||||
#include "misc/gfx/anim.h"
|
||||
#include "lvgl/misc/gfx/anim.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
@@ -209,6 +209,7 @@ lv_obj_t * lv_tabview_add_tab(lv_obj_t * tabview, const char * name)
|
||||
if(ext->tab_cnt == 1) {
|
||||
ext->tab_cur = 0;
|
||||
lv_tabview_set_current_tab(tabview, 0, false);
|
||||
tabview_realign(tabview); /*To set the proper btns height*/
|
||||
}
|
||||
|
||||
return h;
|
||||
@@ -305,19 +306,6 @@ void lv_tabview_set_anim_time(lv_obj_t * tabview, uint16_t anim_time_ms)
|
||||
ext->anim_time = anim_time_ms;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the height of the tab buttons
|
||||
* @param tabview pointer to a tabview object
|
||||
* @param h the new height
|
||||
*/
|
||||
void lv_tabview_set_btn_height(lv_obj_t *tabview, cord_t h)
|
||||
{
|
||||
lv_tabview_ext_t *ext = lv_obj_get_ext_attr(tabview);
|
||||
lv_obj_set_height(ext->btns, h);
|
||||
tabview_realign(tabview);
|
||||
}
|
||||
|
||||
|
||||
void lv_tabview_set_style(lv_obj_t *tabview, lv_tabview_style_t type, lv_style_t *style)
|
||||
{
|
||||
lv_tabview_ext_t *ext = lv_obj_get_ext_attr(tabview);
|
||||
@@ -328,9 +316,11 @@ void lv_tabview_set_style(lv_obj_t *tabview, lv_tabview_style_t type, lv_style_t
|
||||
break;
|
||||
case LV_TABVIEW_STYLE_BTN_BG:
|
||||
lv_btnm_set_style(ext->btns, LV_BTNM_STYLE_BG, style);
|
||||
tabview_realign(tabview);
|
||||
break;
|
||||
case LV_TABVIEW_STYLE_BTN_REL:
|
||||
lv_btnm_set_style(ext->btns, LV_BTNM_STYLE_BTN_REL, style);
|
||||
tabview_realign(tabview);
|
||||
break;
|
||||
case LV_TABVIEW_STYLE_BTN_PR:
|
||||
lv_btnm_set_style(ext->btns, LV_BTNM_STYLE_BTN_PR, style);
|
||||
@@ -673,20 +663,33 @@ static void tabview_realign(lv_obj_t * tabview)
|
||||
lv_tabview_ext_t * ext = lv_obj_get_ext_attr(tabview);
|
||||
|
||||
lv_obj_set_width(ext->btns, lv_obj_get_width(tabview));
|
||||
|
||||
if(ext->tab_cnt != 0) {
|
||||
lv_style_t * style_btn_bg = lv_tabview_get_style(tabview, LV_TABVIEW_STYLE_BTN_BG);
|
||||
lv_style_t * style_btn_rel = lv_tabview_get_style(tabview, LV_TABVIEW_STYLE_BTN_REL);
|
||||
|
||||
/*Set the indicator widths*/
|
||||
cord_t indic_width = (lv_obj_get_width(tabview) - style_btn_bg->body.padding.inner * (ext->tab_cnt - 1) -
|
||||
2 * style_btn_bg->body.padding.hor) / ext->tab_cnt;
|
||||
lv_obj_set_width(ext->indic, indic_width);
|
||||
|
||||
/*Set the tabs height*/
|
||||
cord_t btns_height = font_get_height_scale(style_btn_rel->text.font) +
|
||||
2 * style_btn_rel->body.padding.ver +
|
||||
2 * style_btn_bg->body.padding.ver;
|
||||
lv_obj_set_height(ext->btns, btns_height);
|
||||
|
||||
}
|
||||
|
||||
lv_obj_set_height(ext->content, lv_obj_get_height(tabview) - lv_obj_get_height(ext->btns));
|
||||
lv_obj_align(ext->content, ext->btns, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 0);
|
||||
|
||||
lv_obj_t * pages = lv_obj_get_child(ext->content, NULL);
|
||||
while(pages != NULL) {
|
||||
lv_obj_set_size(pages, lv_obj_get_width(tabview), lv_obj_get_height(ext->content));
|
||||
pages = lv_obj_get_child(ext->content, pages);
|
||||
}
|
||||
|
||||
if(ext->tab_cnt != 0) {
|
||||
lv_style_t * style_tabs = lv_obj_get_style(ext->btns);
|
||||
cord_t indic_width = (lv_obj_get_width(tabview) - style_tabs->body.padding.inner * (ext->tab_cnt - 1) -
|
||||
2 * style_tabs->body.padding.hor) / ext->tab_cnt;
|
||||
lv_obj_set_width(ext->indic, indic_width);
|
||||
}
|
||||
|
||||
lv_obj_align(ext->indic, ext->btns, LV_ALIGN_IN_BOTTOM_LEFT, 0, 0);
|
||||
|
||||
|
||||
@@ -122,13 +122,6 @@ void lv_tabview_set_tab_load_action(lv_obj_t *tabview, lv_tabview_action_t actio
|
||||
*/
|
||||
void lv_tabview_set_anim_time(lv_obj_t * tabview, uint16_t anim_time_ms);
|
||||
|
||||
/**
|
||||
* Set the height of the tab buttons
|
||||
* @param tabview pointer to a tabview object
|
||||
* @param h the new height
|
||||
*/
|
||||
void lv_tabview_set_btn_height(lv_obj_t *tabview, cord_t h);
|
||||
|
||||
|
||||
void lv_tabview_set_style(lv_obj_t *tabview, lv_tabview_style_t type, lv_style_t *style);
|
||||
|
||||
|
||||
@@ -260,6 +260,7 @@ lv_theme_t * lv_theme_get_current(void);
|
||||
#include "lv_theme_templ.h"
|
||||
#include "lv_theme_default.h"
|
||||
#include "lv_theme_alien.h"
|
||||
#include "lv_theme_night.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
|
||||
506
lv_themes/lv_theme_night.c
Normal file
506
lv_themes/lv_theme_night.c
Normal file
@@ -0,0 +1,506 @@
|
||||
/**
|
||||
* @file lv_theme_night.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lvgl/lvgl.h"
|
||||
#include "lv_theme.h"
|
||||
|
||||
#include "lv_conf.h"
|
||||
|
||||
#if USE_LV_THEME_NIGHT
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static lv_theme_t theme;
|
||||
static lv_style_t def;
|
||||
|
||||
/*Static style definitions*/
|
||||
static lv_style_t bg;
|
||||
static lv_style_t prim, sec, hint;
|
||||
static lv_style_t btn_rel, btn_pr, btn_tgl_rel, btn_tgl_pr, btn_ina;
|
||||
static lv_style_t bar_bg, bar_indic;
|
||||
static lv_style_t slider_knob;
|
||||
static lv_style_t ddlist_bg, ddlist_sel;
|
||||
static lv_style_t roller_bg;
|
||||
static lv_style_t list_bg, list_btn_rel, list_btn_pr;
|
||||
|
||||
/*Saved input parameters*/
|
||||
static uint16_t _hue;
|
||||
static font_t * _font;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
static void basic_init(void)
|
||||
{
|
||||
lv_style_copy(&def, &lv_style_pretty); /*Initialize the default style*/
|
||||
|
||||
lv_style_copy(&bg, &lv_style_plain);
|
||||
bg.body.main_color = color_hsv_to_rgb(_hue, 11, 23);
|
||||
bg.body.grad_color = color_hsv_to_rgb(_hue, 11, 23);
|
||||
|
||||
|
||||
theme.bg = &bg;
|
||||
theme.panel = &def;
|
||||
}
|
||||
|
||||
static void btn_init(void)
|
||||
{
|
||||
#if USE_LV_BTN != 0
|
||||
|
||||
lv_style_copy(&btn_rel, &lv_style_pretty);
|
||||
btn_rel.body.main_color = color_hsv_to_rgb(_hue, 10, 40);
|
||||
btn_rel.body.grad_color = color_hsv_to_rgb(_hue, 10, 20);
|
||||
btn_rel.body.border.color = COLOR_HEX3(0x111);
|
||||
btn_rel.body.border.width = 1 << LV_AA;
|
||||
btn_rel.body.border.opa = OPA_COVER;
|
||||
btn_rel.text.color = COLOR_HEX3(0xeee);
|
||||
|
||||
lv_style_copy(&btn_pr, &btn_rel);
|
||||
btn_pr.body.main_color = color_hsv_to_rgb(_hue, 10, 30);
|
||||
btn_pr.body.grad_color = color_hsv_to_rgb(_hue, 10, 10);
|
||||
|
||||
lv_style_copy(&btn_tgl_rel, &btn_rel);
|
||||
btn_tgl_rel.body.main_color = color_hsv_to_rgb(_hue, 10, 20);
|
||||
btn_tgl_rel.body.grad_color = color_hsv_to_rgb(_hue, 10, 40);
|
||||
|
||||
lv_style_copy(&btn_tgl_pr, &btn_rel);
|
||||
btn_tgl_pr.body.main_color = color_hsv_to_rgb(_hue, 10, 10);
|
||||
btn_tgl_pr.body.grad_color = color_hsv_to_rgb(_hue, 10, 30);
|
||||
|
||||
lv_style_copy(&btn_ina, &btn_rel);
|
||||
btn_ina.body.main_color = color_hsv_to_rgb(_hue, 10, 20);
|
||||
btn_ina.body.grad_color = color_hsv_to_rgb(_hue, 10, 20);
|
||||
btn_ina.text.color = COLOR_HEX3(0xaaa);
|
||||
|
||||
theme.btn.rel = &btn_rel;
|
||||
theme.btn.pr = &btn_pr;
|
||||
theme.btn.tgl_rel = &btn_tgl_rel;
|
||||
theme.btn.tgl_pr = &btn_tgl_pr;
|
||||
theme.btn.ina = &btn_ina;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
static void label_init(void)
|
||||
{
|
||||
#if USE_LV_LABEL != 0
|
||||
|
||||
lv_style_copy(&prim, &bg);
|
||||
prim.text.color = color_hsv_to_rgb(_hue, 5, 95);
|
||||
|
||||
lv_style_copy(&sec, &bg);
|
||||
sec.text.color = color_hsv_to_rgb(_hue, 15, 65);
|
||||
|
||||
lv_style_copy(&hint, &bg);
|
||||
hint.text.color = color_hsv_to_rgb(_hue, 20, 55);
|
||||
|
||||
theme.label.prim = &prim;
|
||||
theme.label.sec = &sec;
|
||||
theme.label.hint = &hint;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void img_init(void)
|
||||
{
|
||||
#if USE_LV_IMG != 0
|
||||
|
||||
|
||||
theme.img.light = &def;
|
||||
theme.img.dark = &def;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void line_init(void)
|
||||
{
|
||||
#if USE_LV_LINE != 0
|
||||
|
||||
|
||||
theme.line.decor = &def;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void led_init(void)
|
||||
{
|
||||
#if USE_LV_LED != 0
|
||||
|
||||
|
||||
theme.led = &def;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void bar_init(void)
|
||||
{
|
||||
#if USE_LV_BAR
|
||||
lv_style_copy(&bar_bg, &lv_style_pretty);
|
||||
bar_bg.body.main_color = color_hsv_to_rgb(_hue, 10, 15);
|
||||
bar_bg.body.grad_color = color_hsv_to_rgb(_hue, 10, 15);
|
||||
bar_bg.body.border.color = color_hsv_to_rgb(_hue, 10, 10);
|
||||
bar_bg.body.border.width = 1 << LV_AA;
|
||||
bar_bg.body.border.opa = OPA_COVER;
|
||||
bar_bg.body.radius = LV_RADIUS_CIRCLE;
|
||||
|
||||
lv_style_copy(&bar_indic, &lv_style_pretty);
|
||||
bar_indic.body.main_color = color_hsv_to_rgb(_hue, 80, 70);
|
||||
bar_indic.body.grad_color = color_hsv_to_rgb(_hue, 80, 70);
|
||||
bar_indic.body.border.color = color_hsv_to_rgb(_hue, 20, 15);
|
||||
bar_indic.body.border.width = 1 << LV_AA;
|
||||
bar_indic.body.border.opa = OPA_COVER;
|
||||
bar_indic.body.radius = LV_RADIUS_CIRCLE;
|
||||
bar_indic.body.padding.hor = 0;
|
||||
bar_indic.body.padding.ver = 0;
|
||||
|
||||
theme.bar.bg = &bar_bg;
|
||||
theme.bar.indic = &bar_indic;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void slider_init(void)
|
||||
{
|
||||
#if USE_LV_SLIDER != 0
|
||||
|
||||
lv_style_copy(&slider_knob, &btn_rel);
|
||||
slider_knob.body.radius = LV_RADIUS_CIRCLE;
|
||||
|
||||
theme.slider.bg = &bar_bg;
|
||||
theme.slider.indic = &bar_indic;
|
||||
theme.slider.knob = &slider_knob;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void sw_init(void)
|
||||
{
|
||||
#if USE_LV_SW != 0
|
||||
|
||||
|
||||
theme.sw.bg = &bar_bg;
|
||||
theme.sw.indic = &bar_indic;
|
||||
theme.sw.knob_off = &slider_knob;
|
||||
theme.sw.knob_on = &slider_knob;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
static void lmeter_init(void)
|
||||
{
|
||||
#if USE_LV_LMETER != 0
|
||||
|
||||
|
||||
theme.lmeter = &def;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void gauge_init(void)
|
||||
{
|
||||
#if USE_LV_GAUGE != 0
|
||||
|
||||
|
||||
theme.gauge = &def;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void chart_init(void)
|
||||
{
|
||||
#if USE_LV_CHART
|
||||
|
||||
|
||||
theme.chart = &def;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void cb_init(void)
|
||||
{
|
||||
#if USE_LV_CB != 0
|
||||
|
||||
theme.cb.bg = &lv_style_transp;
|
||||
theme.cb.box.rel = &def;
|
||||
theme.cb.box.pr = &def;
|
||||
theme.cb.box.tgl_rel = &def;
|
||||
theme.cb.box.tgl_pr = &def;
|
||||
theme.cb.box.ina = &def;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
static void btnm_init(void)
|
||||
{
|
||||
#if USE_LV_BTNM
|
||||
static lv_style_t bg, rel, pr, tgl_rel, tgl_pr, ina;
|
||||
|
||||
lv_style_copy(&bg, &btn_rel);
|
||||
bg.body.padding.hor = 2 << LV_AA;
|
||||
bg.body.padding.ver = 2 << LV_AA;
|
||||
bg.body.padding.inner = 0;
|
||||
bg.body.border.width = 1<< LV_AA;//LV_BORDER_RIGHT;
|
||||
|
||||
lv_style_copy(&rel, &btn_rel);
|
||||
rel.body.border.part = LV_BORDER_RIGHT;
|
||||
rel.body.border.width = 2 << LV_AA;
|
||||
rel.body.radius = 0;
|
||||
|
||||
lv_style_copy(&pr, &btn_pr);
|
||||
pr.body.border.part = LV_BORDER_RIGHT;
|
||||
pr.body.border.width = 2 << LV_AA;
|
||||
pr.body.radius = 0;
|
||||
|
||||
lv_style_copy(&tgl_rel, &btn_tgl_rel);
|
||||
tgl_rel.body.border.part = LV_BORDER_RIGHT;
|
||||
tgl_rel.body.border.width = 2 << LV_AA;
|
||||
tgl_rel.body.radius = 0;
|
||||
|
||||
lv_style_copy(&tgl_pr, &btn_tgl_pr);
|
||||
tgl_pr.body.border.part = LV_BORDER_RIGHT;
|
||||
tgl_pr.body.border.width = 2 << LV_AA;
|
||||
tgl_pr.body.radius = 0;
|
||||
|
||||
lv_style_copy(&ina, &btn_ina);
|
||||
ina.body.border.part = LV_BORDER_RIGHT;
|
||||
ina.body.border.width = 2 << LV_AA;
|
||||
ina.body.radius = 0;
|
||||
|
||||
theme.btnm.bg = &bg;
|
||||
theme.btnm.btn.rel = &rel;
|
||||
theme.btnm.btn.pr = ≺
|
||||
theme.btnm.btn.tgl_rel = &tgl_rel;
|
||||
theme.btnm.btn.tgl_pr = &tgl_pr;
|
||||
theme.btnm.btn.ina = &ina;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void kb_init(void)
|
||||
{
|
||||
#if USE_LV_KB
|
||||
|
||||
|
||||
theme.kb.bg = &def;
|
||||
theme.kb.btn.rel = &def;
|
||||
theme.kb.btn.pr = &def;
|
||||
theme.kb.btn.tgl_rel = &def;
|
||||
theme.kb.btn.tgl_pr = &def;
|
||||
theme.kb.btn.ina = &def;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
static void mbox_init(void)
|
||||
{
|
||||
#if USE_LV_MBOX
|
||||
|
||||
|
||||
theme.mbox.bg = &def;
|
||||
theme.mbox.btn.bg = &def;
|
||||
theme.mbox.btn.rel = &def;
|
||||
theme.mbox.btn.pr = &def;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void page_init(void)
|
||||
{
|
||||
#if USE_LV_PAGE
|
||||
|
||||
|
||||
theme.page.bg = &def;
|
||||
theme.page.scrl = &def;
|
||||
theme.page.sb = &def;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void ta_init(void)
|
||||
{
|
||||
#if USE_LV_TA
|
||||
|
||||
|
||||
theme.ta.area = &def;
|
||||
theme.ta.oneline = &def;
|
||||
theme.ta.sb = &def;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void list_init(void)
|
||||
{
|
||||
#if USE_LV_LIST != 0
|
||||
lv_style_copy(&list_bg, &bg);
|
||||
list_bg.body.main_color = color_hsv_to_rgb(_hue, 10, 15);
|
||||
list_bg.body.grad_color = color_hsv_to_rgb(_hue, 10, 15);
|
||||
list_bg.body.radius = LV_DPI / 30;
|
||||
list_bg.body.border.color = color_hsv_to_rgb(_hue, 10, 10);
|
||||
list_bg.body.border.width = 1 << LV_AA;
|
||||
list_bg.body.border.opa = OPA_COVER;
|
||||
list_bg.body.padding.ver = LV_DPI / 20;
|
||||
|
||||
lv_style_copy(&list_btn_rel, &bg);
|
||||
list_btn_rel.body.empty = 1;
|
||||
list_btn_rel.body.border.part = LV_BORDER_BOTTOM;
|
||||
list_btn_rel.body.border.color = color_hsv_to_rgb(_hue, 10, 5);
|
||||
list_btn_rel.body.border.width = 1 << LV_AA;
|
||||
list_btn_rel.text.color = color_hsv_to_rgb(_hue, 5, 80);
|
||||
|
||||
theme.list.sb = &def;
|
||||
theme.list.bg = &list_bg;
|
||||
theme.list.scrl = &lv_style_transp_tight;
|
||||
theme.list.btn.rel = &list_btn_rel;
|
||||
theme.list.btn.pr = &def;
|
||||
theme.list.btn.tgl_rel = &def;
|
||||
theme.list.btn.tgl_pr = &def;
|
||||
theme.list.btn.ina = &def;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void ddlist_init(void)
|
||||
{
|
||||
#if USE_LV_DDLIST != 0
|
||||
lv_style_copy(&ddlist_bg, &btn_rel);
|
||||
ddlist_bg.text.line_space = LV_DPI / 8;
|
||||
ddlist_bg.body.padding.ver = LV_DPI / 8;
|
||||
ddlist_bg.body.padding.hor = LV_DPI / 8;
|
||||
ddlist_bg.body.radius = LV_DPI / 30;
|
||||
|
||||
lv_style_copy(&ddlist_sel, &btn_rel);
|
||||
ddlist_sel.body.main_color = color_hsv_to_rgb(_hue, 10, 50);
|
||||
ddlist_sel.body.grad_color = color_hsv_to_rgb(_hue, 10, 50);
|
||||
ddlist_sel.body.radius = 0;
|
||||
|
||||
theme.ddlist.bg = &ddlist_bg;
|
||||
theme.ddlist.sel = &ddlist_sel;
|
||||
theme.ddlist.sb = &def;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void roller_init(void)
|
||||
{
|
||||
#if USE_LV_ROLLER != 0
|
||||
|
||||
lv_style_copy(&roller_bg, &ddlist_bg);
|
||||
roller_bg.body.main_color = color_hsv_to_rgb(_hue, 10, 20);
|
||||
roller_bg.body.grad_color = color_hsv_to_rgb(_hue, 10, 40);
|
||||
roller_bg.text.color = color_hsv_to_rgb(_hue, 5, 70);
|
||||
roller_bg.text.opa = OPA_60;
|
||||
|
||||
theme.roller.bg = &roller_bg;
|
||||
theme.roller.sel = &ddlist_sel;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void tabview_init(void)
|
||||
{
|
||||
#if USE_LV_TABVIEW != 0
|
||||
|
||||
|
||||
theme.tabview.bg = &bg;
|
||||
theme.tabview.sb = &def;
|
||||
theme.tabview.indic = &lv_style_transp;
|
||||
theme.tabview.btn.bg = &lv_style_transp;
|
||||
theme.tabview.btn.rel = &btn_rel;
|
||||
theme.tabview.btn.pr = &btn_pr;
|
||||
theme.tabview.btn.tgl_rel = &btn_tgl_rel;
|
||||
theme.tabview.btn.tgl_pr = &btn_tgl_pr;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
static void win_init(void)
|
||||
{
|
||||
#if USE_LV_WIN != 0
|
||||
|
||||
|
||||
theme.win.bg = &def;
|
||||
theme.win.sb = &def;
|
||||
theme.win.header = &def;
|
||||
theme.win.content.bg = &def;
|
||||
theme.win.content.scrl = &def;
|
||||
theme.win.btn.rel = &def;
|
||||
theme.win.btn.pr = &def;
|
||||
#endif
|
||||
}
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Initialize the night theme
|
||||
* @param hue [0..360] hue value from HSV color space to define the theme's base color
|
||||
* @param font pointer to a font (NULL to use the default)
|
||||
* @return pointer to the initialized theme
|
||||
*/
|
||||
lv_theme_t * lv_theme_night_init(uint16_t hue, font_t *font)
|
||||
{
|
||||
if(font == NULL) font = LV_FONT_DEFAULT;
|
||||
|
||||
_hue = hue;
|
||||
_font = font;
|
||||
|
||||
/*For backward compatibility initialize all theme elements with a default style */
|
||||
uint16_t i;
|
||||
lv_style_t **style_p = (lv_style_t**) &theme;
|
||||
for(i = 0; i < sizeof(lv_theme_t) / sizeof(lv_style_t*); i++) {
|
||||
*style_p = &def;
|
||||
style_p++;
|
||||
}
|
||||
|
||||
basic_init();
|
||||
btn_init();
|
||||
label_init();
|
||||
img_init();
|
||||
line_init();
|
||||
led_init();
|
||||
bar_init();
|
||||
slider_init();
|
||||
sw_init();
|
||||
lmeter_init();
|
||||
gauge_init();
|
||||
chart_init();
|
||||
cb_init();
|
||||
btnm_init();
|
||||
kb_init();
|
||||
mbox_init();
|
||||
page_init();
|
||||
ta_init();
|
||||
list_init();
|
||||
ddlist_init();
|
||||
roller_init();
|
||||
tabview_init();
|
||||
win_init();
|
||||
|
||||
return &theme;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a pointer to the theme
|
||||
* @return pointer to the theme
|
||||
*/
|
||||
lv_theme_t * lv_theme_get_deafult(void)
|
||||
{
|
||||
return &theme;
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
#endif
|
||||
|
||||
56
lv_themes/lv_theme_night.h
Normal file
56
lv_themes/lv_theme_night.h
Normal file
@@ -0,0 +1,56 @@
|
||||
/**
|
||||
* @file lv_theme_night.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_THEME_NIGHT_H
|
||||
#define LV_THEME_NIGHT_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_conf.h"
|
||||
|
||||
#if USE_LV_THEME_NIGHT
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Initialize the night theme
|
||||
* @param hue [0..360] hue value from HSV color space to define the theme's base color
|
||||
* @param font pointer to a font (NULL to use the default)
|
||||
* @return pointer to the initialized theme
|
||||
*/
|
||||
lv_theme_t * lv_theme_night_init(uint16_t hue, font_t *font);
|
||||
|
||||
/**
|
||||
* Get a pointer to the theme
|
||||
* @return pointer to the theme
|
||||
*/
|
||||
lv_theme_t * lv_theme_get_night(void);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /*LV_THEME_NIGHT_H*/
|
||||
4
lvgl.h
4
lvgl.h
@@ -15,7 +15,9 @@ extern "C" {
|
||||
*********************/
|
||||
|
||||
/*Test misc. module version*/
|
||||
#include "misc/misc.h"
|
||||
#include "lvgl/misc/misc.h"
|
||||
#include "lvgl/misc/os/ptask.h"
|
||||
|
||||
#include "lv_hal/lv_hal.h"
|
||||
|
||||
#include "lv_obj/lv_obj.h"
|
||||
|
||||
37
misc/README.md
Normal file
37
misc/README.md
Normal file
@@ -0,0 +1,37 @@
|
||||
# Miscellaneous Library
|
||||
|
||||
This library is written especially for the Littlev Graphics Library however its useful hardware independent software modules can be used in your non graphical projects too. Some of the most important components:
|
||||
* Dynamic memory manager with defrag. and memory monitoring
|
||||
* Simple task scheduler with priority and idle measurement
|
||||
* File system interface to access different mediums easily
|
||||
* RAM FS
|
||||
* FIFO
|
||||
* Linked list
|
||||
* Fonts
|
||||
* etc
|
||||
|
||||
## Usage
|
||||
1. Clone the repository into the root folder of your project: `git clone https://github.com/littlevgl/misc.git`
|
||||
2. In your IDE add the project **root folder as include path**
|
||||
3. Copy *misc/misc_conf_templ.h* as **misc_conf.h** to the project root folder
|
||||
4. Delete the first `#if 0` and the last `#endif` to enable the file
|
||||
5. Enable/disable or configure the components
|
||||
6. To initialize the library `#include misc/misc.h` and call `misc_init()`
|
||||
|
||||
## Documentation
|
||||
* You will find **well commented** source and header files.
|
||||
* There are same documentation on the graphics library's webpage: http://gl.littlev.hu
|
||||
|
||||
## Contributing
|
||||
1. Fork it!
|
||||
2. Create your feature branch: `git checkout -b my-new-feature`
|
||||
3. Commit your changes: `git commit -am 'Add some feature'`
|
||||
4. Push to the branch: `git push origin my-new-feature`
|
||||
5. Submit a pull request!
|
||||
|
||||
If you find an issue, please report it via GitHub!
|
||||
|
||||
## Donate
|
||||
If you are pleased with the Misc. Library and found it useful please support its further development:
|
||||
|
||||
[](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=LWHHAQYZMRQJS)
|
||||
413
misc/fs/fat32/fat32.c
Normal file
413
misc/fs/fat32/fat32.c
Normal file
@@ -0,0 +1,413 @@
|
||||
/**
|
||||
* @file fat32.c
|
||||
* Functions to give an API to a Fat32 storage device which is compatible
|
||||
* with the fs_int module.
|
||||
* It uses the FatFS as FAT32.
|
||||
* For more information about FatFS see:
|
||||
* http://elm-chan.org/fsw/ff/00index_e.html
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "misc_conf.h"
|
||||
#if USE_FAT32 != 0
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include "fat32.h"
|
||||
#include "ff.h"
|
||||
#include "hw/dev/ext_mem/sdcard.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static fs_res_t fat32_res_trans(FRESULT fat32_res);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
/**
|
||||
* Create a driver for the fat32 device and initilaize it.
|
||||
*/
|
||||
void fat32_init(void)
|
||||
{
|
||||
/*Create the driver*/
|
||||
fs_drv_t fat_drv;
|
||||
memset(&fat_drv, 0, sizeof(fs_drv_t)); /*Initialization*/
|
||||
|
||||
fat_drv.file_size = sizeof(FIL);
|
||||
fat_drv.rddir_size = sizeof(DIR);
|
||||
fat_drv.letter = FAT32_LETTER;
|
||||
fat_drv.ready = fat32_ready;
|
||||
|
||||
fat_drv.open = fat32_open;
|
||||
fat_drv.close = fat32_close;
|
||||
#if _FS_MINIMIZE < 1
|
||||
fat_drv.remove = fat32_remove;
|
||||
#else
|
||||
fat_drv.remove = NULL;
|
||||
#endif
|
||||
fat_drv.read = fat32_read;
|
||||
#if _FS_READONLY == 0
|
||||
fat_drv.write = fat32_write;
|
||||
#else
|
||||
fat_drv.write = NULL;
|
||||
#endif
|
||||
#if _FS_MINIMIZE < 3
|
||||
fat_drv.seek = fat32_seek;
|
||||
#else
|
||||
fat_drv.seek = NULL;
|
||||
#endif
|
||||
fat_drv.tell = fat32_tell;
|
||||
fat_drv.size = fat32_size;
|
||||
fat_drv.trunc = fat32_trunc;
|
||||
#if _FS_MINIMIZE < 2
|
||||
fat_drv.rddir_init = fat32_readdir_init;
|
||||
fat_drv.rddir = fat32_readdir;
|
||||
fat_drv.rddir_close = fat32_readdir_close;
|
||||
#else
|
||||
fat_drv.rddir_init = NULL;
|
||||
fat_drv.rddir = NULL;
|
||||
fat_drv.rddir_close = NULL;
|
||||
#endif
|
||||
|
||||
#if _FS_MINIMIZE == 0
|
||||
fat_drv.free = fat32_free;
|
||||
#else
|
||||
fat_drv.free = NULL;
|
||||
#endif
|
||||
fs_add_drv(&fat_drv);
|
||||
}
|
||||
|
||||
/**
|
||||
* Give the state of the fat32 storage device
|
||||
* @return true if the device is initialized and can be used else false
|
||||
*/
|
||||
bool fat32_ready(void)
|
||||
{
|
||||
return sdcard_ready();
|
||||
}
|
||||
|
||||
/**
|
||||
* Open a file
|
||||
* @param file_p pointer to a FIL type variable
|
||||
* @param path path of the file (e.g. "dir1/dir2/file1.txt")
|
||||
* @param mode open mode (FS_MODE_RD or FS_MODE_WR or both with | (or connection))
|
||||
* @return FS_RES_OK or any error from 'fs_res_t'
|
||||
*/
|
||||
fs_res_t fat32_open (void * file_p, const char * path, fs_mode_t mode)
|
||||
{
|
||||
uint8_t fat32_mode = 0;
|
||||
if(mode & FS_MODE_RD) fat32_mode |= FA_READ;
|
||||
#if _FS_READONLY == 0
|
||||
if(mode & FS_MODE_WR) fat32_mode |= FA_WRITE | FA_OPEN_ALWAYS;
|
||||
#endif
|
||||
|
||||
/*In ready only mode the write is not implemented*/
|
||||
if(mode == 0) return FS_RES_NOT_IMP;
|
||||
|
||||
|
||||
FRESULT fat32_res;
|
||||
fat32_res = f_open(file_p, path, fat32_mode);
|
||||
return fat32_res_trans(fat32_res);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Close an already opened file
|
||||
* @param file_p pointer to a FIL type variable
|
||||
* @return FS_RES_OK or any error from fs_res_t
|
||||
*/
|
||||
fs_res_t fat32_close (void * file_p)
|
||||
{
|
||||
FRESULT fat32_res;
|
||||
fat32_res = f_close(file_p);
|
||||
return fat32_res_trans(fat32_res);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove (delete) a file
|
||||
* @param path the path of the file ("dir1/file1.txt")
|
||||
* @return FS_RES_OK or any error from 'fs_res_t'
|
||||
*/
|
||||
fs_res_t fat32_remove(const char * path)
|
||||
{
|
||||
#if _FS_MINIMIZE < 1
|
||||
FRESULT fat32_res;
|
||||
fat32_res = f_unlink(path);
|
||||
return fat32_res_trans(fat32_res);
|
||||
#else
|
||||
return FS_RES_NOT_IMP;
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* Read data from an opened file
|
||||
* @param file_p pointer to a FIL type variable
|
||||
* @param buf pointer a buffer to store the read bytes
|
||||
* @param btr the number of Bytes To Read
|
||||
* @param br the number of real read bytes (Bytes Read)
|
||||
* @return FS_RES_OK or any error from 'fs_res_t'
|
||||
*/
|
||||
fs_res_t fat32_read (void * file_p, void * buf, uint32_t btr, uint32_t * br)
|
||||
{
|
||||
FRESULT fat32_res;
|
||||
fat32_res = f_read(file_p, buf, btr, (UINT *)br);
|
||||
return fat32_res_trans(fat32_res);
|
||||
}
|
||||
|
||||
/**
|
||||
* Write data to an opened file
|
||||
* @param file_p pointer to a FIL type variable
|
||||
* @param buf pointer to buffer where the data to write is located
|
||||
* @param btw the number of Bytes To Write
|
||||
* @param bw the number of real written bytes (Bytes Written)
|
||||
* @return FS_RES_OK or any error from 'fs_res_t'
|
||||
*/
|
||||
fs_res_t fat32_write (void * file_p, const void * buf, uint32_t btw, uint32_t * bw)
|
||||
{
|
||||
#if _FS_READONLY == 0
|
||||
FRESULT fat32_res;
|
||||
fat32_res = f_write(file_p, buf, btw, (UINT *)bw);
|
||||
return fat32_res_trans(fat32_res);
|
||||
#else
|
||||
return FS_RES_NOT_IMP;
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* Position the read write pointer to given position
|
||||
* @param file_p pointer to a FIL type variable
|
||||
* @param pos the new position expressed in bytes index (0: start of file)
|
||||
* @return FS_RES_OK or any error from 'fs_res_t'
|
||||
*/
|
||||
fs_res_t fat32_seek (void * file_p, uint32_t pos)
|
||||
{
|
||||
#if _FS_MINIMIZE < 3
|
||||
FRESULT fat32_res;
|
||||
fat32_res = f_lseek(file_p, pos);
|
||||
return fat32_res_trans(fat32_res);
|
||||
#else
|
||||
return FS_RES_NOT_IMP;
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* Give the position of the read write pointer
|
||||
* @param file_p pointer to a FIL type variable
|
||||
* @param pos_p pointer to store the position of the read write pointer
|
||||
* @return FS_RES_OK or any error from 'fs_res_t'
|
||||
*/
|
||||
fs_res_t fat32_tell (void * file_p, uint32_t * pos_p)
|
||||
{
|
||||
*pos_p = f_tell((FIL *)file_p);
|
||||
|
||||
return FS_RES_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Truncate the file size to the current position of read write pointer
|
||||
* @param file_p pointer to a FIL type variable
|
||||
* @return FS_RES_OK or any error from 'fs_res_t'
|
||||
*/
|
||||
fs_res_t fat32_trunc (void * file_p)
|
||||
{
|
||||
#if _FS_MINIMIZE < 1
|
||||
FRESULT fat32_res;
|
||||
fat32_res = f_truncate(file_p);
|
||||
return fat32_res_trans(fat32_res);
|
||||
#else
|
||||
return FS_RES_NOT_IMP;
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* Give the size of a file
|
||||
* @param file_p pointer to a FIL type variable
|
||||
* @param size_p pointer to store the size
|
||||
* @return FS_RES_OK or any error from 'fs_res_t'
|
||||
*/
|
||||
fs_res_t fat32_size (void * file_p, uint32_t * size_p)
|
||||
{
|
||||
*size_p = f_size((FIL *)file_p);
|
||||
return FS_RES_OK;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Initialize a variable for directory reading
|
||||
* @param rddir_p pointer to a 'DIR' variable
|
||||
* @param path path to a directory
|
||||
* @return FS_RES_OK or any error from fs_res_t enum
|
||||
*/
|
||||
fs_res_t fat32_readdir_init(void * rddir_p, const char * path)
|
||||
{
|
||||
#if _FS_MINIMIZE < 2
|
||||
FRESULT res = f_opendir(rddir_p, path);
|
||||
|
||||
return fat32_res_trans(res);
|
||||
#else
|
||||
return FS_RES_NOT_IMP;
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the next filename form a directory.
|
||||
* The name of the directories will begin with '/'
|
||||
* @param rddir_p pointer to an initialized 'DIR' variable
|
||||
* @param fn pointer to a buffer to store the filename
|
||||
* @return FS_RES_OK or any error from fs_res_t enum
|
||||
*/
|
||||
fs_res_t fat32_readdir(void * rddir_p, char * fn)
|
||||
{
|
||||
|
||||
#if _FS_MINIMIZE < 2
|
||||
FRESULT res;
|
||||
FILINFO fno;
|
||||
char lfn_buf[FSINT_MAX_FN_LENGTH];
|
||||
fno.lfname = lfn_buf;
|
||||
fno.lfsize = FSINT_MAX_FN_LENGTH;
|
||||
res = f_readdir(rddir_p, &fno);
|
||||
if(res == FR_OK && fno.fname[0] != '\0') {
|
||||
if (fno.fattrib & AM_DIR) { /* It is a directory */
|
||||
#if _USE_LFN != 0
|
||||
sprintf(fn, "/%s", fno.lfname[0] != '\0' ? fno.lfname : fno.fname);
|
||||
#else
|
||||
sprintf(fn, "/%s", fno.fname);
|
||||
#endif
|
||||
} else { /* It is a file. */
|
||||
#if _USE_LFN != 0
|
||||
strcpy(fn, fno.lfname[0] != '\0' ? fno.lfname : fno.fname);
|
||||
#else
|
||||
strcpy(fn, fno.fname);
|
||||
#endif
|
||||
}
|
||||
} else {
|
||||
fn[0] = '\0';
|
||||
}
|
||||
|
||||
return fat32_res_trans(res);
|
||||
#else
|
||||
return FS_RES_NOT_IMP;
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the directory reading
|
||||
* @param rddir_p pointer to an initialized 'DIR' variable
|
||||
* @return FS_RES_OK or any error from fs_res_t enum
|
||||
*/
|
||||
fs_res_t fat32_readdir_close(void * rddir_p)
|
||||
{
|
||||
#if _FS_MINIMIZE < 2
|
||||
f_closedir(rddir_p);
|
||||
return FS_RES_OK;
|
||||
#else
|
||||
return FS_RES_NOT_IMP;
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* Give the size of a drive
|
||||
* @param total_p pointer to store the total size [kB]
|
||||
* @param free_p pointer to store the free size [kB]
|
||||
* @return FS_RES_OK or any error from 'fs_res_t'
|
||||
*/
|
||||
fs_res_t fat32_free (uint32_t * total_p, uint32_t * free_p)
|
||||
{
|
||||
#if _FS_READONLY == 0 && _FS_MINIMIZE == 0
|
||||
FATFS *fs;
|
||||
FRESULT fat32_res;
|
||||
uint32_t fre_clust = 0;
|
||||
uint32_t fre_sect=0;
|
||||
uint32_t tot_sect=0;
|
||||
|
||||
fat32_res = f_getfree("", (unsigned long*)&fre_clust, &fs);
|
||||
tot_sect=(fs->n_fatent - 2) * fs->csize;
|
||||
fre_sect=fre_clust*fs->csize;
|
||||
#if _MAX_SS!=512
|
||||
tot_sect*=fs1->ssize / 512;
|
||||
fre_sect*=fs1->ssize / 512;
|
||||
#endif
|
||||
*total_p=tot_sect >> 1;
|
||||
*free_p=fre_sect >> 1;
|
||||
return fat32_res_trans(fat32_res);
|
||||
#else
|
||||
return FS_RES_NOT_IMP;
|
||||
#endif
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Translate the return codes to fs_res_t
|
||||
* @param fat32_res the original fat_32 result
|
||||
* @return the converted, fs_res_t return code
|
||||
*/
|
||||
|
||||
static fs_res_t fat32_res_trans(FRESULT fat32_res)
|
||||
{
|
||||
switch(fat32_res) {
|
||||
case FR_OK: /* (0) Succeeded */
|
||||
return FS_RES_OK;
|
||||
|
||||
case FR_DISK_ERR: /* (1) A hard error occurred in the low level disk I/O layer */
|
||||
case FR_NOT_READY: /* (3) The physical drive cannot work */
|
||||
return FS_RES_HW_ERR;
|
||||
|
||||
case FR_INT_ERR: /* (2) Assertion failed */
|
||||
case FR_NOT_ENABLED: /* (12) The volume has no work area */
|
||||
case FR_NO_FILESYSTEM: /* (13) There is no valid FAT volume */
|
||||
return FS_RES_FS_ERR;
|
||||
|
||||
case FR_NO_FILE: /* (4) Could not find the file */
|
||||
case FR_NO_PATH: /* (5) Could not find the path */
|
||||
case FR_INVALID_NAME: /* (6) The path name format is invalid */
|
||||
case FR_INVALID_DRIVE: /* (11) The logical drive number is invalid */
|
||||
return FS_RES_NOT_EX;
|
||||
|
||||
case FR_DENIED: /* (7) Access denied due to prohibited access or directory full */
|
||||
case FR_EXIST: /* (8) Access denied due to prohibited access */
|
||||
case FR_WRITE_PROTECTED: /* (10) The physical drive is write protected */
|
||||
case FR_LOCKED: /* (16) The operation is rejected according to the file sharing policy */
|
||||
return FS_RES_DENIED;
|
||||
|
||||
case FR_INVALID_OBJECT: /* (9) The file/directory object is invalid */
|
||||
case FR_INVALID_PARAMETER: /* (19) Given parameter is invalid */
|
||||
return FS_RES_INV_PARAM;
|
||||
|
||||
case FR_TIMEOUT: /* (15) Could not get a grant to access the volume within defined period */
|
||||
return FS_RES_TOUT;
|
||||
|
||||
case FR_TOO_MANY_OPEN_FILES:/* (18) Number of open files > _FS_LOCK */
|
||||
case FR_NOT_ENOUGH_CORE: /* (17) LFN working buffer could not be allocated */
|
||||
return FS_RES_OUT_OF_MEM;
|
||||
|
||||
case FR_MKFS_ABORTED: /* (14) The f_mkfs() aborted due to any parameter error */
|
||||
return FS_RES_UNKNOWN;
|
||||
|
||||
}
|
||||
|
||||
return FS_RES_UNKNOWN;
|
||||
}
|
||||
|
||||
#endif
|
||||
163
misc/fs/fat32/fat32.h
Normal file
163
misc/fs/fat32/fat32.h
Normal file
@@ -0,0 +1,163 @@
|
||||
/**
|
||||
* @file fat32.h
|
||||
* Functions to give an API to a Fat32 storage device which is compatible
|
||||
* with the fs_int module.
|
||||
*/
|
||||
|
||||
#ifndef FAT32_H
|
||||
#define FAT32_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "misc_conf.h"
|
||||
#if USE_FAT32 != 0
|
||||
|
||||
#include "../fsint.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Create a driver for the fat32 device and initilaize it.
|
||||
*/
|
||||
void fat32_init(void);
|
||||
|
||||
/**
|
||||
* Give the state of the fat32 storage device
|
||||
* @return true if the device is initialized and can be used else false
|
||||
*/
|
||||
bool fat32_ready(void);
|
||||
|
||||
/**
|
||||
* Open a file
|
||||
* @param file_p pointer to a FIL type variable
|
||||
* @param path path of the file (e.g. "dir1/dir2/file1.txt")
|
||||
* @param mode open mode (FS_MODE_RD or FS_MODE_WR or both with | (or connection))
|
||||
* @return FS_RES_OK or any error from 'fs_res_t'
|
||||
*/
|
||||
fs_res_t fat32_open (void * file_p, const char * path, fs_mode_t mode);
|
||||
|
||||
/**
|
||||
* Close an already opened file
|
||||
* @param file_p pointer to a FIL type variable
|
||||
* @return FS_RES_OK or any error from fs_res_t
|
||||
*/
|
||||
fs_res_t fat32_close (void * file_p);
|
||||
|
||||
/**
|
||||
* Remove (delete) a file
|
||||
* @param path the path of the file ("dir1/file1.txt")
|
||||
* @return FS_RES_OK or any error from 'fs_res_t'
|
||||
*/
|
||||
fs_res_t fat32_remove(const char * path);
|
||||
|
||||
/**
|
||||
* Read data from an opened file
|
||||
* @param file_p pointer to a FIL type variable
|
||||
* @param buf pointer a buffer to store the read bytes
|
||||
* @param btr the number of Bytes To Read
|
||||
* @param br the number of real read bytes (Bytes Read)
|
||||
* @return FS_RES_OK or any error from 'fs_res_t'
|
||||
*/
|
||||
fs_res_t fat32_read (void * file_p, void * buf, uint32_t btr, uint32_t * br);
|
||||
|
||||
/**
|
||||
* Write data to an opened file
|
||||
* @param file_p pointer to a FIL type variable
|
||||
* @param buf pointer to buffer where the data to write is located
|
||||
* @param btw the number of Bytes To Write
|
||||
* @param bw the number of real written bytes (Bytes Written)
|
||||
* @return FS_RES_OK or any error from 'fs_res_t'
|
||||
*/
|
||||
fs_res_t fat32_write (void * file_p, const void * buf, uint32_t btw, uint32_t * bw);
|
||||
|
||||
/**
|
||||
* Position the read write pointer to given position
|
||||
* @param file_p pointer to a FIL type variable
|
||||
* @param pos the new position expressed in bytes index (0: start of file)
|
||||
* @return FS_RES_OK or any error from 'fs_res_t'
|
||||
*/
|
||||
fs_res_t fat32_seek (void * file_p, uint32_t pos);
|
||||
|
||||
/**
|
||||
* Give the position of the read write pointer
|
||||
* @param file_p pointer to a FIL type variable
|
||||
* @param pos_p pointer to store the position of the read write pointer
|
||||
* @return FS_RES_OK or any error from 'fs_res_t'
|
||||
*/
|
||||
fs_res_t fat32_tell (void * file_p, uint32_t * pos_p);
|
||||
|
||||
/**
|
||||
* Truncate the file size to the current position of read write pointer
|
||||
* @param file_p pointer to a FIL type variable
|
||||
* @return FS_RES_OK or any error from 'fs_res_t'
|
||||
*/
|
||||
fs_res_t fat32_trunc (void * file_p);
|
||||
|
||||
/**
|
||||
* Give the size of a file
|
||||
* @param file_p pointer to a FIL type variable
|
||||
* @param size_p pointer to store the size
|
||||
* @return FS_RES_OK or any error from 'fs_res_t'
|
||||
*/
|
||||
fs_res_t fat32_size (void * file_p, uint32_t * size_p);
|
||||
|
||||
/**
|
||||
* Initialize a variable for directory reading
|
||||
* @param rddir_p pointer to a 'DIR' variable
|
||||
* @param path path to a directory
|
||||
* @return FS_RES_OK or any error from fs_res_t enum
|
||||
*/
|
||||
fs_res_t fat32_readdir_init(void * rddir_p, const char * path);
|
||||
|
||||
/**
|
||||
* Read the next filename form a directory.
|
||||
* The name of the directories will begin with '/'
|
||||
* @param rddir_p pointer to an initialized 'DIR' variable
|
||||
* @param fn pointer to a buffer to store the filename
|
||||
* @return FS_RES_OK or any error from fs_res_t enum
|
||||
*/
|
||||
fs_res_t fat32_readdir(void * rddir_p, char * fn);
|
||||
|
||||
/**
|
||||
* Close the directory reading
|
||||
* @param rddir_p pointer to an initialized 'DIR' variable
|
||||
* @return FS_RES_OK or any error from fs_res_t enum
|
||||
*/
|
||||
fs_res_t fat32_readdir_close(void * rddir_p);
|
||||
|
||||
/**
|
||||
* Give the size of a drive
|
||||
* @param total_p pointer to store the total size [kB]
|
||||
* @param free_p pointer to store the free size [kB]
|
||||
* @return FS_RES_OK or any error from 'fs_res_t'
|
||||
*/
|
||||
fs_res_t fat32_free (uint32_t * total_p, uint32_t * free_p);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
1
misc/fs/fat32/fat32_readme.txt
Normal file
1
misc/fs/fat32/fat32_readme.txt
Normal file
@@ -0,0 +1 @@
|
||||
This is the well known FatFS from http://elm-chan.org/fsw/ff/00index_e.html
|
||||
4681
misc/fs/fat32/ff.c
Normal file
4681
misc/fs/fat32/ff.c
Normal file
File diff suppressed because it is too large
Load Diff
351
misc/fs/fat32/ff.h
Normal file
351
misc/fs/fat32/ff.h
Normal file
@@ -0,0 +1,351 @@
|
||||
/*---------------------------------------------------------------------------/
|
||||
/ FatFs - FAT file system module include R0.11a (C)ChaN, 2015
|
||||
/----------------------------------------------------------------------------/
|
||||
/ FatFs module is a free software that opened under license policy of
|
||||
/ following conditions.
|
||||
/
|
||||
/ Copyright (C) 2015, ChaN, all right reserved.
|
||||
/
|
||||
/ 1. Redistributions of source code must retain the above copyright notice,
|
||||
/ this condition and the following disclaimer.
|
||||
/
|
||||
/ This software is provided by the copyright holder and contributors "AS IS"
|
||||
/ and any warranties related to this software are DISCLAIMED.
|
||||
/ The copyright owner or contributors be NOT LIABLE for any damages caused
|
||||
/ by use of this software.
|
||||
/---------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
#ifndef _FATFS
|
||||
#define _FATFS 64180 /* Revision ID */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "integer.h" /* Basic integer types */
|
||||
#include "ffconf.h" /* FatFs configuration options */
|
||||
|
||||
#if _FATFS != _FFCONF
|
||||
#error Wrong configuration file (ffconf.h).
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/* Definitions of volume management */
|
||||
|
||||
#if _MULTI_PARTITION /* Multiple partition configuration */
|
||||
typedef struct {
|
||||
BYTE pd; /* Physical drive number */
|
||||
BYTE pt; /* Partition: 0:Auto detect, 1-4:Forced partition) */
|
||||
} PARTITION;
|
||||
extern PARTITION VolToPart[]; /* Volume - Partition resolution table */
|
||||
#define LD2PD(vol) (VolToPart[vol].pd) /* Get physical drive number */
|
||||
#define LD2PT(vol) (VolToPart[vol].pt) /* Get partition index */
|
||||
|
||||
#else /* Single partition configuration */
|
||||
#define LD2PD(vol) (BYTE)(vol) /* Each logical drive is bound to the same physical drive number */
|
||||
#define LD2PT(vol) 0 /* Find first valid partition or in SFD */
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/* Type of path name strings on FatFs API */
|
||||
|
||||
#if _LFN_UNICODE /* Unicode string */
|
||||
#if !_USE_LFN
|
||||
#error _LFN_UNICODE must be 0 at non-LFN cfg.
|
||||
#endif
|
||||
#ifndef _INC_TCHAR
|
||||
typedef WCHAR TCHAR;
|
||||
#define _T(x) L ## x
|
||||
#define _TEXT(x) L ## x
|
||||
#endif
|
||||
|
||||
#else /* ANSI/OEM string */
|
||||
#ifndef _INC_TCHAR
|
||||
typedef char TCHAR;
|
||||
#define _T(x) x
|
||||
#define _TEXT(x) x
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/* File system object structure (FATFS) */
|
||||
|
||||
typedef struct {
|
||||
BYTE fs_type; /* FAT sub-type (0:Not mounted) */
|
||||
BYTE drv; /* Physical drive number */
|
||||
BYTE csize; /* Sectors per cluster (1,2,4...128) */
|
||||
BYTE n_fats; /* Number of FAT copies (1 or 2) */
|
||||
BYTE wflag; /* win[] flag (b0:dirty) */
|
||||
BYTE fsi_flag; /* FSINFO flags (b7:disabled, b0:dirty) */
|
||||
WORD id; /* File system mount ID */
|
||||
WORD n_rootdir; /* Number of root directory entries (FAT12/16) */
|
||||
#if _MAX_SS != _MIN_SS
|
||||
WORD ssize; /* Bytes per sector (512, 1024, 2048 or 4096) */
|
||||
#endif
|
||||
#if _FS_REENTRANT
|
||||
_SYNC_t sobj; /* Identifier of sync object */
|
||||
#endif
|
||||
#if !_FS_READONLY
|
||||
DWORD last_clust; /* Last allocated cluster */
|
||||
DWORD free_clust; /* Number of free clusters */
|
||||
#endif
|
||||
#if _FS_RPATH
|
||||
DWORD cdir; /* Current directory start cluster (0:root) */
|
||||
#endif
|
||||
DWORD n_fatent; /* Number of FAT entries, = number of clusters + 2 */
|
||||
DWORD fsize; /* Sectors per FAT */
|
||||
DWORD volbase; /* Volume start sector */
|
||||
DWORD fatbase; /* FAT start sector */
|
||||
DWORD dirbase; /* Root directory start sector (FAT32:Cluster#) */
|
||||
DWORD database; /* Data start sector */
|
||||
DWORD winsect; /* Current sector appearing in the win[] */
|
||||
BYTE win[_MAX_SS]; /* Disk access window for Directory, FAT (and file data at tiny cfg) */
|
||||
} FATFS;
|
||||
|
||||
|
||||
|
||||
/* File object structure (FIL) */
|
||||
|
||||
typedef struct {
|
||||
FATFS* fs; /* Pointer to the related file system object (**do not change order**) */
|
||||
WORD id; /* Owner file system mount ID (**do not change order**) */
|
||||
BYTE flag; /* Status flags */
|
||||
BYTE err; /* Abort flag (error code) */
|
||||
DWORD fptr; /* File read/write pointer (Zeroed on file open) */
|
||||
DWORD fsize; /* File size */
|
||||
DWORD sclust; /* File start cluster (0:no cluster chain, always 0 when fsize is 0) */
|
||||
DWORD clust; /* Current cluster of fpter (not valid when fprt is 0) */
|
||||
DWORD dsect; /* Sector number appearing in buf[] (0:invalid) */
|
||||
#if !_FS_READONLY
|
||||
DWORD dir_sect; /* Sector number containing the directory entry */
|
||||
BYTE* dir_ptr; /* Pointer to the directory entry in the win[] */
|
||||
#endif
|
||||
#if _USE_FASTSEEK
|
||||
DWORD* cltbl; /* Pointer to the cluster link map table (Nulled on file open) */
|
||||
#endif
|
||||
#if _FS_LOCK
|
||||
UINT lockid; /* File lock ID origin from 1 (index of file semaphore table Files[]) */
|
||||
#endif
|
||||
#if !_FS_TINY
|
||||
BYTE buf[_MAX_SS]; /* File private data read/write window */
|
||||
#endif
|
||||
} FIL;
|
||||
|
||||
|
||||
|
||||
/* Directory object structure (DIR) */
|
||||
|
||||
typedef struct {
|
||||
FATFS* fs; /* Pointer to the owner file system object (**do not change order**) */
|
||||
WORD id; /* Owner file system mount ID (**do not change order**) */
|
||||
WORD index; /* Current read/write index number */
|
||||
DWORD sclust; /* Table start cluster (0:Root dir) */
|
||||
DWORD clust; /* Current cluster */
|
||||
DWORD sect; /* Current sector */
|
||||
BYTE* dir; /* Pointer to the current SFN entry in the win[] */
|
||||
BYTE* fn; /* Pointer to the SFN (in/out) {file[8],ext[3],status[1]} */
|
||||
#if _FS_LOCK
|
||||
UINT lockid; /* File lock ID (index of file semaphore table Files[]) */
|
||||
#endif
|
||||
#if _USE_LFN
|
||||
WCHAR* lfn; /* Pointer to the LFN working buffer */
|
||||
WORD lfn_idx; /* Last matched LFN index number (0xFFFF:No LFN) */
|
||||
#endif
|
||||
#if _USE_FIND
|
||||
const TCHAR* pat; /* Pointer to the name matching pattern */
|
||||
#endif
|
||||
} DIR;
|
||||
|
||||
|
||||
|
||||
/* File information structure (FILINFO) */
|
||||
|
||||
typedef struct {
|
||||
DWORD fsize; /* File size */
|
||||
WORD fdate; /* Last modified date */
|
||||
WORD ftime; /* Last modified time */
|
||||
BYTE fattrib; /* Attribute */
|
||||
TCHAR fname[13]; /* Short file name (8.3 format) */
|
||||
#if _USE_LFN
|
||||
TCHAR* lfname; /* Pointer to the LFN buffer */
|
||||
UINT lfsize; /* Size of LFN buffer in TCHAR */
|
||||
#endif
|
||||
} FILINFO;
|
||||
|
||||
|
||||
|
||||
/* File function return code (FRESULT) */
|
||||
|
||||
typedef enum {
|
||||
FR_OK = 0, /* (0) Succeeded */
|
||||
FR_DISK_ERR, /* (1) A hard error occurred in the low level disk I/O layer */
|
||||
FR_INT_ERR, /* (2) Assertion failed */
|
||||
FR_NOT_READY, /* (3) The physical drive cannot work */
|
||||
FR_NO_FILE, /* (4) Could not find the file */
|
||||
FR_NO_PATH, /* (5) Could not find the path */
|
||||
FR_INVALID_NAME, /* (6) The path name format is invalid */
|
||||
FR_DENIED, /* (7) Access denied due to prohibited access or directory full */
|
||||
FR_EXIST, /* (8) Access denied due to prohibited access */
|
||||
FR_INVALID_OBJECT, /* (9) The file/directory object is invalid */
|
||||
FR_WRITE_PROTECTED, /* (10) The physical drive is write protected */
|
||||
FR_INVALID_DRIVE, /* (11) The logical drive number is invalid */
|
||||
FR_NOT_ENABLED, /* (12) The volume has no work area */
|
||||
FR_NO_FILESYSTEM, /* (13) There is no valid FAT volume */
|
||||
FR_MKFS_ABORTED, /* (14) The f_mkfs() aborted due to any parameter error */
|
||||
FR_TIMEOUT, /* (15) Could not get a grant to access the volume within defined period */
|
||||
FR_LOCKED, /* (16) The operation is rejected according to the file sharing policy */
|
||||
FR_NOT_ENOUGH_CORE, /* (17) LFN working buffer could not be allocated */
|
||||
FR_TOO_MANY_OPEN_FILES, /* (18) Number of open files > _FS_LOCK */
|
||||
FR_INVALID_PARAMETER /* (19) Given parameter is invalid */
|
||||
} FRESULT;
|
||||
|
||||
|
||||
|
||||
/*--------------------------------------------------------------*/
|
||||
/* FatFs module application interface */
|
||||
|
||||
FRESULT f_open (FIL* fp, const TCHAR* path, BYTE mode); /* Open or create a file */
|
||||
FRESULT f_close (FIL* fp); /* Close an open file object */
|
||||
FRESULT f_read (FIL* fp, void* buff, UINT btr, UINT* br); /* Read data from a file */
|
||||
FRESULT f_write (FIL* fp, const void* buff, UINT btw, UINT* bw); /* Write data to a file */
|
||||
FRESULT f_forward (FIL* fp, UINT(*func)(const BYTE*,UINT), UINT btf, UINT* bf); /* Forward data to the stream */
|
||||
FRESULT f_lseek (FIL* fp, DWORD ofs); /* Move file pointer of a file object */
|
||||
FRESULT f_truncate (FIL* fp); /* Truncate file */
|
||||
FRESULT f_sync (FIL* fp); /* Flush cached data of a writing file */
|
||||
FRESULT f_opendir (DIR* dp, const TCHAR* path); /* Open a directory */
|
||||
FRESULT f_closedir (DIR* dp); /* Close an open directory */
|
||||
FRESULT f_readdir (DIR* dp, FILINFO* fno); /* Read a directory item */
|
||||
FRESULT f_findfirst (DIR* dp, FILINFO* fno, const TCHAR* path, const TCHAR* pattern); /* Find first file */
|
||||
FRESULT f_findnext (DIR* dp, FILINFO* fno); /* Find next file */
|
||||
FRESULT f_mkdir (const TCHAR* path); /* Create a sub directory */
|
||||
FRESULT f_unlink (const TCHAR* path); /* Delete an existing file or directory */
|
||||
FRESULT f_rename (const TCHAR* path_old, const TCHAR* path_new); /* Rename/Move a file or directory */
|
||||
FRESULT f_stat (const TCHAR* path, FILINFO* fno); /* Get file status */
|
||||
FRESULT f_chmod (const TCHAR* path, BYTE attr, BYTE mask); /* Change attribute of the file/dir */
|
||||
FRESULT f_utime (const TCHAR* path, const FILINFO* fno); /* Change times-tamp of the file/dir */
|
||||
FRESULT f_chdir (const TCHAR* path); /* Change current directory */
|
||||
FRESULT f_chdrive (const TCHAR* path); /* Change current drive */
|
||||
FRESULT f_getcwd (TCHAR* buff, UINT len); /* Get current directory */
|
||||
FRESULT f_getfree (const TCHAR* path, DWORD* nclst, FATFS** fatfs); /* Get number of free clusters on the drive */
|
||||
FRESULT f_getlabel (const TCHAR* path, TCHAR* label, DWORD* vsn); /* Get volume label */
|
||||
FRESULT f_setlabel (const TCHAR* label); /* Set volume label */
|
||||
FRESULT f_mount (FATFS* fs, const TCHAR* path, BYTE opt); /* Mount/Unmount a logical drive */
|
||||
FRESULT f_mkfs (const TCHAR* path, BYTE sfd, UINT au); /* Create a file system on the volume */
|
||||
FRESULT f_fdisk (BYTE pdrv, const DWORD szt[], void* work); /* Divide a physical drive into some partitions */
|
||||
int f_putc (TCHAR c, FIL* fp); /* Put a character to the file */
|
||||
int f_puts (const TCHAR* str, FIL* cp); /* Put a string to the file */
|
||||
int f_printf (FIL* fp, const TCHAR* str, ...); /* Put a formatted string to the file */
|
||||
TCHAR* f_gets (TCHAR* buff, int len, FIL* fp); /* Get a string from the file */
|
||||
|
||||
#define f_eof(fp) ((int)((fp)->fptr == (fp)->fsize))
|
||||
#define f_error(fp) ((fp)->err)
|
||||
#define f_tell(fp) ((fp)->fptr)
|
||||
#define f_size(fp) ((fp)->fsize)
|
||||
#define f_rewind(fp) f_lseek((fp), 0)
|
||||
#define f_rewinddir(dp) f_readdir((dp), 0)
|
||||
|
||||
#ifndef EOF
|
||||
#define EOF (-1)
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
/*--------------------------------------------------------------*/
|
||||
/* Additional user defined functions */
|
||||
|
||||
/* RTC function */
|
||||
#if !_FS_READONLY && !_FS_NORTC
|
||||
DWORD get_fattime (void);
|
||||
#endif
|
||||
|
||||
/* Unicode support functions */
|
||||
#if _USE_LFN /* Unicode - OEM code conversion */
|
||||
WCHAR ff_convert (WCHAR chr, UINT dir); /* OEM-Unicode bidirectional conversion */
|
||||
WCHAR ff_wtoupper (WCHAR chr); /* Unicode upper-case conversion */
|
||||
#if _USE_LFN == 3 /* Memory functions */
|
||||
void* ff_memalloc (UINT msize); /* Allocate memory block */
|
||||
void ff_memfree (void* mblock); /* Free memory block */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Sync functions */
|
||||
#if _FS_REENTRANT
|
||||
int ff_cre_syncobj (BYTE vol, _SYNC_t* sobj); /* Create a sync object */
|
||||
int ff_req_grant (_SYNC_t sobj); /* Lock sync object */
|
||||
void ff_rel_grant (_SYNC_t sobj); /* Unlock sync object */
|
||||
int ff_del_syncobj (_SYNC_t sobj); /* Delete a sync object */
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
/*--------------------------------------------------------------*/
|
||||
/* Flags and offset address */
|
||||
|
||||
|
||||
/* File access control and file status flags (FIL.flag) */
|
||||
|
||||
#define FA_READ 0x01
|
||||
#define FA_OPEN_EXISTING 0x00
|
||||
|
||||
#if !_FS_READONLY
|
||||
#define FA_WRITE 0x02
|
||||
#define FA_CREATE_NEW 0x04
|
||||
#define FA_CREATE_ALWAYS 0x08
|
||||
#define FA_OPEN_ALWAYS 0x10
|
||||
#define FA__WRITTEN 0x20
|
||||
#define FA__DIRTY 0x40
|
||||
#endif
|
||||
|
||||
|
||||
/* FAT sub type (FATFS.fs_type) */
|
||||
|
||||
#define FS_FAT12 1
|
||||
#define FS_FAT16 2
|
||||
#define FS_FAT32 3
|
||||
|
||||
|
||||
/* File attribute bits for directory entry */
|
||||
|
||||
#define AM_RDO 0x01 /* Read only */
|
||||
#define AM_HID 0x02 /* Hidden */
|
||||
#define AM_SYS 0x04 /* System */
|
||||
#define AM_VOL 0x08 /* Volume label */
|
||||
#define AM_LFN 0x0F /* LFN entry */
|
||||
#define AM_DIR 0x10 /* Directory */
|
||||
#define AM_ARC 0x20 /* Archive */
|
||||
#define AM_MASK 0x3F /* Mask of defined bits */
|
||||
|
||||
|
||||
/* Fast seek feature */
|
||||
#define CREATE_LINKMAP 0xFFFFFFFF
|
||||
|
||||
|
||||
|
||||
/*--------------------------------*/
|
||||
/* Multi-byte word access macros */
|
||||
|
||||
#if _WORD_ACCESS == 1 /* Enable word access to the FAT structure */
|
||||
#define LD_WORD(ptr) (WORD)(*(WORD*)(BYTE*)(ptr))
|
||||
#define LD_DWORD(ptr) (DWORD)(*(DWORD*)(BYTE*)(ptr))
|
||||
#define ST_WORD(ptr,val) *(WORD*)(BYTE*)(ptr)=(WORD)(val)
|
||||
#define ST_DWORD(ptr,val) *(DWORD*)(BYTE*)(ptr)=(DWORD)(val)
|
||||
#else /* Use byte-by-byte access to the FAT structure */
|
||||
#define LD_WORD(ptr) (WORD)(((WORD)*((BYTE*)(ptr)+1)<<8)|(WORD)*(BYTE*)(ptr))
|
||||
#define LD_DWORD(ptr) (DWORD)(((DWORD)*((BYTE*)(ptr)+3)<<24)|((DWORD)*((BYTE*)(ptr)+2)<<16)|((WORD)*((BYTE*)(ptr)+1)<<8)|*(BYTE*)(ptr))
|
||||
#define ST_WORD(ptr,val) *(BYTE*)(ptr)=(BYTE)(val); *((BYTE*)(ptr)+1)=(BYTE)((WORD)(val)>>8)
|
||||
#define ST_DWORD(ptr,val) *(BYTE*)(ptr)=(BYTE)(val); *((BYTE*)(ptr)+1)=(BYTE)((WORD)(val)>>8); *((BYTE*)(ptr)+2)=(BYTE)((DWORD)(val)>>16); *((BYTE*)(ptr)+3)=(BYTE)((DWORD)(val)>>24)
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _FATFS */
|
||||
276
misc/fs/fat32/ffconf.h
Normal file
276
misc/fs/fat32/ffconf.h
Normal file
@@ -0,0 +1,276 @@
|
||||
/*---------------------------------------------------------------------------/
|
||||
/ FatFs - FAT file system module configuration file R0.11a (C)ChaN, 2015
|
||||
/---------------------------------------------------------------------------*/
|
||||
|
||||
#define _FFCONF 64180 /* Revision ID */
|
||||
|
||||
/*---------------------------------------------------------------------------/
|
||||
/ Function Configurations
|
||||
/---------------------------------------------------------------------------*/
|
||||
|
||||
#define _FS_READONLY 0
|
||||
/* This option switches read-only configuration. (0:Read/Write or 1:Read-only)
|
||||
/ Read-only configuration removes writing API functions, f_write(), f_sync(),
|
||||
/ f_unlink(), f_mkdir(), f_chmod(), f_rename(), f_truncate(), f_getfree()
|
||||
/ and optional writing functions as well. */
|
||||
|
||||
|
||||
#define _FS_MINIMIZE 0
|
||||
/* This option defines minimization level to remove some basic API functions.
|
||||
/
|
||||
/ 0: All basic functions are enabled.
|
||||
/ 1: f_stat(), f_getfree(), f_unlink(), f_mkdir(), f_chmod(), f_utime(),
|
||||
/ f_truncate() and f_rename() function are removed.
|
||||
/ 2: f_opendir(), f_readdir() and f_closedir() are removed in addition to 1.
|
||||
/ 3: f_lseek() function is removed in addition to 2. */
|
||||
|
||||
|
||||
#define _USE_STRFUNC 0
|
||||
/* This option switches string functions, f_gets(), f_putc(), f_puts() and
|
||||
/ f_printf().
|
||||
/
|
||||
/ 0: Disable string functions.
|
||||
/ 1: Enable without LF-CRLF conversion.
|
||||
/ 2: Enable with LF-CRLF conversion. */
|
||||
|
||||
|
||||
#define _USE_FIND 0
|
||||
/* This option switches filtered directory read feature and related functions,
|
||||
/ f_findfirst() and f_findnext(). (0:Disable or 1:Enable) */
|
||||
|
||||
|
||||
#define _USE_MKFS 0
|
||||
/* This option switches f_mkfs() function. (0:Disable or 1:Enable) */
|
||||
|
||||
|
||||
#define _USE_FASTSEEK 0
|
||||
/* This option switches fast seek feature. (0:Disable or 1:Enable) */
|
||||
|
||||
|
||||
#define _USE_LABEL 0
|
||||
/* This option switches volume label functions, f_getlabel() and f_setlabel().
|
||||
/ (0:Disable or 1:Enable) */
|
||||
|
||||
|
||||
#define _USE_FORWARD 0
|
||||
/* This option switches f_forward() function. (0:Disable or 1:Enable)
|
||||
/ To enable it, also _FS_TINY need to be set to 1. */
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------/
|
||||
/ Locale and Namespace Configurations
|
||||
/---------------------------------------------------------------------------*/
|
||||
|
||||
#define _CODE_PAGE 437
|
||||
/* This option specifies the OEM code page to be used on the target system.
|
||||
/ Incorrect setting of the code page can cause a file open failure.
|
||||
/
|
||||
/ 1 - ASCII (No extended character. Non-LFN cfg. only)
|
||||
/ 437 - U.S.
|
||||
/ 720 - Arabic
|
||||
/ 737 - Greek
|
||||
/ 771 - KBL
|
||||
/ 775 - Baltic
|
||||
/ 850 - Latin 1
|
||||
/ 852 - Latin 2
|
||||
/ 855 - Cyrillic
|
||||
/ 857 - Turkish
|
||||
/ 860 - Portuguese
|
||||
/ 861 - Icelandic
|
||||
/ 862 - Hebrew
|
||||
/ 863 - Canadian French
|
||||
/ 864 - Arabic
|
||||
/ 865 - Nordic
|
||||
/ 866 - Russian
|
||||
/ 869 - Greek 2
|
||||
/ 932 - Japanese (DBCS)
|
||||
/ 936 - Simplified Chinese (DBCS)
|
||||
/ 949 - Korean (DBCS)
|
||||
/ 950 - Traditional Chinese (DBCS)
|
||||
*/
|
||||
|
||||
|
||||
#define _USE_LFN 1
|
||||
#define _MAX_LFN 255
|
||||
/* The _USE_LFN option switches the LFN feature.
|
||||
/
|
||||
/ 0: Disable LFN feature. _MAX_LFN has no effect.
|
||||
/ 1: Enable LFN with static working buffer on the BSS. Always NOT thread-safe.
|
||||
/ 2: Enable LFN with dynamic working buffer on the STACK.
|
||||
/ 3: Enable LFN with dynamic working buffer on the HEAP.
|
||||
/
|
||||
/ When enable the LFN feature, Unicode handling functions (option/unicode.c) must
|
||||
/ be added to the project. The LFN working buffer occupies (_MAX_LFN + 1) * 2 bytes.
|
||||
/ When use stack for the working buffer, take care on stack overflow. When use heap
|
||||
/ memory for the working buffer, memory management functions, ff_memalloc() and
|
||||
/ ff_memfree(), must be added to the project. */
|
||||
|
||||
|
||||
#define _LFN_UNICODE 0
|
||||
/* This option switches character encoding on the API. (0:ANSI/OEM or 1:Unicode)
|
||||
/ To use Unicode string for the path name, enable LFN feature and set _LFN_UNICODE
|
||||
/ to 1. This option also affects behavior of string I/O functions. */
|
||||
|
||||
|
||||
#define _STRF_ENCODE 3
|
||||
/* When _LFN_UNICODE is 1, this option selects the character encoding on the file to
|
||||
/ be read/written via string I/O functions, f_gets(), f_putc(), f_puts and f_printf().
|
||||
/
|
||||
/ 0: ANSI/OEM
|
||||
/ 1: UTF-16LE
|
||||
/ 2: UTF-16BE
|
||||
/ 3: UTF-8
|
||||
/
|
||||
/ When _LFN_UNICODE is 0, this option has no effect. */
|
||||
|
||||
|
||||
#define _FS_RPATH 0
|
||||
/* This option configures relative path feature.
|
||||
/
|
||||
/ 0: Disable relative path feature and remove related functions.
|
||||
/ 1: Enable relative path feature. f_chdir() and f_chdrive() are available.
|
||||
/ 2: f_getcwd() function is available in addition to 1.
|
||||
/
|
||||
/ Note that directory items read via f_readdir() are affected by this option. */
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------/
|
||||
/ Drive/Volume Configurations
|
||||
/---------------------------------------------------------------------------*/
|
||||
|
||||
#define _VOLUMES 1
|
||||
/* Number of volumes (logical drives) to be used. */
|
||||
|
||||
|
||||
#define _STR_VOLUME_ID 0
|
||||
#define _VOLUME_STRS "RAM","NAND","CF","SD1","SD2","USB1","USB2","USB3"
|
||||
/* _STR_VOLUME_ID option switches string volume ID feature.
|
||||
/ When _STR_VOLUME_ID is set to 1, also pre-defined strings can be used as drive
|
||||
/ number in the path name. _VOLUME_STRS defines the drive ID strings for each
|
||||
/ logical drives. Number of items must be equal to _VOLUMES. Valid characters for
|
||||
/ the drive ID strings are: A-Z and 0-9. */
|
||||
|
||||
|
||||
#define _MULTI_PARTITION 0
|
||||
/* This option switches multi-partition feature. By default (0), each logical drive
|
||||
/ number is bound to the same physical drive number and only an FAT volume found on
|
||||
/ the physical drive will be mounted. When multi-partition feature is enabled (1),
|
||||
/ each logical drive number is bound to arbitrary physical drive and partition
|
||||
/ listed in the VolToPart[]. Also f_fdisk() funciton will be available. */
|
||||
|
||||
|
||||
#define _MIN_SS 512
|
||||
#define _MAX_SS 512
|
||||
/* These options configure the range of sector size to be supported. (512, 1024,
|
||||
/ 2048 or 4096) Always set both 512 for most systems, all type of memory cards and
|
||||
/ harddisk. But a larger value may be required for on-board flash memory and some
|
||||
/ type of optical media. When _MAX_SS is larger than _MIN_SS, FatFs is configured
|
||||
/ to variable sector size and GET_SECTOR_SIZE command must be implemented to the
|
||||
/ disk_ioctl() function. */
|
||||
|
||||
|
||||
#define _USE_TRIM 0
|
||||
/* This option switches ATA-TRIM feature. (0:Disable or 1:Enable)
|
||||
/ To enable Trim feature, also CTRL_TRIM command should be implemented to the
|
||||
/ disk_ioctl() function. */
|
||||
|
||||
|
||||
#define _FS_NOFSINFO 0
|
||||
/* If you need to know correct free space on the FAT32 volume, set bit 0 of this
|
||||
/ option, and f_getfree() function at first time after volume mount will force
|
||||
/ a full FAT scan. Bit 1 controls the use of last allocated cluster number.
|
||||
/
|
||||
/ bit0=0: Use free cluster count in the FSINFO if available.
|
||||
/ bit0=1: Do not trust free cluster count in the FSINFO.
|
||||
/ bit1=0: Use last allocated cluster number in the FSINFO if available.
|
||||
/ bit1=1: Do not trust last allocated cluster number in the FSINFO.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------/
|
||||
/ System Configurations
|
||||
/---------------------------------------------------------------------------*/
|
||||
|
||||
#define _FS_TINY 0
|
||||
/* This option switches tiny buffer configuration. (0:Normal or 1:Tiny)
|
||||
/ At the tiny configuration, size of the file object (FIL) is reduced _MAX_SS
|
||||
/ bytes. Instead of private sector buffer eliminated from the file object,
|
||||
/ common sector buffer in the file system object (FATFS) is used for the file
|
||||
/ data transfer. */
|
||||
|
||||
|
||||
#define _FS_NORTC 1
|
||||
#define _NORTC_MON 1
|
||||
#define _NORTC_MDAY 1
|
||||
#define _NORTC_YEAR 2015
|
||||
/* The _FS_NORTC option switches timestamp feature. If the system does not have
|
||||
/ an RTC function or valid timestamp is not needed, set _FS_NORTC to 1 to disable
|
||||
/ the timestamp feature. All objects modified by FatFs will have a fixed timestamp
|
||||
/ defined by _NORTC_MON, _NORTC_MDAY and _NORTC_YEAR.
|
||||
/ When timestamp feature is enabled (_FS_NORTC == 0), get_fattime() function need
|
||||
/ to be added to the project to read current time form RTC. _NORTC_MON,
|
||||
/ _NORTC_MDAY and _NORTC_YEAR have no effect.
|
||||
/ These options have no effect at read-only configuration (_FS_READONLY == 1). */
|
||||
|
||||
|
||||
#define _FS_LOCK 0
|
||||
/* The _FS_LOCK option switches file lock feature to control duplicated file open
|
||||
/ and illegal operation to open objects. This option must be 0 when _FS_READONLY
|
||||
/ is 1.
|
||||
/
|
||||
/ 0: Disable file lock feature. To avoid volume corruption, application program
|
||||
/ should avoid illegal open, remove and rename to the open objects.
|
||||
/ >0: Enable file lock feature. The value defines how many files/sub-directories
|
||||
/ can be opened simultaneously under file lock control. Note that the file
|
||||
/ lock feature is independent of re-entrancy. */
|
||||
|
||||
|
||||
#define _FS_REENTRANT 0
|
||||
#define _FS_TIMEOUT 1000
|
||||
#define _SYNC_t HANDLE
|
||||
/* The _FS_REENTRANT option switches the re-entrancy (thread safe) of the FatFs
|
||||
/ module itself. Note that regardless of this option, file access to different
|
||||
/ volume is always re-entrant and volume control functions, f_mount(), f_mkfs()
|
||||
/ and f_fdisk() function, are always not re-entrant. Only file/directory access
|
||||
/ to the same volume is under control of this feature.
|
||||
/
|
||||
/ 0: Disable re-entrancy. _FS_TIMEOUT and _SYNC_t have no effect.
|
||||
/ 1: Enable re-entrancy. Also user provided synchronization handlers,
|
||||
/ ff_req_grant(), ff_rel_grant(), ff_del_syncobj() and ff_cre_syncobj()
|
||||
/ function, must be added to the project. Samples are available in
|
||||
/ option/syscall.c.
|
||||
/
|
||||
/ The _FS_TIMEOUT defines timeout period in unit of time tick.
|
||||
/ The _SYNC_t defines O/S dependent sync object type. e.g. HANDLE, ID, OS_EVENT*,
|
||||
/ SemaphoreHandle_t and etc.. A header file for O/S definitions needs to be
|
||||
/ included somewhere in the scope of ff.c. */
|
||||
|
||||
|
||||
#define _WORD_ACCESS 0
|
||||
/* The _WORD_ACCESS option is an only platform dependent option. It defines
|
||||
/ which access method is used to the word data on the FAT volume.
|
||||
/
|
||||
/ 0: Byte-by-byte access. Always compatible with all platforms.
|
||||
/ 1: Word access. Do not choose this unless under both the following conditions.
|
||||
/
|
||||
/ * Address misaligned memory access is always allowed to ALL instructions.
|
||||
/ * Byte order on the memory is little-endian.
|
||||
/
|
||||
/ If it is the case, _WORD_ACCESS can also be set to 1 to reduce code size.
|
||||
/ Following table shows allowable settings of some type of processors.
|
||||
/
|
||||
/ ARM7TDMI 0 *2 ColdFire 0 *1 V850E 0 *2
|
||||
/ Cortex-M3 0 *3 Z80 0/1 V850ES 0/1
|
||||
/ Cortex-M0 0 *2 x86 0/1 TLCS-870 0/1
|
||||
/ AVR 0/1 RX600(LE) 0/1 TLCS-900 0/1
|
||||
/ AVR32 0 *1 RL78 0 *2 R32C 0 *2
|
||||
/ PIC18 0/1 SH-2 0 *1 M16C 0/1
|
||||
/ PIC24 0 *2 H8S 0 *1 MSP430 0 *2
|
||||
/ PIC32 0 *1 H8/300H 0 *1 8051 0/1
|
||||
/
|
||||
/ *1:Big-endian.
|
||||
/ *2:Unaligned memory access is not supported.
|
||||
/ *3:Some compilers generate LDM/STM for mem_cpy function.
|
||||
*/
|
||||
|
||||
42
misc/fs/fat32/integer.h
Normal file
42
misc/fs/fat32/integer.h
Normal file
@@ -0,0 +1,42 @@
|
||||
/*-------------------------------------------*/
|
||||
/* Integer type definitions for FatFs module */
|
||||
/*-------------------------------------------*/
|
||||
|
||||
#ifndef _FF_INTEGER
|
||||
#define _FF_INTEGER
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef _WIN32 /* Development platform */
|
||||
|
||||
#include <windows.h>
|
||||
#include <tchar.h>
|
||||
|
||||
#else /* Embedded platform */
|
||||
|
||||
/* This type MUST be 8-bit */
|
||||
typedef unsigned char BYTE;
|
||||
|
||||
/* These types MUST be 16-bit */
|
||||
typedef short SHORT;
|
||||
typedef unsigned short WORD;
|
||||
typedef unsigned short WCHAR;
|
||||
|
||||
/* These types MUST be 16-bit or 32-bit */
|
||||
typedef int INT;
|
||||
typedef unsigned int UINT;
|
||||
|
||||
/* These types MUST be 32-bit */
|
||||
typedef long LONG;
|
||||
typedef unsigned long DWORD;
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif
|
||||
348
misc/fs/fat32/option/ccsbcs.c
Normal file
348
misc/fs/fat32/option/ccsbcs.c
Normal file
@@ -0,0 +1,348 @@
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* Unicode - Local code bidirectional converter (C)ChaN, 2015 */
|
||||
/* (SBCS code pages) */
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* 437 U.S.
|
||||
/ 720 Arabic
|
||||
/ 737 Greek
|
||||
/ 771 KBL
|
||||
/ 775 Baltic
|
||||
/ 850 Latin 1
|
||||
/ 852 Latin 2
|
||||
/ 855 Cyrillic
|
||||
/ 857 Turkish
|
||||
/ 860 Portuguese
|
||||
/ 861 Icelandic
|
||||
/ 862 Hebrew
|
||||
/ 863 Canadian French
|
||||
/ 864 Arabic
|
||||
/ 865 Nordic
|
||||
/ 866 Russian
|
||||
/ 869 Greek 2
|
||||
*/
|
||||
#include "misc_conf.h"
|
||||
#if USE_FAT32 != 0
|
||||
#include "../ff.h"
|
||||
|
||||
|
||||
#if _CODE_PAGE == 437
|
||||
#define _TBLDEF 1
|
||||
static
|
||||
const WCHAR Tbl[] = { /* CP437(0x80-0xFF) to Unicode conversion table */
|
||||
0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5,
|
||||
0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9, 0x00FF, 0x00D6, 0x00DC, 0x00A2, 0x00A3, 0x00A5, 0x20A7, 0x0192,
|
||||
0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA, 0x00BF, 0x2310, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB,
|
||||
0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510,
|
||||
0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567,
|
||||
0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580,
|
||||
0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229,
|
||||
0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0
|
||||
};
|
||||
|
||||
#elif _CODE_PAGE == 720
|
||||
#define _TBLDEF 1
|
||||
static
|
||||
const WCHAR Tbl[] = { /* CP720(0x80-0xFF) to Unicode conversion table */
|
||||
0x0000, 0x0000, 0x00E9, 0x00E2, 0x0000, 0x00E0, 0x0000, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x0000, 0x0000, 0x0000,
|
||||
0x0000, 0x0651, 0x0652, 0x00F4, 0x00A4, 0x0640, 0x00FB, 0x00F9, 0x0621, 0x0622, 0x0623, 0x0624, 0x00A3, 0x0625, 0x0626, 0x0627,
|
||||
0x0628, 0x0629, 0x062A, 0x062B, 0x062C, 0x062D, 0x062E, 0x062F, 0x0630, 0x0631, 0x0632, 0x0633, 0x0634, 0x0635, 0x00AB, 0x00BB,
|
||||
0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510,
|
||||
0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567,
|
||||
0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580,
|
||||
0x0636, 0x0637, 0x0638, 0x0639, 0x063A, 0x0641, 0x00B5, 0x0642, 0x0643, 0x0644, 0x0645, 0x0646, 0x0647, 0x0648, 0x0649, 0x064A,
|
||||
0x2261, 0x064B, 0x064C, 0x064D, 0x064E, 0x064F, 0x0650, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0
|
||||
};
|
||||
|
||||
#elif _CODE_PAGE == 737
|
||||
#define _TBLDEF 1
|
||||
static
|
||||
const WCHAR Tbl[] = { /* CP737(0x80-0xFF) to Unicode conversion table */
|
||||
0x0391, 0x0392, 0x0393, 0x0394, 0x0395, 0x0396, 0x0397, 0x0398, 0x0399, 0x039A, 0x039B, 0x039C, 0x039D, 0x039E, 0x039F, 0x03A0,
|
||||
0x03A1, 0x03A3, 0x03A4, 0x03A5, 0x03A6, 0x03A7, 0x03A8, 0x03A9, 0x03B1, 0x03B2, 0x03B3, 0x03B4, 0x03B5, 0x03B6, 0x03B7, 0x03B8,
|
||||
0x03B9, 0x03BA, 0x03BB, 0x03BC, 0x03BD, 0x03BE, 0x03BF, 0x03C0, 0x03C1, 0x03C3, 0x03C2, 0x03C4, 0x03C5, 0x03C6, 0x03C7, 0x03C8,
|
||||
0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510,
|
||||
0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567,
|
||||
0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580,
|
||||
0x03C9, 0x03AC, 0x03AD, 0x03AE, 0x03CA, 0x03AF, 0x03CC, 0x03CD, 0x03CB, 0x03CE, 0x0386, 0x0388, 0x0389, 0x038A, 0x038C, 0x038E,
|
||||
0x038F, 0x00B1, 0x2265, 0x2264, 0x03AA, 0x03AB, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0
|
||||
};
|
||||
|
||||
#elif _CODE_PAGE == 771
|
||||
#define _TBLDEF 1
|
||||
static
|
||||
const WCHAR Tbl[] = { /* CP771(0x80-0xFF) to Unicode conversion table */
|
||||
0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417, 0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E, 0x041F,
|
||||
0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427, 0x0428, 0x0429, 0x042A, 0x042B, 0x042C, 0x042D, 0x042E, 0x042F,
|
||||
0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437, 0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E, 0x043F,
|
||||
0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x2558, 0x2510,
|
||||
0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567,
|
||||
0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x0104, 0x0105, 0x010C, 0x010D,
|
||||
0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447, 0x0448, 0x0449, 0x044A, 0x044B, 0x044C, 0x044D, 0x044E, 0x044F,
|
||||
0x0118, 0x0119, 0x0116, 0x0117, 0x012E, 0x012F, 0x0160, 0x0161, 0x0172, 0x0173, 0x016A, 0x016B, 0x017D, 0x017E, 0x25A0, 0x00A0
|
||||
};
|
||||
|
||||
#elif _CODE_PAGE == 775
|
||||
#define _TBLDEF 1
|
||||
static
|
||||
const WCHAR Tbl[] = { /* CP775(0x80-0xFF) to Unicode conversion table */
|
||||
0x0106, 0x00FC, 0x00E9, 0x0101, 0x00E4, 0x0123, 0x00E5, 0x0107, 0x0142, 0x0113, 0x0156, 0x0157, 0x012B, 0x0179, 0x00C4, 0x00C5,
|
||||
0x00C9, 0x00E6, 0x00C6, 0x014D, 0x00F6, 0x0122, 0x00A2, 0x015A, 0x015B, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x00D7, 0x00A4,
|
||||
0x0100, 0x012A, 0x00F3, 0x017B, 0x017C, 0x017A, 0x201D, 0x00A6, 0x00A9, 0x00AE, 0x00AC, 0x00BD, 0x00BC, 0x0141, 0x00AB, 0x00BB,
|
||||
0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x0104, 0x010C, 0x0118, 0x0116, 0x2563, 0x2551, 0x2557, 0x255D, 0x012E, 0x0160, 0x2510,
|
||||
0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x0172, 0x016A, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x017D,
|
||||
0x0105, 0x010D, 0x0119, 0x0117, 0x012F, 0x0161, 0x0173, 0x016B, 0x017E, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580,
|
||||
0x00D3, 0x00DF, 0x014C, 0x0143, 0x00F5, 0x00D5, 0x00B5, 0x0144, 0x0136, 0x0137, 0x013B, 0x013C, 0x0146, 0x0112, 0x0145, 0x2019,
|
||||
0x00AD, 0x00B1, 0x201C, 0x00BE, 0x00B6, 0x00A7, 0x00F7, 0x201E, 0x00B0, 0x2219, 0x00B7, 0x00B9, 0x00B3, 0x00B2, 0x25A0, 0x00A0
|
||||
};
|
||||
|
||||
#elif _CODE_PAGE == 850
|
||||
#define _TBLDEF 1
|
||||
static
|
||||
const WCHAR Tbl[] = { /* CP850(0x80-0xFF) to Unicode conversion table */
|
||||
0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5,
|
||||
0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9, 0x00FF, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x00D7, 0x0192,
|
||||
0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA, 0x00BF, 0x00AE, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB,
|
||||
0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x00C1, 0x00C2, 0x00C0, 0x00A9, 0x2563, 0x2551, 0x2557, 0x255D, 0x00A2, 0x00A5, 0x2510,
|
||||
0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x00E3, 0x00C3, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4,
|
||||
0x00F0, 0x00D0, 0x00CA, 0x00CB, 0x00C8, 0x0131, 0x00CD, 0x00CE, 0x00CF, 0x2518, 0x250C, 0x2588, 0x2584, 0x00A6, 0x00CC, 0x2580,
|
||||
0x00D3, 0x00DF, 0x00D4, 0x00D2, 0x00F5, 0x00D5, 0x00B5, 0x00FE, 0x00DE, 0x00DA, 0x00DB, 0x00D9, 0x00FD, 0x00DD, 0x00AF, 0x00B4,
|
||||
0x00AD, 0x00B1, 0x2017, 0x00BE, 0x00B6, 0x00A7, 0x00F7, 0x00B8, 0x00B0, 0x00A8, 0x00B7, 0x00B9, 0x00B3, 0x00B2, 0x25A0, 0x00A0
|
||||
};
|
||||
|
||||
#elif _CODE_PAGE == 852
|
||||
#define _TBLDEF 1
|
||||
static
|
||||
const WCHAR Tbl[] = { /* CP852(0x80-0xFF) to Unicode conversion table */
|
||||
0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x016F, 0x0107, 0x00E7, 0x0142, 0x00EB, 0x0150, 0x0151, 0x00EE, 0x0179, 0x00C4, 0x0106,
|
||||
0x00C9, 0x0139, 0x013A, 0x00F4, 0x00F6, 0x013D, 0x013E, 0x015A, 0x015B, 0x00D6, 0x00DC, 0x0164, 0x0165, 0x0141, 0x00D7, 0x010D,
|
||||
0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x0104, 0x0105, 0x017D, 0x017E, 0x0118, 0x0119, 0x00AC, 0x017A, 0x010C, 0x015F, 0x00AB, 0x00BB,
|
||||
0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x00C1, 0x00C2, 0x011A, 0x015E, 0x2563, 0x2551, 0x2557, 0x255D, 0x017B, 0x017C, 0x2510,
|
||||
0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x0102, 0x0103, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4,
|
||||
0x0111, 0x0110, 0x010E, 0x00CB, 0x010F, 0x0147, 0x00CD, 0x00CE, 0x011B, 0x2518, 0x250C, 0x2588, 0x2584, 0x0162, 0x016E, 0x2580,
|
||||
0x00D3, 0x00DF, 0x00D4, 0x0143, 0x0144, 0x0148, 0x0160, 0x0161, 0x0154, 0x00DA, 0x0155, 0x0170, 0x00FD, 0x00DD, 0x0163, 0x00B4,
|
||||
0x00AD, 0x02DD, 0x02DB, 0x02C7, 0x02D8, 0x00A7, 0x00F7, 0x00B8, 0x00B0, 0x00A8, 0x02D9, 0x0171, 0x0158, 0x0159, 0x25A0, 0x00A0
|
||||
};
|
||||
|
||||
#elif _CODE_PAGE == 855
|
||||
#define _TBLDEF 1
|
||||
static
|
||||
const WCHAR Tbl[] = { /* CP855(0x80-0xFF) to Unicode conversion table */
|
||||
0x0452, 0x0402, 0x0453, 0x0403, 0x0451, 0x0401, 0x0454, 0x0404, 0x0455, 0x0405, 0x0456, 0x0406, 0x0457, 0x0407, 0x0458, 0x0408,
|
||||
0x0459, 0x0409, 0x045A, 0x040A, 0x045B, 0x040B, 0x045C, 0x040C, 0x045E, 0x040E, 0x045F, 0x040F, 0x044E, 0x042E, 0x044A, 0x042A,
|
||||
0x0430, 0x0410, 0x0431, 0x0411, 0x0446, 0x0426, 0x0434, 0x0414, 0x0435, 0x0415, 0x0444, 0x0424, 0x0433, 0x0413, 0x00AB, 0x00BB,
|
||||
0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x0445, 0x0425, 0x0438, 0x0418, 0x2563, 0x2551, 0x2557, 0x255D, 0x0439, 0x0419, 0x2510,
|
||||
0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x043A, 0x041A, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4,
|
||||
0x043B, 0x041B, 0x043C, 0x041C, 0x043D, 0x041D, 0x043E, 0x041E, 0x043F, 0x2518, 0x250C, 0x2588, 0x2584, 0x041F, 0x044F, 0x2580,
|
||||
0x042F, 0x0440, 0x0420, 0x0441, 0x0421, 0x0442, 0x0422, 0x0443, 0x0423, 0x0436, 0x0416, 0x0432, 0x0412, 0x044C, 0x042C, 0x2116,
|
||||
0x00AD, 0x044B, 0x042B, 0x0437, 0x0417, 0x0448, 0x0428, 0x044D, 0x042D, 0x0449, 0x0429, 0x0447, 0x0427, 0x00A7, 0x25A0, 0x00A0
|
||||
};
|
||||
|
||||
#elif _CODE_PAGE == 857
|
||||
#define _TBLDEF 1
|
||||
static
|
||||
const WCHAR Tbl[] = { /* CP857(0x80-0xFF) to Unicode conversion table */
|
||||
0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x0131, 0x00C4, 0x00C5,
|
||||
0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9, 0x0130, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x015E, 0x015F,
|
||||
0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x011E, 0x011F, 0x00BF, 0x00AE, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB,
|
||||
0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x00C1, 0x00C2, 0x00C0, 0x00A9, 0x2563, 0x2551, 0x2557, 0x255D, 0x00A2, 0x00A5, 0x2510,
|
||||
0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x00E3, 0x00C3, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4,
|
||||
0x00BA, 0x00AA, 0x00CA, 0x00CB, 0x00C8, 0x0000, 0x00CD, 0x00CE, 0x00CF, 0x2518, 0x250C, 0x2588, 0x2584, 0x00A6, 0x00CC, 0x2580,
|
||||
0x00D3, 0x00DF, 0x00D4, 0x00D2, 0x00F5, 0x00D5, 0x00B5, 0x0000, 0x00D7, 0x00DA, 0x00DB, 0x00D9, 0x00EC, 0x00FF, 0x00AF, 0x00B4,
|
||||
0x00AD, 0x00B1, 0x0000, 0x00BE, 0x00B6, 0x00A7, 0x00F7, 0x00B8, 0x00B0, 0x00A8, 0x00B7, 0x00B9, 0x00B3, 0x00B2, 0x25A0, 0x00A0
|
||||
};
|
||||
|
||||
#elif _CODE_PAGE == 860
|
||||
#define _TBLDEF 1
|
||||
static
|
||||
const WCHAR Tbl[] = { /* CP860(0x80-0xFF) to Unicode conversion table */
|
||||
0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E3, 0x00E0, 0x00C1, 0x00E7, 0x00EA, 0x00CA, 0x00E8, 0x00CD, 0x00D4, 0x00EC, 0x00C3, 0x00C2,
|
||||
0x00C9, 0x00C0, 0x00C8, 0x00F4, 0x00F5, 0x00F2, 0x00DA, 0x00F9, 0x00CC, 0x00D5, 0x00DC, 0x00A2, 0x00A3, 0x00D9, 0x20A7, 0x00D3,
|
||||
0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA, 0x00BF, 0x00D2, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB,
|
||||
0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x2558, 0x2510,
|
||||
0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567,
|
||||
0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580,
|
||||
0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229,
|
||||
0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0
|
||||
};
|
||||
|
||||
#elif _CODE_PAGE == 861
|
||||
#define _TBLDEF 1
|
||||
static
|
||||
const WCHAR Tbl[] = { /* CP861(0x80-0xFF) to Unicode conversion table */
|
||||
0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E6, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00D0, 0x00F0, 0x00DE, 0x00C4, 0x00C5,
|
||||
0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00FE, 0x00FB, 0x00DD, 0x00FD, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x20A7, 0x0192,
|
||||
0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00C1, 0x00CD, 0x00D3, 0x00DA, 0x00BF, 0x2310, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB,
|
||||
0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510,
|
||||
0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567,
|
||||
0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580,
|
||||
0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229,
|
||||
0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0
|
||||
};
|
||||
|
||||
#elif _CODE_PAGE == 862
|
||||
#define _TBLDEF 1
|
||||
static
|
||||
const WCHAR Tbl[] = { /* CP862(0x80-0xFF) to Unicode conversion table */
|
||||
0x05D0, 0x05D1, 0x05D2, 0x05D3, 0x05D4, 0x05D5, 0x05D6, 0x05D7, 0x05D8, 0x05D9, 0x05DA, 0x05DB, 0x05DC, 0x05DD, 0x05DE, 0x05DF,
|
||||
0x05E0, 0x05E1, 0x05E2, 0x05E3, 0x05E4, 0x05E5, 0x05E6, 0x05E7, 0x05E8, 0x05E9, 0x05EA, 0x00A2, 0x00A3, 0x00A5, 0x20A7, 0x0192,
|
||||
0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA, 0x00BF, 0x2310, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB,
|
||||
0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510,
|
||||
0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567,
|
||||
0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580,
|
||||
0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229,
|
||||
0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0
|
||||
};
|
||||
|
||||
#elif _CODE_PAGE == 863
|
||||
#define _TBLDEF 1
|
||||
static
|
||||
const WCHAR Tbl[] = { /* CP863(0x80-0xFF) to Unicode conversion table */
|
||||
0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00C2, 0x00E0, 0x00B6, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x2017, 0x00C0,
|
||||
0x00C9, 0x00C8, 0x00CA, 0x00F4, 0x00CB, 0x00CF, 0x00FB, 0x00F9, 0x00A4, 0x00D4, 0x00DC, 0x00A2, 0x00A3, 0x00D9, 0x00DB, 0x0192,
|
||||
0x00A6, 0x00B4, 0x00F3, 0x00FA, 0x00A8, 0x00BB, 0x00B3, 0x00AF, 0x00CE, 0x3210, 0x00AC, 0x00BD, 0x00BC, 0x00BE, 0x00AB, 0x00BB,
|
||||
0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510,
|
||||
0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567,
|
||||
0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580,
|
||||
0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2219,
|
||||
0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0
|
||||
};
|
||||
|
||||
#elif _CODE_PAGE == 864
|
||||
#define _TBLDEF 1
|
||||
static
|
||||
const WCHAR Tbl[] = { /* CP864(0x80-0xFF) to Unicode conversion table */
|
||||
0x00B0, 0x00B7, 0x2219, 0x221A, 0x2592, 0x2500, 0x2502, 0x253C, 0x2524, 0x252C, 0x251C, 0x2534, 0x2510, 0x250C, 0x2514, 0x2518,
|
||||
0x03B2, 0x221E, 0x03C6, 0x00B1, 0x00BD, 0x00BC, 0x2248, 0x00AB, 0x00BB, 0xFEF7, 0xFEF8, 0x0000, 0x0000, 0xFEFB, 0xFEFC, 0x0000,
|
||||
0x00A0, 0x00AD, 0xFE82, 0x00A3, 0x00A4, 0xFE84, 0x0000, 0x20AC, 0xFE8E, 0xFE8F, 0xFE95, 0xFE99, 0x060C, 0xFE9D, 0xFEA1, 0xFEA5,
|
||||
0x0660, 0x0661, 0x0662, 0x0663, 0x0664, 0x0665, 0x0666, 0x0667, 0x0668, 0x0669, 0xFED1, 0x061B, 0xFEB1, 0xFEB5, 0xFEB9, 0x061F,
|
||||
0x00A2, 0xFE80, 0xFE81, 0xFE83, 0xFE85, 0xFECA, 0xFE8B, 0xFE8D, 0xFE91, 0xFE93, 0xFE97, 0xFE9B, 0xFE9F, 0xFEA3, 0xFEA7, 0xFEA9,
|
||||
0xFEAB, 0xFEAD, 0xFEAF, 0xFEB3, 0xFEB7, 0xFEBB, 0xFEBF, 0xFEC1, 0xFEC5, 0xFECB, 0xFECF, 0x00A6, 0x00AC, 0x00F7, 0x00D7, 0xFEC9,
|
||||
0x0640, 0xFED3, 0xFED7, 0xFEDB, 0xFEDF, 0xFEE3, 0xFEE7, 0xFEEB, 0xFEED, 0xFEEF, 0xFEF3, 0xFEBD, 0xFECC, 0xFECE, 0xFECD, 0xFEE1,
|
||||
0xFE7D, 0x0651, 0xFEE5, 0xFEE9, 0xFEEC, 0xFEF0, 0xFEF2, 0xFED0, 0xFED5, 0xFEF5, 0xFEF6, 0xFEDD, 0xFED9, 0xFEF1, 0x25A0, 0x0000
|
||||
};
|
||||
|
||||
#elif _CODE_PAGE == 865
|
||||
#define _TBLDEF 1
|
||||
static
|
||||
const WCHAR Tbl[] = { /* CP865(0x80-0xFF) to Unicode conversion table */
|
||||
0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5,
|
||||
0x00C5, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9, 0x00FF, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x20A7, 0x0192,
|
||||
0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA, 0x00BF, 0x2310, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00A4,
|
||||
0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x2558, 0x2510,
|
||||
0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567,
|
||||
0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580,
|
||||
0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229,
|
||||
0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0
|
||||
};
|
||||
|
||||
#elif _CODE_PAGE == 866
|
||||
#define _TBLDEF 1
|
||||
static
|
||||
const WCHAR Tbl[] = { /* CP866(0x80-0xFF) to Unicode conversion table */
|
||||
0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417, 0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E, 0x041F,
|
||||
0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427, 0x0428, 0x0429, 0x042A, 0x042B, 0x042C, 0x042D, 0x042E, 0x042F,
|
||||
0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437, 0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E, 0x043F,
|
||||
0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510,
|
||||
0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567,
|
||||
0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580,
|
||||
0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447, 0x0448, 0x0449, 0x044A, 0x044B, 0x044C, 0x044D, 0x044E, 0x044F,
|
||||
0x0401, 0x0451, 0x0404, 0x0454, 0x0407, 0x0457, 0x040E, 0x045E, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x2116, 0x00A4, 0x25A0, 0x00A0
|
||||
};
|
||||
|
||||
#elif _CODE_PAGE == 869
|
||||
#define _TBLDEF 1
|
||||
static
|
||||
const WCHAR Tbl[] = { /* CP869(0x80-0xFF) to Unicode conversion table */
|
||||
0x00B7, 0x00B7, 0x00B7, 0x00B7, 0x00B7, 0x00B7, 0x0386, 0x00B7, 0x00B7, 0x00AC, 0x00A6, 0x2018, 0x2019, 0x0388, 0x2015, 0x0389,
|
||||
0x038A, 0x03AA, 0x038C, 0x00B7, 0x00B7, 0x038E, 0x03AB, 0x00A9, 0x038F, 0x00B2, 0x00B3, 0x03AC, 0x00A3, 0x03AD, 0x03AE, 0x03AF,
|
||||
0x03CA, 0x0390, 0x03CC, 0x03CD, 0x0391, 0x0392, 0x0393, 0x0394, 0x0395, 0x0396, 0x0397, 0x00BD, 0x0398, 0x0399, 0x00AB, 0x00BB,
|
||||
0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x039A, 0x039B, 0x039C, 0x039D, 0x2563, 0x2551, 0x2557, 0x255D, 0x039E, 0x039F, 0x2510,
|
||||
0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x0A30, 0x03A1, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x03A3,
|
||||
0x03A4, 0x03A5, 0x03A6, 0x03A7, 0x03A8, 0x03A9, 0x03B1, 0x03B2, 0x03B3, 0x2518, 0x250C, 0x2588, 0x2584, 0x03B4, 0x03B5, 0x2580,
|
||||
0x03B6, 0x03B7, 0x03B8, 0x03B9, 0x03BA, 0x03BB, 0x03BC, 0x03BD, 0x03BE, 0x03BF, 0x03C0, 0x03C1, 0x03C3, 0x03C2, 0x03C4, 0x0384,
|
||||
0x00AD, 0x00B1, 0x03C5, 0x03C6, 0x03C7, 0x00A7, 0x03C8, 0x0385, 0x00B0, 0x00A8, 0x03C9, 0x03CB, 0x03B0, 0x03CE, 0x25A0, 0x00A0
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#if !_TBLDEF || !_USE_LFN
|
||||
#error This file is not needed at current configuration. Remove from the project.
|
||||
#endif
|
||||
|
||||
|
||||
/* Converted character, Returns zero on error */
|
||||
/* Character code to be converted */
|
||||
/* 0: Unicode to OEM code, 1: OEM code to Unicode */
|
||||
WCHAR ff_convert (WCHAR chr, UINT dir)
|
||||
{
|
||||
WCHAR c;
|
||||
|
||||
|
||||
if (chr < 0x80) { /* ASCII */
|
||||
c = chr;
|
||||
|
||||
} else {
|
||||
if (dir) { /* OEM code to Unicode */
|
||||
c = (chr >= 0x100) ? 0 : Tbl[chr - 0x80];
|
||||
|
||||
} else { /* Unicode to OEM code */
|
||||
for (c = 0; c < 0x80; c++) {
|
||||
if (chr == Tbl[c]) break;
|
||||
}
|
||||
c = (c + 0x80) & 0xFF;
|
||||
}
|
||||
}
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
WCHAR ff_wtoupper ( /* Returns upper converted character */
|
||||
WCHAR chr /* Unicode character to be upper converted */
|
||||
)
|
||||
{
|
||||
static const WCHAR lower[] = { /* Lower case characters to be converted */
|
||||
/* Latin Supplement */ 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF,
|
||||
/* Latin Extended-A */ 0x101,0x103,0x105,0x107,0x109,0x10B,0x10D,0x10F,0x111,0x113,0x115,0x117,0x119,0x11B,0x11D,0x11F,0x121,0x123,0x125,0x127,0x129,0x12B,0x12D,0x12F,0x131,0x133,0x135,0x137,0x13A,0x13C,0x13E,0x140,0x142,0x144,0x146,0x148,0x14B,0x14D,0x14F,0x151,0x153,0x155,0x157,0x159,0x15B,0x15D,0x15F,0x161,0x163,0x165,0x167,0x169,0x16B,0x16D,0x16F,0x171,0x173,0x175,0x177,0x17A,0x17C,0x17E,
|
||||
/* Latin Extended-B */ 0x183,0x185,0x188,0x18C,0x192,0x199,0x1A1,0x1A3,0x1A8,0x1AD,0x1B0,0x1B4,0x1B6,0x1B9,0x1BD,0x1C6,0x1C9,0x1CC,0x1CE,0x1D0,0x1D2,0x1D4,0x1D6,0x1D8,0x1DA,0x1DC,0x1DD,0x1DF,0x1E1,0x1E3,0x1E5,0x1E7,0x1E9,0x1EB,0x1ED,0x1EF,0x1F3,0x1F5,0x1FB,0x1FD,0x1FF,0x201,0x203,0x205,0x207,0x209,0x20B,0x20D,0x20F,0x211,0x213,0x215,0x217,
|
||||
/* Greek, Coptic */ 0x3B1,0x3B2,0x3B3,0x3B4,0x3B5,0x3B6,0x3B7,0x3B8,0x3B9,0x3BA,0x3BB,0x3BC,0x3BD,0x3BE,0x3BF,0x3C0,0x3C1,0x3C3,0x3C4,0x3C5,0x3C6,0x3C7,0x3C8,0x3C9,0x3CA,0x3CB,0x3CC,0x3CD,0x3CE,0x3E3,0x3E5,0x3E7,0x3E9,0x3EB,
|
||||
/* Cyrillic */ 0x430,0x431,0x432,0x433,0x434,0x435,0x436,0x437,0x438,0x439,0x43A,0x43B,0x43C,0x43D,0x43E,0x43F,0x440,0x441,0x442,0x443,0x444,0x445,0x446,0x447,0x448,0x449,0x44A,0x44B,0x44C,0x44D,0x44E,0x44F,0x452,0x453,0x454,0x455,0x456,0x457,0x458,0x459,0x45A,0x45B,0x45C,0x45E,0x45F,0x461,0x463,0x465,0x467,0x469,0x46B,0x46D,0x46F,0x471,0x473,0x475,0x477,0x479,0x47B,0x47D,0x47F,0x481,0x491,0x493,0x495,0x497,0x499,0x49B,0x49D,0x49F,0x4A1,0x4A3,0x4A5,0x4A7,0x4A9,0x4AB,0x4AD,0x4AF,0x4B1,0x4B3,0x4B5,0x4B7,0x4B9,0x4BB,0x4BD,0x4BF,0x4C2,0x4C4,0x4C8,0x4D1,0x4D3,0x4D5,0x4D7,0x4D9,0x4DB,0x4DD,0x4DF,0x4E1,0x4E3,0x4E5,0x4E7,0x4E9,0x4EB,0x4ED,0x4EF,0x4F1,0x4F3,0x4F5,0x4F9,
|
||||
/* Armenian */ 0x561,0x562,0x563,0x564,0x565,0x566,0x567,0x568,0x569,0x56A,0x56B,0x56C,0x56D,0x56E,0x56F,0x570,0x571,0x572,0x573,0x574,0x575,0x576,0x577,0x578,0x579,0x57A,0x57B,0x57C,0x57D,0x57E,0x57F,0x580,0x581,0x582,0x583,0x584,0x585,0x586,
|
||||
/* Latin Extended Additional */ 0x1E01,0x1E03,0x1E05,0x1E07,0x1E09,0x1E0B,0x1E0D,0x1E0F,0x1E11,0x1E13,0x1E15,0x1E17,0x1E19,0x1E1B,0x1E1D,0x1E1F,0x1E21,0x1E23,0x1E25,0x1E27,0x1E29,0x1E2B,0x1E2D,0x1E2F,0x1E31,0x1E33,0x1E35,0x1E37,0x1E39,0x1E3B,0x1E3D,0x1E3F,0x1E41,0x1E43,0x1E45,0x1E47,0x1E49,0x1E4B,0x1E4D,0x1E4F,0x1E51,0x1E53,0x1E55,0x1E57,0x1E59,0x1E5B,0x1E5D,0x1E5F,0x1E61,0x1E63,0x1E65,0x1E67,0x1E69,0x1E6B,0x1E6D,0x1E6F,0x1E71,0x1E73,0x1E75,0x1E77,0x1E79,0x1E7B,0x1E7D,0x1E7F,0x1E81,0x1E83,0x1E85,0x1E87,0x1E89,0x1E8B,0x1E8D,0x1E8F,0x1E91,0x1E93,0x1E95,0x1E97,0x1E99,0x1E9B,0x1E9D,0x1E9F,0x1EA1,0x1EA3,0x1EA5,0x1EA7,0x1EA9,0x1EAB,0x1EAD,0x1EAF,0x1EB1,0x1EB3,0x1EB5,0x1EB7,0x1EB9,0x1EBB,0x1EBD,0x1EBF,0x1EC1,0x1EC3,0x1EC5,0x1EC7,0x1EC9,0x1ECB,0x1ECD,0x1ECF,0x1ED1,0x1ED3,0x1ED5,0x1ED7,0x1ED9,0x1EDB,0x1EDD,0x1EDF,0x1EE1,0x1EE3,0x1EE5,0x1EE7,0x1EE9,0x1EEB,0x1EED,0x1EEF,0x1EF1,0x1EF3,0x1EF5,0x1EF7,0x1EF9,
|
||||
/* Number forms */ 0x2170,0x2171,0x2172,0x2173,0x2174,0x2175,0x2176,0x2177,0x2178,0x2179,0x217A,0x217B,0x217C,0x217D,0x217E,0x217F,
|
||||
/* Full-width */ 0xFF41,0xFF42,0xFF43,0xFF44,0xFF45,0xFF46,0xFF47,0xFF48,0xFF49,0xFF4A,0xFF4B,0xFF4C,0xFF4D,0xFF4E,0xFF4F,0xFF50,0xFF51,0xFF52,0xFF53,0xFF54,0xFF55,0xFF56,0xFF57,0xFF58,0xFF59,0xFF5A
|
||||
};
|
||||
static const WCHAR upper[] = { /* Upper case characters correspond to lower[] */
|
||||
0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0x178,
|
||||
0x100,0x102,0x104,0x106,0x108,0x10A,0x10C,0x10E,0x110,0x112,0x114,0x116,0x118,0x11A,0x11C,0x11E,0x120,0x122,0x124,0x126,0x128,0x12A,0x12C,0x12E,0x130,0x132,0x134,0x136,0x139,0x13B,0x13D,0x13F,0x141,0x143,0x145,0x147,0x14A,0x14C,0x14E,0x150,0x152,0x154,0x156,0x158,0x15A,0x15C,0x15E,0x160,0x162,0x164,0x166,0x168,0x16A,0x16C,0x16E,0x170,0x172,0x174,0x176,0x179,0x17B,0x17D,
|
||||
0x182,0x184,0x187,0x18B,0x191,0x198,0x1A0,0x1A2,0x1A7,0x1AC,0x1AF,0x1B3,0x1B5,0x1B8,0x1BC,0x1C4,0x1C7,0x1CA,0x1CD,0x1CF,0x1D1,0x1D3,0x1D5,0x1D7,0x1D9,0x1DB,0x18E,0x1DE,0x1E0,0x1E2,0x1E4,0x1E6,0x1E8,0x1EA,0x1EC,0x1EE,0x1F1,0x1F4,0x1FA,0x1FC,0x1FE,0x200,0x202,0x204,0x206,0x208,0x20A,0x20C,0x20E,0x210,0x212,0x214,0x216,
|
||||
0x391,0x392,0x393,0x394,0x395,0x396,0x397,0x398,0x399,0x39A,0x39B,0x39C,0x39D,0x39E,0x39F,0x3A0,0x3A1,0x3A3,0x3A4,0x3A5,0x3A6,0x3A7,0x3A8,0x3A9,0x3AA,0x3AB,0x38C,0x38E,0x38F,0x3E2,0x3E4,0x3E6,0x3E8,0x3EA,
|
||||
0x410,0x411,0x412,0x413,0x414,0x415,0x416,0x417,0x418,0x419,0x41A,0x41B,0x41C,0x41D,0x41E,0x41F,0x420,0x421,0x422,0x423,0x424,0x425,0x426,0x427,0x428,0x429,0x42A,0x42B,0x42C,0x42D,0x42E,0x42F,0x402,0x403,0x404,0x405,0x406,0x407,0x408,0x409,0x40A,0x40B,0x40C,0x40E,0x40F,0x460,0x462,0x464,0x466,0x468,0x46A,0x46C,0x46E,0x470,0x472,0x474,0x476,0x478,0x47A,0x47C,0x47E,0x480,0x490,0x492,0x494,0x496,0x498,0x49A,0x49C,0x49E,0x4A0,0x4A2,0x4A4,0x4A6,0x4A8,0x4AA,0x4AC,0x4AE,0x4B0,0x4B2,0x4B4,0x4B6,0x4B8,0x4BA,0x4BC,0x4BE,0x4C1,0x4C3,0x5C7,0x4D0,0x4D2,0x4D4,0x4D6,0x4D8,0x4DA,0x4DC,0x4DE,0x4E0,0x4E2,0x4E4,0x4E6,0x4E8,0x4EA,0x4EC,0x4EE,0x4F0,0x4F2,0x4F4,0x4F8,
|
||||
0x531,0x532,0x533,0x534,0x535,0x536,0x537,0x538,0x539,0x53A,0x53B,0x53C,0x53D,0x53E,0x53F,0x540,0x541,0x542,0x543,0x544,0x545,0x546,0x547,0x548,0x549,0x54A,0x54B,0x54C,0x54D,0x54E,0x54F,0x550,0x551,0x552,0x553,0x554,0x555,0x556,
|
||||
0x1E00,0x1E02,0x1E04,0x1E06,0x1E08,0x1E0A,0x1E0C,0x1E0E,0x1E10,0x1E12,0x1E14,0x1E16,0x1E18,0x1E1A,0x1E1C,0x1E1E,0x1E20,0x1E22,0x1E24,0x1E26,0x1E28,0x1E2A,0x1E2C,0x1E2E,0x1E30,0x1E32,0x1E34,0x1E36,0x1E38,0x1E3A,0x1E3C,0x1E3E,0x1E40,0x1E42,0x1E44,0x1E46,0x1E48,0x1E4A,0x1E4C,0x1E4E,0x1E50,0x1E52,0x1E54,0x1E56,0x1E58,0x1E5A,0x1E5C,0x1E5E,0x1E60,0x1E62,0x1E64,0x1E66,0x1E68,0x1E6A,0x1E6C,0x1E6E,0x1E70,0x1E72,0x1E74,0x1E76,0x1E78,0x1E7A,0x1E7C,0x1E7E,0x1E80,0x1E82,0x1E84,0x1E86,0x1E88,0x1E8A,0x1E8C,0x1E8E,0x1E90,0x1E92,0x1E94,0x1E96,0x1E98,0x1E9A,0x1E9C,0x1E9E,0x1EA0,0x1EA2,0x1EA4,0x1EA6,0x1EA8,0x1EAA,0x1EAC,0x1EAE,0x1EB0,0x1EB2,0x1EB4,0x1EB6,0x1EB8,0x1EBA,0x1EBC,0x1EBE,0x1EC0,0x1EC2,0x1EC4,0x1EC6,0x1EC8,0x1ECA,0x1ECC,0x1ECE,0x1ED0,0x1ED2,0x1ED4,0x1ED6,0x1ED8,0x1EDA,0x1EDC,0x1EDE,0x1EE0,0x1EE2,0x1EE4,0x1EE6,0x1EE8,0x1EEA,0x1EEC,0x1EEE,0x1EF0,0x1EF2,0x1EF4,0x1EF6,0x1EF8,
|
||||
0x2160,0x2161,0x2162,0x2163,0x2164,0x2165,0x2166,0x2167,0x2168,0x2169,0x216A,0x216B,0x216C,0x216D,0x216E,0x216F,
|
||||
0xFF21,0xFF22,0xFF23,0xFF24,0xFF25,0xFF26,0xFF27,0xFF28,0xFF29,0xFF2A,0xFF2B,0xFF2C,0xFF2D,0xFF2E,0xFF2F,0xFF30,0xFF31,0xFF32,0xFF33,0xFF34,0xFF35,0xFF36,0xFF37,0xFF38,0xFF39,0xFF3A
|
||||
};
|
||||
UINT i, n, hi, li;
|
||||
|
||||
|
||||
if (chr < 0x80) { /* ASCII characters (acceleration) */
|
||||
if (chr >= 0x61 && chr <= 0x7A) chr -= 0x20;
|
||||
|
||||
} else { /* Non ASCII characters (table search) */
|
||||
n = 12; li = 0; hi = sizeof lower / sizeof lower[0];
|
||||
do {
|
||||
i = li + (hi - li) / 2;
|
||||
if (chr == lower[i]) break;
|
||||
if (chr > lower[i]) li = i; else hi = i;
|
||||
} while (--n);
|
||||
if (n) chr = upper[i];
|
||||
}
|
||||
|
||||
return chr;
|
||||
}
|
||||
|
||||
#endif
|
||||
154
misc/fs/fat32/option/syscall.c
Normal file
154
misc/fs/fat32/option/syscall.c
Normal file
@@ -0,0 +1,154 @@
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* Sample code of OS dependent controls for FatFs */
|
||||
/* (C)ChaN, 2014 */
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
#include "misc_conf.h"
|
||||
#if USE_FAT32 != 0
|
||||
|
||||
#include "../ff.h"
|
||||
|
||||
|
||||
#if _FS_REENTRANT
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* Create a Synchronization Object */
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* This function is called in f_mount() function to create a new
|
||||
/ synchronization object, such as semaphore and mutex. When a 0 is returned,
|
||||
/ the f_mount() function fails with FR_INT_ERR.
|
||||
*/
|
||||
|
||||
int ff_cre_syncobj ( /* !=0:Function succeeded, ==0:Could not create due to any error */
|
||||
BYTE vol, /* Corresponding logical drive being processed */
|
||||
_SYNC_t *sobj /* Pointer to return the created sync object */
|
||||
)
|
||||
{
|
||||
int ret;
|
||||
|
||||
|
||||
*sobj = CreateMutex(NULL, FALSE, NULL); /* Win32 */
|
||||
ret = (int)(*sobj != INVALID_HANDLE_VALUE);
|
||||
|
||||
// *sobj = SyncObjects[vol]; /* uITRON (give a static created sync object) */
|
||||
// ret = 1; /* The initial value of the semaphore must be 1. */
|
||||
|
||||
// *sobj = OSMutexCreate(0, &err); /* uC/OS-II */
|
||||
// ret = (int)(err == OS_NO_ERR);
|
||||
|
||||
// *sobj = xSemaphoreCreateMutex(); /* FreeRTOS */
|
||||
// ret = (int)(*sobj != NULL);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* Delete a Synchronization Object */
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* This function is called in f_mount() function to delete a synchronization
|
||||
/ object that created with ff_cre_syncobj function. When a 0 is returned,
|
||||
/ the f_mount() function fails with FR_INT_ERR.
|
||||
*/
|
||||
|
||||
int ff_del_syncobj ( /* !=0:Function succeeded, ==0:Could not delete due to any error */
|
||||
_SYNC_t sobj /* Sync object tied to the logical drive to be deleted */
|
||||
)
|
||||
{
|
||||
int ret;
|
||||
|
||||
|
||||
ret = CloseHandle(sobj); /* Win32 */
|
||||
|
||||
// ret = 1; /* uITRON (nothing to do) */
|
||||
|
||||
// OSMutexDel(sobj, OS_DEL_ALWAYS, &err); /* uC/OS-II */
|
||||
// ret = (int)(err == OS_NO_ERR);
|
||||
|
||||
// vSemaphoreDelete(sobj); /* FreeRTOS */
|
||||
// ret = 1;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* Request Grant to Access the Volume */
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* This function is called on entering file functions to lock the volume.
|
||||
/ When a 0 is returned, the file function fails with FR_TIMEOUT.
|
||||
*/
|
||||
|
||||
int ff_req_grant ( /* 1:Got a grant to access the volume, 0:Could not get a grant */
|
||||
_SYNC_t sobj /* Sync object to wait */
|
||||
)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = (int)(WaitForSingleObject(sobj, _FS_TIMEOUT) == WAIT_OBJECT_0); /* Win32 */
|
||||
|
||||
// ret = (int)(wai_sem(sobj) == E_OK); /* uITRON */
|
||||
|
||||
// OSMutexPend(sobj, _FS_TIMEOUT, &err)); /* uC/OS-II */
|
||||
// ret = (int)(err == OS_NO_ERR);
|
||||
|
||||
// ret = (int)(xSemaphoreTake(sobj, _FS_TIMEOUT) == pdTRUE); /* FreeRTOS */
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* Release Grant to Access the Volume */
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* This function is called on leaving file functions to unlock the volume.
|
||||
*/
|
||||
|
||||
void ff_rel_grant (
|
||||
_SYNC_t sobj /* Sync object to be signaled */
|
||||
)
|
||||
{
|
||||
ReleaseMutex(sobj); /* Win32 */
|
||||
|
||||
// sig_sem(sobj); /* uITRON */
|
||||
|
||||
// OSMutexPost(sobj); /* uC/OS-II */
|
||||
|
||||
// xSemaphoreGive(sobj); /* FreeRTOS */
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
#if _USE_LFN == 3 /* LFN with a working buffer on the heap */
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* Allocate a memory block */
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* If a NULL is returned, the file function fails with FR_NOT_ENOUGH_CORE.
|
||||
*/
|
||||
|
||||
void* ff_memalloc ( /* Returns pointer to the allocated memory block */
|
||||
UINT msize /* Number of bytes to allocate */
|
||||
)
|
||||
{
|
||||
return malloc(msize); /* Allocate a new memory block with POSIX API */
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* Free a memory block */
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
void ff_memfree (
|
||||
void* mblock /* Pointer to the memory block to free */
|
||||
)
|
||||
{
|
||||
free(mblock); /* Discard the memory block with POSIX API */
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif /*USE_FAT32 != 0*/
|
||||
540
misc/fs/fsint.c
Normal file
540
misc/fs/fsint.c
Normal file
@@ -0,0 +1,540 @@
|
||||
/**
|
||||
* @file fs_int.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
|
||||
#include "misc_conf.h"
|
||||
#if USE_FSINT != 0
|
||||
|
||||
#include "fsint.h"
|
||||
#include <string.h>
|
||||
#include "../mem/linked_list.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static const char * fs_get_real_path(const char * path);
|
||||
static fs_drv_t* fs_get_drv(char letter);
|
||||
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static ll_dsc_t drv_ll;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Initialize the File system interface
|
||||
*/
|
||||
void fs_init(void)
|
||||
{
|
||||
ll_init(&drv_ll, sizeof(fs_drv_t));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Open a file
|
||||
* @param file_p pointer to a fs_file_t variable
|
||||
* @param path path to the file beginning with the driver letter (e.g. S:/folder/file.txt)
|
||||
* @param mode read: FS_MODE_RD, write: FS_MODE_WR, both: FS_MODE_RD | FS_MODE_WR
|
||||
* @return FS_RES_OK or any error from fs_res_t enum
|
||||
*/
|
||||
fs_res_t fs_open (fs_file_t * file_p, const char * path, fs_mode_t mode)
|
||||
{
|
||||
file_p->drv = NULL;
|
||||
file_p->file_d = NULL;
|
||||
|
||||
if(path == NULL) return FS_RES_INV_PARAM;
|
||||
|
||||
char letter = path[0];
|
||||
|
||||
file_p->drv = fs_get_drv(letter);
|
||||
|
||||
if(file_p->drv == NULL) {
|
||||
file_p->file_d = NULL;
|
||||
return FS_RES_NOT_EX;
|
||||
}
|
||||
|
||||
if(file_p->drv->ready != NULL) {
|
||||
if(file_p->drv->ready() == false) {
|
||||
file_p->drv = NULL;
|
||||
file_p->file_d = NULL;
|
||||
return FS_RES_HW_ERR;
|
||||
}
|
||||
}
|
||||
|
||||
file_p->file_d = dm_alloc(file_p->drv->file_size);
|
||||
if(file_p->file_d == NULL) {
|
||||
file_p->drv = NULL;
|
||||
return FS_RES_OUT_OF_MEM; /* Out of memory */
|
||||
}
|
||||
|
||||
if(file_p->drv->open == NULL) {
|
||||
return FS_RES_NOT_IMP;
|
||||
}
|
||||
|
||||
const char * real_path = fs_get_real_path(path);
|
||||
fs_res_t res = file_p->drv->open(file_p->file_d, real_path, mode);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Close an already opened file
|
||||
* @param file_p pointer to a fs_file_t variable
|
||||
* @return FS_RES_OK or any error from fs_res_t enum
|
||||
*/
|
||||
fs_res_t fs_close (fs_file_t * file_p)
|
||||
{
|
||||
if(file_p->drv == NULL) {
|
||||
return FS_RES_INV_PARAM;
|
||||
}
|
||||
|
||||
if(file_p->drv->close == NULL) {
|
||||
return FS_RES_NOT_IMP;
|
||||
}
|
||||
|
||||
fs_res_t res = file_p->drv->close(file_p->file_d);
|
||||
|
||||
dm_free(file_p->file_d); /*Clean up*/
|
||||
file_p->file_d = NULL;
|
||||
file_p->drv = NULL;
|
||||
file_p->file_d = NULL;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a file
|
||||
* @param path path of the file to delete
|
||||
* @return FS_RES_OK or any error from fs_res_t enum
|
||||
*/
|
||||
fs_res_t fs_remove (const char * path)
|
||||
{
|
||||
if(path == NULL) return FS_RES_INV_PARAM;
|
||||
fs_drv_t * drv = NULL;
|
||||
|
||||
char letter = path[0];
|
||||
|
||||
drv = fs_get_drv(letter);
|
||||
if(drv == NULL) return FS_RES_NOT_EX;
|
||||
if(drv->ready != NULL) {
|
||||
if(drv->ready() == false) return FS_RES_HW_ERR;
|
||||
}
|
||||
|
||||
if(drv->remove == NULL) return FS_RES_NOT_IMP;
|
||||
|
||||
const char * real_path = fs_get_real_path(path);
|
||||
fs_res_t res = drv->remove(real_path);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read from a file
|
||||
* @param file_p pointer to a fs_file_t variable
|
||||
* @param buf pointer to a buffer where the read bytes are stored
|
||||
* @param btr Bytes To Read
|
||||
* @param br the number of real read bytes (Bytes Read). NULL if unused.
|
||||
* @return FS_RES_OK or any error from fs_res_t enum
|
||||
*/
|
||||
fs_res_t fs_read (fs_file_t * file_p, void * buf, uint32_t btr, uint32_t * br)
|
||||
{
|
||||
if(br != NULL) *br = 0;
|
||||
if(file_p->drv == NULL || file_p->drv == NULL) return FS_RES_INV_PARAM;
|
||||
if(file_p->drv->read == NULL) return FS_RES_NOT_IMP;
|
||||
|
||||
uint32_t br_tmp = 0;
|
||||
fs_res_t res = file_p->drv->read(file_p->file_d, buf, btr, &br_tmp);
|
||||
if(br != NULL) *br = br_tmp;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write into a file
|
||||
* @param file_p pointer to a fs_file_t variable
|
||||
* @param buf pointer to a buffer with the bytes to write
|
||||
* @param btr Bytes To Write
|
||||
* @param br the number of real written bytes (Bytes Written). NULL if unused.
|
||||
* @return FS_RES_OK or any error from fs_res_t enum
|
||||
*/
|
||||
fs_res_t fs_write (fs_file_t * file_p, const void * buf, uint32_t btw, uint32_t * bw)
|
||||
{
|
||||
if(bw != NULL) *bw = 0;
|
||||
|
||||
if(file_p->drv == NULL || file_p->drv == NULL) {
|
||||
return FS_RES_INV_PARAM;
|
||||
}
|
||||
|
||||
if(file_p->drv->write == NULL) {
|
||||
return FS_RES_NOT_IMP;
|
||||
}
|
||||
|
||||
uint32_t bw_tmp = 0;
|
||||
fs_res_t res = file_p->drv->write(file_p->file_d, buf, btw, &bw_tmp);
|
||||
if(bw != NULL) *bw = bw_tmp;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the position of the 'cursor' (read write pointer) in a file
|
||||
* @param file_p pointer to a fs_file_t variable
|
||||
* @param pos the new position expressed in bytes index (0: start of file)
|
||||
* @return FS_RES_OK or any error from fs_res_t enum
|
||||
*/
|
||||
fs_res_t fs_seek (fs_file_t * file_p, uint32_t pos)
|
||||
{
|
||||
if(file_p->drv == NULL || file_p->drv == NULL) {
|
||||
return FS_RES_INV_PARAM;
|
||||
}
|
||||
|
||||
if(file_p->drv->seek == NULL) {
|
||||
return FS_RES_NOT_IMP;
|
||||
}
|
||||
|
||||
fs_res_t res = file_p->drv->seek(file_p->file_d, pos);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Give the position of the read write pointer
|
||||
* @param file_p pointer to a fs_file_t variable
|
||||
* @param pos_p pointer to store the position of the read write pointer
|
||||
* @return FS_RES_OK or any error from 'fs_res_t'
|
||||
*/
|
||||
fs_res_t fs_tell (fs_file_t * file_p, uint32_t * pos)
|
||||
{
|
||||
if(file_p->drv == NULL || file_p->drv == NULL) {
|
||||
pos = 0;
|
||||
return FS_RES_INV_PARAM;
|
||||
}
|
||||
|
||||
if(file_p->drv->tell == NULL) {
|
||||
pos = 0;
|
||||
return FS_RES_NOT_IMP;
|
||||
}
|
||||
|
||||
fs_res_t res = file_p->drv->tell(file_p->file_d, pos);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Give the size of a file bytes
|
||||
* @param file_p pointer to a fs_file_t variable
|
||||
* @param size pointer to a variable to store the size
|
||||
* @return FS_RES_OK or any error from fs_res_t enum
|
||||
*/
|
||||
fs_res_t fs_size (fs_file_t * file_p, uint32_t * size)
|
||||
{
|
||||
if(file_p->drv == NULL || file_p->drv == NULL) {
|
||||
return FS_RES_INV_PARAM;
|
||||
}
|
||||
|
||||
if(file_p->drv->size == NULL) return FS_RES_NOT_IMP;
|
||||
|
||||
|
||||
if(size == NULL) return FS_RES_INV_PARAM;
|
||||
|
||||
fs_res_t res = file_p->drv->size(file_p->file_d, size);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize a 'fs_read_dir_t' variable for directory reading
|
||||
* @param rddir_p pointer to a 'fs_read_dir_t' variable
|
||||
* @param path path to a directory
|
||||
* @return FS_RES_OK or any error from fs_res_t enum
|
||||
*/
|
||||
fs_res_t fs_readdir_init(fs_readdir_t * rddir_p, const char * path)
|
||||
{
|
||||
if(path == NULL) return FS_RES_INV_PARAM;
|
||||
|
||||
char letter = path[0];
|
||||
|
||||
rddir_p->drv = fs_get_drv(letter);
|
||||
|
||||
if(rddir_p->drv == NULL) {
|
||||
rddir_p->rddir_d = NULL;
|
||||
return FS_RES_NOT_EX;
|
||||
}
|
||||
|
||||
rddir_p->rddir_d = dm_alloc(rddir_p->drv->file_size);
|
||||
if(rddir_p->rddir_d == NULL) {
|
||||
rddir_p->rddir_d = NULL;
|
||||
return FS_RES_OUT_OF_MEM; /* Out of memory */
|
||||
}
|
||||
|
||||
if(rddir_p->drv->rddir_init == NULL) {
|
||||
return FS_RES_NOT_IMP;
|
||||
}
|
||||
|
||||
const char * real_path = fs_get_real_path(path);
|
||||
fs_res_t res = rddir_p->drv->rddir_init(rddir_p->rddir_d, real_path);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the next filename form a directory.
|
||||
* The name of the directories will begin with '/'
|
||||
* @param rddir_p pointer to an initialized 'fs_read_dir_t' variable
|
||||
* @param fn pointer to a buffer to store the filename
|
||||
* @return FS_RES_OK or any error from fs_res_t enum
|
||||
*/
|
||||
fs_res_t fs_readdir (fs_readdir_t * rddir_p, char * fn)
|
||||
{
|
||||
if(rddir_p->drv == NULL || rddir_p->rddir_d == NULL) {
|
||||
return FS_RES_INV_PARAM;
|
||||
}
|
||||
|
||||
if(rddir_p->drv->rddir == NULL) {
|
||||
return FS_RES_NOT_IMP;
|
||||
}
|
||||
|
||||
fs_res_t res = rddir_p->drv->rddir(rddir_p->rddir_d, fn);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the directory reading
|
||||
* @param rddir_p pointer to an initialized 'fs_read_dir_t' variable
|
||||
* @return FS_RES_OK or any error from fs_res_t enum
|
||||
*/
|
||||
fs_res_t fs_readdir_close (fs_readdir_t * rddir_p)
|
||||
{
|
||||
if(rddir_p->drv == NULL || rddir_p->rddir_d == NULL) {
|
||||
return FS_RES_INV_PARAM;
|
||||
}
|
||||
|
||||
fs_res_t res;
|
||||
|
||||
if(rddir_p->drv->rddir_close == NULL) {
|
||||
res = FS_RES_NOT_IMP;
|
||||
} else {
|
||||
res = rddir_p->drv->rddir_close(rddir_p->rddir_d);
|
||||
}
|
||||
|
||||
dm_free(rddir_p->rddir_d); /*Clean up*/
|
||||
rddir_p->rddir_d = NULL;
|
||||
rddir_p->drv = NULL;
|
||||
rddir_p->rddir_d = NULL;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the free and total size of a driver in kB
|
||||
* @param letter the driver letter
|
||||
* @param total_p pointer to store the total size [kB]
|
||||
* @param free_p pointer to store the free size [kB]
|
||||
* @return FS_RES_OK or any error from fs_res_t enum
|
||||
*/
|
||||
fs_res_t fs_free (char letter, uint32_t * total_p, uint32_t * free_p)
|
||||
{
|
||||
fs_drv_t * drv = fs_get_drv(letter);
|
||||
|
||||
if(drv == NULL) {
|
||||
return FS_RES_INV_PARAM;
|
||||
}
|
||||
|
||||
fs_res_t res;
|
||||
|
||||
if(drv->free == NULL) {
|
||||
res = FS_RES_NOT_IMP;
|
||||
} else {
|
||||
uint32_t total_tmp = 0;
|
||||
uint32_t free_tmp = 0;
|
||||
res = drv->free(&total_tmp, &free_tmp);
|
||||
|
||||
if(total_p != NULL) *total_p = total_tmp;
|
||||
if(free_p != NULL) *free_p = free_tmp;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new drive
|
||||
* @param drv_p pointer to an fs_drv_t structure which is inited with the
|
||||
* corresponding function pointer. The data will be copied so the variable can be local.
|
||||
*/
|
||||
void fs_add_drv(fs_drv_t * drv_p)
|
||||
{
|
||||
/*Save the new driver*/
|
||||
fs_drv_t* new_drv;
|
||||
new_drv = ll_ins_head(&drv_ll);
|
||||
dm_assert(new_drv);
|
||||
memcpy(new_drv, drv_p, sizeof(fs_drv_t));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Fill a buffer with the letters of existing drivers
|
||||
* @param buf buffer to store the letters ('\0' added after the last letter)
|
||||
* @return the buffer
|
||||
*/
|
||||
char * fs_get_letters(char * buf)
|
||||
{
|
||||
fs_drv_t* drv;
|
||||
uint8_t i = 0;
|
||||
|
||||
LL_READ(drv_ll, drv) {
|
||||
buf[i] = drv->letter;
|
||||
i++;
|
||||
}
|
||||
|
||||
buf[i] = '\0';
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return with the extension of the filename
|
||||
* @param fn string with a filename
|
||||
* @return pointer to the beginning extension or empty string if no extension
|
||||
*/
|
||||
const char * fs_get_ext(const char * fn)
|
||||
{
|
||||
uint16_t i;
|
||||
for(i = strlen(fn); i > 0; i --) {
|
||||
if(fn[i] == '.') {
|
||||
return &fn[i + 1];
|
||||
} else if(fn[i] == '/' || fn[i] == '\\') {
|
||||
return ""; /*No extension if a '\' or '/' found*/
|
||||
}
|
||||
}
|
||||
|
||||
return ""; /*Empty string if no '.' in the file name. */
|
||||
}
|
||||
|
||||
/**
|
||||
* Step up one level
|
||||
* @param path pointer to a file name
|
||||
* @return the truncated file name
|
||||
*/
|
||||
char * fs_up(char * path)
|
||||
{
|
||||
uint16_t len = strlen(path);
|
||||
if(len == 0) return path;
|
||||
|
||||
len --; /*Go before the trailing '\0'*/
|
||||
|
||||
/*Ignore trailing '/' or '\'*/
|
||||
while(path[len] == '/' || path[len] == '\\') {
|
||||
path[len] = '\0';
|
||||
if(len > 0) len --;
|
||||
else return path;
|
||||
}
|
||||
|
||||
uint16_t i;
|
||||
for(i = len; i > 0; i --) {
|
||||
if(path[i] == '/' || path[i] == '\\') break;
|
||||
}
|
||||
|
||||
path[i] = '\0';
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the last element of a path (e.g. U:/folder/file -> file)
|
||||
* @param path a character sting with the path to search in
|
||||
* @return pointer to the beginning of the last element in the path
|
||||
*/
|
||||
const char * fs_get_last(const char * path)
|
||||
{
|
||||
uint16_t len = strlen(path);
|
||||
if(len == 0) return path;
|
||||
|
||||
len --; /*Go before the trailing '\0'*/
|
||||
|
||||
/*Ignore trailing '/' or '\'*/
|
||||
while(path[len] == '/' || path[len] == '\\') {
|
||||
if(len > 0) len --;
|
||||
else return path;
|
||||
}
|
||||
|
||||
uint16_t i;
|
||||
for(i = len; i > 0; i --) {
|
||||
if(path[i] == '/' || path[i] == '\\') break;
|
||||
}
|
||||
|
||||
/*No '/' or '\' in the path so return with path itself*/
|
||||
if(i == 0) return path;
|
||||
|
||||
return &path[i + 1];
|
||||
}
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Leave the driver letters and / or \ letters from beginning of the path
|
||||
* @param path path string (E.g. S:/folder/file.txt)
|
||||
* @return pointer to the beginning of the real path (E.g. folder/file.txt)
|
||||
*/
|
||||
static const char * fs_get_real_path(const char * path)
|
||||
{
|
||||
/* Example path: "S:/folder/file.txt"
|
||||
* Leave the letter and the : / \ characters*/
|
||||
|
||||
path ++; /*Ignore the driver letter*/
|
||||
|
||||
while(*path != '\0') {
|
||||
if(*path == ':' || *path == '\\' || *path == '/'){
|
||||
path ++;
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Give a pointer to a driver from its letter
|
||||
* @param letter the driver letter
|
||||
* @return pointer to a driver or NULL if not found
|
||||
*/
|
||||
static fs_drv_t* fs_get_drv(char letter)
|
||||
{
|
||||
fs_drv_t* drv;
|
||||
|
||||
LL_READ(drv_ll, drv) {
|
||||
if(drv->letter == letter) {
|
||||
return drv;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#endif
|
||||
248
misc/fs/fsint.h
Normal file
248
misc/fs/fsint.h
Normal file
@@ -0,0 +1,248 @@
|
||||
/**
|
||||
* @file fsint.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef FSINT_H
|
||||
#define FSINT_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "misc_conf.h"
|
||||
#if USE_FSINT != 0
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "../mem/dyn_mem.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define FSINT_MAX_FN_LENGTH 64
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
typedef enum
|
||||
{
|
||||
FS_RES_OK = 0,
|
||||
FS_RES_HW_ERR, /*Low level hardwer error*/
|
||||
FS_RES_FS_ERR, /*Error in the file system structure */
|
||||
FS_RES_NOT_EX, /*Driver, file or direcory is not exists*/
|
||||
FS_RES_FULL, /*Disk full*/
|
||||
FS_RES_LOCKED, /*The file is already opened*/
|
||||
FS_RES_DENIED, /*Access denied. Check 'fs_open' modes and write protect*/
|
||||
FS_BUSY, /*The filesystem now can't handle it, try later*/
|
||||
FS_RES_TOUT, /*Process timeouted*/
|
||||
FS_RES_NOT_IMP, /*Requested function is not implemented*/
|
||||
FS_RES_OUT_OF_MEM, /*Not enough memory for an internal opretion*/
|
||||
FS_RES_INV_PARAM, /*Invalid parameter among arguments*/
|
||||
FS_RES_UNKNOWN, /*Other unknown error*/
|
||||
}fs_res_t;
|
||||
|
||||
struct __fs_drv_struct;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
void * file_d;
|
||||
struct __fs_drv_struct* drv;
|
||||
}fs_file_t;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
void * rddir_d;
|
||||
struct __fs_drv_struct * drv;
|
||||
}fs_readdir_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
FS_MODE_WR = 0x01,
|
||||
FS_MODE_RD = 0x02,
|
||||
}fs_mode_t;
|
||||
|
||||
typedef struct __fs_drv_struct
|
||||
{
|
||||
char letter;
|
||||
uint16_t file_size;
|
||||
uint16_t rddir_size;
|
||||
bool (*ready) (void);
|
||||
|
||||
fs_res_t (*open) (void * file_p, const char * path, fs_mode_t mode);
|
||||
fs_res_t (*close) (void * file_p);
|
||||
fs_res_t (*remove) (const char * fn);
|
||||
fs_res_t (*read) (void * file_p, void * buf, uint32_t btr, uint32_t * br);
|
||||
fs_res_t (*write) (void * file_p, const void * buf, uint32_t btw, uint32_t * bw);
|
||||
fs_res_t (*seek) (void * file_p, uint32_t pos);
|
||||
fs_res_t (*tell) (void * file_p, uint32_t * pos_p);
|
||||
fs_res_t (*trunc) (void * file_p);
|
||||
fs_res_t (*size) (void * file_p, uint32_t * size_p);
|
||||
fs_res_t (*free) (uint32_t * total_p, uint32_t * free_p);
|
||||
|
||||
fs_res_t (*rddir_init) (void * rddir_p, const char * path);
|
||||
fs_res_t (*rddir) (void * rddir_p, char * fn);
|
||||
fs_res_t (*rddir_close) (void * rddir_p);
|
||||
}fs_drv_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Initialize the File system interface
|
||||
*/
|
||||
void fs_init(void);
|
||||
|
||||
/**
|
||||
* Add a new drive
|
||||
* @param drv_p pointer to an fs_drv_t structure which is inited with the
|
||||
* corresponding function pointer
|
||||
*/
|
||||
void fs_add_drv(fs_drv_t * drv_p);
|
||||
|
||||
/**
|
||||
* Open a file
|
||||
* @param file_p pointer to a fs_file_t variable
|
||||
* @param path path to the file beginning with the driver letter (e.g. S:/folder/file.txt)
|
||||
* @param mode read: FS_MODE_RD, write: FS_MODE_WR, both: FS_MODE_RD | FS_MODE_WR
|
||||
* @return FS_RES_OK or any error from fs_res_t enum
|
||||
*/
|
||||
fs_res_t fs_open (fs_file_t * file_p, const char * path, fs_mode_t mode);
|
||||
|
||||
/**
|
||||
* Close an already opened file
|
||||
* @param file_p pointer to a fs_file_t variable
|
||||
* @return FS_RES_OK or any error from fs_res_t enum
|
||||
*/
|
||||
fs_res_t fs_close (fs_file_t * file_p);
|
||||
|
||||
/**
|
||||
* Delete a file
|
||||
* @param path path of the file to delete
|
||||
* @return FS_RES_OK or any error from fs_res_t enum
|
||||
*/
|
||||
fs_res_t fs_remove (const char * path);
|
||||
|
||||
/**
|
||||
* Read from a file
|
||||
* @param file_p pointer to a fs_file_t variable
|
||||
* @param buf pointer to a buffer where the read bytes are stored
|
||||
* @param btr Bytes To Read
|
||||
* @param br the number of real read bytes (Bytes Read). NULL if unused.
|
||||
* @return FS_RES_OK or any error from fs_res_t enum
|
||||
*/
|
||||
fs_res_t fs_read (fs_file_t * file_p, void * buf, uint32_t btr, uint32_t * br);
|
||||
|
||||
/**
|
||||
* Write into a file
|
||||
* @param file_p pointer to a fs_file_t variable
|
||||
* @param buf pointer to a buffer with the bytes to write
|
||||
* @param btr Bytes To Write
|
||||
* @param br the number of real written bytes (Bytes Written). NULL if unused.
|
||||
* @return FS_RES_OK or any error from fs_res_t enum
|
||||
*/
|
||||
fs_res_t fs_write (fs_file_t * file_p, const void * buf, uint32_t btw, uint32_t * bw);
|
||||
|
||||
/**
|
||||
* Set the position of the 'cursor' (read write pointer) in a file
|
||||
* @param file_p pointer to a fs_file_t variable
|
||||
* @param pos the new position expressed in bytes index (0: start of file)
|
||||
* @return FS_RES_OK or any error from fs_res_t enum
|
||||
*/
|
||||
fs_res_t fs_seek (fs_file_t * file_p, uint32_t pos);
|
||||
|
||||
/**
|
||||
* Give the position of the read write pointer
|
||||
* @param file_p pointer to a fs_file_t variable
|
||||
* @param pos_p pointer to store the position of the read write pointer
|
||||
* @return FS_RES_OK or any error from 'fs_res_t'
|
||||
*/
|
||||
fs_res_t fs_tell (fs_file_t * file_p, uint32_t * pos);
|
||||
|
||||
/**
|
||||
* Give the size of a file bytes
|
||||
* @param file_p pointer to a fs_file_t variable
|
||||
* @param size pointer to a variable to store the size
|
||||
* @return FS_RES_OK or any error from fs_res_t enum
|
||||
*/
|
||||
fs_res_t fs_size (fs_file_t * file_p, uint32_t * size);
|
||||
|
||||
/**
|
||||
* Initialize a 'fs_read_dir_t' variable for directory reading
|
||||
* @param rddir_p pointer to a 'fs_read_dir_t' variable
|
||||
* @param path path to a directory
|
||||
* @return FS_RES_OK or any error from fs_res_t enum
|
||||
*/
|
||||
fs_res_t fs_readdir_init(fs_readdir_t * rddir_p, const char * path);
|
||||
|
||||
/**
|
||||
* Read the next filename form a directory.
|
||||
* The name of the directories will begin with '/'
|
||||
* @param rddir_p pointer to an initialized 'fs_read_dir_t' variable
|
||||
* @param fn pointer to a buffer to store the filename
|
||||
* @return FS_RES_OK or any error from fs_res_t enum
|
||||
*/
|
||||
fs_res_t fs_readdir (fs_readdir_t * rddir_p, char * fn);
|
||||
|
||||
/**
|
||||
* Close the directory reading
|
||||
* @param rddir_p pointer to an initialized 'fs_read_dir_t' variable
|
||||
* @return FS_RES_OK or any error from fs_res_t enum
|
||||
*/
|
||||
fs_res_t fs_readdir_close (fs_readdir_t * rddir_p);
|
||||
|
||||
/**
|
||||
* Get the free and total size of a driver in kB
|
||||
* @param letter the driver letter
|
||||
* @param total_p pointer to store the total size [kB]
|
||||
* @param free_p pointer to store the free size [kB]
|
||||
* @return FS_RES_OK or any error from fs_res_t enum
|
||||
*/
|
||||
fs_res_t fs_free (char letter, uint32_t * total_p, uint32_t * free_p);
|
||||
|
||||
/**
|
||||
* Fill a buffer with the letters of existing drivers
|
||||
* @param buf buffer to store the letters ('\0' added after the last letter)
|
||||
* @return the buffer
|
||||
*/
|
||||
char * fs_get_letters(char * buf);
|
||||
|
||||
/**
|
||||
* Return with the extension of the filename
|
||||
* @param fn string with a filename
|
||||
* @return pointer to the beginning extension or empty string if no extension
|
||||
*/
|
||||
const char * fs_get_ext(const char * fn);
|
||||
|
||||
/**
|
||||
* Step up one level
|
||||
* @param path pointer to a file name
|
||||
* @return the truncated file name
|
||||
*/
|
||||
char * fs_up(char * path);
|
||||
|
||||
/**
|
||||
* Get the last element of a path (e.g. U:/folder/file -> file)
|
||||
* @param buf buffer to store the letters ('\0' added after the last letter)
|
||||
* @return pointer to the beginning of the last element in the path
|
||||
*/
|
||||
const char * fs_get_last(const char * path);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
319
misc/fs/linuxfs/linuxfs.c
Normal file
319
misc/fs/linuxfs/linuxfs.c
Normal file
@@ -0,0 +1,319 @@
|
||||
/**
|
||||
* @file linuxfs.c
|
||||
* Functions to give an API to the standard
|
||||
* file operation functions to be compatible
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "misc_conf.h"
|
||||
#if USE_LINUXFS != 0
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <dirent.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
#include "linuxfs.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static fs_res_t linuxfs_res_trans(int linuxfs_res);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
/**
|
||||
* Create a driver for the linuxfs device and initilaize it.
|
||||
*/
|
||||
void linuxfs_init(void)
|
||||
{
|
||||
/*Create the driver*/
|
||||
fs_drv_t linux_drv;
|
||||
memset(&linux_drv, 0, sizeof(fs_drv_t)); /*Initialization*/
|
||||
|
||||
linux_drv.file_size = sizeof(FILE *);
|
||||
linux_drv.rddir_size = sizeof(DIR *);
|
||||
linux_drv.letter = LINUXFS_LETTER;
|
||||
linux_drv.ready = linuxfs_ready;
|
||||
|
||||
linux_drv.open = linuxfs_open;
|
||||
linux_drv.close = linuxfs_close;
|
||||
linux_drv.remove = linuxfs_remove;
|
||||
linux_drv.read = linuxfs_read;
|
||||
linux_drv.write = linuxfs_write;
|
||||
linux_drv.seek = linuxfs_seek;
|
||||
linux_drv.tell = linuxfs_tell;
|
||||
linux_drv.size = linuxfs_size;
|
||||
linux_drv.trunc = NULL;
|
||||
|
||||
linux_drv.rddir_init = linuxfs_readdir_init;
|
||||
linux_drv.rddir = linuxfs_readdir;
|
||||
linux_drv.rddir_close = linuxfs_readdir_close;
|
||||
|
||||
linux_drv.free = NULL;
|
||||
fs_add_drv(&linux_drv);
|
||||
}
|
||||
|
||||
/**
|
||||
* Give the state of the linuxfs
|
||||
* @return true if it is already initialized
|
||||
*/
|
||||
bool linuxfs_ready(void)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Open a file
|
||||
* @param file_p pointer to a FIL type variable
|
||||
* @param path path of the file (e.g. "dir1/dir2/file1.txt")
|
||||
* @param mode open mode (FS_MODE_RD or FS_MODE_WR or both with | (or connection))
|
||||
* @return FS_RES_OK or any error from 'fs_res_t'
|
||||
*/
|
||||
fs_res_t linuxfs_open (void * file_p, const char * path, fs_mode_t mode)
|
||||
{
|
||||
FILE ** fp = file_p;
|
||||
|
||||
errno = 0;
|
||||
const char * linuxfs_mode = 0;
|
||||
if(mode == FS_MODE_RD) linuxfs_mode = "r";
|
||||
if(mode == FS_MODE_WR) linuxfs_mode = "a";
|
||||
if(mode == (FS_MODE_WR | FS_MODE_RD)) linuxfs_mode = "a+";
|
||||
|
||||
*fp = fopen(path, linuxfs_mode);
|
||||
return linuxfs_res_trans(errno);
|
||||
}
|
||||
|
||||
/**
|
||||
* Close an already opened file
|
||||
* @param file_p pointer to a FIL type variable
|
||||
* @return FS_RES_OK or any error from fs_res_t
|
||||
*/
|
||||
fs_res_t linuxfs_close (void * file_p)
|
||||
{
|
||||
FILE ** fp = file_p;
|
||||
if(*fp == NULL) return FS_RES_INV_PARAM;
|
||||
errno = 0;
|
||||
fclose(*fp);
|
||||
return linuxfs_res_trans(errno);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove (delete) a file
|
||||
* @param path the path of the file ("dir1/file1.txt")
|
||||
* @return FS_RES_OK or any error from 'fs_res_t'
|
||||
*/
|
||||
fs_res_t linuxfs_remove(const char * path)
|
||||
{
|
||||
errno = 0;
|
||||
remove(path);
|
||||
return linuxfs_res_trans(errno);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read data from an opened file
|
||||
* @param file_p pointer to a FIL type variable
|
||||
* @param buf pointer a buffer to store the read bytes
|
||||
* @param btr the number of Bytes To Read
|
||||
* @param br the number of real read bytes (Bytes Read)
|
||||
* @return FS_RES_OK or any error from 'fs_res_t'
|
||||
*/
|
||||
fs_res_t linuxfs_read (void * file_p, void * buf, uint32_t btr, uint32_t * br)
|
||||
{
|
||||
FILE ** fp = file_p;
|
||||
if(*fp == NULL) return FS_RES_INV_PARAM;
|
||||
|
||||
errno = 0;
|
||||
(*br) = fread(buf, 1, btr, *fp);
|
||||
return linuxfs_res_trans(errno);
|
||||
}
|
||||
|
||||
/**
|
||||
* Write data to an opened file
|
||||
* @param file_p pointer to a FIL type variable
|
||||
* @param buf pointer to buffer where the data to write is located
|
||||
* @param btw the number of Bytes To Write
|
||||
* @param bw the number of real written bytes (Bytes Written)
|
||||
* @return FS_RES_OK or any error from 'fs_res_t'
|
||||
*/
|
||||
fs_res_t linuxfs_write (void * file_p, const void * buf, uint32_t btw, uint32_t * bw)
|
||||
{
|
||||
FILE ** fp = file_p;
|
||||
if(*fp == NULL) return FS_RES_INV_PARAM;
|
||||
|
||||
errno = 0;
|
||||
(*bw) = fwrite(buf, 1, btw, *fp);
|
||||
return linuxfs_res_trans(errno);
|
||||
}
|
||||
|
||||
/**
|
||||
* Position the read write pointer to given position
|
||||
* @param file_p pointer to a FIL type variable
|
||||
* @param pos the new position expressed in bytes index (0: start of file)
|
||||
* @return FS_RES_OK or any error from 'fs_res_t'
|
||||
*/
|
||||
fs_res_t linuxfs_seek (void * file_p, uint32_t pos)
|
||||
{
|
||||
FILE ** fp = file_p;
|
||||
if(*fp == NULL) return FS_RES_INV_PARAM;
|
||||
|
||||
errno = 0;
|
||||
fseek(*fp, pos, SEEK_SET);
|
||||
return linuxfs_res_trans(errno);
|
||||
}
|
||||
|
||||
/**
|
||||
* Give the position of the read write pointer
|
||||
* @param file_p pointer to a FIL type variable
|
||||
* @param pos_p pointer to store the position of the read write pointer
|
||||
* @return FS_RES_OK or any error from 'fs_res_t'
|
||||
*/
|
||||
fs_res_t linuxfs_tell (void * file_p, uint32_t * pos_p)
|
||||
{
|
||||
FILE ** fp = file_p;
|
||||
if(*fp == NULL) return FS_RES_INV_PARAM;
|
||||
|
||||
errno = 0;
|
||||
long int x = ftell(*fp);
|
||||
if(x < 0) *pos_p = 0;
|
||||
else *pos_p = (uint32_t)x;
|
||||
|
||||
return linuxfs_res_trans(errno);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Give the size of a file
|
||||
* @param file_p pointer to a FIL type variable
|
||||
* @param size_p pointer to store the size
|
||||
* @return FS_RES_OK or any error from 'fs_res_t'
|
||||
*/
|
||||
fs_res_t linuxfs_size (void * file_p, uint32_t * size_p)
|
||||
{
|
||||
FILE ** fp = file_p;
|
||||
if(*fp == NULL) return FS_RES_INV_PARAM;
|
||||
|
||||
errno = 0;
|
||||
/*Save the current position*/
|
||||
long int ori = ftell(*fp);
|
||||
if(errno) return linuxfs_res_trans(errno);
|
||||
|
||||
/* Seek to the and read the position.
|
||||
* It is equal to the size*/
|
||||
fseek(*fp, 0, SEEK_END);
|
||||
if(errno) return linuxfs_res_trans(errno);
|
||||
long int x;
|
||||
x = ftell(*fp);
|
||||
if(errno) return linuxfs_res_trans(errno);
|
||||
|
||||
*size_p = (uint32_t)x;
|
||||
|
||||
/*Revert the position*/
|
||||
fseek(*fp, ori, SEEK_SET); // seek back read write pointer
|
||||
|
||||
return linuxfs_res_trans(errno);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Initialize a variable for directory reading
|
||||
* @param rddir_p pointer to a 'DIR' variable
|
||||
* @param path path to a directory
|
||||
* @return FS_RES_OK or any error from fs_res_t enum
|
||||
*/
|
||||
fs_res_t linuxfs_readdir_init(void * rddir_p, const char * path)
|
||||
{
|
||||
errno = 0;
|
||||
char path_buf[512];
|
||||
sprintf(path_buf,"%s%s" , LINUXFS_ROOT_DIR, path);
|
||||
|
||||
DIR ** rd = rddir_p;
|
||||
*rd = opendir(path_buf);
|
||||
|
||||
return linuxfs_res_trans(errno);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the next filename form a directory.
|
||||
* The name of the directories will begin with '/'
|
||||
* @param rddir_p pointer to an initialized 'DIR' variable
|
||||
* @param fn pointer to a buffer to store the filename
|
||||
* @return FS_RES_OK or any error from fs_res_t enum
|
||||
*/
|
||||
fs_res_t linuxfs_readdir(void * rddir_p, char * fn)
|
||||
{
|
||||
errno = 0;
|
||||
DIR ** rd = rddir_p;
|
||||
if(*rd == NULL) return FS_RES_INV_PARAM;
|
||||
|
||||
struct dirent *dirp;
|
||||
|
||||
do {
|
||||
dirp = readdir(*rd);
|
||||
if(dirp == NULL){
|
||||
fn[0] = '\0';
|
||||
break;
|
||||
}
|
||||
} while(dirp->d_name[0] == '.'); /*Ignore "." and ".."*/
|
||||
|
||||
/*Save the filename*/
|
||||
if(dirp != NULL) {
|
||||
if(dirp->d_type == DT_DIR) sprintf(fn, "/%s", dirp->d_name);
|
||||
else sprintf(fn, "%s", dirp->d_name);
|
||||
}
|
||||
|
||||
return linuxfs_res_trans(errno);
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the directory reading
|
||||
* @param rddir_p pointer to an initialized 'DIR' variable
|
||||
* @return FS_RES_OK or any error from fs_res_t enum
|
||||
*/
|
||||
fs_res_t linuxfs_readdir_close(void * rddir_p)
|
||||
{
|
||||
DIR ** rd = rddir_p;
|
||||
if(*rd == NULL) return FS_RES_INV_PARAM;
|
||||
|
||||
errno = 0;
|
||||
closedir(*rd);
|
||||
return FS_RES_OK;
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Translate the return codes to fs_res_t
|
||||
* @param linuxfs_res the original fat_32 result
|
||||
* @return the converted, fs_res_t return code
|
||||
*/
|
||||
|
||||
static fs_res_t linuxfs_res_trans(int linuxfs_res)
|
||||
{
|
||||
if(linuxfs_res == 0) return FS_RES_OK;
|
||||
return FS_RES_UNKNOWN;
|
||||
}
|
||||
|
||||
#endif
|
||||
149
misc/fs/linuxfs/linuxfs.h
Normal file
149
misc/fs/linuxfs/linuxfs.h
Normal file
@@ -0,0 +1,149 @@
|
||||
/**
|
||||
* @file linuxfs.c
|
||||
* Functions to give an API to the standard
|
||||
* file operation functions to be compatible
|
||||
*/
|
||||
|
||||
|
||||
#ifndef LINUXFS_H
|
||||
#define LINUXFS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "misc_conf.h"
|
||||
#if USE_LINUXFS != 0
|
||||
|
||||
#include "../fsint.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Create a driver for the linuxfs device and initilaize it.
|
||||
*/
|
||||
void linuxfs_init(void);
|
||||
|
||||
/**
|
||||
* Give the state of the linuxfs
|
||||
* @return true if it is already initialized
|
||||
*/
|
||||
bool linuxfs_ready(void);
|
||||
|
||||
/**
|
||||
* Open a file
|
||||
* @param file_p pointer to a FIL type variable
|
||||
* @param path path of the file (e.g. "dir1/dir2/file1.txt")
|
||||
* @param mode open mode (FS_MODE_RD or FS_MODE_WR or both with | (or connection))
|
||||
* @return FS_RES_OK or any error from 'fs_res_t'
|
||||
*/
|
||||
fs_res_t linuxfs_open (void * file_p, const char * path, fs_mode_t mode);
|
||||
|
||||
/**
|
||||
* Close an already opened file
|
||||
* @param file_p pointer to a FIL type variable
|
||||
* @return FS_RES_OK or any error from fs_res_t
|
||||
*/
|
||||
fs_res_t linuxfs_close (void * file_p);
|
||||
|
||||
/**
|
||||
* Remove (delete) a file
|
||||
* @param path the path of the file ("dir1/file1.txt")
|
||||
* @return FS_RES_OK or any error from 'fs_res_t'
|
||||
*/
|
||||
fs_res_t linuxfs_remove(const char * path);
|
||||
|
||||
/**
|
||||
* Read data from an opened file
|
||||
* @param file_p pointer to a FIL type variable
|
||||
* @param buf pointer a buffer to store the read bytes
|
||||
* @param btr the number of Bytes To Read
|
||||
* @param br the number of real read bytes (Bytes Read)
|
||||
* @return FS_RES_OK or any error from 'fs_res_t'
|
||||
*/
|
||||
fs_res_t linuxfs_read (void * file_p, void * buf, uint32_t btr, uint32_t * br);
|
||||
|
||||
/**
|
||||
* Write data to an opened file
|
||||
* @param file_p pointer to a FIL type variable
|
||||
* @param buf pointer to buffer where the data to write is located
|
||||
* @param btw the number of Bytes To Write
|
||||
* @param bw the number of real written bytes (Bytes Written)
|
||||
* @return FS_RES_OK or any error from 'fs_res_t'
|
||||
*/
|
||||
fs_res_t linuxfs_write (void * file_p, const void * buf, uint32_t btw, uint32_t * bw);
|
||||
|
||||
/**
|
||||
* Position the read write pointer to given position
|
||||
* @param file_p pointer to a FIL type variable
|
||||
* @param pos the new position expressed in bytes index (0: start of file)
|
||||
* @return FS_RES_OK or any error from 'fs_res_t'
|
||||
*/
|
||||
fs_res_t linuxfs_seek (void * file_p, uint32_t pos);
|
||||
|
||||
/**
|
||||
* Give the position of the read write pointer
|
||||
* @param file_p pointer to a FIL type variable
|
||||
* @param pos_p pointer to store the position of the read write pointer
|
||||
* @return FS_RES_OK or any error from 'fs_res_t'
|
||||
*/
|
||||
fs_res_t linuxfs_tell (void * file_p, uint32_t * pos_p);
|
||||
|
||||
/**
|
||||
* Give the size of a file
|
||||
* @param file_p pointer to a FIL type variable
|
||||
* @param size_p pointer to store the size
|
||||
* @return FS_RES_OK or any error from 'fs_res_t'
|
||||
*/
|
||||
fs_res_t linuxfs_size (void * file_p, uint32_t * size_p);
|
||||
|
||||
/**
|
||||
* Initialize a variable for directory reading
|
||||
* @param rddir_p pointer to a 'DIR' variable
|
||||
* @param path path to a directory
|
||||
* @return FS_RES_OK or any error from fs_res_t enum
|
||||
*/
|
||||
fs_res_t linuxfs_readdir_init(void * rddir_p, const char * path);
|
||||
|
||||
/**
|
||||
* Read the next filename form a directory.
|
||||
* The name of the directories will begin with '/'
|
||||
* @param rddir_p pointer to an initialized 'DIR' variable
|
||||
* @param fn pointer to a buffer to store the filename
|
||||
* @return FS_RES_OK or any error from fs_res_t enum
|
||||
*/
|
||||
fs_res_t linuxfs_readdir(void * rddir_p, char * fn);
|
||||
|
||||
/**
|
||||
* Close the directory reading
|
||||
* @param rddir_p pointer to an initialized 'DIR' variable
|
||||
* @return FS_RES_OK or any error from fs_res_t enum
|
||||
*/
|
||||
fs_res_t linuxfs_readdir_close(void * rddir_p);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
501
misc/fs/ufs/ufs.c
Normal file
501
misc/fs/ufs/ufs.c
Normal file
@@ -0,0 +1,501 @@
|
||||
/**
|
||||
* @file ufs.c
|
||||
* Implementation of RAM file system which do NOT support directories.
|
||||
* The API is compatible with the fs_int module.
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
|
||||
#include "misc_conf.h"
|
||||
#if USE_UFS != 0
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include "ufs.h"
|
||||
#include "../../mem/linked_list.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static ufs_ent_t* ufs_ent_get(const char * fn);
|
||||
static ufs_ent_t* ufs_ent_new(const char * fn);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static ll_dsc_t file_ll;
|
||||
static bool inited = false;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Create a driver for ufs and initialize it.
|
||||
*/
|
||||
void ufs_init(void)
|
||||
{
|
||||
ll_init(&file_ll, sizeof(ufs_ent_t));
|
||||
|
||||
fs_drv_t ufs_drv;
|
||||
memset(&ufs_drv, 0, sizeof(fs_drv_t)); /*Initialization*/
|
||||
|
||||
ufs_drv.file_size = sizeof(ufs_file_t);
|
||||
ufs_drv.rddir_size = sizeof(ufs_read_dir_t);
|
||||
ufs_drv.letter = UFS_LETTER;
|
||||
ufs_drv.ready = ufs_ready;
|
||||
|
||||
ufs_drv.open = ufs_open;
|
||||
ufs_drv.close = ufs_close;
|
||||
ufs_drv.remove = ufs_remove;
|
||||
ufs_drv.read = ufs_read;
|
||||
ufs_drv.write = ufs_write;
|
||||
ufs_drv.seek = ufs_seek;
|
||||
ufs_drv.tell = ufs_tell;
|
||||
ufs_drv.size = ufs_size;
|
||||
ufs_drv.trunc = ufs_trunc;
|
||||
ufs_drv.free = ufs_free;
|
||||
|
||||
ufs_drv.rddir_init = ufs_readdir_init;
|
||||
ufs_drv.rddir = ufs_readdir;
|
||||
ufs_drv.rddir_close = ufs_readdir_close;
|
||||
|
||||
fs_add_drv(&ufs_drv);
|
||||
|
||||
inited = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Give the state of the ufs
|
||||
* @return true if ufs is initialized and can be used else false
|
||||
*/
|
||||
bool ufs_ready(void)
|
||||
{
|
||||
return inited;
|
||||
}
|
||||
|
||||
/**
|
||||
* Open a file in ufs
|
||||
* @param file_p pointer to a ufs_file_t variable
|
||||
* @param fn name of the file. There are no directories so e.g. "myfile.txt"
|
||||
* @param mode element of 'fs_mode_t' enum or its 'OR' connection (e.g. FS_MODE_WR | FS_MODE_RD)
|
||||
* @return FS_RES_OK: no error, the file is opened
|
||||
* any error from fs_res_t enum
|
||||
*/
|
||||
fs_res_t ufs_open (void * file_p, const char * fn, fs_mode_t mode)
|
||||
{
|
||||
ufs_file_t * fp = file_p; /*Convert type*/
|
||||
ufs_ent_t* ent = ufs_ent_get(fn);
|
||||
|
||||
fp->ent = NULL;
|
||||
|
||||
/*If the file not exists ...*/
|
||||
if( ent == NULL) {
|
||||
if((mode & FS_MODE_WR) != 0) { /*Create the file if opened for write*/
|
||||
ent = ufs_ent_new(fn);
|
||||
if(ent == NULL) return FS_RES_FULL; /*No space for the new file*/
|
||||
} else {
|
||||
return FS_RES_NOT_EX; /*Can not read not existing file*/
|
||||
}
|
||||
}
|
||||
|
||||
/*Can not write already opened and const data files*/
|
||||
if((mode & FS_MODE_WR) != 0) {
|
||||
if(ent->oc != 0) return FS_RES_LOCKED;
|
||||
if(ent->const_data != 0) return FS_RES_DENIED;
|
||||
}
|
||||
|
||||
/*No error, the file can be opened*/
|
||||
fp->ent = ent;
|
||||
fp->ar = mode & FS_MODE_RD ? 1 : 0;
|
||||
fp->aw = mode & FS_MODE_WR ? 1 : 0;
|
||||
fp->rwp = 0;
|
||||
ent->oc ++;
|
||||
|
||||
return FS_RES_OK;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create a file with a constant data
|
||||
* @param fn name of the file (directories are not supported)
|
||||
* @param const_p pointer to a constant data
|
||||
* @param len length of the data pointed by 'const_p' in bytes
|
||||
* @return FS_RES_OK: no error, the file is read
|
||||
* any error from fs_res_t enum
|
||||
*/
|
||||
fs_res_t ufs_create_const(const char * fn, const void * const_p, uint32_t len)
|
||||
{
|
||||
ufs_file_t file;
|
||||
fs_res_t res;
|
||||
|
||||
/*Error if the file already exists*/
|
||||
res = ufs_open(&file, fn, FS_MODE_RD);
|
||||
if(res == FS_RES_OK) {
|
||||
ufs_close(&file);
|
||||
return FS_RES_DENIED;
|
||||
}
|
||||
|
||||
ufs_close(&file);
|
||||
|
||||
res = ufs_open(&file, fn, FS_MODE_WR);
|
||||
if(res != FS_RES_OK) return res;
|
||||
|
||||
ufs_ent_t* ent = file.ent;
|
||||
|
||||
if(ent->data_d != NULL) return FS_RES_DENIED;
|
||||
|
||||
ent->data_d = (void *) const_p;
|
||||
ent->size = len;
|
||||
ent->const_data = 1;
|
||||
|
||||
res = ufs_close(&file);
|
||||
if(res != FS_RES_OK) return res;
|
||||
|
||||
return FS_RES_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Close an opened file
|
||||
* @param file_p pointer to an 'ufs_file_t' variable. (opened with ufs_open)
|
||||
* @return FS_RES_OK: no error, the file is read
|
||||
* any error from fs_res_t enum
|
||||
*/
|
||||
fs_res_t ufs_close (void * file_p)
|
||||
{
|
||||
ufs_file_t * fp = file_p; /*Convert type*/
|
||||
|
||||
if(fp->ent == NULL) return FS_RES_OK;
|
||||
|
||||
/*Decrement the Open counter*/
|
||||
if(fp->ent->oc > 0) {
|
||||
fp->ent->oc--;
|
||||
}
|
||||
|
||||
return FS_RES_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a file. The file can not be opened.
|
||||
* @param fn '\0' terminated string
|
||||
* @return FS_RES_OK: no error, the file is removed
|
||||
* FS_RES_DENIED: the file was opened, remove failed
|
||||
*/
|
||||
fs_res_t ufs_remove(const char * fn)
|
||||
{
|
||||
ufs_ent_t* ent = ufs_ent_get(fn);
|
||||
|
||||
/*Can not be deleted is opened*/
|
||||
if(ent->oc != 0) return FS_RES_DENIED;
|
||||
|
||||
ll_rem(&file_ll, ent);
|
||||
dm_free(ent->fn_d);
|
||||
ent->fn_d = NULL;
|
||||
if(ent->const_data == 0){
|
||||
dm_free(ent->data_d);
|
||||
ent->data_d = NULL;
|
||||
}
|
||||
|
||||
dm_free(ent);
|
||||
|
||||
return FS_RES_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read data from an opened file
|
||||
* @param file_p pointer to an 'ufs_file_t' variable. (opened with ufs_open )
|
||||
* @param buf pointer to a memory block where to store the read data
|
||||
* @param btr number of Bytes To Read
|
||||
* @param br the real number of read bytes (Byte Read)
|
||||
* @return FS_RES_OK: no error, the file is read
|
||||
* any error from fs_res_t enum
|
||||
*/
|
||||
fs_res_t ufs_read (void * file_p, void * buf, uint32_t btr, uint32_t * br)
|
||||
{
|
||||
ufs_file_t * fp = file_p; /*Convert type*/
|
||||
|
||||
ufs_ent_t* ent = fp->ent;
|
||||
*br = 0;
|
||||
|
||||
if(ent->data_d == NULL || ent->size == 0) { /*Don't read empty files*/
|
||||
return FS_RES_OK;
|
||||
} else if(fp->ar == 0) { /*The file is not opened for read*/
|
||||
return FS_RES_DENIED;
|
||||
}
|
||||
|
||||
/*No error, read the file*/
|
||||
if(fp->rwp + btr > ent->size) { /*Check too much bytes read*/
|
||||
*br = ent->size - fp->rwp;
|
||||
} else {
|
||||
*br = btr;
|
||||
}
|
||||
|
||||
/*Read the data*/
|
||||
uint8_t * data8_p;
|
||||
if(ent->const_data == 0) {
|
||||
data8_p = (uint8_t*) ent->data_d;
|
||||
} else {
|
||||
data8_p = ent->data_d;
|
||||
}
|
||||
|
||||
data8_p += fp->rwp;
|
||||
memcpy(buf, data8_p, *br);
|
||||
|
||||
fp->rwp += *br; /*Refresh the read write pointer*/
|
||||
|
||||
return FS_RES_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write data to an opened file
|
||||
* @param file_p pointer to an 'ufs_file_t' variable. (opened with ufs_open)
|
||||
* @param buf pointer to a memory block which content will be written
|
||||
* @param btw the number Bytes To Write
|
||||
* @param bw The real number of written bytes (Byte Written)
|
||||
* @return FS_RES_OK: no error, the file is read
|
||||
* any error from fs_res_t enum
|
||||
*/
|
||||
fs_res_t ufs_write (void * file_p, const void * buf, uint32_t btw, uint32_t * bw)
|
||||
{
|
||||
ufs_file_t * fp = file_p; /*Convert type*/
|
||||
*bw = 0;
|
||||
|
||||
if(fp->aw == 0) return FS_RES_DENIED; /*Not opened for write*/
|
||||
|
||||
ufs_ent_t* ent = fp->ent;
|
||||
|
||||
/*Reallocate data array if it necessary*/
|
||||
uint32_t new_size = fp->rwp + btw;
|
||||
if(new_size > ent->size) {
|
||||
uint8_t* new_data = dm_realloc(ent->data_d, new_size);
|
||||
if(new_data == NULL) return FS_RES_FULL; /*Cannot allocate the new memory*/
|
||||
|
||||
ent->data_d = new_data;
|
||||
ent->size = new_size;
|
||||
}
|
||||
|
||||
/*Write the file*/
|
||||
uint8_t * data8_p = (uint8_t*) ent->data_d;
|
||||
data8_p += fp->rwp;
|
||||
memcpy(data8_p, buf, btw);
|
||||
*bw = btw;
|
||||
fp->rwp += *bw;
|
||||
|
||||
return FS_RES_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the read write pointer. Also expand the file size if necessary.
|
||||
* @param file_p pointer to an 'ufs_file_t' variable. (opened with ufs_open )
|
||||
* @param pos the new position of read write pointer
|
||||
* @return FS_RES_OK: no error, the file is read
|
||||
* any error from fs_res_t enum
|
||||
*/
|
||||
fs_res_t ufs_seek (void * file_p, uint32_t pos)
|
||||
{
|
||||
ufs_file_t * fp = file_p; /*Convert type*/
|
||||
ufs_ent_t* ent = fp->ent;
|
||||
|
||||
/*Simply move the rwp before EOF*/
|
||||
if(pos < ent->size) {
|
||||
fp->rwp = pos;
|
||||
} else { /*Expand the file size*/
|
||||
if(fp->aw == 0) return FS_RES_DENIED; /*Not opened for write*/
|
||||
|
||||
uint8_t* new_data = dm_realloc(ent->data_d, pos);
|
||||
if(new_data == NULL) return FS_RES_FULL; /*Out of memory*/
|
||||
|
||||
ent->data_d = new_data;
|
||||
ent->size = pos;
|
||||
fp->rwp = pos;
|
||||
}
|
||||
|
||||
return FS_RES_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Give the position of the read write pointer
|
||||
* @param file_p pointer to an 'ufs_file_t' variable. (opened with ufs_open )
|
||||
* @param pos_p pointer to to store the result
|
||||
* @return FS_RES_OK: no error, the file is read
|
||||
* any error from fs_res_t enum
|
||||
*/
|
||||
fs_res_t ufs_tell (void * file_p, uint32_t * pos_p)
|
||||
{
|
||||
ufs_file_t * fp = file_p; /*Convert type*/
|
||||
|
||||
*pos_p = fp->rwp;
|
||||
|
||||
return FS_RES_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Truncate the file size to the current position of the read write pointer
|
||||
* @param file_p pointer to an 'ufs_file_t' variable. (opened with ufs_open )
|
||||
* @return FS_RES_OK: no error, the file is read
|
||||
* any error from fs_res_t enum
|
||||
*/
|
||||
fs_res_t ufs_trunc (void * file_p)
|
||||
{
|
||||
ufs_file_t * fp = file_p; /*Convert type*/
|
||||
ufs_ent_t* ent = fp->ent;
|
||||
|
||||
if(fp->aw == 0) return FS_RES_DENIED; /*Not opened for write*/
|
||||
|
||||
void * new_data = dm_realloc(ent->data_d, fp->rwp);
|
||||
if(new_data == NULL) return FS_RES_FULL; /*Out of memory*/
|
||||
|
||||
ent->data_d = new_data;
|
||||
ent->size = fp->rwp;
|
||||
|
||||
return FS_RES_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Give the size of the file in bytes
|
||||
* @param file_p file_p pointer to an 'ufs_file_t' variable. (opened with ufs_open )
|
||||
* @param size_p pointer to store the size
|
||||
* @return FS_RES_OK: no error, the file is read
|
||||
* any error from fs_res_t enum
|
||||
*/
|
||||
fs_res_t ufs_size (void * file_p, uint32_t * size_p)
|
||||
{
|
||||
ufs_file_t * fp = file_p; /*Convert type*/
|
||||
ufs_ent_t* ent = fp->ent;
|
||||
|
||||
*size_p = ent->size;
|
||||
|
||||
return FS_RES_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize a ufs_read_dir_t variable to directory reading
|
||||
* @param rddir_p pointer to a 'ufs_read_dir_t' variable
|
||||
* @param path uFS doesn't support folders so it has to be ""
|
||||
* @return FS_RES_OK or any error from fs_res_t enum
|
||||
*/
|
||||
fs_res_t ufs_readdir_init(void * rddir_p, const char * path)
|
||||
{
|
||||
ufs_read_dir_t * ufs_rddir_p = rddir_p;
|
||||
|
||||
ufs_rddir_p->last_ent = NULL;
|
||||
|
||||
if(path[0] != '\0') return FS_RES_NOT_EX;
|
||||
else return FS_RES_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the next file name
|
||||
* @param rddir_p pointer to an initialized 'ufs_read_dir_t' variable
|
||||
* @param fn pointer to buffer to sore the file name
|
||||
* @return FS_RES_OK or any error from fs_res_t enum
|
||||
*/
|
||||
fs_res_t ufs_readdir(void * rddir_p, char * fn)
|
||||
{
|
||||
ufs_read_dir_t * ufs_rddir_p = rddir_p;
|
||||
|
||||
if(ufs_rddir_p->last_ent == NULL) {
|
||||
ufs_rddir_p->last_ent = ll_get_head(&file_ll);
|
||||
} else {
|
||||
ufs_rddir_p->last_ent = ll_get_next(&file_ll, ufs_rddir_p->last_ent);
|
||||
}
|
||||
|
||||
if(ufs_rddir_p->last_ent != NULL) {
|
||||
strcpy(fn, ufs_rddir_p->last_ent->fn_d);
|
||||
} else {
|
||||
fn[0] = '\0';
|
||||
}
|
||||
|
||||
return FS_RES_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the directory reading
|
||||
* @param rddir_p pointer to an initialized 'ufs_read_dir_t' variable
|
||||
* @return FS_RES_OK or any error from fs_res_t enum
|
||||
*/
|
||||
fs_res_t ufs_readdir_close(void * rddir_p)
|
||||
{
|
||||
return FS_RES_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Give the size of a drive
|
||||
* @param total_p pointer to store the total size [kB]
|
||||
* @param free_p pointer to store the free site [kB]
|
||||
* @return FS_RES_OK or any error from 'fs_res_t'
|
||||
*/
|
||||
fs_res_t ufs_free (uint32_t * total_p, uint32_t * free_p)
|
||||
{
|
||||
dm_mon_t mon;
|
||||
|
||||
dm_monitor(&mon);
|
||||
*total_p = DM_MEM_SIZE >> 10; /*Convert bytes to kB*/
|
||||
*free_p = mon.size_free >> 10;
|
||||
|
||||
return FS_RES_OK;
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Gives the ufs_entry from a filename
|
||||
* @param fn filename ('\0' terminated string)
|
||||
* @return pointer to the dynamically allocated entry with 'fn' filename.
|
||||
* NULL if no entry found with that name.
|
||||
*/
|
||||
static ufs_ent_t* ufs_ent_get(const char * fn)
|
||||
{
|
||||
ufs_ent_t* fp;
|
||||
|
||||
LL_READ(file_ll, fp) {
|
||||
if(strcmp(fp->fn_d, fn) == 0) {
|
||||
return fp;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new entry with 'fn' filename
|
||||
* @param fn filename ('\0' terminated string)
|
||||
* @return pointer to the dynamically allocated new entry.
|
||||
* NULL if no space for the entry.
|
||||
*/
|
||||
static ufs_ent_t* ufs_ent_new(const char * fn)
|
||||
{
|
||||
ufs_ent_t* new_ent = NULL;
|
||||
new_ent = ll_ins_head(&file_ll); /*Create a new file*/
|
||||
if(new_ent == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
new_ent->fn_d = dm_alloc(strlen(fn) + 1); /*Save the name*/
|
||||
strcpy(new_ent->fn_d, fn);
|
||||
new_ent->data_d = NULL;
|
||||
new_ent->size = 0;
|
||||
new_ent->oc = 0;
|
||||
new_ent->const_data = 0;
|
||||
|
||||
return new_ent;
|
||||
}
|
||||
|
||||
#endif
|
||||
209
misc/fs/ufs/ufs.h
Normal file
209
misc/fs/ufs/ufs.h
Normal file
@@ -0,0 +1,209 @@
|
||||
/**
|
||||
* @file ufs.h
|
||||
* Implementation of RAM file system which do NOT support directories.
|
||||
* The API is compatible with the fs_int module.
|
||||
*/
|
||||
|
||||
#ifndef UFS_H
|
||||
#define UFS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "misc_conf.h"
|
||||
#if USE_UFS != 0
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "../fsint.h"
|
||||
#include "../../mem/dyn_mem.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
/*Description of a file entry */
|
||||
typedef struct
|
||||
{
|
||||
char * fn_d;
|
||||
void * data_d;
|
||||
uint32_t size; /*Data length in bytes*/
|
||||
uint16_t oc; /*Open Count*/
|
||||
uint8_t const_data :1;
|
||||
}ufs_ent_t;
|
||||
|
||||
/*File descriptor, used to handle opening an entry more times simultaneously
|
||||
Contains unique informations about the specific opening*/
|
||||
typedef struct
|
||||
{
|
||||
ufs_ent_t* ent; /*Pointer to the entry*/
|
||||
uint32_t rwp; /*Read Write Pointer*/
|
||||
uint8_t ar :1; /*1: Access for read is enabled */
|
||||
uint8_t aw :1; /*1: Access for write is enabled */
|
||||
}ufs_file_t;
|
||||
|
||||
/* Read directory descriptor.
|
||||
* It is used to to iterate through the entries in a directory*/
|
||||
typedef struct
|
||||
{
|
||||
ufs_ent_t * last_ent;
|
||||
}ufs_read_dir_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Create a driver for ufs and initialize it.
|
||||
*/
|
||||
void ufs_init(void);
|
||||
|
||||
/**
|
||||
* Give the state of the ufs
|
||||
* @return true if ufs is initialized and can be used else false
|
||||
*/
|
||||
bool ufs_ready(void);
|
||||
|
||||
/**
|
||||
* Open a file in ufs
|
||||
* @param file_p pointer to a ufs_file_t variable
|
||||
* @param fn name of the file. There are no directories so e.g. "myfile.txt"
|
||||
* @param mode element of 'fs_mode_t' enum or its 'OR' connection (e.g. FS_MODE_WR | FS_MODE_RD)
|
||||
* @return FS_RES_OK: no error, the file is opened
|
||||
* any error from fs_res_t enum
|
||||
*/
|
||||
fs_res_t ufs_open (void * file_p, const char * fn, fs_mode_t mode);
|
||||
|
||||
/**
|
||||
* Create a file with a constant data
|
||||
* @param fn name of the file (directories are not supported)
|
||||
* @param const_p pointer to a constant data
|
||||
* @param len length of the data pointed by 'const_p' in bytes
|
||||
* @return FS_RES_OK: no error, the file is read
|
||||
* any error from fs_res_t enum
|
||||
*/
|
||||
fs_res_t ufs_create_const(const char * fn, const void * const_p, uint32_t len);
|
||||
|
||||
/**
|
||||
* Close an opened file
|
||||
* @param file_p pointer to an 'ufs_file_t' variable. (opened with ufs_open)
|
||||
* @return FS_RES_OK: no error, the file is read
|
||||
* any error from fs_res_t enum
|
||||
*/
|
||||
fs_res_t ufs_close (void * file_p);
|
||||
|
||||
/**
|
||||
* Remove a file. The file can not be opened.
|
||||
* @param fn '\0' terminated string
|
||||
* @return FS_RES_OK: no error, the file is removed
|
||||
* FS_RES_DENIED: the file was opened, remove failed
|
||||
*/
|
||||
fs_res_t ufs_remove(const char * fn);
|
||||
|
||||
/**
|
||||
* Read data from an opened file
|
||||
* @param file_p pointer to an 'ufs_file_t' variable. (opened with ufs_open )
|
||||
* @param buf pointer to a memory block where to store the read data
|
||||
* @param btr number of Bytes To Read
|
||||
* @param br the real number of read bytes (Byte Read)
|
||||
* @return FS_RES_OK: no error, the file is read
|
||||
* any error from fs_res_t enum
|
||||
*/
|
||||
fs_res_t ufs_read (void * file_p, void * buf, uint32_t btr, uint32_t * br);
|
||||
|
||||
/**
|
||||
* Write data to an opened file
|
||||
* @param file_p pointer to an 'ufs_file_t' variable. (opened with ufs_open)
|
||||
* @param buf pointer to a memory block which content will be written
|
||||
* @param btw the number Bytes To Write
|
||||
* @param bw The real number of written bytes (Byte Written)
|
||||
* @return FS_RES_OK: no error, the file is read
|
||||
* any error from fs_res_t enum
|
||||
*/
|
||||
fs_res_t ufs_write (void * file_p, const void * buf, uint32_t btw, uint32_t * bw);
|
||||
|
||||
/**
|
||||
* Set the read write pointer. Also expand the file size if necessary.
|
||||
* @param file_p pointer to an 'ufs_file_t' variable. (opened with ufs_open )
|
||||
* @param pos the new position of read write pointer
|
||||
* @return FS_RES_OK: no error, the file is read
|
||||
* any error from fs_res_t enum
|
||||
*/
|
||||
fs_res_t ufs_seek (void * file_p, uint32_t pos);
|
||||
|
||||
/**
|
||||
* Give the position of the read write pointer
|
||||
* @param file_p pointer to an 'ufs_file_t' variable. (opened with ufs_open )
|
||||
* @param pos_p pointer to to store the result
|
||||
* @return FS_RES_OK: no error, the file is read
|
||||
* any error from fs_res_t enum
|
||||
*/
|
||||
fs_res_t ufs_tell (void * file_p, uint32_t * pos_p);
|
||||
|
||||
/**
|
||||
* Truncate the file size to the current position of the read write pointer
|
||||
* @param file_p pointer to an 'ufs_file_t' variable. (opened with ufs_open )
|
||||
* @return FS_RES_OK: no error, the file is read
|
||||
* any error from fs_res_t enum
|
||||
*/
|
||||
fs_res_t ufs_trunc (void * file_p);
|
||||
|
||||
/**
|
||||
* Give the size of the file in bytes
|
||||
* @param file_p file_p pointer to an 'ufs_file_t' variable. (opened with ufs_open )
|
||||
* @param size_p pointer to store the size
|
||||
* @return FS_RES_OK: no error, the file is read
|
||||
* any error from fs_res_t enum
|
||||
*/
|
||||
fs_res_t ufs_size (void * file_p, uint32_t * size_p);
|
||||
|
||||
/**
|
||||
* Initialize a ufs_read_dir_t variable to directory reading
|
||||
* @param rddir_p pointer to a 'ufs_read_dir_t' variable
|
||||
* @param path uFS doesn't support folders so it has to be ""
|
||||
* @return FS_RES_OK or any error from fs_res_t enum
|
||||
*/
|
||||
fs_res_t ufs_readdir_init(void * rddir_p, const char * path);
|
||||
|
||||
/**
|
||||
* Read the next file name
|
||||
* @param rddir_p pointer to an initialized 'ufs_read_dir_t' variable
|
||||
* @param fn pointer to buffer to sore the file name
|
||||
* @return FS_RES_OK or any error from fs_res_t enum
|
||||
*/
|
||||
fs_res_t ufs_readdir(void * rddir_p, char * fn);
|
||||
|
||||
/**
|
||||
* Close the directory reading
|
||||
* @param rddir_p pointer to an initialized 'ufs_read_dir_t' variable
|
||||
* @return FS_RES_OK or any error from fs_res_t enum
|
||||
*/
|
||||
fs_res_t ufs_readdir_close(void * rddir_p);
|
||||
|
||||
/**
|
||||
* Give the size of a drive
|
||||
* @param total_p pointer to store the total size [kB]
|
||||
* @param free_p pointer to store the free site [kB]
|
||||
* @return FS_RES_OK or any error from 'fs_res_t'
|
||||
*/
|
||||
fs_res_t ufs_free (uint32_t * total_p, uint32_t * free_p);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
353
misc/gfx/anim.c
Normal file
353
misc/gfx/anim.c
Normal file
@@ -0,0 +1,353 @@
|
||||
/**
|
||||
* @file anim.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "misc_conf.h"
|
||||
#include "../os/ptask.h"
|
||||
#include "anim.h"
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
|
||||
#if USE_ANIM != 0
|
||||
#include "../math/math_base.h"
|
||||
#include MISC_SYSTICK_INCLUDE
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define ANIM_PATH_LENGTH 129 /*Elements in a path array*/
|
||||
#define ANIM_PATH_START 64 /*In path array a value which corresponds to the start position*/
|
||||
#define ANIM_PATH_END 192 /* ... to the end position. Not required, just for clearance.*/
|
||||
#define ANIM_PATH_NORM_SHIFT 7 /*ANIM_PATH_START - ANIM_PATH_END. Must be 2^N. The exponent goes here. */
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static void anim_task (void * param);
|
||||
static bool anim_ready_handler(anim_t * a);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
static ll_dsc_t anim_ll;
|
||||
static uint32_t last_task_run;
|
||||
static bool anim_del_global_flag = false;
|
||||
|
||||
static anim_path_t anim_path_lin[] =
|
||||
{64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
|
||||
96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127,
|
||||
128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159,
|
||||
160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192};
|
||||
|
||||
static anim_path_t anim_path_step[] =
|
||||
{64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
|
||||
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
|
||||
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
|
||||
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 192,};
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Init. the animation module
|
||||
*/
|
||||
void anim_init(void)
|
||||
{
|
||||
ll_init(&anim_ll, sizeof(anim_t));
|
||||
last_task_run = MISC_SYSTICK_GET();
|
||||
ptask_create(anim_task, ANIM_REFR_PERIOD, PTASK_PRIO_MID, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an animation
|
||||
* @param anim_p an initialized 'anim_t' variable. Not required after call.
|
||||
*/
|
||||
void anim_create(anim_t * anim_p)
|
||||
{
|
||||
/* Do not let two animations for the same 'var' with the same 'fp'*/
|
||||
if(anim_p->fp != NULL) anim_del(anim_p->var, anim_p->fp); /*fp == NULL would delete all animations of var*/
|
||||
|
||||
/*Add the new animation to the animation linked list*/
|
||||
anim_t * new_anim = ll_ins_head(&anim_ll);
|
||||
dm_assert(new_anim);
|
||||
|
||||
/*Initialize the animation descriptor*/
|
||||
anim_p->playback_now = 0;
|
||||
memcpy(new_anim, anim_p, sizeof(anim_t));
|
||||
|
||||
/*Set the start value*/
|
||||
if(new_anim->fp != NULL) new_anim->fp(new_anim->var, new_anim->start);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete an animation for a variable with a given animatior function
|
||||
* @param var pointer to variable
|
||||
* @param fp a function pointer which is animating 'var',
|
||||
* or NULL to delete all animations of 'var'
|
||||
* @return true: at least 1 animation is deleted, false: no animation is deleted
|
||||
*/
|
||||
bool anim_del(void * var, anim_fp_t fp)
|
||||
{
|
||||
bool del = false;
|
||||
anim_t * a;
|
||||
anim_t * a_next;
|
||||
a = ll_get_head(&anim_ll);
|
||||
while(a != NULL) {
|
||||
/*'a' might be deleted, so get the next object while 'a' is valid*/
|
||||
a_next = ll_get_next(&anim_ll, a);
|
||||
|
||||
if(a->var == var && (a->fp == fp || fp == NULL)) {
|
||||
ll_rem(&anim_ll, a);
|
||||
dm_free(a);
|
||||
del = true;
|
||||
anim_del_global_flag = true;
|
||||
}
|
||||
|
||||
a = a_next;
|
||||
}
|
||||
|
||||
return del;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the time of an animation with a given speed and the start and end values
|
||||
* @param speed speed of animation in unit/sec
|
||||
* @param start start value of the animation
|
||||
* @param end end value of the animation
|
||||
* @return the required time [ms] for the animation with the given parameters
|
||||
*/
|
||||
uint16_t anim_speed_to_time(uint16_t speed, int32_t start, int32_t end)
|
||||
{
|
||||
int32_t d = MATH_ABS((int32_t) start - end);
|
||||
uint16_t time = (int32_t)((int32_t)(d * 1000) / speed);
|
||||
|
||||
if(time == 0) {
|
||||
time++;
|
||||
}
|
||||
|
||||
return time;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a predefine animation path
|
||||
* @param name name of the path from 'anim_path_name_t'
|
||||
* @return pointer to the path array
|
||||
*/
|
||||
anim_path_t * anim_get_path(anim_path_name_t name)
|
||||
{
|
||||
switch (name) {
|
||||
case ANIM_PATH_LIN:
|
||||
return anim_path_lin;
|
||||
break;
|
||||
case ANIM_PATH_STEP:
|
||||
return anim_path_step;
|
||||
break;
|
||||
default:
|
||||
return NULL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Periodically handle the animations.
|
||||
* @param param unused
|
||||
*/
|
||||
static void anim_task (void * param)
|
||||
{
|
||||
volatile uint32_t elaps;
|
||||
elaps = MISC_SYSTICK_ELAPS(last_task_run);
|
||||
|
||||
anim_t * a;
|
||||
anim_t * a_next;
|
||||
a = ll_get_head(&anim_ll);
|
||||
while(a != NULL) {
|
||||
/*'a' might be deleted, so get the next object while 'a' is valid*/
|
||||
a_next = ll_get_next(&anim_ll, a);
|
||||
|
||||
a->act_time += elaps;
|
||||
if(a->act_time >= 0) {
|
||||
if(a->act_time > a->time) a->act_time = a->time;
|
||||
|
||||
/* Get the index of the path array based on the elapsed time*/
|
||||
uint8_t path_i;
|
||||
if(a->time == a->act_time) {
|
||||
path_i = ANIM_PATH_LENGTH - 1; /*Use the last value id the time fully elapsed*/
|
||||
} else {
|
||||
path_i = a->act_time * (ANIM_PATH_LENGTH - 1) / a->time;
|
||||
}
|
||||
/* Get the new value which will be proportional to the current element of 'path_p'
|
||||
* and the 'start' and 'end' values*/
|
||||
int32_t new_val;
|
||||
new_val = (int32_t)(a->path[path_i] - ANIM_PATH_START) * (a->end - a->start);
|
||||
new_val = new_val >> ANIM_PATH_NORM_SHIFT;
|
||||
new_val += a->start;
|
||||
|
||||
if(a->fp != NULL) a->fp(a->var, new_val); /*Apply the calculated value*/
|
||||
|
||||
/*If the time is elapsed the animation is ready*/
|
||||
if(a->act_time >= a->time) {
|
||||
bool invalid;
|
||||
invalid = anim_ready_handler(a);
|
||||
if(invalid != false) {
|
||||
a_next = ll_get_head(&anim_ll); /*a_next might be invalid if animation delete occurred*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
a = a_next;
|
||||
}
|
||||
|
||||
last_task_run = MISC_SYSTICK_GET();
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when an animation is ready to do the necessary thinks
|
||||
* e.g. repeat, play back, delete etc.
|
||||
* @param a pointer to an animation descriptor
|
||||
* @return true: animation delete occurred
|
||||
* */
|
||||
static bool anim_ready_handler(anim_t * a)
|
||||
{
|
||||
bool invalid = false;
|
||||
|
||||
/*Delete the animation if
|
||||
* - no repeat and no play back (simple one shot animation)
|
||||
* - no repeat, play back is enabled and play back is ready */
|
||||
if((a->repeat == 0 && a->playback == 0) ||
|
||||
(a->repeat == 0 && a->playback == 1 && a->playback_now == 1)) {
|
||||
void (*cb) (void *) = a->end_cb;
|
||||
void * p = a->var;
|
||||
ll_rem(&anim_ll, a);
|
||||
dm_free(a);
|
||||
|
||||
/*Call the callback function at the end*/
|
||||
/* Check if an animation is deleted in the cb function
|
||||
* if yes then the caller function has to know this*/
|
||||
anim_del_global_flag = false;
|
||||
if(cb != NULL) cb(p);
|
||||
invalid = anim_del_global_flag;
|
||||
}
|
||||
/*If the animation is not deleted then restart it*/
|
||||
else {
|
||||
a->act_time = - a->repeat_pause; /*Restart the animation*/
|
||||
/*Swap the start and end values in play back mode*/
|
||||
if(a->playback != 0) {
|
||||
/*If now turning back use the 'playback_pause*/
|
||||
if(a->playback_now == 0) a->act_time = - a->playback_pause;
|
||||
|
||||
/*Toggle the play back state*/
|
||||
a->playback_now = a->playback_now == 0 ? 1: 0;
|
||||
/*Swap the start and end values*/
|
||||
int32_t tmp;
|
||||
tmp = a->start;
|
||||
a->start = a->end;
|
||||
a->end = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
return invalid;
|
||||
}
|
||||
|
||||
/*For compatibility add dummy functions*/
|
||||
#else
|
||||
|
||||
#if USE_PTASK != 0
|
||||
static void anim_dummy_handler(void * anim_dm);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Create an animation. Immediately set to end value
|
||||
* @param anim_p an initialized 'anim_t' variable. Not required after call.
|
||||
*/
|
||||
void anim_create(anim_t * anim_p)
|
||||
{
|
||||
|
||||
/*If no delay simply set the end value end call the callback */
|
||||
if(anim_p->act_time == 0) {
|
||||
if(anim_p->fp != NULL) anim_p->fp(anim_p->var, anim_p->end);
|
||||
if(anim_p->end_cb != NULL) anim_p->end_cb(anim_p->var);
|
||||
}
|
||||
/*With delay set the start value and set a one shot ptask to set end value and call the callback*/
|
||||
else {
|
||||
#if USE_DYN_MEM != 0 && USE_PTASK != 0
|
||||
if(anim_p->fp != NULL) anim_p->fp(anim_p->var, anim_p->start);
|
||||
void * anim_dm = dm_alloc(sizeof(anim_t));
|
||||
memcpy(anim_dm, anim_p, sizeof(anim_t));
|
||||
ptask_t * ptask = ptask_create(anim_dummy_handler, -anim_p->act_time, PTASK_PRIO_LOW, anim_dm);
|
||||
ptask_once(ptask);
|
||||
#else
|
||||
if(anim_p->fp != NULL) anim_p->fp(anim_p->var, anim_p->end);
|
||||
if(anim_p->end_cb != NULL) anim_p->end_cb(anim_p->var);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete an animation for a variable with a given animatior function (Now do nothing)
|
||||
* @param var pointer to variable
|
||||
* @param fp a function pointer which is animating 'var',
|
||||
* or NULL to ignore it and delete all animation with 'var
|
||||
* @return true: at least 1 animation is deleted, false: no animation is deleted
|
||||
*/
|
||||
bool anim_del(void * var, anim_fp_t fp)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the time of an animation with a given speed and the start and end values (Give dummy value)
|
||||
* @param speed speed of animation in unit/sec
|
||||
* @param start start value of the animation
|
||||
* @param end end value of the animation
|
||||
* @return the required time [ms] for the animation with the given parameters
|
||||
*/
|
||||
uint16_t anim_speed_to_time(uint16_t speed, int32_t start, int32_t end)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a predefine animation path (Give NULL)
|
||||
* @param name name of the path from 'anim_path_name_t'
|
||||
* @return pointer to the path array
|
||||
*/
|
||||
anim_path_t * anim_get_path(anim_path_name_t name)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#if USE_PTASK != 0
|
||||
|
||||
/**
|
||||
* A One Shot ptask to handle end callbacks with delay
|
||||
* @param anim_dm pointer to temporal dynamically allocated animation
|
||||
*/
|
||||
static void anim_dummy_handler(void * anim_dm)
|
||||
{
|
||||
anim_t * anim = anim_dm;
|
||||
|
||||
if(anim->fp != NULL) anim->fp(anim->var, anim->end);
|
||||
if(anim->end_cb != NULL) anim->end_cb(anim->var);
|
||||
|
||||
dm_free(anim_dm);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*USE_ANIM*/
|
||||
|
||||
123
misc/gfx/anim.h
Normal file
123
misc/gfx/anim.h
Normal file
@@ -0,0 +1,123 @@
|
||||
/**
|
||||
* @file anim.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ANIM_H
|
||||
#define ANIM_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "misc_conf.h"
|
||||
/*For compatibility always include this header*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
typedef enum
|
||||
{
|
||||
ANIM_PATH_LIN,
|
||||
ANIM_PATH_STEP,
|
||||
}anim_path_name_t;
|
||||
|
||||
typedef uint8_t anim_path_t;
|
||||
|
||||
typedef void (*anim_fp_t)(void *, int32_t);
|
||||
typedef void (*anim_cb_t)(void *);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
void * var; /*Variable to animate*/
|
||||
anim_fp_t fp; /*Animator function*/
|
||||
anim_cb_t end_cb; /*Call it when the animation is ready*/
|
||||
anim_path_t * path; /*An array with the steps of animations*/
|
||||
int32_t start; /*Start value*/
|
||||
int32_t end; /*End value*/
|
||||
int16_t time; /*Animation time in ms*/
|
||||
int16_t act_time; /*Current time in animation. Set to negative to make delay.*/
|
||||
uint16_t playback_pause; /*Wait before play back*/
|
||||
uint16_t repeat_pause; /*Wait before repeat*/
|
||||
uint8_t playback :1; /*When the animation is ready play it back*/
|
||||
uint8_t repeat :1; /*Repeat the animation infinitely*/
|
||||
/*Animation system use these - user shouldn't set*/
|
||||
uint8_t playback_now :1; /*Play back is in progress*/
|
||||
}anim_t;
|
||||
|
||||
/*Example initialization
|
||||
anim_t a;
|
||||
a.var = obj;
|
||||
a.start = lv_obj_get_height(obj);
|
||||
a.end = new_height;
|
||||
a.fp = (anim_fp_t)lv_obj_set_height;
|
||||
a.path = anim_get_path(ANIM_PATH_LIN);
|
||||
a.end_cb = NULL;
|
||||
a.act_time = 0;
|
||||
a.time = 200;
|
||||
a.playback = 0;
|
||||
a.playback_pause = 0;
|
||||
a.repeat = 0;
|
||||
a.repeat_pause = 0;
|
||||
*/
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Init. the animation module
|
||||
*/
|
||||
void anim_init(void);
|
||||
|
||||
/**
|
||||
* Create an animation
|
||||
* @param anim_p an initialized 'anim_t' variable. Not required after call.
|
||||
*/
|
||||
void anim_create(anim_t * anim_p);
|
||||
|
||||
/**
|
||||
* Delete an animation for a variable with a given animatior function
|
||||
* @param var pointer to variable
|
||||
* @param fp a function pointer which is animating 'var',
|
||||
* or NULL to ignore it and delete all animation with 'var
|
||||
* @return true: at least 1 animation is deleted, false: no animation is deleted
|
||||
*/
|
||||
bool anim_del(void * var, anim_fp_t fp);
|
||||
|
||||
/**
|
||||
* Calculate the time of an animation with a given speed and the start and end values
|
||||
* @param speed speed of animation in unit/sec
|
||||
* @param start start value of the animation
|
||||
* @param end end value of the animation
|
||||
* @return the required time [ms] for the animation with the given parameters
|
||||
*/
|
||||
uint16_t anim_speed_to_time(uint16_t speed, int32_t start, int32_t end);
|
||||
|
||||
/**
|
||||
* Get a predefine animation path
|
||||
* @param name name of the path from 'anim_path_name_t'
|
||||
* @return pointer to the path array
|
||||
*/
|
||||
anim_path_t * anim_get_path(anim_path_name_t name);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif
|
||||
238
misc/gfx/area.c
Normal file
238
misc/gfx/area.c
Normal file
@@ -0,0 +1,238 @@
|
||||
/**
|
||||
* @file 2d.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "misc_conf.h"
|
||||
#if USE_AREA != 0
|
||||
|
||||
#include "area.h"
|
||||
#include "../math/math_base.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Initialize an area
|
||||
* @param area_p pointer to an area
|
||||
* @param x1 left coordinate of the area
|
||||
* @param y1 top coordinate of the area
|
||||
* @param x2 right coordinate of the area
|
||||
* @param y2 bottom coordinate of the area
|
||||
*/
|
||||
void area_set(area_t * area_p, cord_t x1, cord_t y1, cord_t x2, cord_t y2)
|
||||
{
|
||||
area_p->x1 = x1;
|
||||
area_p->y1 = y1;
|
||||
area_p->x2 = x2;
|
||||
area_p->y2 = y2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the width of an area
|
||||
* @param area_p pointer to an area
|
||||
* @param w the new width of the area (w == 1 makes x1 == x2)
|
||||
*/
|
||||
void area_set_width(area_t * area_p, cord_t w)
|
||||
{
|
||||
area_p->x2 = area_p->x1 + w - 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the height of an area
|
||||
* @param area_p pointer to an area
|
||||
* @param h the new height of the area (h == 1 makes y1 == y2)
|
||||
*/
|
||||
void area_set_height(area_t * area_p, cord_t h)
|
||||
{
|
||||
area_p->y2 = area_p->y1 + h - 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the position of an area (width and height will be kept)
|
||||
* @param area_p pointer to an area
|
||||
* @param x the new x coordinate of the area
|
||||
* @param y the new y coordinate of the area
|
||||
*/
|
||||
void area_set_pos(area_t * area_p, cord_t x, cord_t y)
|
||||
{
|
||||
cord_t w = area_get_width(area_p);
|
||||
cord_t h = area_get_height(area_p);
|
||||
area_p->x1 = x;
|
||||
area_p->y1 = y;
|
||||
area_set_width(area_p, w);
|
||||
area_set_height(area_p, h);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return with area of an area (x * y)
|
||||
* @param area_p pointer to an area
|
||||
* @return size of area
|
||||
*/
|
||||
uint32_t area_get_size(const area_t * area_p)
|
||||
{
|
||||
uint32_t size;
|
||||
|
||||
size = (uint32_t)(area_p->x2 - area_p->x1 + 1) *
|
||||
(area_p->y2 - area_p->y1 + 1);
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the common parts of two areas
|
||||
* @param res_p pointer to an area, the result will be stored her
|
||||
* @param a1_p pointer to the first area
|
||||
* @param a2_p pointer to the second area
|
||||
* @return false: the two area has NO common parts, res_p is invalid
|
||||
*/
|
||||
bool area_union(area_t * res_p, const area_t * a1_p, const area_t * a2_p)
|
||||
{
|
||||
/* Get the smaller area from 'a1_p' and 'a2_p' */
|
||||
res_p->x1 = MATH_MAX(a1_p->x1, a2_p->x1);
|
||||
res_p->y1 = MATH_MAX(a1_p->y1, a2_p->y1);
|
||||
res_p->x2 = MATH_MIN(a1_p->x2, a2_p->x2);
|
||||
res_p->y2 = MATH_MIN(a1_p->y2, a2_p->y2);
|
||||
|
||||
/*If x1 or y1 greater then x2 or y2 then the areas union is empty*/
|
||||
bool union_ok = true;
|
||||
if((res_p->x1 > res_p->x2) ||
|
||||
(res_p->y1 > res_p->y2))
|
||||
{
|
||||
union_ok = false;
|
||||
}
|
||||
|
||||
return union_ok;
|
||||
}
|
||||
/**
|
||||
* Join two areas into a third which involves the other two
|
||||
* @param res_p pointer to an area, the result will be stored here
|
||||
* @param a1_p pointer to the first area
|
||||
* @param a2_p pointer to the second area
|
||||
*/
|
||||
void area_join(area_t * a_res_p, const area_t * a1_p, const area_t * a2_p)
|
||||
{
|
||||
a_res_p->x1 = MATH_MIN(a1_p->x1, a2_p->x1);
|
||||
a_res_p->y1 = MATH_MIN(a1_p->y1, a2_p->y1);
|
||||
a_res_p->x2 = MATH_MAX(a1_p->x2, a2_p->x2);
|
||||
a_res_p->y2 = MATH_MAX(a1_p->y2, a2_p->y2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a point is on an area
|
||||
* @param a_p pointer to an area
|
||||
* @param p_p pointer to a point
|
||||
* @return false:the point is out of the area
|
||||
*/
|
||||
bool area_is_point_on(const area_t * a_p, const point_t * p_p)
|
||||
{
|
||||
bool is_on = false;
|
||||
|
||||
if((p_p->x >= a_p->x1 && p_p->x <= a_p->x2) &&
|
||||
((p_p->y >= a_p->y1 && p_p->y <= a_p->y2)))
|
||||
{
|
||||
is_on = true;
|
||||
}
|
||||
|
||||
return is_on;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if two area has common parts
|
||||
* @param a1_p pointer to an area.
|
||||
* @param a2_p pointer to an other area
|
||||
* @return false: a1_p and a2_p has no common parts
|
||||
*/
|
||||
bool area_is_on(const area_t * a1_p, const area_t * a2_p)
|
||||
{
|
||||
/*Two area are on each other if... */
|
||||
|
||||
point_t p;
|
||||
/*a2 left-top corner is on a1*/
|
||||
p.x = a2_p->x1;
|
||||
p.y = a2_p->y1;
|
||||
if(area_is_point_on(a1_p, &p)) return true;
|
||||
|
||||
/*a2 right-top corner is on a1*/
|
||||
p.x = a2_p->x1;
|
||||
p.y = a2_p->y1;
|
||||
if(area_is_point_on(a1_p, &p)) return true;
|
||||
|
||||
/*a2 left-bottom corner is on a1*/
|
||||
p.x = a2_p->x1;
|
||||
p.y = a2_p->y2;
|
||||
if(area_is_point_on(a1_p, &p)) return true;
|
||||
|
||||
/*a2 right-bottom corner is on a1*/
|
||||
p.x = a2_p->x2;
|
||||
p.y = a2_p->y2;
|
||||
if(area_is_point_on(a1_p, &p)) return true;
|
||||
|
||||
/*a2 is horizontally bigger then a1 and covers it*/
|
||||
if((a2_p->x1 <= a1_p->x1 && a2_p->x2 >= a1_p->x2) && /*a2 hor. cover a1?*/
|
||||
((a2_p->y1 <= a1_p->y1 && a2_p->y1 >= a1_p->y2) || /*upper edge is on a1?*/
|
||||
(a2_p->y2 <= a1_p->y1 && a2_p->y2 >= a1_p->y2) ||/* or lower edge is on a1?*/
|
||||
(a2_p->y1 <= a1_p->y1 && a2_p->y2 >= a1_p->y2))) /*or a2 vert bigger then a1*/
|
||||
return true;
|
||||
|
||||
/*a2 is vertically bigger then a1 and covers it*/
|
||||
if((a2_p->y1 <= a1_p->y1 && a2_p->y2 >= a1_p->y2) && /*a2 vert. cover a1?*/
|
||||
((a2_p->x1 <= a1_p->x1 && a2_p->x1 >= a1_p->x2) || /*left edge is on a1?*/
|
||||
(a2_p->x2 <= a1_p->x1 && a2_p->x2 >= a1_p->x2) ||/* or right edge is on a1?*/
|
||||
(a2_p->x1 <= a1_p->x1 && a2_p->x2 >= a1_p->x2))) /*or a2 hor. bigger then a1*/
|
||||
return true;
|
||||
|
||||
/*Else no cover*/
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if an area is fully on an other
|
||||
* @param ain_p pointer to an area which could be on aholder_p
|
||||
* @param aholder pointer to an area which could involve ain_p
|
||||
* @return
|
||||
*/
|
||||
bool area_is_in(const area_t * ain_p, const area_t * aholder_p)
|
||||
{
|
||||
bool is_in = false;
|
||||
|
||||
if(ain_p->x1 >= aholder_p->x1 &&
|
||||
ain_p->y1 >= aholder_p->y1 &&
|
||||
ain_p->x2 <= aholder_p->x2 &&
|
||||
ain_p->y2 <= aholder_p->y2)
|
||||
{
|
||||
is_in = true;
|
||||
}
|
||||
|
||||
return is_in;
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
#endif /*USE_AREA*/
|
||||
174
misc/gfx/area.h
Normal file
174
misc/gfx/area.h
Normal file
@@ -0,0 +1,174 @@
|
||||
/**
|
||||
* @file area.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef AREA_H
|
||||
#define AREA_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "misc_conf.h"
|
||||
#if USE_AREA != 0
|
||||
|
||||
#include <string.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define CORD_MAX (16383) /*To avoid overflow don't let the max [-32,32k] range */
|
||||
#define CORD_MIN (-16384)
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
typedef int16_t cord_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
cord_t x;
|
||||
cord_t y;
|
||||
}point_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
cord_t x1;
|
||||
cord_t y1;
|
||||
cord_t x2;
|
||||
cord_t y2;
|
||||
}area_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Initialize an area
|
||||
* @param area_p pointer to an area
|
||||
* @param x1 left coordinate of the area
|
||||
* @param y1 top coordinate of the area
|
||||
* @param x2 right coordinate of the area
|
||||
* @param y2 bottom coordinate of the area
|
||||
*/
|
||||
void area_set(area_t * area_p, cord_t x1, cord_t y1, cord_t x2, cord_t y2);
|
||||
|
||||
/**
|
||||
* Copy an area
|
||||
* @param dest pointer to the destination area
|
||||
* @param src pointer to the source area
|
||||
*/
|
||||
static void inline area_cpy(area_t * dest, const area_t * src)
|
||||
{
|
||||
memcpy(dest, src, sizeof(area_t));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the width of an area
|
||||
* @param area_p pointer to an area
|
||||
* @return the width of the area (if x1 == x2 -> width = 1)
|
||||
*/
|
||||
static inline cord_t area_get_width(const area_t * area_p)
|
||||
{
|
||||
return area_p->x2 - area_p->x1 + 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the height of an area
|
||||
* @param area_p pointer to an area
|
||||
* @return the height of the area (if y1 == y2 -> height = 1)
|
||||
*/
|
||||
static inline cord_t area_get_height(const area_t * area_p)
|
||||
{
|
||||
return area_p->y2 - area_p->y1 + 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the width of an area
|
||||
* @param area_p pointer to an area
|
||||
* @param w the new width of the area (w == 1 makes x1 == x2)
|
||||
*/
|
||||
void area_set_width(area_t * area_p, cord_t w);
|
||||
|
||||
/**
|
||||
* Set the height of an area
|
||||
* @param area_p pointer to an area
|
||||
* @param h the new height of the area (h == 1 makes y1 == y2)
|
||||
*/
|
||||
void area_set_height(area_t * area_p, cord_t h);
|
||||
|
||||
/**
|
||||
* Set the position of an area (width and height will be kept)
|
||||
* @param area_p pointer to an area
|
||||
* @param x the new x coordinate of the area
|
||||
* @param y the new y coordinate of the area
|
||||
*/
|
||||
void area_set_pos(area_t * area_p, cord_t x, cord_t y);
|
||||
|
||||
/**
|
||||
* Return with area of an area (x * y)
|
||||
* @param area_p pointer to an area
|
||||
* @return size of area
|
||||
*/
|
||||
uint32_t area_get_size(const area_t * area_p);
|
||||
|
||||
/**
|
||||
* Get the common parts of two areas
|
||||
* @param res_p pointer to an area, the result will be stored her
|
||||
* @param a1_p pointer to the first area
|
||||
* @param a2_p pointer to the second area
|
||||
* @return false: the two area has NO common parts, res_p is invalid
|
||||
*/
|
||||
bool area_union(area_t * res_p, const area_t * a1_p, const area_t * a2_p);
|
||||
|
||||
/**
|
||||
* Join two areas into a third which involves the other two
|
||||
* @param res_p pointer to an area, the result will be stored here
|
||||
* @param a1_p pointer to the first area
|
||||
* @param a2_p pointer to the second area
|
||||
*/
|
||||
void area_join(area_t * a_res_p, const area_t * a1_p, const area_t * a2_p);
|
||||
|
||||
/**
|
||||
* Check if a point is on an area
|
||||
* @param a_p pointer to an area
|
||||
* @param p_p pointer to a point
|
||||
* @return false:the point is out of the area
|
||||
*/
|
||||
bool area_is_point_on(const area_t * a_p, const point_t * p_p);
|
||||
|
||||
/**
|
||||
* Check if two area has common parts
|
||||
* @param a1_p pointer to an area.
|
||||
* @param a2_p pointer to an other area
|
||||
* @return false: a1_p and a2_p has no common parts
|
||||
*/
|
||||
bool area_is_on(const area_t * a1_p, const area_t * a2_p);
|
||||
|
||||
/**
|
||||
* Check if an area is fully on an other
|
||||
* @param ain_p pointer to an area which could be on aholder_p
|
||||
* @param aholder pointer to an area which could involve ain_p
|
||||
* @return
|
||||
*/
|
||||
bool area_is_in(const area_t * ain_p, const area_t * aholder_p);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif /*USE_AREA*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
84
misc/gfx/circ.c
Normal file
84
misc/gfx/circ.c
Normal file
@@ -0,0 +1,84 @@
|
||||
/**
|
||||
* @file circ.c
|
||||
* Circle drawing algorithm (with Bresenham)
|
||||
* Only a 1/8 circle is calculated. Use CIRC_OCT1_X, CIRC_OCT1_Y macros to get
|
||||
* the other octets.
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "misc_conf.h"
|
||||
#if USE_CIRC != 0
|
||||
|
||||
#include "area.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Initialize the circle drawing
|
||||
* @param c pointer to a point. The coordinates will be calculated here
|
||||
* @param tmp point to a variable. It will store temporary data
|
||||
* @param radius radius of the circle
|
||||
*/
|
||||
void circ_init(point_t * c, cord_t * tmp, cord_t radius)
|
||||
{
|
||||
c->x = radius;
|
||||
c->y = 0;
|
||||
*tmp = 1 - radius;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the circle drawing is ready or not
|
||||
* @param c same as in circ_init
|
||||
* @return true if the circle is not ready yet
|
||||
*/
|
||||
bool circ_cont(point_t * c)
|
||||
{
|
||||
return c->y <= c->x ? true : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the next point from the circle
|
||||
* @param c same as in circ_init. The next point stored here.
|
||||
* @param tmp same as in circ_init.
|
||||
*/
|
||||
void circ_next(point_t * c, cord_t * tmp)
|
||||
{
|
||||
c->y++;
|
||||
|
||||
if (*tmp <= 0) {
|
||||
(*tmp) += 2 * c->y + 1; // Change in decision criterion for y -> y+1
|
||||
} else {
|
||||
c->x--;
|
||||
(*tmp) += 2 * (c->y - c->x) + 1; // Change for y -> y+1, x -> x-1
|
||||
}
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
#endif /*USE_CIRC*/
|
||||
|
||||
84
misc/gfx/circ.h
Normal file
84
misc/gfx/circ.h
Normal file
@@ -0,0 +1,84 @@
|
||||
/**
|
||||
* @file circ.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CIRC_H
|
||||
#define CIRC_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "misc_conf.h"
|
||||
#if USE_CIRC != 0
|
||||
|
||||
#include "area.h"
|
||||
#include <stddef.h>
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define CIRC_OCT1_X(p) (p.x)
|
||||
#define CIRC_OCT1_Y(p) (p.y)
|
||||
#define CIRC_OCT2_X(p) (p.y)
|
||||
#define CIRC_OCT2_Y(p) (p.x)
|
||||
#define CIRC_OCT3_X(p) (-p.y)
|
||||
#define CIRC_OCT3_Y(p) (p.x)
|
||||
#define CIRC_OCT4_X(p) (-p.x)
|
||||
#define CIRC_OCT4_Y(p) (p.y)
|
||||
#define CIRC_OCT5_X(p) (-p.x)
|
||||
#define CIRC_OCT5_Y(p) (-p.y)
|
||||
#define CIRC_OCT6_X(p) (-p.y)
|
||||
#define CIRC_OCT6_Y(p) (-p.x)
|
||||
#define CIRC_OCT7_X(p) (p.y)
|
||||
#define CIRC_OCT7_Y(p) (-p.x)
|
||||
#define CIRC_OCT8_X(p) (p.x)
|
||||
#define CIRC_OCT8_Y(p) (-p.y)
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Initialize the circle drawing
|
||||
* @param c pointer to a point. The coordinates will be calculated here
|
||||
* @param tmp point to a variable. It will store temporary data
|
||||
* @param radius radius of the circle
|
||||
*/
|
||||
void circ_init(point_t * c, cord_t * tmp, cord_t radius);
|
||||
|
||||
/**
|
||||
* Test the circle drawing is ready or not
|
||||
* @param c same as in circ_init
|
||||
* @return true if the circle is not ready yet
|
||||
*/
|
||||
bool circ_cont(point_t * c);
|
||||
|
||||
/**
|
||||
* Get the next point from the circle
|
||||
* @param c same as in circ_init. The next point stored here.
|
||||
* @param tmp same as in circ_init.
|
||||
*/
|
||||
void circ_next(point_t * c, cord_t * tmp);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif /*USE_CIRC*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
138
misc/gfx/color.c
Normal file
138
misc/gfx/color.c
Normal file
@@ -0,0 +1,138 @@
|
||||
/**
|
||||
* @file color.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "color.h"
|
||||
#if USE_COLOR != 0
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Convert a HSV color to RGB
|
||||
* @param h hue [0..359]
|
||||
* @param s saturation [0..100]
|
||||
* @param v value [0..100]
|
||||
* @return the given RGB color in RGB (with COLOR_DEPTH depth)
|
||||
*/
|
||||
color_t color_hsv_to_rgb(uint16_t h, uint8_t s, uint8_t v)
|
||||
{
|
||||
h = (uint32_t)((uint32_t)h * 255) / 360;
|
||||
s = (uint16_t)((uint16_t)s * 255) / 100;
|
||||
v = (uint16_t)((uint16_t)v * 255) / 100;
|
||||
|
||||
uint8_t r, g, b;
|
||||
|
||||
uint8_t region, remainder, p, q, t;
|
||||
|
||||
if (s == 0)
|
||||
{
|
||||
r = v;
|
||||
g = v;
|
||||
b = v;
|
||||
return COLOR_MAKE(v, v, v);
|
||||
}
|
||||
|
||||
region = h / 43;
|
||||
remainder = (h - (region * 43)) * 6;
|
||||
|
||||
p = (v * (255 - s)) >> 8;
|
||||
q = (v * (255 - ((s * remainder) >> 8))) >> 8;
|
||||
t = (v * (255 - ((s * (255 - remainder)) >> 8))) >> 8;
|
||||
|
||||
switch (region)
|
||||
{
|
||||
case 0:
|
||||
r = v; g = t; b = p;
|
||||
break;
|
||||
case 1:
|
||||
r = q; g = v; b = p;
|
||||
break;
|
||||
case 2:
|
||||
r = p; g = v; b = t;
|
||||
break;
|
||||
case 3:
|
||||
r = p; g = q; b = v;
|
||||
break;
|
||||
case 4:
|
||||
r = t; g = p; b = v;
|
||||
break;
|
||||
default:
|
||||
r = v; g = p; b = q;
|
||||
break;
|
||||
}
|
||||
|
||||
color_t result = COLOR_MAKE(r, g, b);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an RGB color to HSV
|
||||
* @param r red
|
||||
* @param g green
|
||||
* @param b blue
|
||||
* @return the given RGB color n HSV
|
||||
*/
|
||||
color_hsv_t color_rgb_to_hsv(uint8_t r, uint8_t g, uint8_t b)
|
||||
{
|
||||
color_hsv_t hsv;
|
||||
uint8_t rgbMin, rgbMax;
|
||||
|
||||
rgbMin = r < g ? (r < b ? r : b) : (g < b ? g : b);
|
||||
rgbMax = r > g ? (r > b ? r : b) : (g > b ? g : b);
|
||||
|
||||
hsv.v = rgbMax;
|
||||
if (hsv.v == 0)
|
||||
{
|
||||
hsv.h = 0;
|
||||
hsv.s = 0;
|
||||
return hsv;
|
||||
}
|
||||
|
||||
hsv.s = 255 * (long)(rgbMax - rgbMin) / hsv.v;
|
||||
if (hsv.s == 0)
|
||||
{
|
||||
hsv.h = 0;
|
||||
return hsv;
|
||||
}
|
||||
|
||||
if (rgbMax == r)
|
||||
hsv.h = 0 + 43 * (g - b) / (rgbMax - rgbMin);
|
||||
else if (rgbMax == g)
|
||||
hsv.h = 85 + 43 * (b - r) / (rgbMax - rgbMin);
|
||||
else
|
||||
hsv.h = 171 + 43 * (r - g) / (rgbMax - rgbMin);
|
||||
|
||||
return hsv;
|
||||
}
|
||||
|
||||
#endif /*USE_COLOR*/
|
||||
314
misc/gfx/color.h
Normal file
314
misc/gfx/color.h
Normal file
@@ -0,0 +1,314 @@
|
||||
/**
|
||||
* @file color.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef COLOR_H
|
||||
#define COLOR_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "misc_conf.h"
|
||||
#if USE_COLOR != 0
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define COLOR_BLACK COLOR_MAKE(0x00,0x00,0x00)
|
||||
#define COLOR_WHITE COLOR_MAKE(0xFF,0xFF,0xFF)
|
||||
#define COLOR_RED COLOR_MAKE(0xFF,0x00,0x00)
|
||||
#define COLOR_LIME COLOR_MAKE(0x00,0xFF,0x00)
|
||||
#define COLOR_BLUE COLOR_MAKE(0x00,0x00,0xFF)
|
||||
#define COLOR_YELLOW COLOR_MAKE(0xFF,0xFF,0x00)
|
||||
#define COLOR_CYAN COLOR_MAKE(0x00,0xFF,0xFF)
|
||||
#define COLOR_AQUA COLOR_CYAN
|
||||
#define COLOR_MAGENTA COLOR_MAKE(0xFF,0x00,0xFF)
|
||||
#define COLOR_SILVER COLOR_MAKE(0xC0,0xC0,0xC0)
|
||||
#define COLOR_GRAY COLOR_MAKE(0x80,0x80,0x80)
|
||||
#define COLOR_MARRON COLOR_MAKE(0x80,0x00,0x00)
|
||||
#define COLOR_OLIVE COLOR_MAKE(0x80,0x80,0x00)
|
||||
#define COLOR_GREEN COLOR_MAKE(0x00,0x80,0x00)
|
||||
#define COLOR_PURPLE COLOR_MAKE(0x80,0x00,0x80)
|
||||
#define COLOR_TEAL COLOR_MAKE(0x00,0x80,0x80)
|
||||
#define COLOR_NAVY COLOR_MAKE(0x00,0x00,0x80)
|
||||
#define COLOR_ORANGE COLOR_MAKE(0xFF,0xA5,0x00)
|
||||
|
||||
#define OPA_TRANSP 0
|
||||
#define OPA_0 0
|
||||
#define OPA_10 25
|
||||
#define OPA_20 51
|
||||
#define OPA_30 76
|
||||
#define OPA_40 102
|
||||
#define OPA_50 127
|
||||
#define OPA_60 153
|
||||
#define OPA_70 178
|
||||
#define OPA_80 204
|
||||
#define OPA_90 229
|
||||
#define OPA_100 256
|
||||
#define OPA_COVER 256
|
||||
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
typedef union
|
||||
{
|
||||
uint8_t blue :1;
|
||||
uint8_t green :1;
|
||||
uint8_t red :1;
|
||||
uint8_t full :1;
|
||||
}color1_t;
|
||||
|
||||
typedef union
|
||||
{
|
||||
struct
|
||||
{
|
||||
uint8_t blue :2;
|
||||
uint8_t green :3;
|
||||
uint8_t red :3;
|
||||
};
|
||||
uint8_t full;
|
||||
}color8_t;
|
||||
|
||||
typedef union
|
||||
{
|
||||
struct
|
||||
{
|
||||
uint16_t blue :5;
|
||||
uint16_t green :6;
|
||||
uint16_t red :5;
|
||||
};
|
||||
uint16_t full;
|
||||
}color16_t;
|
||||
|
||||
typedef union
|
||||
{
|
||||
struct
|
||||
{
|
||||
uint8_t blue;
|
||||
uint8_t green;
|
||||
uint8_t red;
|
||||
};
|
||||
uint32_t full;
|
||||
}color24_t;
|
||||
|
||||
#if COLOR_DEPTH == 1
|
||||
typedef uint8_t color_int_t;
|
||||
typedef color1_t color_t;
|
||||
#elif COLOR_DEPTH == 8
|
||||
typedef uint8_t color_int_t;
|
||||
typedef color8_t color_t;
|
||||
#elif COLOR_DEPTH == 16
|
||||
typedef uint16_t color_int_t;
|
||||
typedef color16_t color_t;
|
||||
#elif COLOR_DEPTH == 24
|
||||
typedef uint32_t color_int_t;
|
||||
typedef color24_t color_t;
|
||||
#else
|
||||
#error "Invalid COLOR_DEPTH in misc_conf.h! Set it to 1, 8, 16 or 24!"
|
||||
#endif
|
||||
|
||||
typedef uint16_t opa_t; /* 0..256 (not 255 to cab be normalized with >> 8*/
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint16_t h;
|
||||
uint8_t s;
|
||||
uint8_t v;
|
||||
} color_hsv_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/*In color conversations:
|
||||
* - When converting to bigger color type the LSB weight of 1 LSB is calculated
|
||||
* E.g. 16 bit Red has 5 bits
|
||||
* 8 bit Red has 2 bits
|
||||
* ----------------------
|
||||
* 8 bit red LSB = (2^5 - 1) / (2^2 - 1) = 31 / 3 = 10
|
||||
*
|
||||
* - When calculating to smaller color type simply shift out the LSBs
|
||||
* E.g. 8 bit Red has 2 bits
|
||||
* 16 bit Red has 5 bits
|
||||
* ----------------------
|
||||
* Shift right with 5 - 3 = 2
|
||||
*/
|
||||
|
||||
static inline uint8_t color_to1(color_t color)
|
||||
{
|
||||
#if COLOR_DEPTH == 1
|
||||
return color.full;
|
||||
#elif COLOR_DEPTH == 8
|
||||
if((color.red & 0b100) ||
|
||||
(color.green & 0b100) ||
|
||||
(color.blue & 0b10)) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
#elif COLOR_DEPTH == 16
|
||||
if((color.red & 0b10000) ||
|
||||
(color.green & 0b100000) ||
|
||||
(color.blue & 0b10000)) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
#elif COLOR_DEPTH == 24
|
||||
if((color.red & 0x80) ||
|
||||
(color.green & 0x80) ||
|
||||
(color.blue & 0x80)) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline uint8_t color_to8(color_t color)
|
||||
{
|
||||
#if COLOR_DEPTH == 1
|
||||
if(color.full == 0) return 0;
|
||||
else return 0xFF;
|
||||
#elif COLOR_DEPTH == 8
|
||||
return color.full;
|
||||
#elif COLOR_DEPTH == 16
|
||||
color8_t ret;
|
||||
ret.red = color.red >> 2; /* 5 - 3 = 2*/
|
||||
ret.green = color.green >> 3; /* 6 - 3 = 3*/
|
||||
ret.blue = color.blue >> 3; /* 5 - 2 = 3*/
|
||||
return ret.full;
|
||||
#elif COLOR_DEPTH == 24
|
||||
color8_t ret;
|
||||
ret.red = color.red >> 5; /* 8 - 3 = 5*/
|
||||
ret.green = color.green >> 5; /* 8 - 3 = 5*/
|
||||
ret.blue = color.blue >> 6; /* 8 - 2 = 6*/
|
||||
return ret.full;
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline uint16_t color_to16(color_t color)
|
||||
{
|
||||
#if COLOR_DEPTH == 1
|
||||
if(color.full == 0) return 0;
|
||||
else return 0xFFFF;
|
||||
#elif COLOR_DEPTH == 8
|
||||
color16_t ret;
|
||||
ret.red = color.red * 4; /*(2^5 - 1)/(2^3 - 1) = 31/7 = 4*/
|
||||
ret.green = color.green * 9; /*(2^6 - 1)/(2^3 - 1) = 63/7 = 9*/
|
||||
ret.blue = color.blue * 10; /*(2^5 - 1)/(2^2 - 1) = 31/3 = 10*/
|
||||
return ret.full;
|
||||
#elif COLOR_DEPTH == 16
|
||||
return color.full;
|
||||
#elif COLOR_DEPTH == 24
|
||||
color16_t ret;
|
||||
ret.red = color.red >> 3; /* 8 - 5 = 3*/
|
||||
ret.green = color.green >> 2; /* 8 - 6 = 2*/
|
||||
ret.blue = color.blue >> 3; /* 8 - 5 = 3*/
|
||||
return ret.full;
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline uint32_t color_to24(color_t color)
|
||||
{
|
||||
#if COLOR_DEPTH == 1
|
||||
if(color.full == 0) return 0;
|
||||
else return 0xFFFFFF;
|
||||
#elif COLOR_DEPTH == 8
|
||||
color24_t ret;
|
||||
ret.red = color.red * 36; /*(2^8 - 1)/(2^3 - 1) = 255/7 = 36*/
|
||||
ret.green = color.green * 36; /*(2^8 - 1)/(2^3 - 1) = 255/7 = 36*/
|
||||
ret.blue = color.blue * 85; /*(2^8 - 1)/(2^2 - 1) = 255/3 = 85*/
|
||||
return ret.full;
|
||||
#elif COLOR_DEPTH == 16
|
||||
color24_t ret;
|
||||
ret.red = color.red * 8; /*(2^8 - 1)/(2^5 - 1) = 255/31 = 8*/
|
||||
ret.green = color.green * 4; /*(2^8 - 1)/(2^6 - 1) = 255/63 = 4*/
|
||||
ret.blue = color.blue * 8; /*(2^8 - 1)/(2^5 - 1) = 255/31 = 8*/
|
||||
return ret.full;
|
||||
#elif COLOR_DEPTH == 24
|
||||
return color.full;
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline color_t color_mix(color_t c1, color_t c2, uint16_t mix)
|
||||
{
|
||||
color_t ret;
|
||||
ret.red = (uint16_t)((uint16_t) c1.red * mix + (c2.red * (256 - mix))) >> 8;
|
||||
ret.green = (uint16_t)((uint16_t) c1.green * mix + (c2.green * (256 - mix))) >> 8;
|
||||
ret.blue = (uint16_t)((uint16_t) c1.blue * mix + (c2.blue * (256 - mix))) >> 8;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the brightness of a color
|
||||
* @param color a color
|
||||
* @return the brightness [0..255]
|
||||
*/
|
||||
static inline uint8_t color_brightness(color_t color)
|
||||
{
|
||||
color24_t c24;
|
||||
c24.full = color_to24(color);
|
||||
uint16_t bright = 3 * c24.red + c24.blue + 4 * c24.green;
|
||||
return (uint16_t) bright >> 3;
|
||||
}
|
||||
|
||||
#if COLOR_DEPTH == 1
|
||||
#define COLOR_MAKE(r8, g8, b8) ((color_t){b8 >> 7 | g8 >> 7 | r8 >> 7})
|
||||
#elif COLOR_DEPTH == 8
|
||||
#define COLOR_MAKE(r8, g8, b8) ((color_t){{b8 >> 6, g8 >> 5, r8 >> 5}})
|
||||
#elif COLOR_DEPTH == 16
|
||||
#define COLOR_MAKE(r8, g8, b8) ((color_t){{b8 >> 3, g8 >> 2, r8 >> 3}})
|
||||
#elif COLOR_DEPTH == 24
|
||||
#define COLOR_MAKE(r8, g8, b8) ((color_t){{b8, g8, r8}})
|
||||
#endif
|
||||
|
||||
#define COLOR_HEX(c) COLOR_MAKE(((uint32_t)((uint32_t)c >> 16) & 0xFF), \
|
||||
((uint32_t)((uint32_t)c >> 8) & 0xFF), \
|
||||
((uint32_t) c & 0xFF))
|
||||
|
||||
/*Usage COLOR_HEX3(0x16C) which means COLOR_HEX(0x1166CC)*/
|
||||
#define COLOR_HEX3(c) COLOR_MAKE((((c >> 4) & 0xF0) | ((c >> 8) & 0xF)), \
|
||||
((uint32_t)(c & 0xF0) | ((c & 0xF0) >> 4)), \
|
||||
((uint32_t)(c & 0xF) | ((c & 0xF) << 4)))
|
||||
|
||||
|
||||
/**
|
||||
* Convert a HSV color to RGB
|
||||
* @param h hue [0..359]
|
||||
* @param s saturation [0..100]
|
||||
* @param v value [0..100]
|
||||
* @return the given RGB color in RGB (with COLOR_DEPTH depth)
|
||||
*/
|
||||
color_t color_hsv_to_rgb(uint16_t h, uint8_t s, uint8_t v);
|
||||
|
||||
/**
|
||||
* Convert an RGB color to HSV
|
||||
* @param r red
|
||||
* @param g green
|
||||
* @param b blue
|
||||
* @return the given RGB color n HSV
|
||||
*/
|
||||
color_hsv_t color_rgb_to_hsv(uint8_t r, uint8_t g, uint8_t b);
|
||||
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif /*USE_COLOR*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif
|
||||
328
misc/gfx/font.c
Normal file
328
misc/gfx/font.c
Normal file
@@ -0,0 +1,328 @@
|
||||
/**
|
||||
* @file font.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "misc_conf.h"
|
||||
#if USE_FONT != 0
|
||||
|
||||
#include <stddef.h>
|
||||
#include "font.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Initialize the built-in fonts
|
||||
*/
|
||||
void font_init(void)
|
||||
{
|
||||
|
||||
/*DEJAVU 10*/
|
||||
#if USE_FONT_DEJAVU_10 != 0
|
||||
font_add(&font_dejavu_10, NULL);
|
||||
#endif
|
||||
|
||||
#if USE_FONT_DEJAVU_10_SUP != 0
|
||||
font_add(&font_dejavu_10_sup, &font_dejavu_10);
|
||||
#endif
|
||||
|
||||
#if USE_FONT_DEJAVU_10_LATIN_EXT_A != 0
|
||||
font_add(&font_dejavu_10_latin_ext_a, &font_dejavu_10);
|
||||
#endif
|
||||
|
||||
#if USE_FONT_DEJAVU_10_LATIN_EXT_B != 0
|
||||
font_add(&font_dejavu_10_latin_ext_b, &font_dejavu_10);
|
||||
#endif
|
||||
|
||||
#if USE_FONT_DEJAVU_10_CYRILLIC != 0
|
||||
font_add(&font_dejavu_10_cyrillic, &font_dejavu_10);
|
||||
#endif
|
||||
|
||||
/*SYMBOL 10*/
|
||||
#if USE_FONT_SYMBOL_10_BASIC != 0
|
||||
font_add(&font_symbol_10_basic, &font_dejavu_10);
|
||||
#endif
|
||||
|
||||
#if USE_FONT_SYMBOL_10_FILE != 0
|
||||
font_add(&font_symbol_10_file, &font_symbol_10_basic);
|
||||
#endif
|
||||
|
||||
#if USE_FONT_SYMBOL_10_FEEDBACK != 0
|
||||
font_add(&font_symbol_10_feedback, &font_symbol_10_basic);
|
||||
#endif
|
||||
|
||||
/*DEJAVU 20*/
|
||||
#if USE_FONT_DEJAVU_20 != 0
|
||||
font_add(&font_dejavu_20, NULL);
|
||||
#endif
|
||||
|
||||
#if USE_FONT_DEJAVU_20_SUP != 0
|
||||
font_add(&font_dejavu_20_sup, &font_dejavu_20);
|
||||
#endif
|
||||
|
||||
#if USE_FONT_DEJAVU_20_LATIN_EXT_A != 0
|
||||
font_add(&font_dejavu_20_latin_ext_a, &font_dejavu_20);
|
||||
#endif
|
||||
|
||||
#if USE_FONT_DEJAVU_20_LATIN_EXT_B != 0
|
||||
font_add(&font_dejavu_20_latin_ext_b, &font_dejavu_20);
|
||||
#endif
|
||||
|
||||
#if USE_FONT_DEJAVU_20_CYRILLIC != 0
|
||||
font_add(&font_dejavu_20_cyrillic, &font_dejavu_20);
|
||||
#endif
|
||||
|
||||
/*SYMBOL 20*/
|
||||
#if USE_FONT_SYMBOL_20_BASIC != 0
|
||||
font_add(&font_symbol_20_basic, &font_dejavu_20);
|
||||
#endif
|
||||
|
||||
#if USE_FONT_SYMBOL_20_FILE != 0
|
||||
font_add(&font_symbol_20_file, &font_symbol_20_basic);
|
||||
#endif
|
||||
|
||||
#if USE_FONT_SYMBOL_20_FEEDBACK != 0
|
||||
font_add(&font_symbol_20_feedback, &font_symbol_20_basic);
|
||||
#endif
|
||||
|
||||
/*DEJAVU 30*/
|
||||
#if USE_FONT_DEJAVU_30 != 0
|
||||
font_add(&font_dejavu_30, NULL);
|
||||
#endif
|
||||
|
||||
#if USE_FONT_DEJAVU_30_SUP != 0
|
||||
font_add(&font_dejavu_30_sup, &font_dejavu_30);
|
||||
#endif
|
||||
|
||||
#if USE_FONT_DEJAVU_30_LATIN_EXT_A != 0
|
||||
font_add(&font_dejavu_30_latin_ext_a, &font_dejavu_30);
|
||||
#endif
|
||||
|
||||
#if USE_FONT_DEJAVU_30_LATIN_EXT_B != 0
|
||||
font_add(&font_dejavu_30_latin_ext_b, &font_dejavu_30);
|
||||
#endif
|
||||
|
||||
#if USE_FONT_DEJAVU_30_CYRILLIC != 0
|
||||
font_add(&font_dejavu_30_cyrillic, &font_dejavu_30);
|
||||
#endif
|
||||
|
||||
/*SYMBOL 30*/
|
||||
#if USE_FONT_SYMBOL_30_BASIC != 0
|
||||
font_add(&font_symbol_30_basic, &font_dejavu_30);
|
||||
#endif
|
||||
|
||||
#if USE_FONT_SYMBOL_30_FILE != 0
|
||||
font_add(&font_symbol_30_file, &font_symbol_30_basic);
|
||||
#endif
|
||||
|
||||
#if USE_FONT_SYMBOL_30_FEEDBACK != 0
|
||||
font_add(&font_symbol_30_feedback, &font_symbol_30_basic);
|
||||
#endif
|
||||
|
||||
/*DEJAVU 40*/
|
||||
#if USE_FONT_DEJAVU_40 != 0
|
||||
font_add(&font_dejavu_40, NULL);
|
||||
#endif
|
||||
|
||||
#if USE_FONT_DEJAVU_40_SUP != 0
|
||||
font_add(&font_dejavu_40_sup, &font_dejavu_40);
|
||||
#endif
|
||||
|
||||
#if USE_FONT_DEJAVU_40_LATIN_EXT_A != 0
|
||||
font_add(&font_dejavu_40_latin_ext_a, &font_dejavu_40);
|
||||
#endif
|
||||
|
||||
#if USE_FONT_DEJAVU_40_LATIN_EXT_B != 0
|
||||
font_add(&font_dejavu_40_latin_ext_b, &font_dejavu_40);
|
||||
#endif
|
||||
|
||||
#if USE_FONT_DEJAVU_40_CYRILLIC != 0
|
||||
font_add(&font_dejavu_40_cyrillic, &font_dejavu_40);
|
||||
#endif
|
||||
|
||||
/*SYMBOL 40*/
|
||||
#if USE_FONT_SYMBOL_40_BASIC != 0
|
||||
font_add(&font_symbol_40_basic, &font_dejavu_40);
|
||||
#endif
|
||||
|
||||
#if USE_FONT_SYMBOL_40_FILE != 0
|
||||
font_add(&font_symbol_40_file, &font_symbol_40_basic);
|
||||
#endif
|
||||
|
||||
#if USE_FONT_SYMBOL_40_FEEDBACK != 0
|
||||
font_add(&font_symbol_40_feedback, &font_symbol_40_basic);
|
||||
#endif
|
||||
|
||||
/*DEJAVU 60*/
|
||||
#if USE_FONT_DEJAVU_60 != 0
|
||||
font_add(&font_dejavu_60, NULL);
|
||||
#endif
|
||||
|
||||
#if USE_FONT_DEJAVU_60_SUP != 0
|
||||
font_add(&font_dejavu_60_sup, &font_dejavu_60);
|
||||
#endif
|
||||
|
||||
#if USE_FONT_DEJAVU_60_LATIN_EXT_A != 0
|
||||
font_add(&font_dejavu_60_latin_ext_a, &font_dejavu_60);
|
||||
#endif
|
||||
|
||||
#if USE_FONT_DEJAVU_60_LATIN_EXT_B != 0
|
||||
font_add(&font_dejavu_60_latin_ext_b, &font_dejavu_60);
|
||||
#endif
|
||||
|
||||
#if USE_FONT_DEJAVU_60_CYRILLIC != 0
|
||||
font_add(&font_dejavu_60_cyrillic, &font_dejavu_60);
|
||||
#endif
|
||||
|
||||
/*SYMBOL 60*/
|
||||
#if USE_FONT_SYMBOL_60_BASIC != 0
|
||||
font_add(&font_symbol_60_basic, &font_dejavu_60);
|
||||
#endif
|
||||
|
||||
#if USE_FONT_SYMBOL_60_FILE != 0
|
||||
font_add(&font_symbol_60_file, &font_symbol_60_basic);
|
||||
#endif
|
||||
|
||||
#if USE_FONT_SYMBOL_60_FEEDBACK != 0
|
||||
font_add(&font_symbol_60_feedback, &font_symbol_60_basic);
|
||||
#endif
|
||||
|
||||
/*DEJAVU 80*/
|
||||
#if USE_FONT_DEJAVU_80 != 0
|
||||
font_add(&font_dejavu_80, NULL);
|
||||
#endif
|
||||
|
||||
#if USE_FONT_DEJAVU_80_SUP != 0
|
||||
font_add(&font_dejavu_80_sup, &font_dejavu_80);
|
||||
#endif
|
||||
|
||||
#if USE_FONT_DEJAVU_80_LATIN_EXT_A != 0
|
||||
font_add(&font_dejavu_80_latin_ext_a, &font_dejavu_80);
|
||||
#endif
|
||||
|
||||
#if USE_FONT_DEJAVU_80_LATIN_EXT_B != 0
|
||||
font_add(&font_dejavu_80_latin_ext_b, &font_dejavu_80);
|
||||
#endif
|
||||
|
||||
#if USE_FONT_DEJAVU_80_CYRILLIC != 0
|
||||
font_add(&font_dejavu_80_cyrillic, &font_dejavu_80);
|
||||
#endif
|
||||
|
||||
/*SYMBOL 80*/
|
||||
#if USE_FONT_SYMBOL_80_BASIC != 0
|
||||
font_add(&font_symbol_80_basic, &font_dejavu_80);
|
||||
#endif
|
||||
|
||||
#if USE_FONT_SYMBOL_80_FILE != 0
|
||||
font_add(&font_symbol_80_file, &font_symbol_80_basic);
|
||||
#endif
|
||||
|
||||
#if USE_FONT_SYMBOL_80_FEEDBACK != 0
|
||||
font_add(&font_symbol_80_feedback, &font_symbol_80_basic);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a pair from font name and font dsc. get function. After it 'font_get' can be used for this font
|
||||
* @param name name of the font
|
||||
* @param dsc_get_fp the font descriptor get function
|
||||
* @param parent add this font as charter set extension of 'parent'
|
||||
*/
|
||||
void font_add(font_t *child, font_t *parent)
|
||||
{
|
||||
if(parent == NULL) return;
|
||||
|
||||
while(parent->next_page != NULL) {
|
||||
parent = parent->next_page; /*Got to the last page and add the new font there*/
|
||||
}
|
||||
|
||||
parent->next_page = child;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Return with the bitmap of a font.
|
||||
* @param font_p pointer to a font
|
||||
* @param letter a letter
|
||||
* @return pointer to the bitmap of the letter
|
||||
*/
|
||||
const uint8_t * font_get_bitmap(const font_t * font_p, uint32_t letter)
|
||||
{
|
||||
const font_t * font_i = font_p;
|
||||
while(font_i != NULL) {
|
||||
if(letter >= font_i->first_ascii && letter <= font_i->last_ascii) {
|
||||
uint32_t index = (letter - font_i->first_ascii);
|
||||
return &font_i->bitmap[font_i->map[index]];
|
||||
}
|
||||
|
||||
font_i = font_i->next_page;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the width of a letter in a font
|
||||
* @param font_p pointer to a font
|
||||
* @param letter a letter
|
||||
* @return the width of a letter
|
||||
*/
|
||||
uint8_t font_get_width(const font_t * font_p, uint32_t letter)
|
||||
{
|
||||
const font_t * font_i = font_p;
|
||||
while(font_i != NULL) {
|
||||
if(letter >= font_i->first_ascii && letter <= font_i->last_ascii) {
|
||||
uint32_t index = (letter - font_i->first_ascii);
|
||||
return font_i->width[index];
|
||||
}
|
||||
font_i = font_i->next_page;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the width of a letter in a font )Give the real size on the screen (half size if FONT_ANTIALIAS is enabled)
|
||||
* @param font_p pointer to a font
|
||||
* @param letter a letter
|
||||
* @return the width of a letter
|
||||
*/
|
||||
uint8_t font_get_width_scale(const font_t * font_p, uint32_t letter)
|
||||
{
|
||||
return font_get_width(font_p, letter) >> FONT_ANTIALIAS;
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
#endif /*USE_FONT*/
|
||||
177
misc/gfx/font.h
Normal file
177
misc/gfx/font.h
Normal file
@@ -0,0 +1,177 @@
|
||||
/**
|
||||
* @file font.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef FONT_H
|
||||
#define FONT_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "misc_conf.h"
|
||||
#if USE_FONT != 0
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include "fonts/symbol_def.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
struct _font_struct;
|
||||
|
||||
typedef struct _font_struct
|
||||
{
|
||||
uint32_t first_ascii;
|
||||
uint32_t last_ascii;
|
||||
uint8_t height_row;
|
||||
const uint8_t * bitmap;
|
||||
const uint32_t * map;
|
||||
const uint8_t * width;
|
||||
struct _font_struct * next_page; /*Pointer to a font extension*/
|
||||
}font_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Initialize the built-in fonts
|
||||
*/
|
||||
void font_init(void);
|
||||
|
||||
/**
|
||||
* Create a pair from font name and font dsc. get function. After it 'font_get' can be used for this font
|
||||
* @param child pointer to a font to join to the 'parent'
|
||||
* @param parent pointer to a font. 'child' will be joined here
|
||||
*/
|
||||
void font_add(font_t *child, font_t *parent);
|
||||
|
||||
/**
|
||||
* Return with the bitmap of a font.
|
||||
* @param font_p pointer to a font
|
||||
* @param letter a letter
|
||||
* @return pointer to the bitmap of the letter
|
||||
*/
|
||||
const uint8_t * font_get_bitmap(const font_t * font_p, uint32_t letter);
|
||||
|
||||
/**
|
||||
* Get the height of a font
|
||||
* @param font_p pointer to a font
|
||||
* @return the height of a font
|
||||
*/
|
||||
static inline uint8_t font_get_height(const font_t * font_p)
|
||||
{
|
||||
return font_p->height_row;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the height of a font. Give the real size on the screen (half size if FONT_ANTIALIAS is enabled)
|
||||
* @param font_p pointer to a font
|
||||
* @return the height of a font
|
||||
*/
|
||||
static inline uint8_t font_get_height_scale(const font_t * font_p)
|
||||
{
|
||||
return font_p->height_row >> FONT_ANTIALIAS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the width of a letter in a font
|
||||
* @param font_p pointer to a font
|
||||
* @param letter a letter
|
||||
* @return the width of a letter
|
||||
*/
|
||||
uint8_t font_get_width(const font_t * font_p, uint32_t letter);
|
||||
|
||||
/**
|
||||
* Get the width of a letter in a font )Give the real size on the screen (half size if FONT_ANTIALIAS is enabled)
|
||||
* @param font_p pointer to a font
|
||||
* @param letter a letter
|
||||
* @return the width of a letter
|
||||
*/
|
||||
uint8_t font_get_width_scale(const font_t * font_p, uint32_t letter);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/***********************
|
||||
* POST INCLUDES
|
||||
***********************/
|
||||
/*Add built-in fonts*/
|
||||
|
||||
#include "fonts/dejavu_10.h"
|
||||
#include "fonts/dejavu_10_sup.h"
|
||||
#include "fonts/dejavu_10_latin_ext_a.h"
|
||||
#include "fonts/dejavu_10_latin_ext_b.h"
|
||||
#include "fonts/dejavu_10_cyrillic.h"
|
||||
#include "fonts/symbol_10_basic.h"
|
||||
#include "fonts/symbol_10_file.h"
|
||||
#include "fonts/symbol_10_feedback.h"
|
||||
|
||||
#include "fonts/dejavu_20.h"
|
||||
#include "fonts/dejavu_20_sup.h"
|
||||
#include "fonts/dejavu_20_latin_ext_a.h"
|
||||
#include "fonts/dejavu_20_latin_ext_b.h"
|
||||
#include "fonts/dejavu_20_cyrillic.h"
|
||||
#include "fonts/symbol_20_basic.h"
|
||||
#include "fonts/symbol_20_file.h"
|
||||
#include "fonts/symbol_20_feedback.h"
|
||||
|
||||
#include "fonts/dejavu_30.h"
|
||||
#include "fonts/dejavu_30_sup.h"
|
||||
#include "fonts/dejavu_30_latin_ext_a.h"
|
||||
#include "fonts/dejavu_30_latin_ext_b.h"
|
||||
#include "fonts/dejavu_30_cyrillic.h"
|
||||
#include "fonts/symbol_30_basic.h"
|
||||
#include "fonts/symbol_30_file.h"
|
||||
#include "fonts/symbol_30_feedback.h"
|
||||
|
||||
#include "fonts/dejavu_40.h"
|
||||
#include "fonts/dejavu_40_sup.h"
|
||||
#include "fonts/dejavu_40_latin_ext_a.h"
|
||||
#include "fonts/dejavu_40_latin_ext_b.h"
|
||||
#include "fonts/dejavu_40_cyrillic.h"
|
||||
#include "fonts/symbol_40_basic.h"
|
||||
#include "fonts/symbol_40_file.h"
|
||||
#include "fonts/symbol_40_feedback.h"
|
||||
|
||||
#include "fonts/dejavu_60.h"
|
||||
#include "fonts/dejavu_60_sup.h"
|
||||
#include "fonts/dejavu_60_latin_ext_a.h"
|
||||
#include "fonts/dejavu_60_latin_ext_b.h"
|
||||
#include "fonts/dejavu_60_cyrillic.h"
|
||||
#include "fonts/symbol_60_basic.h"
|
||||
#include "fonts/symbol_60_file.h"
|
||||
#include "fonts/symbol_60_feedback.h"
|
||||
|
||||
#include "fonts/dejavu_80.h"
|
||||
#include "fonts/dejavu_80_sup.h"
|
||||
#include "fonts/dejavu_80_latin_ext_a.h"
|
||||
#include "fonts/dejavu_80_latin_ext_b.h"
|
||||
#include "fonts/dejavu_80_cyrillic.h"
|
||||
#include "fonts/symbol_80_basic.h"
|
||||
#include "fonts/symbol_80_file.h"
|
||||
#include "fonts/symbol_80_feedback.h"
|
||||
|
||||
#endif /*USE_FONT*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
1194
misc/gfx/fonts/dejavu_10.c
Normal file
1194
misc/gfx/fonts/dejavu_10.c
Normal file
File diff suppressed because it is too large
Load Diff
17
misc/gfx/fonts/dejavu_10.h
Normal file
17
misc/gfx/fonts/dejavu_10.h
Normal file
@@ -0,0 +1,17 @@
|
||||
#ifndef DEJAVU_10_H
|
||||
#define DEJAVU_10_H
|
||||
|
||||
/*Use UTF-8 encoding in the IDE*/
|
||||
|
||||
#include "misc_conf.h"
|
||||
|
||||
#if USE_FONT_DEJAVU_10 != 0
|
||||
|
||||
#include <stdint.h>
|
||||
#include "lvgl/misc/gfx/font.h"
|
||||
|
||||
extern font_t font_dejavu_10;
|
||||
|
||||
#endif /*USE_FONT_DEJAVU_10 != 0*/
|
||||
|
||||
#endif /*DEJAVU_10_H*/
|
||||
3166
misc/gfx/fonts/dejavu_10_cyrillic.c
Normal file
3166
misc/gfx/fonts/dejavu_10_cyrillic.c
Normal file
File diff suppressed because it is too large
Load Diff
17
misc/gfx/fonts/dejavu_10_cyrillic.h
Normal file
17
misc/gfx/fonts/dejavu_10_cyrillic.h
Normal file
@@ -0,0 +1,17 @@
|
||||
#ifndef DEJAVU_10_CYRILLIC_H
|
||||
#define DEJAVU_10_CYRILLIC_H
|
||||
|
||||
/*Use UTF-8 encoding in the IDE*/
|
||||
|
||||
#include "misc_conf.h"
|
||||
|
||||
#if USE_FONT_DEJAVU_10_CYRILLIC != 0
|
||||
|
||||
#include <stdint.h>
|
||||
#include "lvgl/misc/gfx/font.h"
|
||||
|
||||
extern font_t font_dejavu_10_cyrillic;
|
||||
|
||||
#endif /*USE_FONT_DEJAVU_10_CYRILLIC != 0*/
|
||||
|
||||
#endif /*DEJAVU_10_CYRILLIC_H*/
|
||||
1598
misc/gfx/fonts/dejavu_10_latin_ext_a.c
Normal file
1598
misc/gfx/fonts/dejavu_10_latin_ext_a.c
Normal file
File diff suppressed because it is too large
Load Diff
17
misc/gfx/fonts/dejavu_10_latin_ext_a.h
Normal file
17
misc/gfx/fonts/dejavu_10_latin_ext_a.h
Normal file
@@ -0,0 +1,17 @@
|
||||
#ifndef DEJAVU_10_LATIN_EXT_A_H
|
||||
#define DEJAVU_10_LATIN_EXT_A_H
|
||||
|
||||
/*Use UTF-8 encoding in the IDE*/
|
||||
|
||||
#include "misc_conf.h"
|
||||
|
||||
#if USE_FONT_DEJAVU_10_LATIN_EXT_A != 0
|
||||
|
||||
#include <stdint.h>
|
||||
#include "lvgl/misc/gfx/font.h"
|
||||
|
||||
extern font_t font_dejavu_10_latin_ext_a;
|
||||
|
||||
#endif /*USE_FONT_DEJAVU_10_LATIN_EXT_A != 0*/
|
||||
|
||||
#endif /*DEJAVU_10_LATIN_EXT_A_H*/
|
||||
2578
misc/gfx/fonts/dejavu_10_latin_ext_b.c
Normal file
2578
misc/gfx/fonts/dejavu_10_latin_ext_b.c
Normal file
File diff suppressed because it is too large
Load Diff
17
misc/gfx/fonts/dejavu_10_latin_ext_b.h
Normal file
17
misc/gfx/fonts/dejavu_10_latin_ext_b.h
Normal file
@@ -0,0 +1,17 @@
|
||||
#ifndef DEJAVU_10_LATIN_EXT_B_H
|
||||
#define DEJAVU_10_LATIN_EXT_B_H
|
||||
|
||||
/*Use UTF-8 encoding in the IDE*/
|
||||
|
||||
#include "misc_conf.h"
|
||||
|
||||
#if USE_FONT_DEJAVU_10_LATIN_EXT_B != 0
|
||||
|
||||
#include <stdint.h>
|
||||
#include "lvgl/misc/gfx/font.h"
|
||||
|
||||
extern font_t font_dejavu_10_latin_ext_b;
|
||||
|
||||
#endif /*USE_FONT_DEJAVU_10_LATIN_EXT_B != 0*/
|
||||
|
||||
#endif /*DEJAVU_10_LATIN_EXT_B_H*/
|
||||
1206
misc/gfx/fonts/dejavu_10_sup.c
Normal file
1206
misc/gfx/fonts/dejavu_10_sup.c
Normal file
File diff suppressed because it is too large
Load Diff
17
misc/gfx/fonts/dejavu_10_sup.h
Normal file
17
misc/gfx/fonts/dejavu_10_sup.h
Normal file
@@ -0,0 +1,17 @@
|
||||
#ifndef DEJAVU_10_SUP_H
|
||||
#define DEJAVU_10_SUP_H
|
||||
|
||||
/*Use UTF-8 encoding in the IDE*/
|
||||
|
||||
#include "misc_conf.h"
|
||||
|
||||
#if USE_FONT_DEJAVU_10_SUP != 0
|
||||
|
||||
#include <stdint.h>
|
||||
#include "lvgl/misc/gfx/font.h"
|
||||
|
||||
extern font_t font_dejavu_10_sup;
|
||||
|
||||
#endif /*USE_FONT_DEJAVU_10_SUP != 0*/
|
||||
|
||||
#endif /*DEJAVU_10_SUP_H*/
|
||||
2144
misc/gfx/fonts/dejavu_20.c
Normal file
2144
misc/gfx/fonts/dejavu_20.c
Normal file
File diff suppressed because it is too large
Load Diff
17
misc/gfx/fonts/dejavu_20.h
Normal file
17
misc/gfx/fonts/dejavu_20.h
Normal file
@@ -0,0 +1,17 @@
|
||||
#ifndef DEJAVU_20_H
|
||||
#define DEJAVU_20_H
|
||||
|
||||
/*Use UTF-8 encoding in the IDE*/
|
||||
|
||||
#include "misc_conf.h"
|
||||
|
||||
#if USE_FONT_DEJAVU_20 != 0
|
||||
|
||||
#include <stdint.h>
|
||||
#include "lvgl/misc/gfx/font.h"
|
||||
|
||||
extern font_t font_dejavu_20;
|
||||
|
||||
#endif /*USE_FONT_DEJAVU_20 != 0*/
|
||||
|
||||
#endif /*DEJAVU_20_H*/
|
||||
5726
misc/gfx/fonts/dejavu_20_cyrillic.c
Normal file
5726
misc/gfx/fonts/dejavu_20_cyrillic.c
Normal file
File diff suppressed because it is too large
Load Diff
17
misc/gfx/fonts/dejavu_20_cyrillic.h
Normal file
17
misc/gfx/fonts/dejavu_20_cyrillic.h
Normal file
@@ -0,0 +1,17 @@
|
||||
#ifndef DEJAVU_20_CYRILLIC_H
|
||||
#define DEJAVU_20_CYRILLIC_H
|
||||
|
||||
/*Use UTF-8 encoding in the IDE*/
|
||||
|
||||
#include "misc_conf.h"
|
||||
|
||||
#if USE_FONT_DEJAVU_20_CYRILLIC != 0
|
||||
|
||||
#include <stdint.h>
|
||||
#include "lvgl/misc/gfx/font.h"
|
||||
|
||||
extern font_t font_dejavu_20_cyrillic;
|
||||
|
||||
#endif /*USE_FONT_DEJAVU_20_CYRILLIC != 0*/
|
||||
|
||||
#endif /*DEJAVU_20_CYRILLIC_H*/
|
||||
2878
misc/gfx/fonts/dejavu_20_latin_ext_a.c
Normal file
2878
misc/gfx/fonts/dejavu_20_latin_ext_a.c
Normal file
File diff suppressed because it is too large
Load Diff
17
misc/gfx/fonts/dejavu_20_latin_ext_a.h
Normal file
17
misc/gfx/fonts/dejavu_20_latin_ext_a.h
Normal file
@@ -0,0 +1,17 @@
|
||||
#ifndef DEJAVU_20_LATIN_EXT_A_H
|
||||
#define DEJAVU_20_LATIN_EXT_A_H
|
||||
|
||||
/*Use UTF-8 encoding in the IDE*/
|
||||
|
||||
#include "misc_conf.h"
|
||||
|
||||
#if USE_FONT_DEJAVU_20_LATIN_EXT_A != 0
|
||||
|
||||
#include <stdint.h>
|
||||
#include "lvgl/misc/gfx/font.h"
|
||||
|
||||
extern font_t font_dejavu_20_latin_ext_a;
|
||||
|
||||
#endif /*USE_FONT_DEJAVU_20_LATIN_EXT_A != 0*/
|
||||
|
||||
#endif /*DEJAVU_20_LATIN_EXT_A_H*/
|
||||
4658
misc/gfx/fonts/dejavu_20_latin_ext_b.c
Normal file
4658
misc/gfx/fonts/dejavu_20_latin_ext_b.c
Normal file
File diff suppressed because it is too large
Load Diff
17
misc/gfx/fonts/dejavu_20_latin_ext_b.h
Normal file
17
misc/gfx/fonts/dejavu_20_latin_ext_b.h
Normal file
@@ -0,0 +1,17 @@
|
||||
#ifndef DEJAVU_20_LATIN_EXT_B_H
|
||||
#define DEJAVU_20_LATIN_EXT_B_H
|
||||
|
||||
/*Use UTF-8 encoding in the IDE*/
|
||||
|
||||
#include "misc_conf.h"
|
||||
|
||||
#if USE_FONT_DEJAVU_20_LATIN_EXT_B != 0
|
||||
|
||||
#include <stdint.h>
|
||||
#include "lvgl/misc/gfx/font.h"
|
||||
|
||||
extern font_t font_dejavu_20_latin_ext_b;
|
||||
|
||||
#endif /*USE_FONT_DEJAVU_20_LATIN_EXT_B != 0*/
|
||||
|
||||
#endif /*DEJAVU_20_LATIN_EXT_B_H*/
|
||||
2166
misc/gfx/fonts/dejavu_20_sup.c
Normal file
2166
misc/gfx/fonts/dejavu_20_sup.c
Normal file
File diff suppressed because it is too large
Load Diff
17
misc/gfx/fonts/dejavu_20_sup.h
Normal file
17
misc/gfx/fonts/dejavu_20_sup.h
Normal file
@@ -0,0 +1,17 @@
|
||||
#ifndef DEJAVU_20_SUP_H
|
||||
#define DEJAVU_20_SUP_H
|
||||
|
||||
/*Use UTF-8 encoding in the IDE*/
|
||||
|
||||
#include "misc_conf.h"
|
||||
|
||||
#if USE_FONT_DEJAVU_20_SUP != 0
|
||||
|
||||
#include <stdint.h>
|
||||
#include "lvgl/misc/gfx/font.h"
|
||||
|
||||
extern font_t font_dejavu_20_sup;
|
||||
|
||||
#endif /*USE_FONT_DEJAVU_20_SUP != 0*/
|
||||
|
||||
#endif /*DEJAVU_20_SUP_H*/
|
||||
3094
misc/gfx/fonts/dejavu_30.c
Normal file
3094
misc/gfx/fonts/dejavu_30.c
Normal file
File diff suppressed because it is too large
Load Diff
17
misc/gfx/fonts/dejavu_30.h
Normal file
17
misc/gfx/fonts/dejavu_30.h
Normal file
@@ -0,0 +1,17 @@
|
||||
#ifndef DEJAVU_30_H
|
||||
#define DEJAVU_30_H
|
||||
|
||||
/*Use UTF-8 encoding in the IDE*/
|
||||
|
||||
#include "misc_conf.h"
|
||||
|
||||
#if USE_FONT_DEJAVU_30 != 0
|
||||
|
||||
#include <stdint.h>
|
||||
#include "lvgl/misc/gfx/font.h"
|
||||
|
||||
extern font_t font_dejavu_30;
|
||||
|
||||
#endif /*USE_FONT_DEJAVU_30 != 0*/
|
||||
|
||||
#endif /*DEJAVU_30_H*/
|
||||
8286
misc/gfx/fonts/dejavu_30_cyrillic.c
Normal file
8286
misc/gfx/fonts/dejavu_30_cyrillic.c
Normal file
File diff suppressed because it is too large
Load Diff
17
misc/gfx/fonts/dejavu_30_cyrillic.h
Normal file
17
misc/gfx/fonts/dejavu_30_cyrillic.h
Normal file
@@ -0,0 +1,17 @@
|
||||
#ifndef DEJAVU_30_CYRILLIC_H
|
||||
#define DEJAVU_30_CYRILLIC_H
|
||||
|
||||
/*Use UTF-8 encoding in the IDE*/
|
||||
|
||||
#include "misc_conf.h"
|
||||
|
||||
#if USE_FONT_DEJAVU_30_CYRILLIC != 0
|
||||
|
||||
#include <stdint.h>
|
||||
#include "lvgl/misc/gfx/font.h"
|
||||
|
||||
extern font_t font_dejavu_30_cyrillic;
|
||||
|
||||
#endif /*USE_FONT_DEJAVU_30_CYRILLIC != 0*/
|
||||
|
||||
#endif /*DEJAVU_30_CYRILLIC_H*/
|
||||
4158
misc/gfx/fonts/dejavu_30_latin_ext_a.c
Normal file
4158
misc/gfx/fonts/dejavu_30_latin_ext_a.c
Normal file
File diff suppressed because it is too large
Load Diff
17
misc/gfx/fonts/dejavu_30_latin_ext_a.h
Normal file
17
misc/gfx/fonts/dejavu_30_latin_ext_a.h
Normal file
@@ -0,0 +1,17 @@
|
||||
#ifndef DEJAVU_30_LATIN_EXT_A_H
|
||||
#define DEJAVU_30_LATIN_EXT_A_H
|
||||
|
||||
/*Use UTF-8 encoding in the IDE*/
|
||||
|
||||
#include "misc_conf.h"
|
||||
|
||||
#if USE_FONT_DEJAVU_30_LATIN_EXT_A != 0
|
||||
|
||||
#include <stdint.h>
|
||||
#include "lvgl/misc/gfx/font.h"
|
||||
|
||||
extern font_t font_dejavu_30_latin_ext_a;
|
||||
|
||||
#endif /*USE_FONT_DEJAVU_30_LATIN_EXT_A != 0*/
|
||||
|
||||
#endif /*DEJAVU_30_LATIN_EXT_A_H*/
|
||||
6738
misc/gfx/fonts/dejavu_30_latin_ext_b.c
Normal file
6738
misc/gfx/fonts/dejavu_30_latin_ext_b.c
Normal file
File diff suppressed because it is too large
Load Diff
17
misc/gfx/fonts/dejavu_30_latin_ext_b.h
Normal file
17
misc/gfx/fonts/dejavu_30_latin_ext_b.h
Normal file
@@ -0,0 +1,17 @@
|
||||
#ifndef DEJAVU_30_LATIN_EXT_B_H
|
||||
#define DEJAVU_30_LATIN_EXT_B_H
|
||||
|
||||
/*Use UTF-8 encoding in the IDE*/
|
||||
|
||||
#include "misc_conf.h"
|
||||
|
||||
#if USE_FONT_DEJAVU_30_LATIN_EXT_B != 0
|
||||
|
||||
#include <stdint.h>
|
||||
#include "lvgl/misc/gfx/font.h"
|
||||
|
||||
extern font_t font_dejavu_30_latin_ext_b;
|
||||
|
||||
#endif /*USE_FONT_DEJAVU_30_LATIN_EXT_B != 0*/
|
||||
|
||||
#endif /*DEJAVU_30_LATIN_EXT_B_H*/
|
||||
3126
misc/gfx/fonts/dejavu_30_sup.c
Normal file
3126
misc/gfx/fonts/dejavu_30_sup.c
Normal file
File diff suppressed because it is too large
Load Diff
17
misc/gfx/fonts/dejavu_30_sup.h
Normal file
17
misc/gfx/fonts/dejavu_30_sup.h
Normal file
@@ -0,0 +1,17 @@
|
||||
#ifndef DEJAVU_30_SUP_H
|
||||
#define DEJAVU_30_SUP_H
|
||||
|
||||
/*Use UTF-8 encoding in the IDE*/
|
||||
|
||||
#include "misc_conf.h"
|
||||
|
||||
#if USE_FONT_DEJAVU_30_SUP != 0
|
||||
|
||||
#include <stdint.h>
|
||||
#include "lvgl/misc/gfx/font.h"
|
||||
|
||||
extern font_t font_dejavu_30_sup;
|
||||
|
||||
#endif /*USE_FONT_DEJAVU_30_SUP != 0*/
|
||||
|
||||
#endif /*DEJAVU_30_SUP_H*/
|
||||
4044
misc/gfx/fonts/dejavu_40.c
Normal file
4044
misc/gfx/fonts/dejavu_40.c
Normal file
File diff suppressed because it is too large
Load Diff
17
misc/gfx/fonts/dejavu_40.h
Normal file
17
misc/gfx/fonts/dejavu_40.h
Normal file
@@ -0,0 +1,17 @@
|
||||
#ifndef DEJAVU_40_H
|
||||
#define DEJAVU_40_H
|
||||
|
||||
/*Use UTF-8 encoding in the IDE*/
|
||||
|
||||
#include "misc_conf.h"
|
||||
|
||||
#if USE_FONT_DEJAVU_40 != 0
|
||||
|
||||
#include <stdint.h>
|
||||
#include "lvgl/misc/gfx/font.h"
|
||||
|
||||
extern font_t font_dejavu_40;
|
||||
|
||||
#endif /*USE_FONT_DEJAVU_40 != 0*/
|
||||
|
||||
#endif /*DEJAVU_40_H*/
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user