From c263ec9b672ea9db048aa1226dfcbfef0efc6193 Mon Sep 17 00:00:00 2001 From: sean <1026025056@qq.com> Date: Thu, 17 Aug 2023 11:55:44 +0800 Subject: [PATCH] release v0.2.9 and update workflows --- .github/actions/action.yml | 115 +++ .github/actions/arduino-test-compile.sh | 506 ++++++++++++++ .github/workflows/Arduino-Lint-Check.yml | 15 + .../arduino-action-stickc-compile.yml | 80 +++ .github/workflows/clang-format-check.yml | 2 +- README.md | 4 + README_cn.md | 4 + .../Cellular_Automata/Cellular_Automata.ino | 6 +- examples/Advanced/Display/HZK16/str.h | 2 +- .../Display/TFT_Ellipse/TFT_Ellipse.ino | 2 +- examples/Advanced/HallSensor/HallSensor.ino | 8 +- examples/Advanced/MQTT/MQTT.ino | 2 +- examples/Advanced/MultiTask/MultiTask.ino | 2 +- examples/Advanced/Storage/EEPROM/EEPROM.ino | 6 +- .../Advanced/Storage/SPIFFS/SPIFFS/SPIFFS.ino | 2 +- .../Storage/SPIFFS/SPIFFS_Add/SPIFFS_Add.ino | 2 +- .../WIFI/BasicHttpClient/BasicHttpClient.ino | 4 +- .../WIFI/WiFiAccessPoint/WiFiAccessPoint.ino | 4 +- .../Advanced/WIFI/WiFiSetting/Parsing.cpp | 2 +- .../Advanced/WIFI/WiFiSetting/WebServer.cpp | 2 +- .../Advanced/WIFI/WiFiSetting/WiFiSetting.ino | 2 +- .../WIFI/WiFiSmartConfig/WiFiSmartConfig.ino | 2 +- examples/Advanced/WIFI/WiFiTCP/WiFiTCP.ino | 2 +- examples/Basics/FactoryTest/FactoryTest.ino | 6 +- examples/Basics/FactoryTest/LOGO_C.c | 18 +- examples/Unit/COLOR_TCS3472/COLOR_TCS3472.ino | 2 +- .../MAX30100_RawData/MAX30100_RawData.ino | 4 +- examples/Unit/HEART/ScreenShow/ScreenShow.ino | 2 +- examples/Unit/IMU_MPU6886/IMU_6886.h | 2 +- examples/Unit/NEOFLASH/DisplayCurrentTime.cpp | 55 +- examples/Unit/NEOFLASH/NEOFLASH.ino | 2 +- examples/Unit/PDM_SPM1423/fft.cpp | 653 ++++++++++++++++++ examples/Unit/PDM_SPM1423/fft.h | 75 ++ examples/Unit/RFID/MFRC522_I2C.cpp | 19 +- examples/Unit/RFID_RC522/RFID_RC522.ino | 2 +- examples/Unit/RGB_SK6812/RGB_SK6812.ino | 4 +- examples/Unit/UWB_DW1000/UWB_DW1000.ino | 4 +- library.json | 2 +- library.properties | 4 +- 39 files changed, 1549 insertions(+), 81 deletions(-) create mode 100644 .github/actions/action.yml create mode 100755 .github/actions/arduino-test-compile.sh create mode 100644 .github/workflows/Arduino-Lint-Check.yml create mode 100644 .github/workflows/arduino-action-stickc-compile.yml create mode 100644 examples/Unit/PDM_SPM1423/fft.cpp create mode 100644 examples/Unit/PDM_SPM1423/fft.h 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..ab3a237 100644 --- a/examples/Unit/NEOFLASH/DisplayCurrentTime.cpp +++ b/examples/Unit/NEOFLASH/DisplayCurrentTime.cpp @@ -1,27 +1,42 @@ #include "FastLED.h" #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 -int one[10] = {3, 26, 27, 51, 75, - 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 +// Lattice of Number 0 +int zero[18] = {1, 2, 3, 4, 25, 28, 49, 52, 73, + 76, 97, 100, 121, 124, 145, 146, 147, 148}; + +// Lattice of Number 1 +int one[10] = {3, 26, 27, 51, 75, 99, 123, 146, 147, 148}; +// Lattice of Number 2 +int two[16] = {1, 2, 3, 4, 28, 52, 73, 74, 75, 76, 97, 121, 145, 146, 147, 148}; + +// Lattice of Number 3 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 -int five[16] = {1, 2, 3, 4, 25, 49, 73, 74, - 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 -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, - 75, 76, 97, 100, 121, 124, 145, 146, 147, 148}; // Lattice of Number 8 -int nine[18] = {1, 2, 3, 4, 25, 28, 49, 52, 73, 74, - 75, 76, 100, 124, 145, 146, 147, 148}; // Lattice of Number 9 -int point[2] = {84, 132}; // Lattice of character : + 75, 76, 100, 124, 145, 146, 147, 148}; + +// Lattice of Number 4 +int four[13] = {1, 3, 25, 27, 49, 51, 73, 74, 75, 76, 99, 123, 147}; +// Lattice of Number 5 +int five[16] = {1, 2, 3, 4, 25, 49, 73, 74, + + 75, 76, 100, 124, 145, 146, 147, 148}; +// Lattice of Number 6 +int six[18] = {1, 2, 3, 4, 25, 49, 73, 74, 75, + 76, 97, 100, 121, 124, 145, 146, 147, 148}; + +// Lattice of Number 7 +int seven[10] = {1, 2, 3, 4, 28, 51, 75, 99, 123, 147}; + +// Lattice of Number 8 +int eight[20] = {1, 2, 3, 4, 25, 28, 49, 52, 73, 74, + 75, 76, 97, 100, 121, 124, 145, 146, 147, 148}; + +// Lattice of Number 9 +int nine[18] = {1, 2, 3, 4, 25, 28, 49, 52, 73, + 74, 75, 76, 100, 124, 145, 146, 147, 148}; + +// Lattice of character : +int point[2] = {84, 132}; int lenth[11] = {18, 10, 16, 16, 13, 16, 18, 10, 20, 18, 2}; int *num[10] = {zero, one, two, three, four, five, six, seven, eight, nine}; 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/PDM_SPM1423/fft.cpp b/examples/Unit/PDM_SPM1423/fft.cpp new file mode 100644 index 0000000..476d443 --- /dev/null +++ b/examples/Unit/PDM_SPM1423/fft.cpp @@ -0,0 +1,653 @@ +/* + + ESP32 FFT + ========= + + This provides a vanilla radix-2 FFT implementation and a test example. + + Author + ------ + + This code was written by [Robin Scheibler](http://www.robinscheibler.org) + during rainy days in October 2017. + + License + ------- + + Copyright (c) 2017 Robin Scheibler + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. + +*/ +#include +#include +#include +#include + +#include "fft.h" + +#define TWO_PI 6.28318530 +#define USE_SPLIT_RADIX 1 +#define LARGE_BASE_CASE 1 + +fft_config_t *fft_init(int size, fft_type_t type, fft_direction_t direction, + float *input, float *output) { + /* + * Prepare an FFT of correct size and types. + * + * If no input or output buffers are provided, they will be allocated. + */ + int k, m; + + fft_config_t *config = (fft_config_t *)malloc(sizeof(fft_config_t)); + + // Check if the size is a power of two + if ((size & (size - 1)) != 0) // tests if size is a power of two + return NULL; + + // start configuration + config->flags = 0; + config->type = type; + config->direction = direction; + config->size = size; + + // Allocate and precompute twiddle factors + config->twiddle_factors = (float *)malloc(2 * config->size * sizeof(float)); + + float two_pi_by_n = TWO_PI / config->size; + + for (k = 0, m = 0; k < config->size; k++, m += 2) { + config->twiddle_factors[m] = cosf(two_pi_by_n * k); // real + config->twiddle_factors[m + 1] = sinf(two_pi_by_n * k); // imag + } + + // Allocate input buffer + if (input != NULL) + config->input = input; + else { + if (config->type == FFT_REAL) + config->input = (float *)malloc(config->size * sizeof(float)); + else if (config->type == FFT_COMPLEX) + config->input = (float *)malloc(2 * config->size * sizeof(float)); + + config->flags |= FFT_OWN_INPUT_MEM; + } + + if (config->input == NULL) return NULL; + + // Allocate output buffer + if (output != NULL) + config->output = output; + else { + if (config->type == FFT_REAL) + config->output = (float *)malloc(config->size * sizeof(float)); + else if (config->type == FFT_COMPLEX) + config->output = (float *)malloc(2 * config->size * sizeof(float)); + + config->flags |= FFT_OWN_OUTPUT_MEM; + } + + if (config->output == NULL) return NULL; + + return config; +} + +void fft_destroy(fft_config_t *config) { + if (config->flags & FFT_OWN_INPUT_MEM) free(config->input); + + if (config->flags & FFT_OWN_OUTPUT_MEM) free(config->output); + + free(config->twiddle_factors); + free(config); +} + +void fft_execute(fft_config_t *config) { + if (config->type == FFT_REAL && config->direction == FFT_FORWARD) + rfft(config->input, config->output, config->twiddle_factors, + config->size); + else if (config->type == FFT_REAL && config->direction == FFT_BACKWARD) + irfft(config->input, config->output, config->twiddle_factors, + config->size); + else if (config->type == FFT_COMPLEX && config->direction == FFT_FORWARD) + fft(config->input, config->output, config->twiddle_factors, + config->size); + else if (config->type == FFT_COMPLEX && config->direction == FFT_BACKWARD) + ifft(config->input, config->output, config->twiddle_factors, + config->size); +} + +void fft(float *input, float *output, float *twiddle_factors, int n) { + /* + * Forward fast Fourier transform + * DIT, radix-2, out-of-place implementation + * + * Parameters + * ---------- + * input (float *) + * The input array containing the complex samples with + * real/imaginary parts interleaved [Re(x0), Im(x0), ..., Re(x_n-1), + * Im(x_n-1)] output (float *) The output array containing the complex + * samples with real/imaginary parts interleaved [Re(x0), Im(x0), ..., + * Re(x_n-1), Im(x_n-1)] n (int) The FFT size, should be a power of 2 + */ + +#if USE_SPLIT_RADIX + split_radix_fft(input, output, n, 2, twiddle_factors, 2); +#else + fft_primitive(input, output, n, 2, twiddle_factors, 2); +#endif +} + +void ifft(float *input, float *output, float *twiddle_factors, int n) { + /* + * Inverse fast Fourier transform + * DIT, radix-2, out-of-place implementation + * + * Parameters + * ---------- + * input (float *) + * The input array containing the complex samples with + * real/imaginary parts interleaved [Re(x0), Im(x0), ..., Re(x_n-1), + * Im(x_n-1)] output (float *) The output array containing the complex + * samples with real/imaginary parts interleaved [Re(x0), Im(x0), ..., + * Re(x_n-1), Im(x_n-1)] n (int) The FFT size, should be a power of 2 + */ + ifft_primitive(input, output, n, 2, twiddle_factors, 2); +} + +void rfft(float *x, float *y, float *twiddle_factors, int n) { + // This code uses the two-for-the-price-of-one strategy +#if USE_SPLIT_RADIX + split_radix_fft(x, y, n / 2, 2, twiddle_factors, 4); +#else + fft_primitive(x, y, n / 2, 2, twiddle_factors, 4); +#endif + + // Now apply post processing to recover positive + // frequencies of the real FFT + float t = y[0]; + y[0] = t + y[1]; // DC coefficient + y[1] = t - y[1]; // Center coefficient + + // Apply post processing to quarter element + // this boils down to taking complex conjugate + y[n / 2 + 1] = -y[n / 2 + 1]; + + // Now process all the other frequencies + int k; + for (k = 2; k < n / 2; k += 2) { + float xer, xei, xor_t, xoi, c, s, tr, ti; + + c = twiddle_factors[k]; + s = twiddle_factors[k + 1]; + + // even half coefficient + xer = 0.5 * (y[k] + y[n - k]); + xei = 0.5 * (y[k + 1] - y[n - k + 1]); + + // odd half coefficient + xor_t = 0.5 * (y[k + 1] + y[n - k + 1]); + xoi = -0.5 * (y[k] - y[n - k]); + + tr = c * xor_t + s * xoi; + ti = -s * xor_t + c * xoi; + + y[k] = xer + tr; + y[k + 1] = xei + ti; + + y[n - k] = xer - tr; + y[n - k + 1] = -(xei - ti); + } +} + +void irfft(float *x, float *y, float *twiddle_factors, int n) { + /* + * Destroys content of input vector + */ + int k; + + // Here we need to apply a pre-processing first + float t = x[0]; + x[0] = 0.5 * (t + x[1]); + x[1] = 0.5 * (t - x[1]); + + x[n / 2 + 1] = -x[n / 2 + 1]; + + for (k = 2; k < n / 2; k += 2) { + float xer, xei, xor_t, xoi, c, s, tr, ti; + + c = twiddle_factors[k]; + s = twiddle_factors[k + 1]; + + xer = 0.5 * (x[k] + x[n - k]); + tr = 0.5 * (x[k] - x[n - k]); + + xei = 0.5 * (x[k + 1] - x[n - k + 1]); + ti = 0.5 * (x[k + 1] + x[n - k + 1]); + + xor_t = c * tr - s * ti; + xoi = s * tr + c * ti; + + x[k] = xer - xoi; + x[k + 1] = xor_t + xei; + + x[n - k] = xer + xoi; + x[n - k + 1] = xor_t - xei; + } + + ifft_primitive(x, y, n / 2, 2, twiddle_factors, 4); +} + +void fft_primitive(float *x, float *y, int n, int stride, + float *twiddle_factors, int tw_stride) { + /* + * This code will compute the FFT of the input vector x + * + * The input data is assumed to be real/imag interleaved + * + * The size n should be a power of two + * + * y is an output buffer of size 2n to accomodate for complex numbers + * + * Forward fast Fourier transform + * DIT, radix-2, out-of-place implementation + * + * For a complex FFT, call first stage as: + * fft(x, y, n, 2, 2); + * + * Parameters + * ---------- + * x (float *) + * The input array containing the complex samples with + * real/imaginary parts interleaved [Re(x0), Im(x0), ..., Re(x_n-1), + * Im(x_n-1)] y (float *) The output array containing the complex samples + * with real/imaginary parts interleaved [Re(x0), Im(x0), ..., Re(x_n-1), + * Im(x_n-1)] n (int) The FFT size, should be a power of 2 stride (int) The + * number of elements to skip between two successive samples tw_stride (int) + * The number of elements to skip between two successive twiddle factors + */ + int k; + float t; + +#if LARGE_BASE_CASE + // End condition, stop at n=8 to avoid one trivial recursion + if (n == 8) { + fft8(x, stride, y, 2); + return; + } +#else + // End condition, stop at n=2 to avoid one trivial recursion + if (n == 2) { + y[0] = x[0] + x[stride]; + y[1] = x[1] + x[stride + 1]; + y[2] = x[0] - x[stride]; + y[3] = x[1] - x[stride + 1]; + return; + } +#endif + + // Recursion -- Decimation In Time algorithm + fft_primitive(x, y, n / 2, 2 * stride, twiddle_factors, + 2 * tw_stride); // even half + fft_primitive(x + stride, y + n, n / 2, 2 * stride, twiddle_factors, + 2 * tw_stride); // odd half + + // Stitch back together + + // We can a few multiplications in the first step + t = y[0]; + y[0] = t + y[n]; + y[n] = t - y[n]; + + t = y[1]; + y[1] = t + y[n + 1]; + y[n + 1] = t - y[n + 1]; + + for (k = 1; k < n / 2; k++) { + float x1r, x1i, x2r, x2i, c, s; + c = twiddle_factors[k * tw_stride]; + s = twiddle_factors[k * tw_stride + 1]; + + x1r = y[2 * k]; + x1i = y[2 * k + 1]; + x2r = c * y[n + 2 * k] + s * y[n + 2 * k + 1]; + x2i = -s * y[n + 2 * k] + c * y[n + 2 * k + 1]; + + y[2 * k] = x1r + x2r; + y[2 * k + 1] = x1i + x2i; + + y[n + 2 * k] = x1r - x2r; + y[n + 2 * k + 1] = x1i - x2i; + } +} + +void split_radix_fft(float *x, float *y, int n, int stride, + float *twiddle_factors, int tw_stride) { + /* + * This code will compute the FFT of the input vector x + * + * The input data is assumed to be real/imag interleaved + * + * The size n should be a power of two + * + * y is an output buffer of size 2n to accomodate for complex numbers + * + * Forward fast Fourier transform + * Split-Radix + * DIT, radix-2, out-of-place implementation + * + * For a complex FFT, call first stage as: + * fft(x, y, n, 2, 2); + * + * Parameters + * ---------- + * x (float *) + * The input array containing the complex samples with + * real/imaginary parts interleaved [Re(x0), Im(x0), ..., Re(x_n-1), + * Im(x_n-1)] y (float *) The output array containing the complex samples + * with real/imaginary parts interleaved [Re(x0), Im(x0), ..., Re(x_n-1), + * Im(x_n-1)] n (int) The FFT size, should be a power of 2 stride (int) The + * number of elements to skip between two successive samples twiddle_factors + * (float *) The array of twiddle factors tw_stride (int) The number of + * elements to skip between two successive twiddle factors + */ + int k; + +#if LARGE_BASE_CASE + // End condition, stop at n=2 to avoid one trivial recursion + if (n == 8) { + fft8(x, stride, y, 2); + return; + } else if (n == 4) { + fft4(x, stride, y, 2); + return; + } +#else + // End condition, stop at n=2 to avoid one trivial recursion + if (n == 2) { + y[0] = x[0] + x[stride]; + y[1] = x[1] + x[stride + 1]; + y[2] = x[0] - x[stride]; + y[3] = x[1] - x[stride + 1]; + return; + } else if (n == 1) { + y[0] = x[0]; + y[1] = x[1]; + return; + } +#endif + + // Recursion -- Decimation In Time algorithm + split_radix_fft(x, y, n / 2, 2 * stride, twiddle_factors, 2 * tw_stride); + split_radix_fft(x + stride, y + n, n / 4, 4 * stride, twiddle_factors, + 4 * tw_stride); + split_radix_fft(x + 3 * stride, y + n + n / 2, n / 4, 4 * stride, + twiddle_factors, 4 * tw_stride); + + // Stitch together the output + float u1r, u1i, u2r, u2i, x1r, x1i, x2r, x2i; + float t; + + // We can save a few multiplications in the first step + u1r = y[0]; + u1i = y[1]; + u2r = y[n / 2]; + u2i = y[n / 2 + 1]; + + x1r = y[n]; + x1i = y[n + 1]; + x2r = y[n / 2 + n]; + x2i = y[n / 2 + n + 1]; + + t = x1r + x2r; + y[0] = u1r + t; + y[n] = u1r - t; + + t = x1i + x2i; + y[1] = u1i + t; + y[n + 1] = u1i - t; + + t = x2i - x1i; + y[n / 2] = u2r - t; + y[n + n / 2] = u2r + t; + + t = x1r - x2r; + y[n / 2 + 1] = u2i - t; + y[n + n / 2 + 1] = u2i + t; + + for (k = 1; k < n / 4; k++) { + float u1r, u1i, u2r, u2i, x1r, x1i, x2r, x2i, c1, s1, c2, s2; + c1 = twiddle_factors[k * tw_stride]; + s1 = twiddle_factors[k * tw_stride + 1]; + c2 = twiddle_factors[3 * k * tw_stride]; + s2 = twiddle_factors[3 * k * tw_stride + 1]; + + u1r = y[2 * k]; + u1i = y[2 * k + 1]; + u2r = y[2 * k + n / 2]; + u2i = y[2 * k + n / 2 + 1]; + + x1r = c1 * y[n + 2 * k] + s1 * y[n + 2 * k + 1]; + x1i = -s1 * y[n + 2 * k] + c1 * y[n + 2 * k + 1]; + x2r = c2 * y[n / 2 + n + 2 * k] + s2 * y[n / 2 + n + 2 * k + 1]; + x2i = -s2 * y[n / 2 + n + 2 * k] + c2 * y[n / 2 + n + 2 * k + 1]; + + t = x1r + x2r; + y[2 * k] = u1r + t; + y[2 * k + n] = u1r - t; + + t = x1i + x2i; + y[2 * k + 1] = u1i + t; + y[2 * k + n + 1] = u1i - t; + + t = x2i - x1i; + y[2 * k + n / 2] = u2r - t; + y[2 * k + n + n / 2] = u2r + t; + + t = x1r - x2r; + y[2 * k + n / 2 + 1] = u2i - t; + y[2 * k + n + n / 2 + 1] = u2i + t; + } +} + +void ifft_primitive(float *input, float *output, int n, int stride, + float *twiddle_factors, int tw_stride) { +#if USE_SPLIT_RADIX + split_radix_fft(input, output, n, stride, twiddle_factors, tw_stride); +#else + fft_primitive(input, output, n, stride, twiddle_factors, tw_stride); +#endif + + int ks; + + int ns = n * stride; + + // reverse all coefficients from 1 to n / 2 - 1 + for (ks = stride; ks < ns / 2; ks += stride) { + float t; + + t = output[ks]; + output[ks] = output[ns - ks]; + output[ns - ks] = t; + + t = output[ks + 1]; + output[ks + 1] = output[ns - ks + 1]; + output[ns - ks + 1] = t; + } + + // Apply normalization + float norm = 1. / n; + for (ks = 0; ks < ns; ks += stride) { + output[ks] *= norm; + output[ks + 1] *= norm; + } +} + +inline void fft8(float *input, int stride_in, float *output, int stride_out) { + /* + * Unrolled implementation of FFT8 for a little more performance + */ + float a0r, a1r, a2r, a3r, a4r, a5r, a6r, a7r; + float a0i, a1i, a2i, a3i, a4i, a5i, a6i, a7i; + float b0r, b1r, b2r, b3r, b4r, b5r, b6r, b7r; + float b0i, b1i, b2i, b3i, b4i, b5i, b6i, b7i; + float t; + float sin_pi_4 = 0.7071067812; + + a0r = input[0]; + a0i = input[1]; + a1r = input[stride_in]; + a1i = input[stride_in + 1]; + a2r = input[2 * stride_in]; + a2i = input[2 * stride_in + 1]; + a3r = input[3 * stride_in]; + a3i = input[3 * stride_in + 1]; + a4r = input[4 * stride_in]; + a4i = input[4 * stride_in + 1]; + a5r = input[5 * stride_in]; + a5i = input[5 * stride_in + 1]; + a6r = input[6 * stride_in]; + a6i = input[6 * stride_in + 1]; + a7r = input[7 * stride_in]; + a7i = input[7 * stride_in + 1]; + + // Stage 1 + + b0r = a0r + a4r; + b0i = a0i + a4i; + + b1r = a1r + a5r; + b1i = a1i + a5i; + + b2r = a2r + a6r; + b2i = a2i + a6i; + + b3r = a3r + a7r; + b3i = a3i + a7i; + + b4r = a0r - a4r; + b4i = a0i - a4i; + + b5r = a1r - a5r; + b5i = a1i - a5i; + // W_8^1 = 1/sqrt(2) - j / sqrt(2) + t = b5r + b5i; + b5i = (b5i - b5r) * sin_pi_4; + b5r = t * sin_pi_4; + + // W_8^2 = -j + b6r = a2i - a6i; + b6i = a6r - a2r; + + b7r = a3r - a7r; + b7i = a3i - a7i; + // W_8^3 = -1 / sqrt(2) + j / sqrt(2) + t = sin_pi_4 * (b7i - b7r); + b7i = -(b7r + b7i) * sin_pi_4; + b7r = t; + + // Stage 2 + + a0r = b0r + b2r; + a0i = b0i + b2i; + + a1r = b1r + b3r; + a1i = b1i + b3i; + + a2r = b0r - b2r; + a2i = b0i - b2i; + + // * j + a3r = b1i - b3i; + a3i = b3r - b1r; + + a4r = b4r + b6r; + a4i = b4i + b6i; + + a5r = b5r + b7r; + a5i = b5i + b7i; + + a6r = b4r - b6r; + a6i = b4i - b6i; + + // * j + a7r = b5i - b7i; + a7i = b7r - b5r; + + // Stage 3 + + // X[0] + output[0] = a0r + a1r; + output[1] = a0i + a1i; + + // X[4] + output[4 * stride_out] = a0r - a1r; + output[4 * stride_out + 1] = a0i - a1i; + + // X[2] + output[2 * stride_out] = a2r + a3r; + output[2 * stride_out + 1] = a2i + a3i; + + // X[6] + output[6 * stride_out] = a2r - a3r; + output[6 * stride_out + 1] = a2i - a3i; + + // X[1] + output[stride_out] = a4r + a5r; + output[stride_out + 1] = a4i + a5i; + + // X[5] + output[5 * stride_out] = a4r - a5r; + output[5 * stride_out + 1] = a4i - a5i; + + // X[3] + output[3 * stride_out] = a6r + a7r; + output[3 * stride_out + 1] = a6i + a7i; + + // X[7] + output[7 * stride_out] = a6r - a7r; + output[7 * stride_out + 1] = a6i - a7i; +} + +inline void fft4(float *input, int stride_in, float *output, int stride_out) { + /* + * Unrolled implementation of FFT4 for a little more performance + */ + float t1, t2; + + t1 = input[0] + input[2 * stride_in]; + t2 = input[stride_in] + input[3 * stride_in]; + output[0] = t1 + t2; + output[2 * stride_out] = t1 - t2; + + t1 = input[1] + input[2 * stride_in + 1]; + t2 = input[stride_in + 1] + input[3 * stride_in + 1]; + output[1] = t1 + t2; + output[2 * stride_out + 1] = t1 - t2; + + t1 = input[0] - input[2 * stride_in]; + t2 = input[stride_in + 1] - input[3 * stride_in + 1]; + output[stride_out] = t1 + t2; + output[3 * stride_out] = t1 - t2; + + t1 = input[1] - input[2 * stride_in + 1]; + t2 = input[3 * stride_in] - input[stride_in]; + output[stride_out + 1] = t1 + t2; + output[3 * stride_out + 1] = t1 - t2; +} diff --git a/examples/Unit/PDM_SPM1423/fft.h b/examples/Unit/PDM_SPM1423/fft.h new file mode 100644 index 0000000..a823aeb --- /dev/null +++ b/examples/Unit/PDM_SPM1423/fft.h @@ -0,0 +1,75 @@ +/* + + ESP32 FFT + ========= + + This provides a vanilla radix-2 FFT implementation and a test example. + + Author + ------ + + This code was written by [Robin Scheibler](http://www.robinscheibler.org) + during rainy days in October 2017. + + License + ------- + + Copyright (c) 2017 Robin Scheibler + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. + +*/ +#ifndef __FFT_H__ +#define __FFT_H__ + +typedef enum { FFT_REAL, FFT_COMPLEX } fft_type_t; + +typedef enum { FFT_FORWARD, FFT_BACKWARD } fft_direction_t; + +#define FFT_OWN_INPUT_MEM 1 +#define FFT_OWN_OUTPUT_MEM 2 + +typedef struct { + int size; // FFT size + float *input; // pointer to input buffer + float *output; // pointer to output buffer + float *twiddle_factors; // pointer to buffer holding twiddle factors + fft_type_t type; // real or complex + fft_direction_t direction; // forward or backward + unsigned int flags; // FFT flags +} fft_config_t; + +fft_config_t *fft_init(int size, fft_type_t type, fft_direction_t direction, + float *input, float *output); +void fft_destroy(fft_config_t *config); +void fft_execute(fft_config_t *config); +void fft(float *input, float *output, float *twiddle_factors, int n); +void ifft(float *input, float *output, float *twiddle_factors, int n); +void rfft(float *x, float *y, float *twiddle_factors, int n); +void irfft(float *x, float *y, float *twiddle_factors, int n); +void fft_primitive(float *x, float *y, int n, int stride, + float *twiddle_factors, int tw_stride); +void split_radix_fft(float *x, float *y, int n, int stride, + float *twiddle_factors, int tw_stride); +void ifft_primitive(float *input, float *output, int n, int stride, + float *twiddle_factors, int tw_stride); +void fft8(float *input, int stride_in, float *output, int stride_out); +void fft4(float *input, int stride_in, float *output, int stride_out); + +#endif // __FFT_H__ diff --git a/examples/Unit/RFID/MFRC522_I2C.cpp b/examples/Unit/RFID/MFRC522_I2C.cpp index c250c0f..4b26761 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); @@ -1068,8 +1069,8 @@ byte MFRC522::MIFARE_Write( byte cmdBuffer[2]; cmdBuffer[0] = PICC_CMD_MF_WRITE; cmdBuffer[1] = blockAddr; - result = PCD_MIFARE_Transceive( - cmdBuffer, 2); // Adds CRC_A and checks that the response is MF_ACK. + // Adds CRC_A and checks that the response is MF_ACK. + result = PCD_MIFARE_Transceive(cmdBuffer, 2); if (result != STATUS_OK) { return result; } @@ -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