This commit is contained in:
2025-11-15 11:56:42 +03:00
parent bb13b7b3b6
commit 80307fc435
42 changed files with 4336 additions and 12 deletions

View File

@@ -1 +1 @@
idf_component_register(SRCS "ate0004.c" INCLUDE_DIRS "" REQUIRES zh_pcf8574 esp_wifi nvs_flash)
idf_component_register(SRCS "ate0004.c" INCLUDE_DIRS "" REQUIRES zh_pcf8574 esp_wifi nvs_flash esp_http_server ota_ws_update)

View File

@@ -1,6 +1,7 @@
#include "ate0004.h"
static i2c_master_bus_handle_t i2c_bus_handle = NULL;
static httpd_handle_t webserver_handle = NULL;
static zh_pcf8574_handle_t button_handle = {0};
static zh_pcf8574_handle_t led_handle = {0};
@@ -11,6 +12,7 @@ static bool is_ret = false;
static bool is_ext = false;
static void zh_wifi_softap_init(void);
static void zh_webserver_init(void);
static void zh_gpio_init(void);
static void zh_io_expander_init(void);
static void zh_pcf8574_event_handler(void *arg, esp_event_base_t event_base, int32_t event_id, void *event_data);
@@ -22,6 +24,7 @@ void app_main(void)
nvs_flash_init();
esp_event_loop_create_default();
zh_wifi_softap_init();
zh_webserver_init();
zh_gpio_init();
gpio_set_level(TRIAC_GPIO, LOW);
zh_io_expander_init();
@@ -49,6 +52,13 @@ static void zh_wifi_softap_init(void)
esp_wifi_start();
}
static void zh_webserver_init(void)
{
httpd_config_t config = HTTPD_DEFAULT_CONFIG();
httpd_start(&webserver_handle, &config);
ota_ws_register_uri_handler(webserver_handle);
}
static void zh_gpio_init(void)
{
gpio_config_t triac_pin_config = {
@@ -164,5 +174,4 @@ static void zh_pcf8574_event_handler(void *arg, esp_event_base_t event_base, int
default:
break;
}
printf("Interrupt happened on device address 0x%02X on GPIO number %d at level %d.\n", event->i2c_address, event->gpio_number, event->gpio_level);
}

View File

@@ -3,6 +3,8 @@
#include "zh_pcf8574.h"
#include "nvs_flash.h"
#include "esp_wifi.h"
#include "esp_http_server.h"
#include "ota_ws_update.h"
#define HIGH true
#define LOW false