diff --git a/.github/actions/action.yml b/.github/actions/action.yml new file mode 100644 index 0000000..fb13812 --- /dev/null +++ b/.github/actions/action.yml @@ -0,0 +1,115 @@ +name: 'Test compile for Arduino' +description: 'Compile sketches or Arduino library examples for one board type using arduino-cli and check for errors' +author: 'Armin Joachimsmeyer' +inputs: + cli-version: + description: 'Version of arduino-cli to use when building. Current (8/2022) one is 0.26.0.' + default: 'latest' + required: false + + sketch-names: + description: 'Comma sepatated list of patterns or filenames (without path) of the sketch(es) to test compile. Useful if the sketch is a *.cpp or *.c file or only one sketch in the repository should be compiled.' + default: '*.ino' + required: false + + sketch-names-find-start: + description: 'The start directory to look for the sketch-names to test compile. Can be a path like "digistump-avr/libraries/*/examples/C*/" .' + default: '.' + required: false + + arduino-board-fqbn: + #In the Arduino IDE, the fqbn is printed in the first line of the verbose output for compilation as parameter -fqbn=... for the "arduino-builder -dump-prefs" command + description: 'Fully Qualified Board Name of the Arduino board. You may add a suffix behind the fqbn with "|" to specify one board for e.g. different compile options like arduino:avr:uno|trace.' + default: 'arduino:avr:uno' + required: false + + arduino-platform: + description: 'Comma separated list of platform specifiers, if you require a fixed version like "arduino:avr@1.8.2" or do not want the specifier derived from the 2 first elements of the arduino-board-fqbn or need more than one core. The suffix "@latest" is always removed.' + default: '' + required: false + + platform-default-url: + description: 'The platform URL for the required board description if arduino-board-fqbn does not start with "arduino:" and not explicitly specified by platform-url.' + default: '' + required: false + + platform-url: + description: 'The platform URL for the required board description if arduino-board-fqbn does not start with "arduino:".' + default: '' + required: false + + required-libraries: + description: 'Comma separated list of arduino library names required for compiling the sketches / examples for this board.' + default: '' + required: false + + sketches-exclude: + description: 'Comma or space separated list of complete names of all sketches / examples to be excluded in the build for this board.' + default: '' + required: false + + build-properties: + description: | + Build parameter like -DDEBUG for each example specified or for all examples, if example name is "All". In json format. + For example: build-properties: '{ "WhistleSwitch": "-DDEBUG -DFREQUENCY_RANGE_LOW", "SimpleFrequencyDetector": "-DINFO" }' + default: '' + required: false + + extra-arduino-cli-args: + description: | + This string is passed verbatim without double quotes to the arduino-cli compile commandline as last argument before the filename. + See https://arduino.github.io/arduino-cli/commands/arduino-cli_compile/ for compile parameters. + default: '' + required: false + + extra-arduino-lib-install-args: + description: | + This string is passed verbatim without double quotes to the arduino-cli lib install commandline as last argument before the library names. + It can be used e.g. to suppress dependency resolving for libraries by using --no-deps as argument string. + default: '' + required: false + + set-build-path: + description: 'Flag to set the build directory (arduino-cli paramer --build-path) to /build subdirectory of compiled sketches.' + default: 'false' + required: false + + debug-compile: + description: 'If set to "true" the action logs verbose compile output even during successful builds' + default: '' + required: false + + debug-install: + description: 'If set to "true" the action logs verbose arduino-cli output during installation' + default: '' + required: false + +runs: + using: 'composite' + steps: + - name: Compile all sketches / examples using the bash script arduino-test-compile.sh + env: + # Passing parameters to the script by setting the appropriate ENV_* variables. + # Direct passing as arguments is not possible because of blanks in the arguments. + ENV_CLI_VERSION: ${{ inputs.cli-version }} + ENV_SKETCH_NAMES: ${{ inputs.sketch-names }} + ENV_SKETCH_NAMES_FIND_START: ${{ inputs.sketch-names-find-start }} + ENV_ARDUINO_BOARD_FQBN: ${{ inputs.arduino-board-fqbn }} + ENV_ARDUINO_PLATFORM: ${{ inputs.arduino-platform }} + ENV_PLATFORM_DEFAULT_URL: ${{ inputs.platform-default-url }} + ENV_PLATFORM_URL: ${{ inputs.platform-url }} + ENV_REQUIRED_LIBRARIES: ${{ inputs.required-libraries }} + ENV_SKETCHES_EXCLUDE: ${{ inputs.sketches-exclude }} + ENV_BUILD_PROPERTIES: ${{ inputs.build-properties }} + ENV_EXTRA_ARDUINO_CLI_ARGS: ${{ inputs.extra-arduino-cli-args }} + ENV_EXTRA_ARDUINO_LIB_INSTALL_ARGS: ${{ inputs.extra-arduino-lib-install-args }} + ENV_SET_BUILD_PATH: ${{ inputs.set-build-path }} + ENV_DEBUG_COMPILE: ${{ inputs.debug-compile }} + ENV_DEBUG_INSTALL: ${{ inputs.debug-install }} + + run: ${{ github.action_path }}/arduino-test-compile.sh + shell: bash + +branding: + icon: 'eye' + color: 'red' \ No newline at end of file diff --git a/.github/actions/arduino-test-compile.sh b/.github/actions/arduino-test-compile.sh new file mode 100755 index 0000000..f3d7e5f --- /dev/null +++ b/.github/actions/arduino-test-compile.sh @@ -0,0 +1,506 @@ +#!/bin/bash + +# arduino-test-compile.sh +# Bash script to do a test-compile of one or more Arduino programs in a repository each with different compile parameters. +# +# Copyright (C) 2020-2022 Armin Joachimsmeyer +# https://github.com/ArminJo/Github-Actions +# License: MIT +# + +# Input parameter, which is normally not used for Githup actions +CLI_VERSION="$1" +SKETCH_NAMES="$2" +SKETCH_NAMES_FIND_START="$3" +ARDUINO_BOARD_FQBN="$4" +ARDUINO_PLATFORM="$5" +PLATFORM_DEFAULT_URL="$6" +PLATFORM_URL="$7" +REQUIRED_LIBRARIES="$8" +SKETCHES_EXCLUDE="$9" +EXAMPLES_EXCLUDE="${10}" +BUILD_PROPERTIES="${11}" +EXAMPLES_BUILD_PROPERTIES="${12}" +EXTRA_ARDUINO_CLI_ARGS="${13}" +EXTRA_ARDUINO_LIB_INSTALL_ARGS="${14}" +SET_BUILD_PATH="${15}" +DEBUG_COMPILE="${16}" +DEBUG_INSTALL="${17}" + +readonly RED='\033[0;31m' +readonly GREEN='\033[0;32m' +readonly YELLOW='\033[1;33m' +readonly BLUE='\033[0;34m' + +# +# Get env parameter from action run with higher priority, which enables the script to run directly in a step +# +if [[ -n $ENV_CLI_VERSION ]]; then CLI_VERSION=$ENV_CLI_VERSION; fi +if [[ -n $ENV_SKETCH_NAMES ]]; then SKETCH_NAMES=$ENV_SKETCH_NAMES; fi +if [[ -n $ENV_SKETCH_NAMES_FIND_START ]]; then SKETCH_NAMES_FIND_START=$ENV_SKETCH_NAMES_FIND_START; fi +if [[ -n $ENV_ARDUINO_BOARD_FQBN ]]; then ARDUINO_BOARD_FQBN=$ENV_ARDUINO_BOARD_FQBN; fi +if [[ -n $ENV_ARDUINO_PLATFORM ]]; then ARDUINO_PLATFORM=$ENV_ARDUINO_PLATFORM; fi +if [[ -n $ENV_PLATFORM_DEFAULT_URL ]]; then PLATFORM_DEFAULT_URL=$ENV_PLATFORM_DEFAULT_URL; fi +if [[ -n $ENV_PLATFORM_URL ]]; then PLATFORM_URL=$ENV_PLATFORM_URL; fi +if [[ -n $ENV_REQUIRED_LIBRARIES ]]; then REQUIRED_LIBRARIES=$ENV_REQUIRED_LIBRARIES; fi +if [[ -n $ENV_SKETCHES_EXCLUDE ]]; then SKETCHES_EXCLUDE=$ENV_SKETCHES_EXCLUDE; fi +if [[ -n $ENV_EXAMPLES_EXCLUDE ]]; then EXAMPLES_EXCLUDE=$ENV_EXAMPLES_EXCLUDE; fi #deprecated +if [[ -n $ENV_BUILD_PROPERTIES ]]; then BUILD_PROPERTIES=$ENV_BUILD_PROPERTIES; fi +if [[ -n $ENV_EXAMPLES_BUILD_PROPERTIES ]]; then EXAMPLES_BUILD_PROPERTIES=$ENV_EXAMPLES_BUILD_PROPERTIES; fi #deprecated +if [[ -n $ENV_EXTRA_ARDUINO_CLI_ARGS ]]; then EXTRA_ARDUINO_CLI_ARGS=$ENV_EXTRA_ARDUINO_CLI_ARGS; fi +if [[ -n $ENV_EXTRA_ARDUINO_LIB_INSTALL_ARGS ]]; then EXTRA_ARDUINO_LIB_INSTALL_ARGS=$ENV_EXTRA_ARDUINO_LIB_INSTALL_ARGS; fi +if [[ -n $ENV_SET_BUILD_PATH ]]; then SET_BUILD_PATH=$ENV_SET_BUILD_PATH; fi + +if [[ -n $ENV_DEBUG_COMPILE ]]; then DEBUG_COMPILE=$ENV_DEBUG_COMPILE; fi +if [[ -n $ENV_DEBUG_INSTALL ]]; then DEBUG_INSTALL=$ENV_DEBUG_INSTALL; fi + +# +# Handle deprecated names +# +if [[ -z $SKETCHES_EXCLUDE && -n $EXAMPLES_EXCLUDE ]]; then + echo "Please change parameter name from \"examples-exclude\" to \"sketches-exclude\"" + SKETCHES_EXCLUDE=${EXAMPLES_EXCLUDE} +fi +if [[ -z $BUILD_PROPERTIES && -n $EXAMPLES_BUILD_PROPERTIES ]]; then + echo "Please change parameter name from \"examples-build-properties\" to \"build-properties\"" + BUILD_PROPERTIES=${EXAMPLES_BUILD_PROPERTIES} +fi + +# +# Enforce defaults. Required at least for script version. !!! MUST be equal the defaults in action.yml !!! +# +echo -e "\r\n${YELLOW}Set defaults" +if [[ -z $ARDUINO_BOARD_FQBN ]]; then + echo "Set ARDUINO_BOARD_FQBN to default value: \"arduino:avr:uno\"" + ARDUINO_BOARD_FQBN='arduino:avr:uno' +fi +if [[ -z $PLATFORM_URL && -n $PLATFORM_DEFAULT_URL ]]; then + echo -e "Set PLATFORM_URL to default value: \"${PLATFORM_DEFAULT_URL}\"" + PLATFORM_URL=$PLATFORM_DEFAULT_URL +fi +if [[ -z $CLI_VERSION ]]; then + echo "Set CLI_VERSION to default value: \"latest\"" + CLI_VERSION='latest' +fi +if [[ -z $SKETCH_NAMES ]]; then + echo -e "Set SKETCH_NAMES to default value: \"*.ino\"" + SKETCH_NAMES='*.ino' +fi +if [[ -z $SKETCH_NAMES_FIND_START ]]; then + echo -e "Set SKETCH_NAMES_FIND_START to default value: \".\" (root of repository)" + SKETCH_NAMES_FIND_START='.' +fi +if [[ -z $SET_BUILD_PATH ]]; then + echo -e "Set SET_BUILD_PATH to default value: \"false\"" + SET_BUILD_PATH='false' +fi + +# +# Echo input parameter +# +echo -e "\r\n${YELLOW}Echo input parameter" +echo CLI_VERSION=$CLI_VERSION +echo SKETCH_NAMES=$SKETCH_NAMES +echo SKETCH_NAMES_FIND_START=$SKETCH_NAMES_FIND_START +echo ARDUINO_BOARD_FQBN=$ARDUINO_BOARD_FQBN +echo ARDUINO_PLATFORM=$ARDUINO_PLATFORM +echo PLATFORM_DEFAULT_URL=$PLATFORM_DEFAULT_URL +echo PLATFORM_URL=$PLATFORM_URL +echo REQUIRED_LIBRARIES=$REQUIRED_LIBRARIES +echo SKETCHES_EXCLUDE=$SKETCHES_EXCLUDE +echo BUILD_PROPERTIES=$BUILD_PROPERTIES +echo EXTRA_ARDUINO_CLI_ARGS=$EXTRA_ARDUINO_CLI_ARGS +echo EXTRA_ARDUINO_LIB_INSTALL_ARGS=$EXTRA_ARDUINO_LIB_INSTALL_ARGS +echo SET_BUILD_PATH=$SET_BUILD_PATH + +echo DEBUG_COMPILE=$DEBUG_COMPILE +echo DEBUG_INSTALL=$DEBUG_INSTALL + +VERBOSE_PARAMETER= +if [[ $DEBUG_INSTALL == true ]]; then + VERBOSE_PARAMETER=--verbose + echo + echo HOME=$HOME # /home/runner + echo PWD=$PWD # *** + echo GITHUB_WORKSPACE=$GITHUB_WORKSPACE # /home/runner/work// +#set +#ls -lR $GITHUB_WORKSPACE +fi + +# Show calling parameters +declare -p BASH_ARGV + +# +# Download and install arduino IDE, if not already cached +# +echo -n -e "\r\n${YELLOW}arduino-cli " +if [[ -f $HOME/arduino_ide/arduino-cli ]]; then + echo -e "cached: ${GREEN}\xe2\x9c\x93" # never seen :-( +else + echo -n "downloading: " + wget --quiet https://downloads.arduino.cc/arduino-cli/arduino-cli_${CLI_VERSION}_Linux_64bit.tar.gz + if [[ $? -ne 0 ]]; then + echo -e "${RED}\xe2\x9c\x96" + echo "::error:: Unable to download arduino-cli_${CLI_VERSION}_Linux_64bit.tar.gz" + exit 3 + else + echo -e "${GREEN}\xe2\x9c\x93" + fi + echo -n "Upacking arduino-cli to ${HOME}/arduino_ide: " + if [[ ! -d $HOME/arduino_ide/ ]]; then + mkdir $HOME/arduino_ide + fi + tar xf arduino-cli_${CLI_VERSION}_Linux_64bit.tar.gz -C $HOME/arduino_ide/ + if [[ $? -ne 0 ]]; then + echo -e "${RED}\xe2\x9c\x96" + else + echo -e "${GREEN}\xe2\x9c\x93" + fi +# ls -l $HOME/arduino_ide/* # LICENSE.txt + arduino-cli +# ls -l $HOME # only arduino_ide +fi + +# add the arduino CLI to our PATH +export PATH="$HOME/arduino_ide:$PATH" + +#print version +arduino-cli version + +# +# Add *Custom* directories to Arduino library directory +# +# if ls $GITHUB_WORKSPACE/*Custom* >/dev/null 2>&1; then +# echo -e "\r\n${YELLOW}Add *Custom* as Arduino library" +# mkdir --parents $HOME/Arduino/libraries +# rm --force --recursive $GITHUB_WORKSPACE/*Custom*/.git # do not want to move the whole .git directory +# # mv to avoid the library examples to be test compiled +# echo mv --no-clobber $VERBOSE_PARAMETER $GITHUB_WORKSPACE/\*Custom\* $HOME/Arduino/libraries/ +# mv --no-clobber $VERBOSE_PARAMETER $GITHUB_WORKSPACE/*Custom* $HOME/Arduino/libraries/ +# fi + +echo "Download Depends Arduino library" +mkdir --parents $HOME/Arduino/libraries + +if [[ -f $GITHUB_WORKSPACE/library.properties ]]; then + OLD_IFS="$IFS" + IFS=$'\n' + for line in $(cat $GITHUB_WORKSPACE/library.properties); do + result=$(echo $line | grep "depends=") + if [[ "$result" != "" ]]; then + depends_str=${line##*depends=} + IFS="," + for lib in ${depends_str[@]}; do + echo "download $lib" + arduino-cli lib install $lib + done + fi + done + IFS="$OLD_IFS" +fi + +echo "Check Arduino library" +repo_name="${GITHUB_WORKSPACE##*/}" +if [[ -d $HOME/Arduino/libraries/$repo_name ]]; then + rm -r $HOME/Arduino/libraries/$repo_name + echo "Same Arduino library: ${repo_name}, replace this repository" +fi + +cp -r $GITHUB_WORKSPACE $HOME/Arduino/libraries/ +ls $HOME/Arduino/libraries/$repo_name + +# Link this repository as Arduino library +# +# Check if repo is an Arduino library +# if [[ -f $GITHUB_WORKSPACE/library.properties ]]; then +# echo -e "\r\n${YELLOW}Link this repository as Arduino library" +# mkdir --parents $HOME/Arduino/libraries +# repo_name="${GITHUB_WORKSPACE##*/}" +# if [[ -d $HOME/Arduino/libraries/$repo_name ]]; then +# rm -r $HOME/Arduino/libraries/$repo_name +# echo -e "\r\nSame Arduino library: ${repo_name}, replace this repository" +# fi +# ln --symbolic $GITHUB_WORKSPACE $HOME/Arduino/libraries/. +# if [[ $DEBUG_INSTALL == true ]]; then +# echo ln --symbolic $GITHUB_WORKSPACE $HOME/Arduino/libraries/. +# rm --force --recursive $HOME/Arduino/libraries/*/.git # do not want to list the whole .git directory +# echo ls -l --dereference --recursive --all $HOME/Arduino/libraries/ +# ls -l --dereference --recursive --all $HOME/Arduino/libraries/ +# fi +# fi + +# +# Update index and install the required board platform +# +echo -e "\r\n${YELLOW}Update index and install the required board platform" +if [[ -z $ARDUINO_PLATFORM ]]; then + # ARDUINO_PLATFORM is empty -> derive platform from the 2 first elements of the arduino-board-fqbn + remainder=${ARDUINO_BOARD_FQBN#*:} + provider=${ARDUINO_BOARD_FQBN%%:*} + PLATFORM=${provider}:${remainder%%:*} +else + # Remove @latest from specified platform + PLATFORM=${ARDUINO_PLATFORM%@latest} +fi +echo PLATFORM=${PLATFORM} # e.g. digistump:avr +if [[ ${PLATFORM} != *arduino* && -z $PLATFORM_URL ]]; then + # check if the requested platform is manually installed + if [[ ! -d $HOME/.arduino15/packages/${provider} ]]; then + echo -e "::error::Non Arduino platform $PLATFORM requested, but \"platform-url\" parameter is missing." + exit 1 + fi +fi + +if [[ -n $PLATFORM_URL ]]; then + PLATFORM_URL=${PLATFORM_URL// /,} # replace space by comma to enable multiple urls which are space separated + PLATFORM_URL_COMMAND="--additional-urls" +fi + +PLATFORM=${PLATFORM//,/ } # replace all comma by space to enable multiple platforms which are comma separated +declare -a PLATFORM_ARRAY=($PLATFORM) +if [[ $DEBUG_INSTALL == true ]]; then + declare -p PLATFORM_ARRAY # print properties of PLATFORM_ARRAY +fi +for single_platform in "${PLATFORM_ARRAY[@]}"; do # Loop over all platforms specified + if [[ $DEBUG_INSTALL == true ]]; then + echo -e "arduino-cli core update-index $PLATFORM_URL_COMMAND $PLATFORM_URL --verbose" + arduino-cli core update-index $PLATFORM_URL_COMMAND $PLATFORM_URL --verbose # must specify --additional-urls here + if [[ $? -ne 0 ]]; then + echo "::error::Updating index of $PLATFORM_URL failed" + exit 1 + fi + echo -e "arduino-cli core install $single_platform $PLATFORM_URL_COMMAND $PLATFORM_URL -v" + arduino-cli core install $single_platform $PLATFORM_URL_COMMAND $PLATFORM_URL --verbose + else + echo -e "arduino-cli core update-index $PLATFORM_URL_COMMAND $PLATFORM_URL > /dev/null" + arduino-cli core update-index $PLATFORM_URL_COMMAND $PLATFORM_URL >/dev/null # must specify --additional-urls here + if [[ $? -ne 0 ]]; then + echo "::error::Updating index of $PLATFORM_URL failed" + exit 1 + fi + echo -e "arduino-cli core install $single_platform $PLATFORM_URL_COMMAND $PLATFORM_URL > /dev/null" + arduino-cli core install $single_platform $PLATFORM_URL_COMMAND $PLATFORM_URL >/dev/null + fi + if [[ $? -ne 0 ]]; then + echo "::error::Install core for $single_platform failed" + exit 1 + fi +done + +# +# Special esp8266 and esp32 platform handling +# +echo -e "\r\n${YELLOW}Special esp8266 and esp32 platform handling" +if [[ ${PLATFORM} == esp8266:esp8266 && ! -f /usr/bin/python3 ]]; then + # python3 is a link in the esp8266 package: /github/home/.arduino15/packages/esp8266/tools/python3/3.7.2-post1/python3 -> /usr/bin/python3 + echo -e "\r\n${YELLOW}install python3 for ESP8266" + apt-get install -qq python3 >/dev/null +fi + +if [[ $PLATFORM == esp32:esp32 ]]; then + if [[ ! -f /usr/bin/pip && ! -f /usr/bin/python ]]; then + echo -e "\r\n${YELLOW}install python and pip for ESP32" + # Here we would get the warning: The directory '/github/home/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. + # Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag. + apt-get install -qq python-pip >/dev/null 2>&1 # this installs also python + fi + pip install pyserial +fi + +# +# List installed boards with their FQBN +# +echo -e "\r\n${YELLOW}List installed boards with their FQBN" +if [[ $DEBUG_INSTALL == true ]]; then + echo arduino-cli board listall --verbose + arduino-cli board listall --verbose +else + echo arduino-cli board listall + arduino-cli board listall +fi + +# +# Install required libraries +# +echo -e "\n${YELLOW}Install required libraries" +if [[ -z $REQUIRED_LIBRARIES ]]; then + echo No additional libraries to install +else + echo Install libraries $REQUIRED_LIBRARIES + BACKUP_IFS="$IFS" + # Split comma separated library list + IFS=$',' + declare -a REQUIRED_LIBRARIES_ARRAY=($REQUIRED_LIBRARIES) + IFS="$BACKUP_IFS" + if [[ $DEBUG_INSTALL == true ]]; then + arduino-cli lib install "${REQUIRED_LIBRARIES_ARRAY[@]}" $EXTRA_ARDUINO_LIB_INSTALL_ARGS + else + arduino-cli lib install "${REQUIRED_LIBRARIES_ARRAY[@]}" $EXTRA_ARDUINO_LIB_INSTALL_ARGS >/dev/null 2>&1 + fi + if [[ $? -ne 0 ]]; then + echo "::error::Installation of $REQUIRED_LIBRARIES failed" + exit 1 + fi +fi + +# Save generated files to the build subfolder of the sketch +export ARDUINO_SKETCH_ALWAYS_EXPORT_BINARIES=true + +# +# Get the build property map +# +echo -e "\n${YELLOW}Compiling sketches / examples for board $ARDUINO_BOARD_FQBN\n" + +# If matrix.build-properties are specified, create an associative shell array +# Input example: { "WhistleSwitch": "-DINFO -DFREQUENCY_RANGE_LOW", "SimpleFrequencyDetector": "-DINFO" } +# Converted to: [All]="-DDEBUG -DINFO" [WhistleSwitch]="-DDEBUG -DINFO" +if [[ -n $BUILD_PROPERTIES && $BUILD_PROPERTIES != "null" ]]; then # contains "null", if passed as environment variable + echo BUILD_PROPERTIES=$BUILD_PROPERTIES + BUILD_PROPERTIES=${BUILD_PROPERTIES#\{} # remove the "{". The "}" is required as end token + # (\w*): * first token before the colon and spaces, ([^,}]*) token after colon and spaces up to "," or "}", [,}] trailing characters + if [[ $DEBUG_COMPILE == true ]]; then + echo BUILD_PROPERTIES is converted to:$(echo $BUILD_PROPERTIES | sed -E 's/"(\w*)": *([^,}]*)[,}]/\[\1\]=\2/g') + fi + declare -A PROP_MAP="( $(echo $BUILD_PROPERTIES | sed -E 's/"(\w*)": *([^,}]*)[,}]/\[\1\]=\2/g') )" + declare -p PROP_MAP # print properties of PROP_MAP +else + declare -A PROP_MAP=([dummy]=dummy) # declare an accociative array +fi + +# +# Finally, we compile all examples +# +# Split comma separated sketch name list +BACKUP_IFS="$IFS" +IFS=$',' +SKETCH_NAMES=${SKETCH_NAMES// /} # replace all spaces +GLOBIGNORE=*:?:[ # Disable filename expansion (globbing) of *.ino to abc.ino if abc.ino is a file in the directory +declare -a SKETCH_NAMES_ARRAY=($SKETCH_NAMES) # declare an indexed array +GLOBIGNORE= # Enable it for cp command below +if [[ $DEBUG_COMPILE == true ]]; then + declare -p SKETCH_NAMES_ARRAY # print properties of SKETCH_NAMES_ARRAY +fi +IFS="$BACKUP_IFS" +COMPILED_SKETCHES= +for sketch_name in "${SKETCH_NAMES_ARRAY[@]}"; do # Loop over all sketch names + if [[ $SET_BUILD_PATH == true ]]; then + # must use $GITHUB_WORKSPACE/$SKETCH_NAMES_FIND_START, since arduino-cli does not support relative path for --build-path + declare -a SKETCHES=($(find ${GITHUB_WORKSPACE}/${SKETCH_NAMES_FIND_START} -type f -name "$sketch_name")) # only search for files + else + declare -a SKETCHES=($(find ${SKETCH_NAMES_FIND_START} -type f -name "$sketch_name")) # only search for files + fi + if [[ $DEBUG_COMPILE == true ]]; then + declare -p SKETCHES + fi + + # Check if find command found a file + if [[ -z ${SKETCHES[0]} ]]; then + GLOBIGNORE=*:?:[ # Disable filename expansion (globbing) of *.ino to abc.ino if abc.ino is a file in the directory + echo -e "::error::\nNo files found to compile with sketch_name=${sketch_name}." + echo "sketch-names=${SKETCH_NAMES} and sketch-names-find-start=${SKETCH_NAMES_FIND_START}" + GLOBIGNORE= + # No files found -> list start directory and execute find command to see what we did + echo -e "find command is: find ${GITHUB_WORKSPACE}/${SKETCH_NAMES_FIND_START} -type f -name \"$sketch_name\"" + echo "\"sketch-names-find-start\" directory content listing with: ls -l ${GITHUB_WORKSPACE}/${SKETCH_NAMES_FIND_START}" + ls -l ${GITHUB_WORKSPACE}/${SKETCH_NAMES_FIND_START} + echo + fi + + for sketch in "${SKETCHES[@]}"; do # Loop over all sketch files + SKETCH_PATH=$(dirname $sketch) # complete path to sketch + SKETCH_DIR=${SKETCH_PATH##*/} # directory of sketch, must match sketch basename + SKETCH_FILENAME=$(basename $sketch) # complete name of sketch + SKETCH_EXTENSION=${SKETCH_FILENAME##*.} # extension of sketch + SKETCH_BASENAME=${SKETCH_FILENAME%%.$SKETCH_EXTENSION} # name without extension / basename of sketch, must match directory name + if [[ $DEBUG_COMPILE == true ]]; then + echo -n "Process $sketch with filename $SKETCH_FILENAME and extension $SKETCH_EXTENSION" + fi + echo -e "\n" + if [[ $SKETCHES_EXCLUDE == *"$SKETCH_BASENAME"* ]]; then + echo -e "Skipping $SKETCH_PATH \xe2\x9e\x9e" # Right arrow + else + # If sketch name does not end with .ino, rename it locally + if [[ $SKETCH_EXTENSION != ino ]]; then + echo "Rename ${SKETCH_PATH}/${SKETCH_FILENAME} to ${SKETCH_PATH}/${SKETCH_BASENAME}.ino" + mv ${SKETCH_PATH}/${SKETCH_FILENAME} ${SKETCH_PATH}/${SKETCH_BASENAME}.ino + fi + # If directory name does not match sketch name, create an appropriate directory, copy the files recursively and compile + if [[ $SKETCH_DIR != $SKETCH_BASENAME ]]; then + mkdir $HOME/$SKETCH_BASENAME + echo "Creating directory $HOME/$SKETCH_BASENAME and copy ${SKETCH_PATH}/* to it" + cp --recursive ${SKETCH_PATH}/* $HOME/$SKETCH_BASENAME + SKETCH_PATH=$HOME/$SKETCH_BASENAME + fi + if [[ $SET_BUILD_PATH == true ]]; then + BUILD_PATH_PARAMETER="--build-path $SKETCH_PATH/build/" + fi + # Check if there is an entry in the associative array and create compile parameter to put in compiler.*.extra_flags + # This flags are also defined in platform.txt as empty, to be overwritten by a platform.local.txt definition. + # But I never saw a distribution using this fature, so we can go on here :-) + echo -n "Compiling $SKETCH_BASENAME " + if [[ -n ${PROP_MAP[$SKETCH_BASENAME]} ]]; then + GCC_EXTRA_FLAGS=${PROP_MAP[$SKETCH_BASENAME]} + echo -n "with $GCC_EXTRA_FLAGS " + elif [[ -n ${PROP_MAP[All]} ]]; then + GCC_EXTRA_FLAGS=${PROP_MAP[All]} + echo -n "with $GCC_EXTRA_FLAGS " + else + GCC_EXTRA_FLAGS= + fi + if [[ -z $GCC_EXTRA_FLAGS ]]; then + build_stdout=$(arduino-cli compile -e --verbose --fqbn ${ARDUINO_BOARD_FQBN%|*} $BUILD_PATH_PARAMETER $EXTRA_ARDUINO_CLI_ARGS $SKETCH_PATH 2>&1) + # build_stdout=$(arduino-cli compile -e --verbose --warnings all --fqbn ${ARDUINO_BOARD_FQBN%|*} $BUILD_PATH_PARAMETER $EXTRA_ARDUINO_CLI_ARGS $SKETCH_PATH 2>&1) + # build_stdout=$(arduino-cli compile -e --log-level error --fqbn ${ARDUINO_BOARD_FQBN%|*} $BUILD_PATH_PARAMETER $EXTRA_ARDUINO_CLI_ARGS $SKETCH_PATH 2>&1) + else + build_stdout=$(arduino-cli compile -e --verbose --fqbn ${ARDUINO_BOARD_FQBN%|*} $BUILD_PATH_PARAMETER --build-property compiler.cpp.extra_flags="${GCC_EXTRA_FLAGS}" --build-property compiler.c.extra_flags="${GCC_EXTRA_FLAGS}" --build-property compiler.S.extra_flags="${GCC_EXTRA_FLAGS}" $EXTRA_ARDUINO_CLI_ARGS $SKETCH_PATH 2>&1) + # build_stdout=$(arduino-cli compile -e --verbose --warnings all --fqbn ${ARDUINO_BOARD_FQBN%|*} $BUILD_PATH_PARAMETER --build-property compiler.cpp.extra_flags="${GCC_EXTRA_FLAGS}" --build-property compiler.c.extra_flags="${GCC_EXTRA_FLAGS}" --build-property compiler.S.extra_flags="${GCC_EXTRA_FLAGS}" $EXTRA_ARDUINO_CLI_ARGS $SKETCH_PATH 2>&1) + # build_stdout=$(arduino-cli compile -e --log-level error --fqbn ${ARDUINO_BOARD_FQBN%|*} $BUILD_PATH_PARAMETER --build-property compiler.cpp.extra_flags="${GCC_EXTRA_FLAGS}" --build-property compiler.c.extra_flags="${GCC_EXTRA_FLAGS}" --build-property compiler.S.extra_flags="${GCC_EXTRA_FLAGS}" $EXTRA_ARDUINO_CLI_ARGS $SKETCH_PATH 2>&1) + fi + if [[ $? -ne 0 ]]; then + echo -e ""${RED}"\xe2\x9c\x96" # If ok output a green checkmark else a red X and the command output. + if [[ -z $GCC_EXTRA_FLAGS ]]; then + echo "arduino-cli compile -e --verbose --fqbn ${ARDUINO_BOARD_FQBN%|*} $BUILD_PATH_PARAMETER $EXTRA_ARDUINO_CLI_ARGS $SKETCH_PATH" + # echo "arduino-cli compile -e --verbose --warnings all --fqbn ${ARDUINO_BOARD_FQBN%|*} $BUILD_PATH_PARAMETER $EXTRA_ARDUINO_CLI_ARGS $SKETCH_PATH" + # echo "arduino-cli compile -e --log-level error --fqbn ${ARDUINO_BOARD_FQBN%|*} $BUILD_PATH_PARAMETER $EXTRA_ARDUINO_CLI_ARGS $SKETCH_PATH" + else + echo "arduino-cli compile -e --verbose --fqbn ${ARDUINO_BOARD_FQBN%|*} $BUILD_PATH_PARAMETER --build-property compiler.cpp.extra_flags=\"${GCC_EXTRA_FLAGS}\" --build-property compiler.c.extra_flags=\"${GCC_EXTRA_FLAGS}\" --build-property compiler.S.extra_flags=\"${GCC_EXTRA_FLAGS}\" $EXTRA_ARDUINO_CLI_ARGS $SKETCH_PATH" + # echo "arduino-cli compile -e --verbose --warnings all --fqbn ${ARDUINO_BOARD_FQBN%|*} $BUILD_PATH_PARAMETER --build-property compiler.cpp.extra_flags=\"${GCC_EXTRA_FLAGS}\" --build-property compiler.c.extra_flags=\"${GCC_EXTRA_FLAGS}\" --build-property compiler.S.extra_flags=\"${GCC_EXTRA_FLAGS}\" $EXTRA_ARDUINO_CLI_ARGS $SKETCH_PATH" + # echo "arduino-cli compile -e --log-level error --fqbn ${ARDUINO_BOARD_FQBN%|*} $BUILD_PATH_PARAMETER --build-property compiler.cpp.extra_flags=\"${GCC_EXTRA_FLAGS}\" --build-property compiler.c.extra_flags=\"${GCC_EXTRA_FLAGS}\" --build-property compiler.S.extra_flags=\"${GCC_EXTRA_FLAGS}\" $EXTRA_ARDUINO_CLI_ARGS $SKETCH_PATH" + fi + echo "::error::Compile of $SKETCH_BASENAME ${GCC_EXTRA_FLAGS} failed" + echo -e "$build_stdout \n" + # repeat the info after hundred lines of output :-) + echo "Compile of $SKETCH_BASENAME ${GCC_EXTRA_FLAGS} failed" + exit_code=1 + else + echo -e "${GREEN}\xe2\x9c\x93" + if [[ -z $GCC_EXTRA_FLAGS ]]; then + echo "arduino-cli compile -e --verbose --fqbn ${ARDUINO_BOARD_FQBN%|*} $BUILD_PATH_PARAMETER $EXTRA_ARDUINO_CLI_ARGS $SKETCH_PATH" + # echo "arduino-cli compile -e --verbose --warnings all --fqbn ${ARDUINO_BOARD_FQBN%|*} $BUILD_PATH_PARAMETER $EXTRA_ARDUINO_CLI_ARGS $SKETCH_PATH" + # echo "arduino-cli compile -e --log-level error --fqbn ${ARDUINO_BOARD_FQBN%|*} $BUILD_PATH_PARAMETER $EXTRA_ARDUINO_CLI_ARGS $SKETCH_PATH" + else + echo "arduino-cli compile -e --verbose --fqbn ${ARDUINO_BOARD_FQBN%|*} $BUILD_PATH_PARAMETER --build-property compiler.cpp.extra_flags=\"${GCC_EXTRA_FLAGS}\" --build-property compiler.c.extra_flags=\"${GCC_EXTRA_FLAGS}\" --build-property compiler.S.extra_flags=\"${GCC_EXTRA_FLAGS}\" $EXTRA_ARDUINO_CLI_ARGS $SKETCH_PATH" + # echo "arduino-cli compile -e --verbose --warnings all --fqbn ${ARDUINO_BOARD_FQBN%|*} $BUILD_PATH_PARAMETER --build-property compiler.cpp.extra_flags=\"${GCC_EXTRA_FLAGS}\" --build-property compiler.c.extra_flags=\"${GCC_EXTRA_FLAGS}\" --build-property compiler.S.extra_flags=\"${GCC_EXTRA_FLAGS}\" $EXTRA_ARDUINO_CLI_ARGS $SKETCH_PATH" + # echo "arduino-cli compile -e --log-level error --fqbn ${ARDUINO_BOARD_FQBN%|*} $BUILD_PATH_PARAMETER --build-property compiler.cpp.extra_flags=\"${GCC_EXTRA_FLAGS}\" --build-property compiler.c.extra_flags=\"${GCC_EXTRA_FLAGS}\" --build-property compiler.S.extra_flags=\"${GCC_EXTRA_FLAGS}\" $EXTRA_ARDUINO_CLI_ARGS $SKETCH_PATH" + fi + if [[ $DEBUG_COMPILE == true || $SET_BUILD_PATH == true ]]; then + echo "Debug mode enabled => compile output will be printed also for successful compilation and sketch directory is listed after compilation" + echo -e "$build_stdout \n" + echo -e "\nls -l --recursive $SKETCH_PATH/build/" + ls -l --recursive $SKETCH_PATH/build/ + echo -e "\r\n" + fi + fi + COMPILED_SKETCHES="$COMPILED_SKETCHES $SKETCH_NAME" + fi + done +done +if [ -z "$COMPILED_SKETCHES" ]; then + echo "::error::Did not find any sketches to compile, probably misconfigured or used checkout twice without \"path:\" parameter?" + exit_code=2 +fi + +echo "compiled all example, export bin file..." +pwd +find . -name "*.bin" + +exit $exit_code diff --git a/.github/workflows/Arduino-Lint-Check.yml b/.github/workflows/Arduino-Lint-Check.yml new file mode 100644 index 0000000..ed10258 --- /dev/null +++ b/.github/workflows/Arduino-Lint-Check.yml @@ -0,0 +1,15 @@ +name: Arduino Lint +on: + push: + pull_request: +jobs: + lint: + name: Lint Check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: arduino/arduino-lint-action@v1 + with: + library-manager: update + compliance: strict + project-type: all \ No newline at end of file diff --git a/.github/workflows/arduino-action-stickc-compile.yml b/.github/workflows/arduino-action-stickc-compile.yml new file mode 100644 index 0000000..61aff6d --- /dev/null +++ b/.github/workflows/arduino-action-stickc-compile.yml @@ -0,0 +1,80 @@ +# arduino-test-compile-ActionTest.yml +# Github workflow script for testing the arduino-test-compile action development. +# +# Copyright (C) 2020 Armin Joachimsmeyer +# https://github.com/ArminJo/Github-Actions +# License: MIT +# + +# This is the name of the workflow, visible on GitHub UI. +name: Arduino Compile +on: + push: # see: https://help.github.com/en/actions/reference/events-that-trigger-workflows#pull-request-event-pull_request + paths: + - '**.ino' + - '**.cpp' + - '**.h' + - 'arduino-test-compile.sh' + - '*.yml' + workflow_dispatch: +jobs: + build: + name: ${{ matrix.arduino-boards-fqbn }} - test compiling examples + + runs-on: ubuntu-latest # ubuntu-latest # I picked Ubuntu to use shell scripts. + + env: + # Comma separated list without double quotes around the list. + CLI_VERSION: latest + + strategy: + matrix: + # The matrix will produce one job for each configuration parameter of type `arduino-boards-fqbn` + # In the Arduino IDE, the fqbn is printed in the first line of the verbose output for compilation as parameter -fqbn=... for the "arduino-builder -dump-prefs" command + # + # Examples: arduino:avr:uno, arduino:avr:leonardo, arduino:avr:nano, arduino:avr:mega + # arduino:sam:arduino_due_x, arduino:samd:arduino_zero_native" + # ATTinyCore:avr:attinyx5:chip=85,clock=1internal, digistump:avr:digispark-tiny, digistump:avr:digispark-pro + # STMicroelectronics:stm32:GenF1:pnum=BLUEPILL_F103C8 + # esp8266:esp8266:huzzah:eesz=4M3M,xtal=80, esp32:esp32:featheresp32:FlashFreq=80 + # You may add a suffix behind the fqbn with "|" to specify one board for e.g. different compile options like arduino:avr:uno|trace + ############################################################################################################# + arduino-boards-fqbn: + - m5stack:esp32:m5stick-c + + # Specify parameters for each board. + ############################################################################################################# + include: + - arduino-boards-fqbn: m5stack:esp32:m5stick-c + platform-url: https://m5stack.oss-cn-shenzhen.aliyuncs.com/resource/arduino/package_m5stack_index.json + sketches-exclude: WhistleSwitch,50Hz,SimpleFrequencyDetector + + # Do not cancel all jobs / architectures if one job fails + fail-fast: false + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Checkout custom library + uses: actions/checkout@v3 + with: + repository: ArminJo/ATtinySerialOut + ref: master + path: CustomLibrary # must match the pattern *Custom* + + # Test of the arduino-test-compile action + - name: Compile all examples using the arduino-test-compile action + # uses: ArminJo/arduino-test-compile@master + uses: ./.github/actions + with: + arduino-board-fqbn: ${{ matrix.arduino-boards-fqbn }} + arduino-platform: ${{ matrix.arduino-platform }} + platform-url: ${{ matrix.platform-url }} + required-libraries: ${{ env.REQUIRED_LIBRARIES }} + sketches-exclude: ${{ matrix.sketches-exclude }} + build-properties: ${{ toJson(matrix.build-properties) }} + sketch-names: "*.ino" + sketch-names-find-start: "examples/*" + debug-compile: true + debug-install: true diff --git a/.github/workflows/clang-format-check.yml b/.github/workflows/clang-format-check.yml index bb57434..0aab8fe 100644 --- a/.github/workflows/clang-format-check.yml +++ b/.github/workflows/clang-format-check.yml @@ -8,7 +8,7 @@ jobs: matrix: path: - check: './' # path to include - exclude: '(utility|RFID|HEART)' # path to exclude + exclude: '(MahonyAHRS)' # path to exclude # - check: 'src' # exclude: '(Fonts)' # Exclude file paths containing "Fonts" # - check: 'examples' diff --git a/README.md b/README.md index 6af439b..4ede6de 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,9 @@ # M5StickC Library +[![Arduino Compile](https://github.com/m5stack/M5StickC/actions/workflows/arduino-action-stickc-compile.yml/badge.svg)](https://github.com/m5stack/M5StickC/actions/workflows/arduino-action-stickc-compile.yml) +[![Arduino Lint](https://github.com/m5stack/M5StickC/actions/workflows/Arduino-Lint-Check.yml/badge.svg)](https://github.com/m5stack/M5StickC/actions/workflows/Arduino-Lint-Check.yml) +[![Clang Format](https://github.com/m5stack/M5StickC/actions/workflows/clang-format-check.yml/badge.svg)](https://github.com/m5stack/M5StickC/actions/workflows/clang-format-check.yml) + English | [中文](README_cn.md) M5StickC_01 diff --git a/README_cn.md b/README_cn.md index dcf4e31..69314cc 100644 --- a/README_cn.md +++ b/README_cn.md @@ -1,5 +1,9 @@ # M5StickC Library +[![Arduino Compile](https://github.com/m5stack/M5StickC/actions/workflows/arduino-action-stickc-compile.yml/badge.svg)](https://github.com/m5stack/M5StickC/actions/workflows/arduino-action-stickc-compile.yml) +[![Arduino Lint](https://github.com/m5stack/M5StickC/actions/workflows/Arduino-Lint-Check.yml/badge.svg)](https://github.com/m5stack/M5StickC/actions/workflows/Arduino-Lint-Check.yml) +[![Clang Format](https://github.com/m5stack/M5StickC/actions/workflows/clang-format-check.yml/badge.svg)](https://github.com/m5stack/M5StickC/actions/workflows/clang-format-check.yml) + [English](README.md) | 中文 M5StickC_01 diff --git a/examples/Advanced/Display/Cellular_Automata/Cellular_Automata.ino b/examples/Advanced/Display/Cellular_Automata/Cellular_Automata.ino index 9e8d626..08a4f02 100644 --- a/examples/Advanced/Display/Cellular_Automata/Cellular_Automata.ino +++ b/examples/Advanced/Display/Cellular_Automata/Cellular_Automata.ino @@ -4,9 +4,9 @@ #include -//#define GRIDX 80 -//#define GRIDY 60 -//#define CELLXY 4 +// #define GRIDX 80 +// #define GRIDY 60 +// #define CELLXY 4 #define GRIDX 80 #define GRIDY 40 diff --git a/examples/Advanced/Display/HZK16/str.h b/examples/Advanced/Display/HZK16/str.h index 3378b52..8527fc7 100644 --- a/examples/Advanced/Display/HZK16/str.h +++ b/examples/Advanced/Display/HZK16/str.h @@ -2,6 +2,6 @@ #define _STR_H_ char* AscStr = "ASCII: \nABCDEFG1234567"; -char* GbkStr = "ɾն ˤ"; +char* GbkStr = "�ɾն����� ����ˤ���"; #endif diff --git a/examples/Advanced/Display/TFT_Ellipse/TFT_Ellipse.ino b/examples/Advanced/Display/TFT_Ellipse/TFT_Ellipse.ino index ddfd919..9818a22 100644 --- a/examples/Advanced/Display/TFT_Ellipse/TFT_Ellipse.ino +++ b/examples/Advanced/Display/TFT_Ellipse/TFT_Ellipse.ino @@ -33,7 +33,7 @@ void loop() { } delay(2000); - M5.Lcd.fillScreen(BLACK); //清空屏幕 + M5.Lcd.fillScreen(BLACK); // 清空屏幕 for (int i = 0; i < 40; i++) { int rx = random(40); diff --git a/examples/Advanced/HallSensor/HallSensor.ino b/examples/Advanced/HallSensor/HallSensor.ino index d59b4d4..2ba2e14 100644 --- a/examples/Advanced/HallSensor/HallSensor.ino +++ b/examples/Advanced/HallSensor/HallSensor.ino @@ -16,8 +16,8 @@ */ #include -#define HORIZONTAL_RESOLUTION 80 //屏幕水平分辨率 -#define VERTICAL_RESOLUTION 160 //屏幕竖直分辨率 +#define HORIZONTAL_RESOLUTION 80 // 屏幕水平分辨率 +#define VERTICAL_RESOLUTION 160 // 屏幕竖直分辨率 #define POSITION_OFFSET_Y 20 uint16_t oldSignal[HORIZONTAL_RESOLUTION]; @@ -52,7 +52,7 @@ void showSignal() { int x, y; for (n = 0; n < HORIZONTAL_RESOLUTION; - n++) //在水平分辨率内,每个像素点根据计算得到的磁力大小绘制 + n++) // 在水平分辨率内,每个像素点根据计算得到的磁力大小绘制 { // Within the horizontal resolution, each pixel is drawn according to the // calculated magnetic force x = n; @@ -66,7 +66,7 @@ void showSignal() { M5.Lcd.setCursor(0, 40); y = map( value, -127, 127, VERTICAL_RESOLUTION, - POSITION_OFFSET_Y); //将value映射至-30~30的范围内,以免绘制超出屏幕 + POSITION_OFFSET_Y); // 将value映射至-30~30的范围内,以免绘制超出屏幕 if (n > 0) { // delete old line element. 删除上次画的线 diff --git a/examples/Advanced/MQTT/MQTT.ino b/examples/Advanced/MQTT/MQTT.ino index 1363c66..477e7d4 100644 --- a/examples/Advanced/MQTT/MQTT.ino +++ b/examples/Advanced/MQTT/MQTT.ino @@ -50,7 +50,7 @@ void loop() { client.loop(); // This function is called periodically to allow clients to // process incoming messages and maintain connections to the // server. - //定期调用此函数,以允许主机处理传入消息并保持与服务器的连接 + // 定期调用此函数,以允许主机处理传入消息并保持与服务器的连接 unsigned long now = millis(); // Obtain the host startup duration. 获取主机开机时长 diff --git a/examples/Advanced/MultiTask/MultiTask.ino b/examples/Advanced/MultiTask/MultiTask.ino index ed9cdcf..808b5ec 100644 --- a/examples/Advanced/MultiTask/MultiTask.ino +++ b/examples/Advanced/MultiTask/MultiTask.ino @@ -48,7 +48,7 @@ void setup() { xTaskCreatePinnedToCore( task1, // Function to implement the task. // 线程对应函数名称(不能有返回值) - "task1", //线程名称 + "task1", // 线程名称 4096, // The size of the task stack specified as the number of * // bytes.任务堆栈的大小(字节) NULL, // Pointer that will be used as the parameter for the task * diff --git a/examples/Advanced/Storage/EEPROM/EEPROM.ino b/examples/Advanced/Storage/EEPROM/EEPROM.ino index c2e3fe6..b4f9f0f 100644 --- a/examples/Advanced/Storage/EEPROM/EEPROM.ino +++ b/examples/Advanced/Storage/EEPROM/EEPROM.ino @@ -29,8 +29,8 @@ void setup() { if (!EEPROM.begin(SIZE)) { // Request storage of SIZE size(success return // 1). 申请SIZE大小的存储(成功返回1) Serial.println( - "\nFailed to initialise EEPROM!"); //串口输出格式化字符串. Serial - // output format string + "\nFailed to initialise EEPROM!"); // 串口输出格式化字符串. Serial + // output format string delay(1000000); } Serial.println("\nRead data from EEPROM. Values are:"); @@ -54,7 +54,7 @@ void loop() { // numbers from 0 to 255. Therefore, if you want to use // EEPROM to store the numeric value read by the analog // input pin, divide the numeric value by 4. - //将要存储于EEPROM的整数数值(EEPROM每一个存储地址可以储存一个字节,只能存储0-255的数.故如果要使用EEPROM存储模拟输入引脚所读取到的数值需要将该数值除以4) + // 将要存储于EEPROM的整数数值(EEPROM每一个存储地址可以储存一个字节,只能存储0-255的数.故如果要使用EEPROM存储模拟输入引脚所读取到的数值需要将该数值除以4) EEPROM.write(addr, val); // Writes the specified data to the specified // address. 向指定地址写入指定数据 diff --git a/examples/Advanced/Storage/SPIFFS/SPIFFS/SPIFFS.ino b/examples/Advanced/Storage/SPIFFS/SPIFFS/SPIFFS.ino index 4d7608e..6dc6b81 100644 --- a/examples/Advanced/Storage/SPIFFS/SPIFFS/SPIFFS.ino +++ b/examples/Advanced/Storage/SPIFFS/SPIFFS/SPIFFS.ino @@ -19,7 +19,7 @@ String file_name = bool SPIFFS_FORMAT = false; // Whether to initialize the SPIFFS. 是否初始化SPIFFS // You don't need to format the flash file system every time you use it. -//无需每次使用闪存都进行格式化 +// 无需每次使用闪存都进行格式化 void setup() { M5.begin(); // Init M5StickC. 初始化 M5StickC diff --git a/examples/Advanced/Storage/SPIFFS/SPIFFS_Add/SPIFFS_Add.ino b/examples/Advanced/Storage/SPIFFS/SPIFFS_Add/SPIFFS_Add.ino index 9c19aa8..2729eff 100644 --- a/examples/Advanced/Storage/SPIFFS/SPIFFS_Add/SPIFFS_Add.ino +++ b/examples/Advanced/Storage/SPIFFS/SPIFFS_Add/SPIFFS_Add.ino @@ -20,7 +20,7 @@ String file_name = bool SPIFFS_FORMAT = true; // Whether to initialize the SPIFFS. 是否初始化SPIFFS // You don't need to format the flash file system every time you use it. -//无需每次使用闪存都进行格式化 +// 无需每次使用闪存都进行格式化 void setup() { M5.begin(); // Init M5StickC. 初始化 M5StickC diff --git a/examples/Advanced/WIFI/BasicHttpClient/BasicHttpClient.ino b/examples/Advanced/WIFI/BasicHttpClient/BasicHttpClient.ino index 2bfa3c3..f804e81 100644 --- a/examples/Advanced/WIFI/BasicHttpClient/BasicHttpClient.ino +++ b/examples/Advanced/WIFI/BasicHttpClient/BasicHttpClient.ino @@ -46,8 +46,8 @@ void loop() { if (httpCode == HTTP_CODE_OK) { // file found at server. 在服务器上找到文件 String payload = http.getString(); - Serial.println(payload); //打印在服务器上读取的文件. Print - // files read on the server + Serial.println(payload); // 打印在服务器上读取的文件. Print + // files read on the server } } else { M5.Lcd.printf("[HTTP] GET... failed, error: %s\n", diff --git a/examples/Advanced/WIFI/WiFiAccessPoint/WiFiAccessPoint.ino b/examples/Advanced/WIFI/WiFiAccessPoint/WiFiAccessPoint.ino index 4a27be3..0af7807 100644 --- a/examples/Advanced/WIFI/WiFiAccessPoint/WiFiAccessPoint.ino +++ b/examples/Advanced/WIFI/WiFiAccessPoint/WiFiAccessPoint.ino @@ -27,7 +27,7 @@ WiFiServer server(80); void setup() { M5.begin(); // Init M5StickC. 初始化M5StickC - M5.lcd.rotation(3); + M5.lcd.setRotation(3); M5.lcd.println("WIFI ACCESS POINT"); // Screen print string. 屏幕打印字符串 M5.lcd.printf("Please connect:%s \nThen access to:", ssid); WiFi.softAP( @@ -73,7 +73,7 @@ void loop() { // HTTP/1.1 200 OK) HTTP的开头总是以响应代码开始(例如 // HTTP/1.1 200 OK) and a content-type so the client // knows what's coming, then a blank line: - //然后是content-type,这样客户端就知道接下来会发生什么,然后是空行: + // 然后是content-type,这样客户端就知道接下来会发生什么,然后是空行: client.println("HTTP/1.1 200 OK"); client.println("Content-type:text/html"); client.println(); diff --git a/examples/Advanced/WIFI/WiFiSetting/Parsing.cpp b/examples/Advanced/WIFI/WiFiSetting/Parsing.cpp index c8085c8..8ff1ea3 100644 --- a/examples/Advanced/WIFI/WiFiSetting/Parsing.cpp +++ b/examples/Advanced/WIFI/WiFiSetting/Parsing.cpp @@ -24,7 +24,7 @@ #include "WiFiClient.h" #include "WebServer.h" -//#define DEBUG_ESP_HTTP_SERVER +// #define DEBUG_ESP_HTTP_SERVER #ifdef DEBUG_ESP_PORT #define DEBUG_OUTPUT DEBUG_ESP_PORT #else diff --git a/examples/Advanced/WIFI/WiFiSetting/WebServer.cpp b/examples/Advanced/WIFI/WiFiSetting/WebServer.cpp index 3130b72..4fd34c3 100644 --- a/examples/Advanced/WIFI/WiFiSetting/WebServer.cpp +++ b/examples/Advanced/WIFI/WiFiSetting/WebServer.cpp @@ -28,7 +28,7 @@ #include "FS.h" #include "detail/RequestHandlersImpl.h" -//#define DEBUG_ESP_HTTP_SERVER +// #define DEBUG_ESP_HTTP_SERVER #ifdef DEBUG_ESP_PORT #define DEBUG_OUTPUT DEBUG_ESP_PORT #else diff --git a/examples/Advanced/WIFI/WiFiSetting/WiFiSetting.ino b/examples/Advanced/WIFI/WiFiSetting/WiFiSetting.ino index a2789aa..6368128 100644 --- a/examples/Advanced/WIFI/WiFiSetting/WiFiSetting.ino +++ b/examples/Advanced/WIFI/WiFiSetting/WiFiSetting.ino @@ -11,7 +11,7 @@ ******************************************************************************* */ #include -#include > +#include #include #include #include diff --git a/examples/Advanced/WIFI/WiFiSmartConfig/WiFiSmartConfig.ino b/examples/Advanced/WIFI/WiFiSmartConfig/WiFiSmartConfig.ino index 80384d7..88a8c5a 100644 --- a/examples/Advanced/WIFI/WiFiSmartConfig/WiFiSmartConfig.ino +++ b/examples/Advanced/WIFI/WiFiSmartConfig/WiFiSmartConfig.ino @@ -29,7 +29,7 @@ void setup() { // 兼容模式,并开始智能配网 // Wait for the M5StickC to receive network information from the phone - //等待M5StickC接收到来自手机的配网信息 + // 等待M5StickC接收到来自手机的配网信息 M5.Lcd.print( "\nWaiting for Phone SmartConfig."); // Screen print format string. // 屏幕打印格式化字符串 diff --git a/examples/Advanced/WIFI/WiFiTCP/WiFiTCP.ino b/examples/Advanced/WIFI/WiFiTCP/WiFiTCP.ino index 378bc0b..4f2f0ed 100644 --- a/examples/Advanced/WIFI/WiFiTCP/WiFiTCP.ino +++ b/examples/Advanced/WIFI/WiFiTCP/WiFiTCP.ino @@ -75,7 +75,7 @@ void loop() { int maxloops = 0; // wait for the server's reply to become available - //等待服务器的回复 + // 等待服务器的回复 while (!client.available() && maxloops < 1000) { maxloops++; delay(1); // delay 1 msec diff --git a/examples/Basics/FactoryTest/FactoryTest.ino b/examples/Basics/FactoryTest/FactoryTest.ino index a652583..8542c5a 100644 --- a/examples/Basics/FactoryTest/FactoryTest.ino +++ b/examples/Basics/FactoryTest/FactoryTest.ino @@ -71,9 +71,9 @@ double cos_alpha = cos(19.47 * PI / 180); double sin_gamma = sin(20.7 * PI / 180); double cos_gamma = cos(20.7 * PI / 180); -//#define NUM_LEDS 3 -//#define DATA_PIN 32 -// CRGB leds[NUM_LEDS]; +// #define NUM_LEDS 3 +// #define DATA_PIN 32 +// CRGB leds[NUM_LEDS]; hw_timer_t *timer = NULL; volatile SemaphoreHandle_t timerSemaphore; diff --git a/examples/Basics/FactoryTest/LOGO_C.c b/examples/Basics/FactoryTest/LOGO_C.c index 7badea4..e472ea1 100644 --- a/examples/Basics/FactoryTest/LOGO_C.c +++ b/examples/Basics/FactoryTest/LOGO_C.c @@ -1,15 +1,15 @@ /*************************************************************************************/ // -// ͼļ -// ṩ˹2001Hades2001 @2018/09/10 +// ͼ���ļ� +// �����ṩ������˹2001��Hades2001�� @2018/09/10 // Mail: 1521377294@qq.com -// ƣ C:\Users\Administrator\Pictures\LOGO_C.c -// ͼС 25600 b -// ͼģʽ ɫλͼ 16λ RGB565 -// ͼˮƽ 160 -// ͼֱ 80 -// ͼɨģʽ ʽ -// ͼ񴢴ģʽ λ +// ���ƣ� C:\Users\Administrator\Pictures\LOGO_C.c +// ͼ���С�� 25600 b +// ͼ��ģʽ�� ��ɫλͼ 16λ��� RGB565 +// ͼ��ˮƽ���� �� 160 +// ͼ��ֱ���� �� 80 +// ͼ��ɨ��ģʽ �� ����ʽ +// ͼ�񴢴�ģʽ �� ��λ���� // /************************************************************************************/ const unsigned char Logodata[25600] = { diff --git a/examples/Unit/COLOR_TCS3472/COLOR_TCS3472.ino b/examples/Unit/COLOR_TCS3472/COLOR_TCS3472.ino index a83d1cd..3c854f6 100644 --- a/examples/Unit/COLOR_TCS3472/COLOR_TCS3472.ino +++ b/examples/Unit/COLOR_TCS3472/COLOR_TCS3472.ino @@ -38,7 +38,7 @@ void setup() { M5.begin(); // Init M5StickC. 初始化 M5StickC M5.Lcd.setRotation(3); // Rotate the screen. 旋转屏幕 M5.Lcd.println("Color View Test!"); - while (!tcs.begin()) { //如果color unit未能初始化 + while (!tcs.begin()) { // 如果color unit未能初始化 M5.Lcd.println("No TCS34725 found ... check your connections"); M5.Lcd.drawString("No Found sensor.", 50, 100, 4); delay(1000); diff --git a/examples/Unit/HEART/MAX30100_RawData/MAX30100_RawData.ino b/examples/Unit/HEART/MAX30100_RawData/MAX30100_RawData.ino index fa68713..d7e7215 100644 --- a/examples/Unit/HEART/MAX30100_RawData/MAX30100_RawData.ino +++ b/examples/Unit/HEART/MAX30100_RawData/MAX30100_RawData.ino @@ -50,8 +50,8 @@ void setup() { void loop() { uint16_t ir, red; - sensor.update(); //更新传感器读取到的数据 - while (sensor.getRawValues(&ir, &red)) { //如果获取到数据 + sensor.update(); // 更新传感器读取到的数据 + while (sensor.getRawValues(&ir, &red)) { // 如果获取到数据 M5.Lcd.setTextFont(4); M5.Lcd.setCursor(0, 20); M5.Lcd.printf("IR:%d ", ir); diff --git a/examples/Unit/HEART/ScreenShow/ScreenShow.ino b/examples/Unit/HEART/ScreenShow/ScreenShow.ino index e0ee68a..f740f16 100644 --- a/examples/Unit/HEART/ScreenShow/ScreenShow.ino +++ b/examples/Unit/HEART/ScreenShow/ScreenShow.ino @@ -139,7 +139,7 @@ void loop() { map(line[0][(led_pos + i) % 320], led_max, led_min, 0, 80); ir_disdata = map(line[1][(ir_Pos + i) % 320], ir_max, ir_min, 0, 80); k_disdata = map(k_number[(ir_Pos + i) % 320], k_number_max, - k_number_min, 0, 80); + k_number_min, 0, 80); { Disbuff.drawLine(i, led_last, i + 1, led_disdata, WHITE); Disbuff.drawLine(i, ir_last, i + 1, ir_disdata, RED); diff --git a/examples/Unit/IMU_MPU6886/IMU_6886.h b/examples/Unit/IMU_MPU6886/IMU_6886.h index 705413d..aee7f24 100644 --- a/examples/Unit/IMU_MPU6886/IMU_6886.h +++ b/examples/Unit/IMU_MPU6886/IMU_6886.h @@ -47,7 +47,7 @@ #define IMU_6886_FIFO_COUNT 0x72 #define IMU_6886_FIFO_R_W 0x74 #define IMU_6886_GYRO_OFFSET 0x13 -//#define G (9.8) +// #define G (9.8) #define RtA 57.324841 #define AtR 0.0174533 #define Gyro_Gr 0.0010653 diff --git a/examples/Unit/NEOFLASH/DisplayCurrentTime.cpp b/examples/Unit/NEOFLASH/DisplayCurrentTime.cpp index ce9d579..b89fa3b 100644 --- a/examples/Unit/NEOFLASH/DisplayCurrentTime.cpp +++ b/examples/Unit/NEOFLASH/DisplayCurrentTime.cpp @@ -2,19 +2,19 @@ #include "DisplayCurrentTime.h" int zero[18] = {1, 2, 3, 4, 25, 28, 49, 52, 73, 76, - 97, 100, 121, 124, 145, 146, 147, 148}; // Lattice of Number 0 + 97, 100, 121, 124, 145, 146, 147, 148}; // Lattice of Number 0 int one[10] = {3, 26, 27, 51, 75, - 99, 123, 146, 147, 148}; // Lattice of Number 1 + 99, 123, 146, 147, 148}; // Lattice of Number 1 int two[16] = {1, 2, 3, 4, 28, 52, 73, 74, - 75, 76, 97, 121, 145, 146, 147, 148}; // Lattice of Number 2 + 75, 76, 97, 121, 145, 146, 147, 148}; // Lattice of Number 2 int three[16] = {1, 2, 3, 4, 28, 52, 73, 74, 75, 76, 100, 124, 145, 146, 147, 148}; // Lattice of Number 3 int four[13] = {1, 3, 25, 27, 49, 51, 73, - 74, 75, 76, 99, 123, 147}; // Lattice of Number 4 + 74, 75, 76, 99, 123, 147}; // Lattice of Number 4 int five[16] = {1, 2, 3, 4, 25, 49, 73, 74, - 75, 76, 100, 124, 145, 146, 147, 148}; // Lattice of Number 5 + 75, 76, 100, 124, 145, 146, 147, 148}; // Lattice of Number 5 int six[18] = {1, 2, 3, 4, 25, 49, 73, 74, 75, 76, - 97, 100, 121, 124, 145, 146, 147, 148}; // Lattice of Number 6 + 97, 100, 121, 124, 145, 146, 147, 148}; // Lattice of Number 6 int seven[10] = {1, 2, 3, 4, 28, 51, 75, 99, 123, 147}; // Lattice of Number 7 int eight[20] = { 1, 2, 3, 4, 25, 28, 49, 52, 73, 74, diff --git a/examples/Unit/NEOFLASH/NEOFLASH.ino b/examples/Unit/NEOFLASH/NEOFLASH.ino index 0725167..23bfa11 100644 --- a/examples/Unit/NEOFLASH/NEOFLASH.ino +++ b/examples/Unit/NEOFLASH/NEOFLASH.ino @@ -20,7 +20,7 @@ FASTLED_USING_NAMESPACE #endif #define DATA_PIN 26 -//#define CLK_PIN 4 +// #define CLK_PIN 4 #define LED_TYPE WS2811 #define COLOR_ORDER GRB #define NUM_LEDS 192 diff --git a/examples/Unit/RFID/MFRC522_I2C.cpp b/examples/Unit/RFID/MFRC522_I2C.cpp index c250c0f..2e75185 100644 --- a/examples/Unit/RFID/MFRC522_I2C.cpp +++ b/examples/Unit/RFID/MFRC522_I2C.cpp @@ -634,8 +634,8 @@ byte MFRC522::PICC_REQA_or_WUPA( * single 4 1 MIFARE * Classic double 7 2 MIFARE * Ultralight - * triple 10 3 Not currently - * in use? + * triple 10 3 Not + * currently in use? * * @return STATUS_OK on success, STATUS_??? otherwise. */ @@ -669,8 +669,9 @@ byte MFRC522::PICC_Select( // Description of buffer structure: // Byte 0: SEL Indicates the Cascade Level: - //PICC_CMD_SEL_CL1, PICC_CMD_SEL_CL2 or PICC_CMD_SEL_CL3 Byte 1: NVB - //Number of Valid Bits (in complete command, not just the UID): High nibble: + // PICC_CMD_SEL_CL1, PICC_CMD_SEL_CL2 or PICC_CMD_SEL_CL3 Byte 1: NVB + // Number of Valid Bits (in complete command, not just the UID): High + // nibble: // complete bytes, Low nibble: Extra bits. Byte 2: UID-data or CT // See explanation below. CT means Cascade Tag. Byte 3: UID-data // Byte 4: UID-data Byte 5: UID-data @@ -919,7 +920,7 @@ byte MFRC522::PICC_HaltA() { // Send the command. // The standard says: // If the PICC responds with any modulation during a period of 1 ms - //after the end of the frame containing the HLTA command, this + // after the end of the frame containing the HLTA command, this // response shall be interpreted as 'not acknowledge'. // We interpret that this way: Only STATUS_TIMEOUT is an success. result = PCD_TransceiveData(buffer, sizeof(buffer), NULL, 0); @@ -1598,10 +1599,10 @@ void MFRC522::PICC_DumpMifareClassicSectorToSerial( // The access bits are stored in a peculiar fashion. // There are four groups: // g[3] Access bits for the sector trailer, block 3 (for sectors - //0-31) or block 15 (for sectors 32-39) g[2] Access bits for + // 0-31) or block 15 (for sectors 32-39) g[2] Access bits for // block 2 (for sectors 0-31) or blocks 10-14 (for sectors 32-39) g[1] // Access bits for block 1 (for sectors 0-31) or blocks 5-9 (for sectors - //32-39) g[0] Access bits for block 0 (for sectors 0-31) or blocks + // 32-39) g[0] Access bits for block 0 (for sectors 0-31) or blocks // 0-4 (for sectors 32-39) // Each group has access bits [C1 C2 C3]. In this code C1 is MSB and C3 is // LSB. The four CX bits are stored together in a nible cx and an inverted diff --git a/examples/Unit/RFID_RC522/RFID_RC522.ino b/examples/Unit/RFID_RC522/RFID_RC522.ino index f0e1376..8b49fe3 100644 --- a/examples/Unit/RFID_RC522/RFID_RC522.ino +++ b/examples/Unit/RFID_RC522/RFID_RC522.ino @@ -32,7 +32,7 @@ void setup() { void loop() { M5.Lcd.setCursor(22, 23); if (!mfrc522.PICC_IsNewCardPresent() || - !mfrc522.PICC_ReadCardSerial()) { //如果没有读取到新的卡片 + !mfrc522.PICC_ReadCardSerial()) { // 如果没有读取到新的卡片 delay(200); return; } diff --git a/examples/Unit/RGB_SK6812/RGB_SK6812.ino b/examples/Unit/RGB_SK6812/RGB_SK6812.ino index 4654166..10bf048 100644 --- a/examples/Unit/RGB_SK6812/RGB_SK6812.ino +++ b/examples/Unit/RGB_SK6812/RGB_SK6812.ino @@ -16,8 +16,8 @@ red, green and blue 请连接端口,控制RGB单元滚动红、绿、蓝三种 #include #include -#define PIN 32 //定义NeoPixel的控制引脚 -#define NUMPIXELS 3 //定义NeoPixel控制灯灯数量 +#define PIN 32 // 定义NeoPixel的控制引脚 +#define NUMPIXELS 3 // 定义NeoPixel控制灯灯数量 Adafruit_NeoPixel pixels = Adafruit_NeoPixel( NUMPIXELS, PIN, diff --git a/examples/Unit/UWB_DW1000/UWB_DW1000.ino b/examples/Unit/UWB_DW1000/UWB_DW1000.ino index 4647b44..5f9c502 100644 --- a/examples/Unit/UWB_DW1000/UWB_DW1000.ino +++ b/examples/Unit/UWB_DW1000/UWB_DW1000.ino @@ -139,7 +139,7 @@ int UWB_setupmode() // AT command "AT+interval=5\r\n"); // Set the calculation precision, the // larger the response is, the slower // it will be - delay(40); //设置计算精度,越大响应越慢 + delay(40); // 设置计算精度,越大响应越慢 Serial2.write( "AT+switchdis=1\r\n"); // Began to distance 开始测距 delay(40); @@ -236,7 +236,7 @@ void UWB_ui_display() { void setup() { M5.begin(); - Serial2.begin(115200, SERIAL_8N1, 33, 32); //一般都是16.17 + Serial2.begin(115200, SERIAL_8N1, 33, 32); // 一般都是16.17 delay(100); UWB_Timer(); diff --git a/library.json b/library.json index 149997d..65593e6 100644 --- a/library.json +++ b/library.json @@ -10,7 +10,7 @@ "type": "git", "url": "https://github.com/m5stack/M5StickC.git" }, - "version": "0.2.8", + "version": "0.2.9", "frameworks": "arduino", "platforms": "espressif32", "headers": "M5StickC.h" diff --git a/library.properties b/library.properties index f9c280b..ebeb082 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=M5StickC -version=0.2.8 +version=0.2.9 author=M5StickC maintainer=M5Stack sentence=Library for M5StickC Core development kit @@ -8,4 +8,4 @@ category=Device Control url=https://github.com/m5stack/M5StickC.git architectures=esp32 includes=M5StickC.h -depends=M5Family,M5Hat-8Servos,M5_JoyC,M5-RoverC \ No newline at end of file +depends=M5Family,M5Hat-8Servos,M5_JoyC,M5-RoverC