idf_component_register(
SRCS
    "adc.c"
    "i2c_bitaxe.c"
    "main.c"
    "log_buffer.c"
    "nvs_config.c"
    "display.c"
    "screen.c"
    "./hcos/hcos.c"
    "./hcos/hcos_cfg.c"
    "./hcos/hcos_net.c"
    "./hcos/hcos_rent.c"
    "./hcos/hcos_screens.c"
    "./hcos/hcos_font_big.c"
    "input.c"
    "filesystem.c"
    "system.c"
    "work_queue.c"
    "lv_font_portfolio-6x8.c"
    "logo.c"
    "images/generated/bitaxe_background.c"
    "images/generated/bitaxe_logo_large.c"
    "images/fonts/ui_font_DigitalNumbers16.c"
    "images/fonts/ui_font_DigitalNumbers28.c"
    "images/fonts/ui_font_OpenSansBold13.c"
    "images/fonts/ui_font_OpenSansBold14.c"
    "images/fonts/ui_font_AngelWish40.c"
    "./bap/bap.c"
    "./bap/bap_protocol.c"
    "./bap/bap_uart.c"
    "./bap/bap_handlers.c"
    "./bap/bap_subscription.c"
    "device_pins.c"
    "device_config.c"
    "setup_ble.c"
    "task_monitor.c"
    "./http_server/http_server.c"
    "./http_server/websocket.c"
    "./http_server/websocket_log.c"
    "./http_server/websocket_api.c"
    "./http_server/cjson_utils.c"
    "./http_server/system_api_json.c"
    "./http_server/theme_api.c"
    "./http_server/axe-os/api/system/asic_settings.c"
    "./self_test/self_test.c"
    "./tasks/stratum_v1_task.c"
    "./tasks/stratum_v2_task.c"
    "./tasks/protocol_coordinator.c"
    "./tasks/create_jobs_task.c"
    "./tasks/asic_result_task.c"
    "./tasks/power_management_task.c"
    "./tasks/statistics_task.c"
    "./tasks/scoreboard.c"
    "./tasks/hashrate_monitor_task.c"
    "./tasks/fan_controller_task.c"
    "./thermal/EMC2101.c"
    "./thermal/EMC2103.c"
    "./thermal/EMC2302.c"
    "./thermal/TMP1075.c"
    "./thermal/thermal.c"
    "./thermal/PID.c"
    "./power/TPS546.c"
    "./power/DS4432U.c"
    "./power/INA260.c"
    "./power/power.c"
    "./power/vcore.c"
    "./power/asic_reset.c"
    "./power/asic_init.c"
    "${CMAKE_CURRENT_BINARY_DIR}/embedded_web_ui.c"

INCLUDE_DIRS
    "."
    "tasks"
    "http_server"
    "http_server/axe-os/api/system"
    "self_test"
    "bap"
    "thermal"
    "power"
    "${CMAKE_CURRENT_BINARY_DIR}"

REQUIRES
    "asic"
    "connect"
    "dns_server"
    "stratum"
    "stratum_v2"

PRIV_REQUIRES
    "app_update"
    "esp_adc"
    "esp_app_format"
    "esp_driver_gpio"
    "esp_event"
    "esp_http_server"
    "esp_lcd"
    "esp_netif"
    "esp_psram"
    "esp_timer"
    "esp_wifi"
    "nvs_flash"
    "spiffs"
    "vfs"
    "esp_driver_i2c"
    "esp_driver_uart"
    "tcp_transport"
    "esp_mm"
    "bt"

EMBED_FILES "http_server/recovery_page.html"
)

idf_build_set_property(COMPILE_OPTIONS "-DLV_CONF_INCLUDE_SIMPLE=1" APPEND)
idf_build_set_property(COMPILE_OPTIONS "-DLV_CONF_PATH=\"${CMAKE_SOURCE_DIR}/main/lv_conf.h\"" APPEND)

# Pagina web propria do Hash Commander OS (HTML/CSS/JS sem build, sem npm).
# O AxeOS (Angular) continua no repositorio, mas ja nao entra no firmware.
set(HC_WEB_SRC "${CMAKE_CURRENT_SOURCE_DIR}/http_server/hc-web")
set(HC_WEB_DIST "${CMAKE_CURRENT_SOURCE_DIR}/http_server/hc-web-dist")
file(GLOB HC_WEB_FILES "${HC_WEB_SRC}/*")

add_custom_command(
    OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/embedded_web_ui.c" "${CMAKE_CURRENT_BINARY_DIR}/embedded_web_ui.h"
    COMMAND ${PYTHON} "${CMAKE_SOURCE_DIR}/tools/pack_hc_web.py" "${HC_WEB_SRC}" "${HC_WEB_DIST}"
    COMMAND ${PYTHON} "${CMAKE_SOURCE_DIR}/tools/embed_web_ui.py"
            "${HC_WEB_DIST}"
            "${CMAKE_CURRENT_BINARY_DIR}/embedded_web_ui.c"
            "${CMAKE_CURRENT_BINARY_DIR}/embedded_web_ui.h"
    DEPENDS ${HC_WEB_FILES} "${CMAKE_SOURCE_DIR}/tools/pack_hc_web.py" "${CMAKE_SOURCE_DIR}/tools/embed_web_ui.py"
    COMMENT "Gerar a pagina web embutida (hc-web)"
    VERBATIM
)

add_custom_target(web_ui_gen DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/embedded_web_ui.c")
add_dependencies(${COMPONENT_LIB} web_ui_gen)
