
@echo off
setlocal

set PATH=MCUXpressoIDE\bin;%PATH%

cd /D "%~dp0"

call :disp_menu
goto :EOF

:select_resolution
echo.
echo You selected to use %1
echo.
SET WANTED_RES=%1
goto :prog_menu

:flash
crt_emu_cm_redlink -g --flash-load-exec %WANTED_RES%\%1 -p MIMXRT1176xxxxx --ConnectScript RT1170_connect_M7_wake_M4.scp -x . --resetscript=RT1170_reset.scp
goto :EOF

:disp_menu
echo.
echo Select display/resolution to use
echo.
echo 0 - MIPI_PANEL_RK055AHD091
echo 1 - MIPI_PANEL_RK055IQH091
echo 2 - MIPI_PANEL_RK055MHD091
echo 3 - MIPI_PANEL_RK043FN02HC
echo 4 - MIPI_PANEL_KD050WVTPA045
echo 5 - MIPI_PANEL_NHD50800480TFATXL
echo 6 - MIPI_PANEL_HDMI_720X480_60
echo 7 - MIPI_PANEL_HDMI_720X576_50
echo 8 - MIPI_PANEL_HDMI_800X480_60
echo 9 - MIPI_PANEL_HDMI_1024X600_76
echo a - MIPI_PANEL_HDMI_1024X768_60
echo b - MIPI_PANEL_HDMI_1280X720_60
echo.
echo q - quit
echo.
set M=-
set /P M=Type 0..b or q then press ENTER:
if %M%==0 ( call :select_resolution MIPI_PANEL_RK055AHD091
          goto :disp_menu )
if %M%==1 ( call :select_resolution MIPI_PANEL_RK055IQH091
          goto :disp_menu )
if %M%==2 ( call :select_resolution MIPI_PANEL_RK055MHD091
          goto :disp_menu )
if %M%==3 ( call :select_resolution MIPI_PANEL_RK043FN02HC
          goto :disp_menu )
if %M%==4 ( call :select_resolution MIPI_PANEL_KD050WVTPA045
          goto :disp_menu )
if %M%==5 ( call :select_resolution MIPI_PANEL_NHD50800480TFATXL
          goto :disp_menu )
if %M%==6 ( call :select_resolution MIPI_PANEL_HDMI_720X480_60
          goto :disp_menu )
if %M%==7 ( call :select_resolution MIPI_PANEL_HDMI_720X576_50
          goto :disp_menu )
if %M%==8 ( call :select_resolution MIPI_PANEL_HDMI_800X480_60
          goto :disp_menu )
if %M%==9 ( call :select_resolution MIPI_PANEL_HDMI_1024X600_76
          goto :disp_menu )
if %M%==a ( call :select_resolution MIPI_PANEL_HDMI_1024X768_60
          goto :disp_menu )
if %M%==b ( call :select_resolution MIPI_PANEL_HDMI_1280X720_60
          goto :disp_menu )
if %M%==q goto :EOF
echo.
echo Unknown option selected %M%
echo.
goto :disp_menu


:prog_menu
echo.
echo Select program to flash
echo.
echo 0 - camera
echo 1 - chess
echo 2 - font_bindings
echo 3 - font_quality
echo 4 - font_quality_all_glyphs
echo 5 - freertos_app_switch
echo 6 - freertos_multitask
echo 7 - image_cache
echo 8 - image_loading
echo 9 - interrupt_handler
echo a - layers
echo b - listmodel
echo c - minimal
echo d - motor_cluster
echo e - multiscreen
echo f - painteditem
echo g - perspective_transforms
echo h - shapes
echo i - styling_default
echo j - swipe_game
echo k - timeline
echo l - translation_all
echo m - translation_lv
echo n - translation_spark
echo.
echo q - quit
echo.
set M=-
set /P M=Type 0..n or q then press ENTER:
if %M%==0 ( call :flash camera.elf
          goto :prog_menu )
if %M%==1 ( call :flash chess.elf
          goto :prog_menu )
if %M%==2 ( call :flash font_bindings.elf
          goto :prog_menu )
if %M%==3 ( call :flash font_quality.elf
          goto :prog_menu )
if %M%==4 ( call :flash font_quality_all_glyphs.elf
          goto :prog_menu )
if %M%==5 ( call :flash freertos_app_switch.elf
          goto :prog_menu )
if %M%==6 ( call :flash freertos_multitask.elf
          goto :prog_menu )
if %M%==7 ( call :flash image_cache.elf
          goto :prog_menu )
if %M%==8 ( call :flash image_loading.elf
          goto :prog_menu )
if %M%==9 ( call :flash interrupt_handler.elf
          goto :prog_menu )
if %M%==a ( call :flash layers.elf
          goto :prog_menu )
if %M%==b ( call :flash listmodel.elf
          goto :prog_menu )
if %M%==c ( call :flash minimal.elf
          goto :prog_menu )
if %M%==d ( call :flash motor_cluster.elf
          goto :prog_menu )
if %M%==e ( call :flash multiscreen.elf
          goto :prog_menu )
if %M%==f ( call :flash painteditem.elf
          goto :prog_menu )
if %M%==g ( call :flash perspective_transforms.elf
          goto :prog_menu )
if %M%==h ( call :flash shapes.elf
          goto :prog_menu )
if %M%==i ( call :flash styling_default.elf
          goto :prog_menu )
if %M%==j ( call :flash swipe_game.elf
          goto :prog_menu )
if %M%==k ( call :flash timeline.elf
          goto :prog_menu )
if %M%==l ( call :flash translation_all.elf
          goto :prog_menu )
if %M%==m ( call :flash translation_lv.elf
          goto :prog_menu )
if %M%==n ( call :flash translation_spark.elf
          goto :prog_menu )
if %M%==q goto :EOF
echo.
echo Unknown option selected %M%
echo.
goto :prog_menu

