export AMPY_PORT=/dev/cu.SLAB_USBtoUART
export BAUD_RATE=115200

ARG=$1

if [ "$ARG" = '--kit' ] || [ "$ARG" = '-k' ]; then
  echo "Using ESP-WOVER-kit_v4.1"
#   export AMPY_PORT=/dev/cu.usbserial-143101
  export AMPY_PORT=/dev/cu.usbserial-14401
fi

function _set_kit_usbserial (){

}


function repl_connect (){
	echo "Connecting to $AMPY_PORT"
	echo "Use Ctrl+a then k to kill the session"
	sleep 2;
	screen $AMPY_PORT $BAUD_RATE
}

function upy (){
	_command=${1}
	shift
# 	echo "command $_command params $@"
	ampy -p $AMPY_PORT -b $BAUD_RATE ${_command} $@
}

# m0 maps to conng
alias mp="mpremote m0"

function esp32-docs () {
	echo "\nDocs: https://docs.micropython.org/en/latest/esp32/quickref.html\n"
	open 'https://docs.micropython.org/en/latest/esp32/quickref.html'
}

function upy-git () {

	echo '\n Upy Git: https://github.com/micropython/micropython\n'
	open 'https://github.com/micropython/micropython'
}

# Cool things you can do with mpremote
function mpremote_usage () {
	echo "\n#### USAGE ####\n"
	echo "\nDocs: https://docs.micropython.org/en/latest/reference/mpremote.html\n"
	echo 'Ideas:'
	echo "- The config file for mprempte is in ~/.config/mpremote/config.py"
	echo '- You can user `mp mount . exec "import foo"` to mount a foo module from curdir and programmatically execute it.'
	echo '- Rapidly iterate compiling C into .mpy files then mounting that file on your board! See: https://www.youtube.com/watch?v=EVJA01W9ArI'
	echo "\n#### USAGE END ####\n"
}


