Commit Graph

109 Commits

Author SHA1 Message Date
ae33204a87 Optimize internal stop calls for output errors 2025-08-27 11:03:55 +03:00
79a66c19d7 Rename time_sec to limit_sec in relay channel functions for clarity
Fixes #1087
2025-08-26 18:08:05 +03:00
9a6b8c9f80 Add upper boundary checks for tilt sensitivity settings
The tilt sensitivity values were passed to the NVS module without
the boundaries being checked, even though the maximum
percent value is 100. This commit fixes this issue.
Also test cases are added to cover the upper boundary checks
for the tilt sensitivity settings.

Fixes #1086
2025-08-26 17:43:19 +03:00
0b75df35d1 Use build profiles instead of providing sdkconfig.defaults manually
ESP-IDF provides a more efficient way of handling and combining
multi-configurations for a project than the way currently used:
Build profiles.

So I switched to this method instead of providing the sdkconfig.defaults.*
files manually. This reduced the number of sdkconfig.defaults.* files
as well as the configuration parameters defined in them.

Refs #1085
2025-08-26 17:03:36 +03:00
da953846c9 Refactor function brackets
Refactor the brackets of the test case functions to align with ESP-IDF style.

Refs #1085
2025-08-26 15:19:09 +03:00
15d1673e77 Refactor and improve for batch operations
Refactor tilt test functions to use batch operations for all channels and improve state checks.

Refs #1085
2025-08-26 15:03:16 +03:00
329812aecc Enhance relay command handling
- `TILT_STOP` command is prioritized in `relay_chn_tilt_issue_cmd()` because it should override any other tilt commands.
- The debug logs are cleaned up.

Fixes #1088
Refs #1085
2025-08-26 13:37:48 +03:00
54c8dc26fc Add .ESP-IDF vscode configuration files 2025-08-26 12:10:02 +03:00
396a02b5ae Cleanup and replace constants
- Delete unused declaration of `g_is_component_initialized`.
- Replace the following constants with approprite config options:
  + `relay_chn_count` > `CONFIG_RELAY_CHN_COUNT`
  + `opposite_inerta_ms` > `CONFIG_RELAY_CHN_OPPOSITE_INERTIA_MS`
- Replace the definition of the `test_delay_margin_ms` constant with  `#define TEST_DELAY_MARGIN_MS 50` for preprocessor calculations.
2025-08-26 09:23:06 +03:00
3831384169 Implement specific *all functions
Specific `_*all` and `_*all_with` functions were implemented to make
the API more concise and clean, and to replace the use of
`RELAY_CHN_ID_ALL`, which caused confusion within the API.

Refs #1085
2025-08-26 08:42:49 +03:00
be4a2ebef6 Fix build path 2025-08-25 18:24:37 +03:00
6ff16b5797 Fix config parameters check
Unnecessary `#if CONFIG_FOO == 1` checks were removed and the
statements were simplified to` #if CONFIG_FOO`.
`#ifdef CONFIG_FOO` statements were also changed to `#if CONFIG_FOO`
to keep the style as uniform as possible.

Refs #1085
2025-08-25 10:56:01 +03:00
5afefc4dc0 Use original names for config parameters
The config parameter names defined in the relay_chn_defs.h file
have been changed back to their original names (with the CONFIG_ prefix),
so that they are not confused with application-level defines.

Refs #1085
2025-08-25 10:24:13 +03:00
9d3f8ddbff Fix implicit-fallthrough warning.
Refs #1085.
2025-08-25 09:40:18 +03:00
6a4872f194 Merge pull request 'feat/1080-run-limit' (!36) from feat/1080-run-limit into dev
Reviewed-on: #36
2025-08-22 17:56:22 +03:00
cb38f71d8e Optimize a flip test case and execute tests upon removing esp_event 2025-08-22 17:42:24 +03:00
7a0f9b1420 Optimize timer callbacks
It turned out that esp_event was adding extra complexity to the code base and it was completely unnecessary. So it has been removed from the component completely. The actions are now executed directly in the `relay_chn_distpacth_cmd()` and `relay_chn_tilt_dispatch_cmd()` functions.
This change has simplified the component as well as reduced the memory footprint.

Fixes #1084, refs #1083
2025-08-22 17:41:08 +03:00
e73c205e3d Optimize event loop resource size
The event loop queue and  task stack size is optimized to be determined by config factors.

Fixes #1083
2025-08-22 15:33:12 +03:00
fb4f34e895 Add and execute unit tests for run limit feature 2025-08-22 12:42:53 +03:00
29803c063e Enhance unit test default sdkconfig files
The sdkconfig.defaults files were enhanced to test the component against all individual configurations for more granularity, as well as with all combinations to ensure consistency and integrity across all configurations.
2025-08-22 12:41:58 +03:00
40633e03d8 Add run limit feature for relay channels with NVS support
- Introduced configuration options for enabling run limits in Kconfig.
- Added APIs to get and set run limits for individual relay channels.
- Implemented run limit timer functionality to automatically stop channels.
- Updated NVS handling to store and retrieve run limit values.
- Enhanced documentation in README and code comments to reflect new feature.

Closes #1080
2025-08-22 12:29:07 +03:00
19d02836dd Merge pull request 'Update README for NVS' (!35) from fix/1082-update-readme-for-nvs into dev
Reviewed-on: #35
2025-08-20 16:36:12 +03:00
a3762cff5f Update README for NVS
Updated README.md with detailed NVS storage configuration and initialization instructions.

Fixes #1082.
2025-08-20 16:30:12 +03:00
fe383d7003 Merge pull request 'Optimize Tilt Counting System and NVS Storage' (!34) from fix/1079-tilt-counting into dev
Reviewed-on: #34
2025-08-20 13:44:37 +03:00
b99622bd23 Fix and document tilt key names.
Fix key names with more approprite ones and add documentation for them. Fixes #1081.
2025-08-20 11:17:40 +03:00
c5fa8a63ae Fix NVS module's tag value.
Fix NVS module's tag string value to match the module name. IssueID #1081.
2025-08-20 11:15:29 +03:00
aeeda44a2c Optimize and refactor tilt counting
- Optimized tilt counting data by reducing the tilt counter variables into one for smaller memory footprint. So the `relay_chn_tilt_counter_t` type is replaced by a single `uint16_t` variable in the `relay_chn_tilt_ctl_t` structure. Hence the `relay_chn_tilt_counter_t` type has been removed since it is not necessary anymore.
- Refactored tilt count handling in NVS: consolidate forward and reverse counts into a single tilt count parameter.
- Updated NVS test files that affected by the data type and function signature changes.

Fixes #1079
2025-08-20 11:07:50 +03:00
dc2aa93d2d Merge pull request 'feat(nvs): Add NVS support for relay channel persistence (#1074)' (!33) from feat/1074-add-nvs-storage into dev
Reviewed-on: #33
2025-08-19 18:55:11 +03:00
96bb139751 Add new utility script and update test tags
- Added new utility script run_tests_all_cfgs.sh to run tests for all configurations and with test tag support.
- Updated run_tests.sh to add the new test tag for NVS unit tests.
2025-08-19 17:40:26 +03:00
61edf11b75 Refactor to remove redundant initialization and add NVS storage tests
- Removed unnecessary calls to relay_chn_create and g_is_component_initialized in multiple test cases across test_relay_chn_core_single.c, test_relay_chn_listener_multi.c, and test_relay_chn_listener_single.c.
- Introduced new test files for NVS functionality: test_relay_chn_nvs_multi.c and test_relay_chn_nvs_single.c, covering initialization, direction setting, invalid parameters, and erase operations.
- Updated partition table configuration to support NVS storage, including the addition of a new partition file part_nvs.csv.
- Adjusted sdkconfig files to enable NVS support and configure custom partition settings for relay channels.
2025-08-19 17:36:23 +03:00
b19f0c553b Add NVS support for relay channel config persistence
- Introduced NVS configuration options in Kconfig.
- Implemented NVS initialization and deinitialization in relay_chn_core.
- Added functions for storing and retrieving relay channel direction and tilt sensitivity in NVS.
- Updated relay_chn_tilt and relay_chn_output to utilize NVS for state management.
- Created relay_chn_nvs.c and relay_chn_nvs.h for NVS-related functionalities.

Closes #1074.
2025-08-19 17:33:45 +03:00
f04632dc77 Unignore .vscode folder.
Unignore .vscode folder and add necessary configuration files for a
synced development environment.
2025-08-14 16:55:25 +03:00
b29768edad Merge pull request 'feat/957-single-channel-mode' (!32) from feat/957-single-channel-mode into dev
Reviewed-on: #32
2025-08-14 09:50:36 +03:00
f1cda4531d Merge remote-tracking branch 'origin/main' into feat/957-single-channel-mode 2025-08-13 18:36:48 +03:00
f8d6e74f23 Refactor and update configuration for single channel mode
- Created `test_relay_chn_tilt_multi.c` and `test_relay_chn_tilt_single.c` to implement comprehensive tests for the tilt functionality of relay channels, covering various scenarios including transitions between states and sensitivity settings.
- Introduced a new partition table in `partitionTable.csv` for proper memory management.
- Updated `sdkconfig` to set the relay channel count to 1 for single channel testing and adjusted related configurations.
- Added default configuration file `sdkconfig.defaults.single` for streamlined testing setup.
2025-08-13 18:36:48 +03:00
9f1134763e Refactor and update the relay_chn component.
Refactor relay channel component to support single and multi-channel modes; update CMake configuration and enhance API documentation.
2025-08-13 18:36:48 +03:00
61f8ed440e Add single channel mode feature.
The addition of a single-channel mode implied further modularisation of the component. This commit has broken the component down into the following modules to avoid a huge single source file and to make unit testing easier.

The modules:

- Separation of public and private code
- *types and *defs
- public relay_chn API
- *adapter
- *output
- *run_info
- *core
- *ctl (control)
- *tilt

Closes #957.
2025-08-13 18:31:05 +03:00
1776c81c8d Merge pull request 'release-0.5.0' (!31) from release-0.5.0 into main
Reviewed-on: #31
0.5.0
2025-07-23 17:48:18 +03:00
22668b6759 Merge pull request 'release-0.5.0' (!30) from release-0.5.0 into dev
Reviewed-on: #30
2025-07-23 17:45:26 +03:00
2e81966afb Bump version to 0.5.0 and update repo URLs. 2025-07-23 17:37:27 +03:00
5734f47cd3 Merge pull request 'feat/1030-more-unit-tests' (!29) from feat/1030-more-unit-tests into dev
Reviewed-on: #29
2025-07-22 16:59:47 +03:00
d884f5f45c Add missing test cases for tilt API.
Added missing test cases for the tilt API.

Closes #1056.
2025-07-22 10:02:40 +03:00
c7678d6084 Add restart chip to make qemu exit in tests. 2025-07-22 10:00:33 +03:00
8527ebea83 Fix imbalanced tilt counts.
Fixed the tilt count logic that causes an imbalance in tilting within the same run frame but opposite direction.

Fixes #1057.
2025-07-22 09:58:59 +03:00
f31eae649f Add a shell utility for running tests. 2025-07-21 18:47:41 +03:00
a143484748 Break down tests into categories.
Break down tests into categories to improve maintainability and test granularity. This makes it easier to execute unit tests in CI/CD pipelines.

Closes #1054.
2025-07-21 15:37:49 +03:00
a9a8169710 Add test cases for ID_ALL channel id.
Add test cases to test all relevant functions that support operating with the `RELAY_CHN_ID_ALL` channel id.

Closes #1052.
2025-07-16 11:42:44 +03:00
74f4341c1d Add test cases for direction flip.
Closes #1051.
2025-07-15 16:14:19 +03:00
a587036093 Add tests for init error handling.
Added tests for covering initialization error handling cases like; NULL pointer, invalid GPIO count etc.

This changed implied removing the `relay_chn_create` from the Unity's `setUp` function and place it in each testcase.

Refs #1050, #1030.
2025-07-15 12:23:21 +03:00
82312ba7c3 Add NULL handling for the gpio_num pointer.
Fixes #1050.
2025-07-15 12:17:46 +03:00