Skip to content

Commit a0afad3

Browse files
committed
init
0 parents  commit a0afad3

33 files changed

+2661
-0
lines changed

.github/scripts/check_versions.sh

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
#!/bin/bash
2+
3+
# Function: Check version format
4+
# Input parameters: $1 The version number
5+
# Return value: 0 if the version numbers are correct, 1 if the first version is incorrect,
6+
check_version_format() {
7+
version_regex="^v[0-9]+\.[0-9]+\.[0-9]+$"
8+
9+
if [[ ! $1 =~ $version_regex ]]; then
10+
return 1
11+
fi
12+
13+
return 0
14+
}
15+
16+
if [ $# -lt 1 ]; then
17+
latest_version="0.0.0"
18+
echo "Don't get the lastest version, use \"0.0.0\" as default"
19+
else
20+
# Get the first input parameter as the version to be compared
21+
latest_version="$1"
22+
# Check the version format
23+
check_version_format "${latest_version}"
24+
result=$?
25+
if [ ${result} -ne 0 ]; then
26+
echo "The latest release version (${latest_version}) format is incorrect."
27+
exit 1
28+
fi
29+
fi
30+
31+
# Specify the directory path
32+
target_directory="./"
33+
34+
echo "Checking directory: ${target_directory}"
35+
36+
# Function: Check if a file exists
37+
# Input parameters: $1 The file to check
38+
# Return value: 0 if the file exists, 1 if the file does not exist
39+
check_file_exists() {
40+
if [ ! -f "$1" ]; then
41+
echo "File '$1' not found."
42+
return 1
43+
fi
44+
return 0
45+
}
46+
47+
# Function: Compare version numbers
48+
# Input parameters: $1 The first version number, $2 The second version number
49+
# Return value: 0 if the version numbers are equal, 1 if the first version is greater,
50+
# 2 if the second version is greater,
51+
compare_versions() {
52+
version_regex="^v[0-9]+\.[0-9]+\.[0-9]+$"
53+
54+
version1=$(echo "$1" | cut -c 2-) # Remove the 'v' at the beginning of the version number
55+
version2=$(echo "$2" | cut -c 2-)
56+
57+
IFS='.' read -ra v1_parts <<< "$version1"
58+
IFS='.' read -ra v2_parts <<< "$version2"
59+
60+
for ((i=0; i<${#v1_parts[@]}; i++)); do
61+
if [[ "${v1_parts[$i]}" -lt "${v2_parts[$i]}" ]]; then
62+
return 2
63+
elif [[ "${v1_parts[$i]}" -gt "${v2_parts[$i]}" ]]; then
64+
return 1
65+
fi
66+
done
67+
68+
return 0
69+
}
70+
71+
echo "Checking file: library.properties"
72+
# Check if "library.properties" file exists
73+
check_file_exists "${target_directory}/library.properties"
74+
if [ $? -ne 0 ]; then
75+
exit 1
76+
fi
77+
# Read the version information from the file
78+
arduino_version=v$(grep -E '^version=' "${target_directory}/library.properties" | cut -d '=' -f 2)
79+
echo "Get Arduino version: ${arduino_version}"
80+
# Check the version format
81+
check_version_format "${arduino_version}"
82+
result=$?
83+
if [ ${result} -ne 0 ]; then
84+
echo "Arduino version (${arduino_version}) format is incorrect."
85+
exit 1
86+
fi
87+
88+
# Compare Arduino Library version with the latest release version
89+
compare_versions "${arduino_version}" "${latest_version}"
90+
result=$?
91+
if [ ${result} -ne 1 ]; then
92+
if [ ${result} -eq 3 ]; then
93+
echo "Arduino version (${arduino_version}) is incorrect."
94+
else
95+
echo "Arduino version (${arduino_version}) is not greater than the latest release version (${latest_version})."
96+
exit 1
97+
fi
98+
fi
99+
100+
echo "Checking file: idf_component.yml"
101+
# Check if "idf_component.yml" file exists
102+
check_file_exists "${target_directory}/idf_component.yml"
103+
if [ $? -eq 0 ]; then
104+
# Read the version information from the file
105+
idf_version=v$(grep -E '^version:' "${target_directory}/idf_component.yml" | awk -F'"' '{print $2}')
106+
echo "Get IDF component version: ${idf_version}"
107+
# Check the version format
108+
check_version_format "${idf_version}"
109+
result=$?
110+
if [ ${result} -ne 0 ]; then
111+
echo "IDF component (${idf_version}) format is incorrect."
112+
exit 1
113+
fi
114+
# Compare IDF Component version with Arduino Library version
115+
compare_versions ${idf_version} ${arduino_version}
116+
result=$?
117+
if [ ${result} -ne 0 ]; then
118+
if [ ${result} -eq 3 ]; then
119+
echo "IDF component version (${idf_version}) is incorrect."
120+
else
121+
echo "IDF component version (${idf_version}) is not equal to the Arduino version (${arduino_version})."
122+
exit 1
123+
fi
124+
fi
125+
# Compare IDF Component version with the latest release version
126+
compare_versions ${idf_version} ${latest_version}
127+
result=$?
128+
if [ ${result} -ne 1 ]; then
129+
if [ ${result} -eq 3 ]; then
130+
echo "IDF component version (${idf_version}) is incorrect."
131+
else
132+
echo "IDF component version (${idf_version}) is not greater than the latest release version (${latest_version})."
133+
exit 1
134+
fi
135+
fi
136+
fi

.github/workflows/arduino_lint.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: Arduino Lint Action
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
types: [opened, reopened, synchronize]
7+
8+
jobs:
9+
lint:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v3
13+
- uses: arduino/arduino-lint-action@v1
14+
with:
15+
library-manager: update

.github/workflows/build_test.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Build Test Application
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
types: [opened, reopened, synchronize]
7+
8+
jobs:
9+
build:
10+
strategy:
11+
matrix:
12+
idf_ver: ["v4.4.5", "v5.0", "v5.1"]
13+
idf_target: ["esp32", "esp32s2", "esp32c3", "esp32s3"]
14+
runs-on: ubuntu-20.04
15+
container: espressif/idf:${{ matrix.idf_ver }}
16+
steps:
17+
- uses: actions/checkout@v3
18+
- name: Build ESP_IOExpander Test Application
19+
env:
20+
IDF_TARGET: ${{ matrix.idf_target }}
21+
working-directory: test_apps
22+
shell: bash
23+
run: |
24+
. ${IDF_PATH}/export.sh
25+
export PEDANTIC_FLAGS="-DIDF_CI_BUILD -Werror -Werror=deprecated-declarations -Werror=unused-variable -Werror=unused-but-set-variable -Werror=unused-function"
26+
export EXTRA_CFLAGS="${PEDANTIC_FLAGS} -Wstrict-prototypes"
27+
export EXTRA_CXXFLAGS="${PEDANTIC_FLAGS}"
28+
idf.py build

.github/workflows/check_versions.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Check Versions
2+
3+
on:
4+
pull_request:
5+
types: [opened, reopened, synchronize]
6+
7+
jobs:
8+
check_versions:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v2
12+
- name: Get latest release info of repository
13+
id: last_release
14+
uses: InsonusK/get-latest-release@v1.1.0
15+
with:
16+
myToken: ${{ github.token }}
17+
exclude_types: "draft|prerelease"
18+
view_top: 1
19+
- name: Print result
20+
run: |
21+
echo "id: ${{ steps.last_release.outputs.id }}"
22+
echo "name: ${{ steps.last_release.outputs.name }}"
23+
echo "tag_name: ${{ steps.last_release.outputs.tag_name }}"
24+
echo "created_at: ${{ steps.last_release.outputs.created_at }}"
25+
echo "draft: ${{ steps.last_release.outputs.draft }}"
26+
echo "prerelease: ${{ steps.last_release.outputs.prerelease }}"
27+
echo "url: ${{ steps.last_release.outputs.url }}"
28+
- name: Check & Compare versions
29+
run: bash ./.github/scripts/check_versions.sh ${{ steps.last_release.outputs.tag_name }}
30+

.github/workflows/pre-commit.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: pre-commit
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
types: [opened, reopened, synchronize]
7+
8+
jobs:
9+
pre-commit:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v2
13+
- uses: actions/setup-python@v2
14+
- uses: pre-commit/action@v2.0.3

.gitignore

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
.config
2+
*.o
3+
*.pyc
4+
*.orig
5+
6+
# gtags
7+
GTAGS
8+
GRTAGS
9+
GPATH
10+
11+
# emacs
12+
.dir-locals.el
13+
14+
# emacs temp file suffixes
15+
*~
16+
.#*
17+
\#*#
18+
19+
# eclipse setting
20+
.settings
21+
22+
# MacOS directory files
23+
.DS_Store
24+
25+
# Unit Test CMake compile log folder
26+
log_ut_cmake
27+
28+
TEST_LOGS
29+
30+
# gcov coverage reports
31+
*.gcda
32+
*.gcno
33+
coverage.info
34+
coverage_report/
35+
36+
test_multi_heap_host
37+
38+
# VS Code Settings
39+
.vscode/
40+
41+
# VIM files
42+
*.swp
43+
*.swo
44+
45+
# Clion IDE CMake build & config
46+
.idea/
47+
cmake-build-*/
48+
49+
# Results for the checking of the Python coding style and static analysis
50+
.mypy_cache
51+
flake8_output.txt
52+
53+
# esp-idf default build directory name
54+
build
55+
build_esp*/
56+
build_linux*/
57+
size_info.txt
58+
sdkconfig
59+
sdkconfig.old
60+
61+
# lock files for examples and components
62+
dependencies.lock
63+
64+
# managed_components for examples
65+
managed_components
66+
67+
# pytest log
68+
pytest_embedded_log/
69+
pytest_log/
70+
.pytest_cache/
71+
XUNIT_RESULT.xml

.pre-commit-config.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
repos:
2+
- repo: https://github.com/igrr/astyle_py.git
3+
rev: master
4+
hooks:
5+
- id: astyle_py
6+
args: ['--style=otbs', '--attach-namespaces', '--attach-classes', '--indent=spaces=4', '--convert-tabs', '--align-pointer=name', '--align-reference=name', '--keep-one-line-statements', '--pad-header', '--pad-oper']
7+
8+
- repo: https://github.com/pre-commit/pre-commit-hooks
9+
rev: v4.3.0
10+
hooks:
11+
- id: trailing-whitespace
12+
types_or: [c, c++]
13+
- id: end-of-file-fixer
14+
types_or: [c, c++]
15+
- id: check-merge-conflict
16+
- id: mixed-line-ending
17+
types_or: [c, c++]
18+
args: ['--fix=lf']
19+
description: Forces to replace line ending by the UNIX 'lf' character
20+
21+
- repo: https://github.com/espressif/check-copyright/
22+
rev: v1.0.3
23+
hooks:
24+
- id: check-copyright
25+
args: ['--config', 'check_copyright_config.yaml']

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# ChangeLog
2+
3+
## v0.0.1 - 2023-09-20
4+
5+
### Enhancements:
6+
7+
* Support for various IO expander chips.
8+
* Support to control individual IO in the same way as Arduino
9+
* Support to control multiple IOs at the same time.

CMakeLists.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
set(SRCS_DIR "src")
2+
3+
file(GLOB_RECURSE CPP_SRCS "${SRCS_DIR}/*.cpp")
4+
file(GLOB_RECURSE C_SRCS "${SRCS_DIR}/*.c")
5+
6+
idf_component_register(
7+
SRCS
8+
${C_SRCS}
9+
${CPP_SRCS}
10+
INCLUDE_DIRS
11+
${SRCS_DIR}
12+
REQUIRES
13+
driver
14+
)
15+
16+
target_compile_options(${COMPONENT_LIB} PRIVATE -Wno-missing-field-initializers)

0 commit comments

Comments
 (0)