作者声明:
本文章主要介绍.jpg格式的图片集,自动化生成保存Flash的相关文件。如有疑问望共同讨论。本文章主要介绍一系列的脚本族,从而实现将.jpg图片转换成的.c进行处理。避免人为的操作,减少误操作及解放程序猿。
应用背景:
在消费级的电子产品中往往需要在显示屏上显示图片、文字增加产品的用户体验。尤其是高保真图片:占用存储空间见较大,以16位LCD显示屏为例:一张80*160的图片占用空间达25KB。因此我们希望将图片存储在外部FLASH中,以便节省MCU内部FLASH空间。一个带屏幕的电子产品可能要存储1000余张图片,那么将这些图片保存在FLASH的一系列数据将花费很大的工作量(FLASH地址、图片大小、图片对应.c的声明、写FLASH的接口、显示图片的接口)。下面我们来看下本人是如何解决此问题的。
工具脚本说明:
1. merge_auto.bat:
::*******************************************************************************************
:: Description: 此脚本的功能可以将同一层目录下的指定.c文件定向输出至同一.c文件中:
::
:: warning: 合并后的.c文件更名为公共名称;
:: 例如:
:: 待合并文件如下:
:: Jun_ch_Jan_37_20.c
:: Jun_en_ger_spain_35_18.c
:: Jun_fran_27_19.c
:: Jun_italy_33_19.c
::
:: 合并后文件命名如下:
:: Jun.c
::
:: Author: wujing wwx338541
::
:: Date: 2018.01.01
::*****************************************************************************************
::clean
::获取当前路径
set CURRENT_PATH=%CD%
::跳转至当前路径
cd /d %CURRENT_PATH%
::获取本层目录下.c文件名称列表,定向输出至FileName.txt
dir *.c /b >FileName.txt
::获取本层目录下.c文件的个数,将信息定向输出至FileNum.txt
findstr /n . FileName.txt|find /c /v "">FileNum.txt
::从FileNum.txt中获取到文件个数并保存到变量FILE_NUM
for /f "delims= tokens=1" %%i in ( FileNum.txt ) do set /a FILE_NUM=%%i
::自动获取合并后.c文件名称
for /f "delims=_ tokens=1" %%i in ( FileName.txt ) do set MERGE_FILE_NAME=%%i
del %MERGE_FILE_NAME%.c
::合并文件至MERGE_FILE_NAME.c中
for /f "delims=. tokens=1" %%i in ( FileName.txt ) do more %%i.c >> %MERGE_FILE_NAME%.c
::定义变量
::for /l %%i in ( 0, 1, %FILE_NUM% ) do set /a version%%i=%%i
::获取ciconfig.xml中 version 的值
::for /f "delims== tokens=2" %%i in ('findstr /b "version" ciconfig.xml') do set /a version=%%i
del FileName.txt FileNum.txt
2.1 filter_header_common.bat:
::*******************************************************************************************
:: Description: 将制作的字库源文件的数组名提取出来,存放在头文件中:自动在每行首添加extern
:: 自动过滤数组大小,自动添加分号;
:: warning: 将制作的字库源文件的数组名提取出来,存放在头文件中;
:: 例如:
:: 待合并文件如下:
:: icon_all.c
:: word_all.c
:: digit_num_all.c
::
:: 合并后文件命名如下:
:: icon_all.h
:: word_all.h
:: digit_num_all.h
::
::
:: Author: wujing wwx338541
:: Date: 2018.01.01
::*****************************************************************************************
::clean
rd /Q /S output
rd /Q /S ecc
rd /Q /S source_output
::rd /Q /S bin
del *.txt *.h
::获取当前路径
set CURRENT_PATH=%CD%
::跳转至当前路径
cd /d %CURRENT_PATH%
::获取本层目录下.c文件名称列表,定向输出至FileName.txt
dir *.c /b >FileName.txt
::自动获取合并后.c文件名称
for /f "delims=. tokens=1" %%i in ( FileName.txt ) do set MERGE_FILE_NAME=%%i
::过滤不需要的行
for /f "eol=0 delims== tokens=1" %%i in (%MERGE_FILE_NAME%.c) do @echo %%i>>temp0.txt
for /f "eol=* delims== tokens=1" %%i in (temp0.txt) do @echo %%i>>temp1.txt
for /f "eol= delims== tokens=1" %%i in (temp1.txt) do @echo %%i>>temp2.txt
for /f "eol=# delims== tokens=1" %%i in (temp2.txt) do @echo %%i>>temp3.txt
for /f "eol=/ delims== tokens=1" %%i in (temp3.txt) do @echo %%i>>temp4.txt
for /f "eol={ delims== tokens=1" %%i in (temp4.txt) do @echo %%i>>temp5.txt
for /f "eol=} delims== tokens=1" %%i in (temp5.txt) do @echo %%i>>%MERGE_FILE_NAME%_temp.txt
::*************************************生成后文件****************************************************
::提取数组名并在行首添加extern
for /f "delims== tokens=1" %%i in (%MERGE_FILE_NAME%_temp.txt) do @echo extern %%i>>%MERGE_FILE_NAME%_temp0.txt
::在行尾添加[];
for /f "delims=[ tokens=1" %%i in (%MERGE_FILE_NAME%_temp0.txt) do @echo %%i[];>>%MERGE_FILE_NAME%_temp1.txt
::删除掉原头文件%MERGE_FILE_NAME%.txt
del %MERGE_FILE_NAME%_temp0.txt
del temp0.txt temp1.txt temp2.txt temp3.txt temp4.txt temp5.txt FileName.txt
::目标头文件重新命名
ren %MERGE_FILE_NAME%_temp1.txt %MERGE_FILE_NAME%_header.h
::****************************************提取图片大小和宏名称*****************************************
::提取数组大小
for /f "delims=[ tokens=2" %%i in (%MERGE_FILE_NAME%_temp.txt) do @echo %%i>>%MERGE_FILE_NAME%_temp0.txt
for /f "delims=] tokens=1" %%i in (%MERGE_FILE_NAME%_temp0.txt) do @echo %%i >>%MERGE_FILE_NAME%_macrosize.xml
del %MERGE_FILE_NAME%_temp0.txt
::提取Flash地址宏名
for /f "tokens=4" %%i in (%MERGE_FILE_NAME%_temp.txt) do @echo %%i>>%MERGE_FILE_NAME%_temp0.txt
for /f "delims=[ tokens=1" %%i in (%MERGE_FILE_NAME%_temp0.txt) do @echo %%i_SIZE>>%MERGE_FILE_NAME%_macroname.txt
for /f "delims=[ tokens=1" %%i in (%MERGE_FILE_NAME%_temp0.txt) do @echo #define %%i_SIZE >>%MERGE_FILE_NAME%_macroname_define.txt
::insert a line which is "wujing start flash address"
set line=0
echo + wujing_start_flash_address>%MERGE_FILE_NAME%_macroname_offset.txt
for /f "delims=" %%i in (%MERGE_FILE_NAME%_macroname.txt) do (
set /a line+=1
@echo + %%i>>%MERGE_FILE_NAME%_macroname_offset.txt
)
::删除中间件 %MERGE_FILE_NAME%_macroname.txt
del %MERGE_FILE_NAME%_temp0.txt
::*****************************************将大小和名称合并************************************************
::合并文件生成flash地址 策略1
::合并文件生成flash地址 策略2
@echo off&setlocal enabledelayedexpansion
set fn=%MERGE_FILE_NAME%_macroname_define.txt,%MERGE_FILE_NAME%_macrosize.xml
for %%i in (%fn%) do (set "n=0"
for /f "usebackq delims=" %%j in ("%%~i") do (
set /a n+=1&call set "#!n!=%%#!n!%%%%j"
)
)
:re
set /a n+=1
if defined #!n! goto re
set /a n-=1
(for /l %%h in (1,1,%n%) do set #%%h=!#%%h:~,-1!&echo !#%%h!)>%MERGE_FILE_NAME%_macro_define_file.h
::%MERGE_FILE_NAME%_macroname.txt
::del %MERGE_FILE_NAME%_macrosize.txt
::ren %MERGE_FILE_NAME%_macro.txt %MERGE_FILE_NAME%_macrosize.txt
::*****************************************************************************************
::create flash address macro
for /f "tokens=4" %%i in (%MERGE_FILE_NAME%_temp.txt) do @echo %%i>>%MERGE_FILE_NAME%_temp0.txt
for /f "delims=[ tokens=1" %%i in (%MERGE_FILE_NAME%_temp0.txt) do @echo %%i_Flash_Adr>>%MERGE_FILE_NAME%_FlashAddr_macro.txt
for /f "delims=[ tokens=1" %%i in (%MERGE_FILE_NAME%_temp0.txt) do @echo #define %%i_Flash_Adr >>%MERGE_FILE_NAME%_FlashAddr_define.txt
::删除中间件
del %MERGE_FILE_NAME%_temp0.txt %MERGE_FILE_NAME%_temp.txt
::insert a line which is "wujing start flash address"
set line=0
echo wujing_start_flash_address>%MERGE_FILE_NAME%_FlashAddr_offset.txt
for /f "delims=" %%i in (%MERGE_FILE_NAME%_FlashAddr_macro.txt) do (
set /a line+=1
echo %%i >>%MERGE_FILE_NAME%_FlashAddr_offset.txt
)
::call merge_flash_addr_demo.bat %MERGE_FILE_NAME%_FlashAddr_define.txt %MERGE_FILE_NAME%_FlashAddr_temp.txt
::pause
::*****************************************************************************************
::packaging flash address macro strategy1
::packaging flash address macro strategy2
::set fn=%MERGE_FILE_NAME%_FlashAddr_define.txt,%MERGE_FILE_NAME%_FlashAddr_temp.txt
::for %%i in (%fn%) do (set "n=0"
:: for /f "usebackq delims=" %%j in ("%%~i") do (
:: set /a n+=1&call set "#!n!=%%#!n!%%%%j"
:: )
::)
:::rew
::set /a n+=1
::if defined #!n! goto rew
::set /a n-=1
::(for /l %%h in (1,1,%n%) do set #%%h=!#%%h:~,-1!&echo !#%%h!)>%MERGE_FILE_NAME%_AddrMerge.txt
::for /f "delims=# tokens=2" %%i in (%MERGE_FILE_NAME%_AddrMerge.txt) do @echo #%%i>>1.txt
::回显输出文件
::start 1.txt
2.2 merge_flash_addr_demo1.bat:
::*******************************************************************************************
:: Description: 将制作的字库头文件,根据数组名生成Flash地址
::
:: warning: 本脚本只需一键执行
:: 例如:
:: 待合并文件如下:
:: 合并地址(未加图片大小)
:: 形如:#define gImage_digit_num1_6_12_Flash_Adr gImage_digit_num0_6_12_Flash_Adr
:: Author: wujing wwx338541
:: Date: 2018.01.01
::*****************************************************************************************
::获取本层目录下.c文件名称列表,定向输出至FileName.txt
dir *.c /b >FileName.txt
::自动获取合并后.c文件名称
for /f "delims=. tokens=1" %%i in ( FileName.txt ) do set CURRENT_FILE=%%i
@echo off&setlocal enabledelayedexpansion
set fn=%CURRENT_FILE%_FlashAddr_define.txt,%CURRENT_FILE%_FlashAddr_offset.txt
for %%i in (%fn%) do (set "n=0"
for /f "usebackq delims=" %%j in ("%%~i") do (
set /a n+=1&call set "#!n!=%%#!n!%%%%j"
)
)
:re
set /a n+=1
if defined #!n! goto re
set /a n-=1
(for /l %%h in (1,1,%n%) do set #%%h=!#%%h:~,-1!&echo !#%%h!)>%CURRENT_FILE%_FlashAddr_combo.txt
del %CURRENT_FILE%_FlashAddr_define.txt %CURRENT_FILE%_FlashAddr_offset.txt FileName.txt
::start %CURRENT_FILE%_FlashAddr_combo.txt
2.3 merge_flash_addr_demo2.bat:
::*******************************************************************************************
:: Description: 将制作的字库头文件,根据数组名生成Flash地址
::
:: warning: 本脚本只需一键执行
:: 例如:
:: 待合并文件如下:
:: 合并地址(添加图片大小)
:: 形如:#define gImage_digit_num1_6_12_Flash_Adr gImage_digit_num0_6_12_Flash_Adr + gImage_digit_num0_6_12_SIZE
:: Author: wujing wwx338541
:: Date: 2018.01.01
::*****************************************************************************************
::get current path
set CURRENT_PATH=%CD%
::get c file while in current path and output it to which name is FileName
dir *.c /b >FileName.txt
:: auto get merge C file name
for /f "delims=. tokens=1" %%i in ( FileName.txt ) do set CURRENT_FILE=%%i
@echo off&setlocal enabledelayedexpansion
set fn=%CURRENT_FILE%_FlashAddr_combo.txt,%CURRENT_FILE%_macroname_offset.txt
for %%i in (%fn%) do (set "n=0"
for /f "usebackq delims=" %%j in ("%%~i") do (
set /a n+=1&call set "#!n!=%%#!n!%%%%j"
)
)
:rew
set /a n+=1
if defined #!n! goto rew
set /a n-=1
(for /l %%h in (1,1,%n%) do set #%%h=!#%%h:~,-1!&echo !#%%h!)>%CURRENT_FILE%_macro.txt
for /f "delims=" %%i in (%CURRENT_FILE%_macro.txt) do echo %%iE>>%CURRENT_FILE%_macro.h
2.4 merge.bat:
::******************************************************************
:: wwx338541
:: wujing
:: 2018.01.07
:: two file intersect merge and output
::******************************************************************
@echo off&setlocal enabledelayedexpansion
::get current path
set CURRENT_PATH=%CD%
::get c file while in current path and output it to which name is FileName
dir *.c /b >FileName.txt
:: auto get merge C file name
for /f "delims=. tokens=1" %%i in ( FileName.txt ) do set CURRENT_FILE=%%i
for /f "delims=" %%i in (%CURRENT_FILE%_macro.h) do (echo.,&echo %%i)>>147.txt
for /f "delims=" %%i in (%CURRENT_FILE%_macro_define_file.h) do (echo %%i &echo.,)>>148.txt
@echo off&setlocal enabledelayedexpansion
set fn=147.txt,148.txt
for %%i in (%fn%) do (set "n=0"
for /f "usebackq delims=" %%j in ("%%~i") do (
set /a n+=1&call set "#!n!=%%#!n!%%%%j"
)
)
:re
set /a n+=1
if defined #!n! goto re
set /a n-=1
(for /l %%h in (1,1,%n%) do set #%%h=!#%%h:~,-1!&echo !#%%h!)>149.txt
for /f "delims=, tokens=1" %%i in (149.txt) do @echo %%i>>%CURRENT_FILE%_macro_intersect.h
mkdir output
mkdir ecc
mkdir source_output
del %CURRENT_FILE%_macro_intersect.h
copy /y %CURRENT_PATH%\%CURRENT_FILE%_macro_define_file.h %CURRENT_PATH%\source_output
copy /y %CURRENT_PATH%\%CURRENT_FILE%_macro.h %CURRENT_PATH%\source_output
move /y *.h %CURRENT_PATH%/output
del *.txt
::start %CURRENT_FILE%_macro.h
2.5 create_write_flash_interface.bat:
::*******************************************************************************************
:: Description: 根据字库源文件*.c自动生成写Flash的C语言代码
::
:: warning: 将字库源文件放在与此脚本同级目录下,双击执行此脚本即可生成写字库代码
::
::
:: Author: wujing wwx338541
:: Date: 2018.01.04
::*****************************************************************************************
::clean
::get current path
set CURRENT_PATH=%CD%
::jump to current path
cd /d %CURRENT_PATH%
::get c file while in current path and output it to which name is FileName
dir *.c /b >FileName.txt
:: auto get merge C file name
for /f "delims=. tokens=1" %%i in ( FileName.txt ) do set MERGE_FILE_NAME=%%i
::filter unused line
for /f "eol=0 delims== tokens=1" %%i in (%MERGE_FILE_NAME%.c) do @echo %%i>>temp0.txt
for /f "eol=* delims== tokens=1" %%i in (temp0.txt) do @echo %%i>>temp1.txt
for /f "eol= delims== tokens=1" %%i in (temp1.txt) do @echo %%i>>temp2.txt
for /f "eol=# delims== tokens=1" %%i in (temp2.txt) do @echo %%i>>temp3.txt
for /f "eol=/ delims== tokens=1" %%i in (temp3.txt) do @echo %%i>>temp4.txt
for /f "eol=} delims== tokens=1" %%i in (temp4.txt) do @echo %%i>>%MERGE_FILE_NAME%_temp.txt
::**************************** create write flash interface **********************************
::filter array info
for /f "tokens=4" %%i in (%MERGE_FILE_NAME%_temp.txt) do @echo %%i>>%MERGE_FILE_NAME%_temp0.txt
::filter array name and store
for /f "delims=[ tokens=1" %%i in (%MERGE_FILE_NAME%_temp0.txt) do @echo %%i >>%MERGE_FILE_NAME%_array_name.xml
::filter array name
for /f "delims=[ tokens=1" %%i in (%MERGE_FILE_NAME%_temp0.txt) do @echo %%i>>%MERGE_FILE_NAME%_name.h
::call filter_icon_width.bat
::pause
::call filter_icon_width_higt.bat
::pause
for /f "delims=[ tokens=1" %%i in (%MERGE_FILE_NAME%_temp0.txt) do @echo Lcd_Flash((uint8_t *)%%i, %%i_Flash_Adr, >>%MERGE_FILE_NAME%_flash.h
for /f "delims=[ tokens=1" %%i in (%MERGE_FILE_NAME%_temp0.txt) do @echo Lcd_ShowImage(%%i_Flash_Adr, (80->>%MERGE_FILE_NAME%_ShowImage_temp.h
del *.txt
::package output file
::mkdir output
::move /y %MERGE_FILE_NAME%_flash.c %CURRENT_PATH%/output
::move /y %MERGE_FILE_NAME%_ShowImage.c %CURRENT_PATH%/output
::del *.txt
::open %MERGE_FILE_NAME%_flash.c
::start %MERGE_FILE_NAME%_flash.c
filter_icon_higt.bat:
:: warning: auto get picture`s width & higt
::
::
:: Author: wujing wwx338541
:: Date: 2018.01.05
::*****************************************************************************************
@echo off
::get current path
set CURRENT_PATH=%CD%
::jump to current path
cd /d %CURRENT_PATH%
::get c file while in current path and output it to which name is FileName
dir *.c /b >FileName2.txt
:: auto get merge C file name
for /f "delims=. tokens=1" %%i in ( FileName2.txt ) do set MERGE_FILE_NAME=%%i
for /f "delims=" %%i in (%MERGE_FILE_NAME%_name.h) do (set "height=%%i"&call:higt)
pause
for /f "delims=_ tokens=1" %%i in (%MERGE_FILE_NAME%_icon_higt.txt) do @echo%%i); >>%MERGE_FILE_NAME%_higt.h
:higt
set height=%height:~-2,2%
echo. %height%>>%MERGE_FILE_NAME%_icon_higt.txt
2.6 filter_icon_width.bat:
::*****************************************************************************************
:: warning: auto get picture`s width & higt
::
::
:: Author: wujing wwx338541
:: Date: 2018.01.05
::*****************************************************************************************
@echo off
::get current path
set CURRENT_PATH=%CD%
::jump to current path
cd /d %CURRENT_PATH%
::get c file while in current path and output it to which name is FileName
dir *.c /b >FileName1.txt
:: auto get merge C file name
for /f "delims=. tokens=1" %%i in ( FileName1.txt ) do set MERGE_FILE_NAME=%%i
for /f "delims=" %%i in (%MERGE_FILE_NAME%_name.h) do (set "width=%%i"&call:wide)
for /f "delims=_ tokens=1" %%i in (%MERGE_FILE_NAME%_wide.txt) do @echo %%i)/2, 0, >>%MERGE_FILE_NAME%_wide1.h
for /f "delims=_ tokens=1" %%i in (%MERGE_FILE_NAME%_wide.txt) do @echo %%i, >>%MERGE_FILE_NAME%_wide.h
del FileName1.txt
:wide
set width=%width:~-5,3%
echo.%width%>>%MERGE_FILE_NAME%_wide.txt
2.7 merge_wide.bat:
::*****************************************************************************************
:: warning: auto get picture`s width & higt
::
::
:: Author: wujing wwx338541
:: Date: 2018.01.05
::*****************************************************************************************
@echo on
::get current path
set CURRENT_PATH=%CD%
::jump to current path
cd /d %CURRENT_PATH%
::get c file while in current path and output it to which name is FileName
dir *.c /b >FileName.txt
:: auto get merge C file name
for /f "delims=. tokens=1" %%i in ( FileName.txt ) do set MERGE_FILE_NAME=%%i
@echo off&setlocal enabledelayedexpansion
set fn=%MERGE_FILE_NAME%_ShowImage_temp.h,%MERGE_FILE_NAME%_wide1.h
for %%i in (%fn%) do (set "n=0"
for /f "usebackq delims=" %%j in ("%%~i") do (
set /a n+=1&call set "#!n!=%%#!n!%%%%j"
)
)
:re
set /a n+=1
if defined #!n! goto re
set /a n-=1
(for /l %%h in (1,1,%n%) do set #%%h=!#%%h:~,-1!&echo !#%%h!)>%MERGE_FILE_NAME%_ShowImage.h
2.8 filter_icon_width_higt.bat:
::*****************************************************************************************
:: warning: auto get picture's width & higt
::
::
:: Author: wujing wwx338541
:: Date: 2018.03.08
::*****************************************************************************************
@echo off
::get current path
set CURRENT_PATH=%CD%
::jump to current path
cd /d %CURRENT_PATH%
::get c file while in current path and output it to which name is FileName
dir *.c /b >FileName2.txt
:: auto get merge C file name
for /f "delims=. tokens=1" %%i in ( FileName2.txt ) do set MERGE_FILE_NAME=%%i
for /f "delims=" %%i in (%MERGE_FILE_NAME%_name.h) do (set "height=%%i"&call:higt)
for /f "delims=_ tokens=2,3" %%i in (%MERGE_FILE_NAME%_icon_higt_width.txt) do @echo %%i %%j >>%MERGE_FILE_NAME%_ecc.xml
::move /y %MERGE_FILE_NAME%_ecc.xml %CURRENT_PATH%/ecc
:higt
set height=%height:~-6,6%
echo. %height% >>%MERGE_FILE_NAME%_icon_higt_width.txt
2.9 merge_flash_image1.bat:
::*****************************************************************************************
:: warning: auto get picture`s width & higt
::
::
:: Author: wujing wwx338541
:: Date: 2018.01.05
::*****************************************************************************************
@echo off
::get current path
set CURRENT_PATH=%CD%
::jump to current path
cd /d %CURRENT_PATH%
::get c file while in current path and output it to which name is FileName
dir *.c /b >FileName.txt
:: auto get merge C file name
for /f "delims=. tokens=1" %%i in ( FileName.txt ) do set MERGE_FILE_NAME=%%i
@echo off&setlocal enabledelayedexpansion
set fn=%MERGE_FILE_NAME%_wide.h,%MERGE_FILE_NAME%_higt.h
for %%i in (%fn%) do (set "n=0"
for /f "usebackq delims=" %%j in ("%%~i") do (
set /a n+=1&call set "#!n!=%%#!n!%%%%j"
)
)
:re
set /a n+=1
if defined #!n! goto re
set /a n-=1
(for /l %%h in (1,1,%n%) do set #%%h=!#%%h:~,-1!&echo !#%%h!)>%MERGE_FILE_NAME%_width_higt.h
del *.txt
2.10 merge_flash_image2.bat:
::*****************************************************************************************
:: warning: auto get picture`s width & higt
::
::
:: Author: wujing wwx338541
:: Date: 2018.01.05
::*****************************************************************************************
@echo on
::get current path
set CURRENT_PATH=%CD%
::mkdir output
::jump to current path
cd /d %CURRENT_PATH%
::get c file while in current path and output it to which name is FileName
dir *.c /b >FileName.txt
:: auto get merge C file name
for /f "delims=. tokens=1" %%i in ( FileName.txt ) do set MERGE_FILE_NAME=%%i
@echo off&setlocal enabledelayedexpansion
set fn=%MERGE_FILE_NAME%_flash.h,%MERGE_FILE_NAME%_width_higt.h
for %%i in (%fn%) do (set "n=0"
for /f "usebackq delims=" %%j in ("%%~i") do (
set /a n+=1&call set "#!n!=%%#!n!%%%%j"
)
)
:re
set /a n+=1
if defined #!n! goto re
set /a n-=1
(for /l %%h in (1,1,%n%) do set #%%h=!#%%h:~,-1!&echo !#%%h!)>%MERGE_FILE_NAME%_lcd_flash.c
move /y %MERGE_FILE_NAME%_lcd_flash.c %CURRENT_PATH%/output
del *.txt
2.11 merge_flash_image3.bat:
::*****************************************************************************************
:: warning: auto get picture`s width & higt
::
::
:: Author: wujing wwx338541
:: Date: 2018.01.05
::*****************************************************************************************
@echo on
::get current path
set CURRENT_PATH=%CD%
::jump to current path
cd /d %CURRENT_PATH%
::get c file while in current path and output it to which name is FileName
dir *.c /b >FileName.txt
:: auto get merge C file name
for /f "delims=. tokens=1" %%i in ( FileName.txt ) do set MERGE_FILE_NAME=%%i
@echo off&setlocal enabledelayedexpansion
set fn=%MERGE_FILE_NAME%_ShowImage.h,%MERGE_FILE_NAME%_width_higt.h
for %%i in (%fn%) do (set "n=0"
for /f "usebackq delims=" %%j in ("%%~i") do (
set /a n+=1&call set "#!n!=%%#!n!%%%%j"
)
)
:re
set /a n+=1
if defined #!n! goto re
set /a n-=1
(for /l %%h in (1,1,%n%) do set #%%h=!#%%h:~,-1!&echo !#%%h!)>%MERGE_FILE_NAME%_Lcd_ShowImage.c
move /y %MERGE_FILE_NAME%_Lcd_ShowImage.c %CURRENT_PATH%/output
del *.h *.txt
2.12 ecc.bat:
::*******************************************************************************************
:: Description: 根据图片的命名校验图片大小是否有命名错误
::
:: warning:
::
::
:: Author: wujing wwx338541
:: Date: 2018.03.08
::*****************************************************************************************
::get current path
set CURRENT_PATH=%CD%
::get c file while in current path and output it to which name is FileName
dir *.c /b >FileName.txt
:: auto get merge C file name
for /f "delims=. tokens=1" %%i in ( FileName.txt ) do set CURRENT_FILE=%%i
::del %CURRENT_FILE%_ecc.xml
@echo off&setlocal enabledelayedexpansion
set fn=%CURRENT_FILE%_macrosize.xml, %CURRENT_FILE%_array_name.xml
for %%i in (%fn%) do (set "n=0"
for /f "usebackq delims=" %%j in ("%%~i") do (
set /a n+=1&call set "#!n!=%%#!n!%%%%j"
)
)
:rew
set /a n+=1
if defined #!n! goto rew
set /a n-=1
(for /l %%h in (1,1,%n%) do set #%%h=!#%%h:~,-1!&echo !#%%h!)>image_size_name.xml
move /y image_size_name.xml %CURRENT_PATH%/ecc
del *.txt %CURRENT_FILE%_array_name.xml %CURRENT_FILE%_macrosize.xml
2.13 process_icon_ecc.bat:
::*******************************************************************************************
:: Description: 根据图片的命名校验图片大小是否有命名错误
::
:: warning:
::
::
:: Author: wujing wwx338541
:: Date: 2018.03.08
::*****************************************************************************************
@echo off
::get current path
set CURRENT_PATH=%CD%
::jump to current path
cd /d %CURRENT_PATH%
@echo off&setlocal enabledelayedexpansion
::get c file while in current path and output it to which name is FileName
dir *.c /b >FileName1.txt
:: auto get merge C file name
for /f "delims=. tokens=1" %%i in ( FileName1.txt ) do set MERGE_FILE_NAME=%%i
for /f "tokens=1,2" %%a in (%MERGE_FILE_NAME%_ecc.xml) do (
set /a temp=%%a*%%b*2
>>image_all_ecc_wuj.xml echo !temp! %%a %%b
)
move /y image_all_ecc_wuj.xml %CURRENT_PATH%/ecc
del FileName1.txt %MERGE_FILE_NAME%_ecc.xml
echo ecc finished!!!
2.14 combo_hex.bat:
::*******************************************************************************************
:: Description: 将制作的字库源文件中,字库数组成员合并
:: warning: 注意.c源文件的顺序和Flash_Addr的地址一致,否则后果自负
:: 例如:
:: 待合并文件如下:
:: icon_all.c
:: word_all.c
::
:: const uint8_t m_Russia_Ukraine_speed_64_16[]=
:: {
:: /*-- speed_Russia_Ukraine_64_16.bmp --*/
:: /*-- width x higt=128x16 --*/
:: 0x00,0xC0,0x20,0x10,0x10,0x10,0x00,0x00,0xF0,0x80,0xC0,0x40,0x20,0x10,0x00,0x00,
:: 0xC0,0x20,0x10,0x10,0x10,0x20,0xC0,0x00,0x00,0xF0,0x20,0x10,0x10,0x10,0x30,0xC0,
:: 0x00,0x00,0xC0,0x20,0x10,0x10,0x10,0x20,0xC0,0x00,0x00,0xC0,0x20,0x10,0x10,0x10,
:: 0x00,0x10,0x10,0xF0,0x10,0x10,0x00,0x00,0xF0,0x80,0x80,0x80,0x80,0x00,0x00,0x00,
:: 0x00,0x00,0x00,0xF0,0x00,0x00,0x00,0xF0,0x00,0x00,0x00,0xF0,0x00,0x00,0xF0,0x90,
:: 0x90,0x90,0x90,0x60,0x00,0xF0,0x00,0x00,0xC0,0x60,0xF0,0x00,0x00,0x00,0xF0,0x10,
:: 0xF0,0x00,0x00,0xF0,0x80,0xC0,0x40,0x20,0x10,0x00,0xF6,0x06,0x00,0xC0,0x20,0x10,
:: 0x10,0x10,0x10,0x10,0xF0,0x10,0x10,0x00,0xF0,0x80,0x80,0x80,0x80,0x00,0x00,0x00,
:: 0x00,0x03,0x0C,0x08,0x08,0x08,0x00,0x00,0x0F,0x01,0x01,0x02,0x04,0x08,0x00,0x00,
:: 0x03,0x04,0x08,0x08,0x08,0x04,0x03,0x00,0x00,0x7F,0x04,0x08,0x08,0x08,0x04,0x03,
:: 0x00,0x00,0x03,0x04,0x08,0x08,0x08,0x04,0x03,0x00,0x00,0x03,0x0C,0x08,0x08,0x08,
:: 0x00,0x00,0x00,0x0F,0x00,0x00,0x00,0x00,0x0F,0x08,0x08,0x08,0x08,0x07,0x00,0x00,
:: 0x00,0x00,0x00,0x0F,0x08,0x08,0x08,0x0F,0x08,0x08,0x08,0x0F,0x00,0x00,0x0F,0x08,
:: 0x08,0x08,0x08,0x07,0x00,0x0F,0x06,0x03,0x00,0x00,0x0F,0x78,0x0C,0x0B,0x08,0x08,
:: 0x0F,0x78,0x00,0x0F,0x01,0x01,0x02,0x04,0x08,0x00,0x0F,0x00,0x00,0x03,0x0C,0x08,
:: 0x08,0x08,0x00,0x00,0x0F,0x00,0x00,0x00,0x0F,0x08,0x08,0x08,0x08,0x07,0x00,0x00
:: };
:: const uint8_t m_Russia_Ukraine_reset_64_16[]=
:: {
:: /*-- speed_Russia_Ukraine_64_16.bmp --*/
:: /*-- width x higt=128x16 --*/
:: 0x00,0xC0,0x20,0x10,0x10,0x10,0x00,0x00,0xF0,0x80,0xC0,0x40,0x20,0x10,0x00,0x00,
:: 0xC0,0x20,0x10,0x10,0x10,0x20,0xC0,0x00,0x00,0xF0,0x20,0x10,0x10,0x10,0x30,0xC0,
:: 0x00,0x00,0xC0,0x20,0x10,0x10,0x10,0x20,0xC0,0x00,0x00,0xC0,0x20,0x10,0x10,0x10,
:: 0x00,0x10,0x10,0xF0,0x10,0x10,0x00,0x00,0xF0,0x80,0x80,0x80,0x80,0x00,0x00,0x00,
:: 0x00,0x00,0x00,0xF0,0x00,0x00,0x00,0xF0,0x00,0x00,0x00,0xF0,0x00,0x00,0xF0,0x90,
:: 0x90,0x90,0x90,0x60,0x00,0xF0,0x00,0x00,0xC0,0x60,0xF0,0x00,0x00,0x00,0xF0,0x10,
:: 0xF0,0x00,0x00,0xF0,0x80,0xC0,0x40,0x20,0x10,0x00,0xF6,0x06,0x00,0xC0,0x20,0x10,
:: 0x10,0x10,0x10,0x10,0xF0,0x10,0x10,0x00,0xF0,0x80,0x80,0x80,0x80,0x00,0x00,0x00,
:: 0x00,0x03,0x0C,0x08,0x08,0x08,0x00,0x00,0x0F,0x01,0x01,0x02,0x04,0x08,0x00,0x00,
:: 0x03,0x04,0x08,0x08,0x08,0x04,0x03,0x00,0x00,0x7F,0x04,0x08,0x08,0x08,0x04,0x03,
:: 0x00,0x00,0x03,0x04,0x08,0x08,0x08,0x04,0x03,0x00,0x00,0x03,0x0C,0x08,0x08,0x08,
:: 0x00,0x00,0x00,0x0F,0x00,0x00,0x00,0x00,0x0F,0x08,0x08,0x08,0x08,0x07,0x00,0x00,
:: 0x00,0x00,0x00,0x0F,0x08,0x08,0x08,0x0F,0x08,0x08,0x08,0x0F,0x00,0x00,0x0F,0x08,
:: 0x08,0x08,0x08,0x07,0x00,0x0F,0x06,0x03,0x00,0x00,0x0F,0x78,0x0C,0x0B,0x08,0x08,
:: 0x0F,0x78,0x00,0x0F,0x01,0x01,0x02,0x04,0x08,0x00,0x0F,0x00,0x00,0x03,0x0C,0x08,
:: 0x08,0x08,0x00,0x00,0x0F,0x00,0x00,0x00,0x0F,0x08,0x08,0x08,0x08,0x07,0x00,0x00
:: };
::
:: Author: wujing wwx338541
:: Date: 2018.01.09
::*****************************************************************************************
::clean
::获取当前路径
set CURRENT_PATH=%CD%
::跳转至当前路径
cd /d %CURRENT_PATH%
::获取本层目录下.c文件名称列表,定向输出至FileName.txt
dir *.c /b >FileName.txt
::自动获取合并后.c文件名称
for /f "delims=. tokens=1" %%i in ( FileName.txt ) do set MERGE_FILE_NAME=%%i
::过滤不需要的行
for /f "eol=c" %%i in (%MERGE_FILE_NAME%.c) do @echo %%i>>temp0.txt
for /f "eol=/ delims== tokens=1" %%i in (temp0.txt) do @echo %%i>>temp1.txt
for /f "eol={ delims== tokens=1" %%i in (temp1.txt) do @echo %%i>>temp2.txt
for /f "eol=#" %%i in (temp2.txt) do @echo %%i>>temp3.txt
for /f "delims=} tokens=1" %%i in (temp3.txt) do @echo %%i>>%MERGE_FILE_NAME%_hex.txt
mkdir bin
move /y *.c %CD%/output
move /y %MERGE_FILE_NAME%_hex.txt %CD%/bin
del *.txt
2.15 finish.bat:
::*******************************************************************************************
:: Description: 根据字库源文件*.c自动生成写Flash的C语言代码
::
:: warning: 将字库源文件放在与此脚本同级目录下,双击执行此脚本即可生成写字库代码
::
::
:: Author: wujing wwx338541 vbYesNo vbokcancel
:: Date: 2018.01.04
::*****************************************************************************************
@echo off&set Q=&set vbs=Questiontmp.vbs
echo Wsh.Echo MsgBox(" create icon info finished!!! ", vbOKOnly, "icon flash info")>%vbs%
for /f %%a in ('cscript %vbs% //nologo //e:vbscript') do set "Q=%%a"
::if %Q%==1 del /q /f %vbs%>nul&goto Yes
::if %Q%==2 del /q /f %vbs%>nul&goto No
::if %Q%==3 del /q /f %vbs%>nul&goto Cancel
del /q /f %vbs%>nul
exit
:Yes
cd /d %CD%\auto_create_interface
start make.bat
exit
:No
start merge_auto.bat
exit
:Cancel
exit
3 make.bat:
::*******************************************************************************************
:: Description: 根据字库源文件*.c自动生成写Flash的C语言代码
::
:: warning: 将字库源文件放在与此脚本同级目录下,双击执行此脚本即可生成写字库代码
::
::
:: Author: wujing wwx338541
:: Date: 2018.01.04
::*****************************************************************************************
call filter_header_common.bat
call merge_flash_addr_demo1.bat
call merge_flash_addr_demo2.bat
call merge.bat
call create_write_flash_interface.bat
call filter_icon_higt.bat
call filter_icon_width.bat
call merge_wide.bat
call filter_icon_width_higt.bat
call merge_flash_image1.bat
call merge_flash_image2.bat
call merge_flash_image3.bat
call ecc.bat
call process_icon_ecc.bat
call combo_hex.bat
call finish.bat
exit
4 enter.bat:
::*******************************************************************************************
:: Description: 根据字库源文件*.c自动生成写Flash的C语言代码
::
:: warning: 将字库源文件放在与此脚本同级目录下,双击执行此脚本即可生成写字库代码
::
::
:: Author: wujing wwx338541
:: Date: 2018.01.04
::*****************************************************************************************
@echo off&set Q=&set vbs=Questiontmp.vbs
echo Wsh.Echo MsgBox("are you want merge c file or filter source file's info ???", vbokcancel, "wwx338541")>%vbs%
for /f %%a in ('cscript %vbs% //nologo //e:vbscript') do set "Q=%%a"
if %Q%==1 del /q /f %vbs%>nul&goto Yes
if %Q%==2 del /q /f %vbs%>nul&goto No
if %Q%==3 del /q /f %vbs%>nul&goto Cancel
del /q /f %vbs%>nul
exit
:Yes
cd /d %CD%\auto_create_interface
start make.bat
exit
:No
start merge_auto.bat
exit
:Cancel
exit
5. 脚本输出:
5.1 bin文件夹
输出图片的所有16进制数据以便通过此文件生成.bin文件;
5.2 ecc文件夹
校验图片的生成数据是哦否正确;
5.3 output文件夹
写FLASH所需要的所有信息;
5.4 source_output文件夹
显示FLASH图片所需要的所有信息。
总结:此文章为本人在工作中遇到的实际问题,相处的解决方法。希望对遇到同等困难的同学有所帮助。