Skip to content

Commit 4deeae7

Browse files
Ali Hassan ShahLzw655
authored andcommitted
ESP-Button
1 parent ee30cbf commit 4deeae7

29 files changed

+3214
-1
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"]
13+
idf_target: ["esp32"]
14+
runs-on: ubuntu-20.04
15+
container: espressif/idf:${{ matrix.idf_ver }}
16+
steps:
17+
- uses: actions/checkout@v3
18+
- name: Build ESP_Button 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: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
exclude: 'src/original'
2+
repos:
3+
- repo: https://github.com/igrr/astyle_py.git
4+
rev: master
5+
hooks:
6+
- id: astyle_py
7+
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']
8+
9+
- repo: https://github.com/pre-commit/pre-commit-hooks
10+
rev: v4.3.0
11+
hooks:
12+
- id: trailing-whitespace
13+
types_or: [c, c++]
14+
- id: end-of-file-fixer
15+
types_or: [c, c++]
16+
- id: check-merge-conflict
17+
- id: mixed-line-ending
18+
types_or: [c, c++]
19+
args: ['--fix=lf']
20+
description: Forces to replace line ending by the UNIX 'lf' character
21+
22+
- repo: https://github.com/espressif/check-copyright/
23+
rev: v1.0.3
24+
hooks:
25+
- id: check-copyright
26+
args: ['--config', 'check_copyright_config.yaml']

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# ChangeLog
2+
3+
## v0.0.1 - [2023-11-10]
4+
5+
### Enhancements:
6+
7+
* Only support for ESP32-S2 and ESP32-S3 SoCs.
8+
* Support video stream through UVC Stream interface.
9+
* Support microphone stream and speaker stream through the UAC Stream interface
10+
* Support volume, mute and other features control through the UAC Control interface
11+
* Support stream separately suspend and resume

CMakeLists.txt

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
if("${IDF_VERSION_MAJOR}.${IDF_VERSION_MINOR}" VERSION_GREATER_EQUAL "5.0")
2+
list(APPEND PRIVREQ esp_adc)
3+
else()
4+
list(APPEND PRIVREQ esp_adc_cal)
5+
endif()
6+
7+
idf_component_register(SRCS "src/original/button_adc.c"
8+
"src/original/button_gpio.c"
9+
"src/original/button_matrix.c"
10+
"src/original/iot_button.c"
11+
# "src/original/adc_oneshot.c"
12+
"src/Button.cpp"
13+
INCLUDE_DIRS "src"
14+
REQUIRES driver ${PRIVREQ}
15+
PRIV_REQUIRES esp_timer)
16+
17+
18+
# set(PRIVREQ esp_timer)
19+
20+
# if("${IDF_VERSION_MAJOR}.${IDF_VERSION_MINOR}" VERSION_GREATER_EQUAL "5.0")
21+
# list(APPEND REQ esp_adc)
22+
# else()
23+
# list(APPEND REQ esp_adc_cal)
24+
# endif()
25+
26+
# idf_component_register(SRCS "src/original/button_adc.c"
27+
# "src/original/button_gpio.c"
28+
# "src/original/button_matrix.c"
29+
# "src/original/iot_button.c"
30+
# "src/Button.cpp"
31+
# INCLUDE_DIRS "src"
32+
# REQUIRES driver ${REQ}
33+
# PRIV_REQUIRES ${PRIVREQ})
34+
# # REQUIRES driver
35+
# # PRIV_REQUIRES esp_timer)
36+
37+
# # include(package_manager)
38+
# # cu_pkg_define_version(${CMAKE_CURRENT_LIST_DIR})

0 commit comments

Comments
 (0)