@ECHO OFF
REM This file was generated by 'ProgGenerator'  
CHCP 65001 >NUL

if not exist MyPrivateBuildScript.cmd (
  REM embedded Fast Build and Upload
  call :build "C:\Program Files (x86)\Arduino\" "LEDs_AutoProg.ino" COM11 "rp2040:rp2040:rpipico:flash=2097152_0,freq=125,dbgport=Disabled,dbglvl=None" 115200  "C:\Users\Harold\Documents\Arduino/libraries" atmega328p %*
) else (
  REM user defined Build and Upload
  call MyPrivateBuildScript.cmd "C:\Program Files (x86)\Arduino\" "LEDs_AutoProg.ino" COM11 "rp2040:rp2040:rpipico:flash=2097152_0,freq=125,dbgport=Disabled,dbglvl=None" 115200  "C:\Users\Harold\Documents\Arduino/libraries" atmega328p %*
)
IF ERRORLEVEL 1 ECHO Start_Arduino_Result: %ERRORLEVEL% > "Start_Arduino_Result.txt"
goto :eof




































































































:build
@ECHO OFF
REM Fast Build command from Juergen
REM ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
REM
REM Speed up by
REM - not using the Arduino Core
REM - not checking the flash at the end (saves 3 sec)
REM
REM This file could be modified by the user to support special compiler switches
REM It is called if the switch the "Schnells Build und Upload verwenden:" in the 'Config' sheet is enabled
REM
REM Parameter:               Example
REM  1: Arduino EXE Path:    "C:\Program Files (x86)\Arduino\"
REM  2: Ino Name:            "LEDs_AutoProg.ino"
REM  3: Com port:            "\\.\COM3"
REM  4: Build options:       "rp2040:rp2040:rpipico:flash=2097152_0,freq=125,dbgport=Disabled,dbglvl=None"
REM  5: Baudrate:            "115200"
REM  6: Arduino Library path "%USERPROFILE%\Documents\Arduino\libraries"
REM  7: CPU type:            "rp2040
REM  8: options:             "noflash"
REM
REM The program uses the captured and adapted command line from the Arduino IDE
REM

SET aHome=%~1
SET fqbn=%~4
SET lib=%~6


call :short aTemp "%USERPROFILE%\AppData\Local\Temp\pyMobaLedLib_build\Pico"
SET aCache=%aTemp%\cache
call :short packages "%USERPROFILE%\AppData\Local\Arduino15\packages"
if not exist "%aTemp%"  md "%aTemp%"
if not exist "%aCache%" md "%aCache%"

REM *** Call the arduino builder ***
"%aHome%\arduino-builder" -compile -logger=human ^
     -hardware "%aHome%\hardware" ^
     -hardware "C:\Users\Harold\AppData\Local\Arduino15\packages" ^
     -tools "%aHome%\tools-builder" ^
     -tools "%aHome%\hardware\tools\avr" ^
     -built-in-libraries "%aHome%\libraries" -libraries "%LIB%" ^
     -fqbn=%fqbn% -build-path "%aTemp%" ^
     -warnings=default ^
     -build-cache "%aCache%" ^
     -prefs=build.warn_data_percentage=75 ^
     -prefs=runtime.platform.path="C:\Users\Harold\AppData\Local\Arduino15\packages\rp2040\hardware\rp2040\4.4.0" ^
     %2


if "%8"=="noflash" goto :EOF
if %errorlevel%==0 (
   REM *** Flash program ***
   :flash
   "%packages%\rp2040\tools\pqt-python3\1.0.1-base-3a57aed-1\python3" "%packages%\rp2040\hardware\rp2040\4.4.0\tools\uf2conv.py" ^
   --serial %3 --family RP2040 --deploy "%aTemp%\LEDs_AutoProg.ino.uf2"
)
goto :eof

:short
set %1=%~s2
goto :eof

