This commit is contained in:
aZholtikov committed 2026-09-10 18:40:56 +03:00
1 parent b8aa3a594d
commit e987d4cafb
15 files changed
+443 -251

No files matched your search

+72 -53
View File
@@ -1,5 +1,18 @@
/**
* @file ate0005.h
*
* @brief Header file for ATE0005 — Universal Optical 2-Channel Angle Gauge / Tachometer
*
* This header defines task priorities, stack sizes, mode constants,
* WiFi configuration, GPIO pin mappings, and data structures for the
* ATE0005 device running on ESP32 platform with FreeRTOS.
*
* Key features:
* - Task configuration for inclinometer, tachometer, encoder, and stats
* - WiFi AP/STA mode configuration
* - I2C and GPIO pin definitions for peripherals
* - Mode selection constants for different operating modes
* - LCD display and PCF8574 expander macros
*/
#pragma once
@@ -15,80 +28,86 @@
#include "zh_espnow.h"
#include "zh_syslog.h"
#define STATS_TASK_PRIORITY tskIDLE_PRIORITY
#define STATS_TASK_STACK_SIZE configMINIMAL_STACK_SIZE + 1280
#define A_INCLINOMETER_TASK_PRIORITY tskIDLE_PRIORITY + 5
#define A_INCLINOMETER_TASK_STACK_SIZE configMINIMAL_STACK_SIZE + 512
#define B_INCLINOMETER_TASK_PRIORITY tskIDLE_PRIORITY + 5
#define B_INCLINOMETER_TASK_STACK_SIZE configMINIMAL_STACK_SIZE + 512
#define A_TACHOMETER_TASK_PRIORITY tskIDLE_PRIORITY + 5
#define A_TACHOMETER_TASK_STACK_SIZE configMINIMAL_STACK_SIZE + 512
#define B_TACHOMETER_TASK_PRIORITY tskIDLE_PRIORITY + 5
#define B_TACHOMETER_TASK_STACK_SIZE configMINIMAL_STACK_SIZE + 512
#define ENCODER_TASK_PRIORITY tskIDLE_PRIORITY + 4
#define ENCODER_TASK_STACK_SIZE configMINIMAL_STACK_SIZE
#define EXPANDER_TASK_PRIORITY tskIDLE_PRIORITY + 4
#define EXPANDER_TASK_STACK_SIZE configMINIMAL_STACK_SIZE
#define STATS_TASK_PRIORITY tskIDLE_PRIORITY /*!< Priority of the statistics logging task. */
#define STATS_TASK_STACK_SIZE configMINIMAL_STACK_SIZE + 1280 /*!< Stack size for the statistics logging task. */
#define A_INCLINOMETER_TASK_PRIORITY tskIDLE_PRIORITY + 5 /*!< Priority of the A inclinometer processing task. */
#define A_INCLINOMETER_TASK_STACK_SIZE configMINIMAL_STACK_SIZE + 512 /*!< Stack size for the A inclinometer processing task. */
#define B_INCLINOMETER_TASK_PRIORITY tskIDLE_PRIORITY + 5 /*!< Priority of the B inclinometer processing task. */
#define B_INCLINOMETER_TASK_STACK_SIZE configMINIMAL_STACK_SIZE + 512 /*!< Stack size for the B inclinometer processing task. */
#define A_TACHOMETER_TASK_PRIORITY tskIDLE_PRIORITY + 5 /*!< Priority of the A tachometer processing task. */
#define A_TACHOMETER_TASK_STACK_SIZE configMINIMAL_STACK_SIZE + 512 /*!< Stack size for the A tachometer processing task. */
#define B_TACHOMETER_TASK_PRIORITY tskIDLE_PRIORITY + 5 /*!< Priority of the B tachometer processing task. */
#define B_TACHOMETER_TASK_STACK_SIZE configMINIMAL_STACK_SIZE + 512 /*!< Stack size for the B tachometer processing task. */
#define ENCODER_TASK_PRIORITY tskIDLE_PRIORITY + 4 /*!< Priority of the mode encoder task. */
#define ENCODER_TASK_STACK_SIZE configMINIMAL_STACK_SIZE /*!< Stack size for the mode encoder task. */
#define EXPANDER_TASK_PRIORITY tskIDLE_PRIORITY + 4 /*!< Priority of the PCF8574 expander task. */
#define EXPANDER_TASK_STACK_SIZE configMINIMAL_STACK_SIZE /*!< Stack size for the PCF8574 expander task. */
#define TRIAC_ON true
#define TRIAC_OFF false
#define TRIAC_ON true /*!< Triac enabled state. */
#define TRIAC_OFF false /*!< Triac disabled state. */
#define ENCODER_BUTTON_RELEASED true
#define ENCODER_BUTTON_PRESSED false
#define ENCODER_BUTTON_RELEASED true /*!< Encoder button released state. */
#define ENCODER_BUTTON_PRESSED false /*!< Encoder button pressed state. */
#define LED_OFF ZH_PCF8574_GPIO_LOW
#define LED_ON ZH_PCF8574_GPIO_HIGH
#define LED_OFF ZH_PCF8574_GPIO_LOW /*!< LED turned off (low level). */
#define LED_ON ZH_PCF8574_GPIO_HIGH /*!< LED turned on (high level). */
#define RELAY_OFF ZH_PCF8574_GPIO_LOW
#define RELAY_ON ZH_PCF8574_GPIO_HIGH
#define RELAY_OFF ZH_PCF8574_GPIO_LOW /*!< Relay disconnected (low level). */
#define RELAY_ON ZH_PCF8574_GPIO_HIGH /*!< Relay connected (high level). */
#define MODE_ANGLE_ANGLE 0
#define MAIN_MENU_ANGLE_ANGLE_NAME "ANGLE/ANGLE"
#define MODE_TACHO_TACHO 1
#define MAIN_MENU_TACHO_TACHO_NAME "TACHO/TACHO"
#define MODE_ANGLE_TACHO 2
#define MAIN_MENU_ANGLE_TACHO_NAME "ANGLE/TACHO"
#define MODE_REMOTE 3
#define MAIN_MENU_REMOTE_NAME "REMOTE"
#define MODE_ANGLE_ANGLE 0 /*!< Operating mode: both inclinometers active. */
#define MAIN_MENU_ANGLE_ANGLE_NAME "ANGLE/ANGLE" /*!< Menu label for angle/angle mode. */
#define MODE_TACHO_TACHO 1 /*!< Operating mode: both tachometers active. */
#define MAIN_MENU_TACHO_TACHO_NAME "TACHO/TACHO" /*!< Menu label for tachometer/tachometer mode. */
#define MODE_ANGLE_TACHO 2 /*!< Operating mode: A inclinometer and B tachometer active. */
#define MAIN_MENU_ANGLE_TACHO_NAME "ANGLE/TACHO" /*!< Menu label for angle/tachometer mode. */
#define MODE_REMOTE 3 /*!< Operating mode: remote control via ESP-NOW. */
#define MAIN_MENU_REMOTE_NAME "REMOTE" /*!< Menu label for remote mode. */
#define WIFI_AP_SSID "ATE0005"
#define WIFI_AP_PASS "repairlab"
#define WIFI_AP_CHANNEL 1
#define MAX_AP_CONNECTION 4
#define WIFI_AP_SSID "ATE0005" /*!< WiFi AP SSID. */
#define WIFI_AP_PASS "repairlab" /*!< WiFi AP password. */
#define WIFI_AP_CHANNEL 1 /*!< WiFi AP channel. */
#define MAX_AP_CONNECTION 4 /*!< Maximum number of stations connected to AP. */
#define WIFI_STA_SSID "rick_professor"
#define WIFI_STA_PASS "repairlab"
#define WIFI_STA_MAXIMUM_RETRY 10
#define WIFI_STA_SSID "rick_professor" /*!< WiFi STA SSID. */
#define WIFI_STA_PASS "repairlab" /*!< WiFi STA password. */
#define WIFI_STA_MAXIMUM_RETRY 10 /*!< Maximum number of reconnection attempts for STA mode. */
#define SYSLOG_IP "77.51.201.8"
#define SYSLOG_IP "77.51.201.8" /*!< IP address of the remote syslog server. */
#define I2C_SCL_GPIO GPIO_NUM_22
#define I2C_SDA_GPIO GPIO_NUM_21
#define I2C_SCL_GPIO GPIO_NUM_22 /*!< I2C clock line GPIO. */
#define I2C_SDA_GPIO GPIO_NUM_21 /*!< I2C data line GPIO. */
#define LCD_I2C_ADDRESS 0x20 /*!< U2. */
#define LCD_I2C_ADDRESS 0x20 /*!< I2C address of the LCD PCF8574 expander (U2). */
#define MODE_ENCODER_NUMBER 0x01 /*!< Connector EN1. */
#define MODE_ENCODER_A_GPIO GPIO_NUM_27
#define MODE_ENCODER_B_GPIO GPIO_NUM_26
#define MODE_ENCODER_S_GPIO GPIO_NUM_25
#define MODE_ENCODER_NUMBER 0x01 /*!< Encoder instance number (Connector EN1). */
#define MODE_ENCODER_A_GPIO GPIO_NUM_27 /*!< Mode encoder A-phase GPIO. */
#define MODE_ENCODER_B_GPIO GPIO_NUM_26 /*!< Mode encoder B-phase GPIO. */
#define MODE_ENCODER_S_GPIO GPIO_NUM_25 /*!< Mode encoder switch GPIO. */
#define A_OPTICAL_DEVICE_A_GPIO GPIO_NUM_14 /*!< Connector EN2. */
#define A_OPTICAL_DEVICE_B_GPIO GPIO_NUM_13
#define A_OPTICAL_DEVICE_A_GPIO GPIO_NUM_14 /*!< Optical device A-phase GPIO for channel A (Connector EN2). */
#define A_OPTICAL_DEVICE_B_GPIO GPIO_NUM_13 /*!< Optical device B-phase GPIO for channel A. */
#define B_OPTICAL_DEVICE_A_GPIO GPIO_NUM_18 /*!< Connector EN3. */
#define B_OPTICAL_DEVICE_B_GPIO GPIO_NUM_19
#define B_OPTICAL_DEVICE_A_GPIO GPIO_NUM_18 /*!< Optical device A-phase GPIO for channel B (Connector EN3). */
#define B_OPTICAL_DEVICE_B_GPIO GPIO_NUM_19 /*!< Optical device B-phase GPIO for channel B. */
#ifdef __cplusplus
extern "C"
{
#endif
/**
* @brief Structure holding minimum free stack sizes for processing tasks.
*
* Tracks the minimum free stack size observed at runtime for each
* processing task, used for syslog monitoring and stack overflow detection.
*/
typedef struct
{
uint32_t a_inclinometer_task_min_stack_size;
uint32_t b_inclinometer_task_min_stack_size;
uint32_t a_tachometer_task_min_stack_size;
uint32_t b_tachometer_task_min_stack_size;
uint32_t a_inclinometer_task_min_stack_size; /*!< Minimum free stack size of the A inclinometer task. */
uint32_t b_inclinometer_task_min_stack_size; /*!< Minimum free stack size of the B inclinometer task. */
uint32_t a_tachometer_task_min_stack_size; /*!< Minimum free stack size of the A tachometer task. */
uint32_t b_tachometer_task_min_stack_size; /*!< Minimum free stack size of the B tachometer task. */
} task_stats_t;
#ifdef __cplusplus