[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M70H7B22N9A5HGHG5FCT0A2P":3,"skill-same:01M70H7B22N9A5HGHG5FCT0A2P":119},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":39,"linkOnly":40,"markdownContent":41,"markdownBody":42,"frontMatter":43,"refName":44,"commitSha":45,"skillDirectory":46,"forksCount":47,"repositoryHtmlUrl":48,"repositoryHomepageUrl":49,"ownerHtmlUrl":50,"ownerBlogUrl":51,"ownerDescription":52,"updatedAt":53,"install":54,"resources":67},"01M70H7B22N9A5HGHG5FCT0A2P","esp32-embedded-dev",null,"Expert ESP32 development with ESP-IDF 5.3.x, covering FreeRTOS patterns, peripheral drivers, WiFi\u002FBLE networking, power management, and hardware optimization. Use when developing ESP32 firmware, implementing FreeRTOS tasks, configuring WiFi\u002FBLE, optimizing memory and power, or working with ESP32-S3 hardware like T-Embed.","shengdabai\u002FTony-Claude-Code-Skills","shengdabai","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F116417419?v=4","01M70F6D2WY5PQV5A92BKYJQEW","Tony Sheng","01M70F6D3GAAAYZ5H4CC1G8VXM",3,"MIT","https:\u002F\u002Fgithub.com\u002Fshengdabai\u002FTony-Claude-Code-Skills\u002Fblob\u002Fmain\u002Fskills\u002F_collections\u002Frghamilton3-dotfiles\u002Fdot_claude\u002Fskills\u002Fesp32-embedded-dev\u002FSKILL.md",[],[19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38],"dev","embedded","esp32","esp32 embedded dev","patterns","power management","tasks","when","ESP","memory","firmware","management","s3","embed","use","ble","implementing","expert","wifi","power","2026-11-10 10:12:30",false,"---\nname: esp32-embedded-dev\ndescription: Expert ESP32 development with ESP-IDF 5.3.x, covering FreeRTOS patterns, peripheral drivers, WiFi\u002FBLE networking, power management, and hardware optimization. Use when developing ESP32 firmware, implementing FreeRTOS tasks, configuring WiFi\u002FBLE, optimizing memory and power, or working with ESP32-S3 hardware like T-Embed.\n---\n\n# ESP32 Embedded Development\n\n## Overview\n\nProvides comprehensive ESP-IDF 5.3.x development guidance for ESP32\u002FESP32-S3 microcontrollers, covering real-time operating system patterns, wireless networking, peripheral drivers, and production-grade firmware development.\n\n**Use this skill when:**\n- Developing ESP32\u002FESP32-S3 firmware with ESP-IDF framework\n- Implementing FreeRTOS tasks, queues, semaphores, or mutexes\n- Configuring WiFi station\u002FAP modes or BLE GATT services\n- Integrating MQTT over WiFi\u002FWebSocket\n- Working with SPI, I2C, UART, GPIO, ADC, or PWM peripherals\n- Optimizing power consumption with sleep modes\n- Implementing OTA firmware updates\n- Debugging memory issues or optimizing flash\u002FRAM usage\n- Working with T-Embed hardware (ESP32-S3, 1.9\" display, rotary encoder, RGB LEDs)\n\n## Quick Start\n\n### Project Structure\n\nESP-IDF projects follow this standard structure:\n\n```\nproject\u002F\n├── main\u002F\n│   ├── CMakeLists.txt\n│   ├── main.c (or .cpp)\n│   └── Kconfig.projbuild (optional)\n├── components\u002F\n│   └── custom_component\u002F\n│       ├── CMakeLists.txt\n│       ├── include\u002F\n│       └── src\u002F\n├── CMakeLists.txt\n├── sdkconfig\n└── partitions.csv (optional)\n```\n\n### Essential idf.py Commands\n\n```bash\n# Set target chip\nidf.py set-target esp32s3\n\n# Configure project (menuconfig)\nidf.py menuconfig\n\n# Build project\nidf.py build\n\n# Flash and monitor\nidf.py -p \u002Fdev\u002FttyUSB0 flash monitor\n\n# Clean build\nidf.py fullclean\n\n# Size analysis\nidf.py size-components\nidf.py size-files\n```\n\n### Component Registration\n\n```cmake\n# components\u002Fmy_component\u002FCMakeLists.txt\nidf_component_register(\n    SRCS \"src\u002Fmy_component.c\"\n    INCLUDE_DIRS \"include\"\n    REQUIRES driver nvs_flash esp_wifi\n)\n```\n\n## FreeRTOS Task Management\n\n### Task Creation Patterns\n\n```c\n#include \"freertos\u002FFreeRTOS.h\"\n#include \"freertos\u002Ftask.h\"\n#include \"freertos\u002Fqueue.h\"\n#include \"freertos\u002Fsemphr.h\"\n\n\u002F\u002F Task priorities (0 = lowest, configMAX_PRIORITIES-1 = highest)\n\u002F\u002F ESP-IDF reserves priority 19+ for system tasks\n#define NETWORK_TASK_PRIORITY    5  \u002F\u002F Network tasks\n#define DISPLAY_TASK_PRIORITY    4  \u002F\u002F UI updates\n#define SENSOR_TASK_PRIORITY     3  \u002F\u002F Sensor reading\n#define LED_TASK_PRIORITY        2  \u002F\u002F LED animations\n#define IDLE_TASK_PRIORITY       1  \u002F\u002F Background tasks\n\n\u002F\u002F Recommended stack sizes\n#define NETWORK_STACK_SIZE  4096  \u002F\u002F Network\u002FMQTT tasks\n#define DISPLAY_STACK_SIZE  3072  \u002F\u002F Display rendering\n#define SENSOR_STACK_SIZE   2048  \u002F\u002F Sensor tasks\n#define LED_STACK_SIZE      2048  \u002F\u002F LED control\n\n\u002F\u002F Task handle for later control\nstatic TaskHandle_t display_task_handle = NULL;\n\nvoid display_task(void *pvParameters) {\n    TickType_t last_wake_time = xTaskGetTickCount();\n    const TickType_t frequency = pdMS_TO_TICKS(33); \u002F\u002F 30 FPS\n\n    while (1) {\n        \u002F\u002F Update display\n        update_display();\n\n        \u002F\u002F Delay until next frame (absolute timing)\n        vTaskDelayUntil(&last_wake_time, frequency);\n    }\n}\n\n\u002F\u002F Create task pinned to specific core (ESP32-S3 has 2 cores)\nxTaskCreatePinnedToCore(\n    display_task,           \u002F\u002F Task function\n    \"display_task\",         \u002F\u002F Name\n    DISPLAY_STACK_SIZE,     \u002F\u002F Stack size\n    NULL,                   \u002F\u002F Parameters\n    DISPLAY_TASK_PRIORITY,  \u002F\u002F Priority\n    &display_task_handle,   \u002F\u002F Task handle\n    1                       \u002F\u002F Core ID (0 or 1, or tskNO_AFFINITY)\n);\n```\n\n### Queue Communication\n\n```c\n\u002F\u002F Create queue (typically as global or passed via parameters)\nstatic QueueHandle_t event_queue = NULL;\n\ntypedef struct {\n    uint8_t event_type;\n    uint32_t value;\n    uint64_t timestamp;\n} event_data_t;\n\nvoid init_queues(void) {\n    event_queue = xQueueCreate(10, sizeof(event_data_t));\n    if (event_queue == NULL) {\n        ESP_LOGE(\"INIT\", \"Failed to create event queue\");\n    }\n}\n\n\u002F\u002F Producer task\nvoid sensor_task(void *pvParameters) {\n    event_data_t event;\n\n    while (1) {\n        event.event_type = SENSOR_EVENT;\n        event.value = read_sensor();\n        event.timestamp = esp_timer_get_time();\n\n        \u002F\u002F Send to queue (wait up to 100ms if full)\n        if (xQueueSend(event_queue, &event, pdMS_TO_TICKS(100)) != pdPASS) {\n            ESP_LOGW(\"SENSOR\", \"Queue full, event dropped\");\n        }\n\n        vTaskDelay(pdMS_TO_TICKS(1000));\n    }\n}\n\n\u002F\u002F Consumer task\nvoid processing_task(void *pvParameters) {\n    event_data_t event;\n\n    while (1) {\n        \u002F\u002F Wait indefinitely for event\n        if (xQueueReceive(event_queue, &event, portMAX_DELAY) == pdPASS) {\n            process_event(&event);\n        }\n    }\n}\n```\n\n### Mutex and Semaphore Patterns\n\n```c\n\u002F\u002F Mutex for protecting shared resources\nstatic SemaphoreHandle_t i2c_mutex = NULL;\n\nvoid init_synchronization(void) {\n    i2c_mutex = xSemaphoreCreateMutex();\n}\n\nesp_err_t safe_i2c_read(uint8_t addr, uint8_t *data, size_t len) {\n    esp_err_t ret = ESP_FAIL;\n\n    \u002F\u002F Take mutex (wait up to 1 second)\n    if (xSemaphoreTake(i2c_mutex, pdMS_TO_TICKS(1000)) == pdTRUE) {\n        ret = i2c_master_read_from_device(I2C_NUM_0, addr, data, len, pdMS_TO_TICKS(100));\n        xSemaphoreGive(i2c_mutex);\n    } else {\n        ESP_LOGE(\"I2C\", \"Failed to acquire mutex\");\n    }\n\n    return ret;\n}\n\n\u002F\u002F Binary semaphore for task synchronization\nstatic SemaphoreHandle_t sync_semaphore = NULL;\n\nvoid init_sync(void) {\n    sync_semaphore = xSemaphoreCreateBinary();\n}\n\n\u002F\u002F ISR gives semaphore\nvoid IRAM_ATTR gpio_isr_handler(void *arg) {\n    BaseType_t higher_priority_task_woken = pdFALSE;\n    xSemaphoreGiveFromISR(sync_semaphore, &higher_priority_task_woken);\n\n    if (higher_priority_task_woken) {\n        portYIELD_FROM_ISR();\n    }\n}\n\n\u002F\u002F Task waits for semaphore\nvoid event_handler_task(void *pvParameters) {\n    while (1) {\n        if (xSemaphoreTake(sync_semaphore, portMAX_DELAY) == pdTRUE) {\n            handle_interrupt_event();\n        }\n    }\n}\n```\n\n## WiFi & BLE Networking\n\n### WiFi Station Mode (Complete Example)\n\n```c\n#include \"esp_wifi.h\"\n#include \"esp_event.h\"\n#include \"esp_netif.h\"\n#include \"nvs_flash.h\"\n\n#define WIFI_SSID      \"your_ssid\"\n#define WIFI_PASSWORD  \"your_password\"\n#define MAX_RETRY      5\n\nstatic EventGroupHandle_t wifi_event_group;\nstatic const int WIFI_CONNECTED_BIT = BIT0;\nstatic const int WIFI_FAIL_BIT = BIT1;\nstatic int retry_count = 0;\n\nstatic void wifi_event_handler(void *arg, esp_event_base_t event_base,\n                               int32_t event_id, void *event_data) {\n    if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_START) {\n        esp_wifi_connect();\n        ESP_LOGI(\"WIFI\", \"Station started, connecting...\");\n    } else if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_DISCONNECTED) {\n        if (retry_count \u003C MAX_RETRY) {\n            esp_wifi_connect();\n            retry_count++;\n            ESP_LOGI(\"WIFI\", \"Retry connection %d\u002F%d\", retry_count, MAX_RETRY);\n        } else {\n            xEventGroupSetBits(wifi_event_group, WIFI_FAIL_BIT);\n            ESP_LOGE(\"WIFI\", \"Failed to connect after %d retries\", MAX_RETRY);\n        }\n    } else if (event_base == IP_EVENT && event_id == IP_EVENT_STA_GOT_IP) {\n        ip_event_got_ip_t *event = (ip_event_got_ip_t *)event_data;\n        ESP_LOGI(\"WIFI\", \"Got IP: \" IPSTR, IP2STR(&event->ip_info.ip));\n        retry_count = 0;\n        xEventGroupSetBits(wifi_event_group, WIFI_CONNECTED_BIT);\n    }\n}\n\nesp_err_t wifi_init_sta(void) {\n    wifi_event_group = xEventGroupCreate();\n\n    \u002F\u002F Initialize network interface\n    ESP_ERROR_CHECK(esp_netif_init());\n    ESP_ERROR_CHECK(esp_event_loop_create_default());\n    esp_netif_create_default_wifi_sta();\n\n    \u002F\u002F WiFi configuration\n    wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();\n    ESP_ERROR_CHECK(esp_wifi_init(&cfg));\n\n    \u002F\u002F Register event handlers\n    ESP_ERROR_CHECK(esp_event_handler_instance_register(\n        WIFI_EVENT, ESP_EVENT_ANY_ID, &wifi_event_handler, NULL, NULL));\n    ESP_ERROR_CHECK(esp_event_handler_instance_register(\n        IP_EVENT, IP_EVENT_STA_GOT_IP, &wifi_event_handler, NULL, NULL));\n\n    \u002F\u002F Configure WiFi\n    wifi_config_t wifi_config = {\n        .sta = {\n            .ssid = WIFI_SSID,\n            .password = WIFI_PASSWORD,\n            .threshold.authmode = WIFI_AUTH_WPA2_PSK,\n            .pmf_cfg = {\n                .capable = true,\n                .required = false\n            },\n        },\n    };\n\n    ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA));\n    ESP_ERROR_CHECK(esp_wifi_set_config(WIFI_IF_STA, &wifi_config));\n    ESP_ERROR_CHECK(esp_wifi_start());\n\n    \u002F\u002F Wait for connection or failure\n    EventBits_t bits = xEventGroupWaitBits(wifi_event_group,\n        WIFI_CONNECTED_BIT | WIFI_FAIL_BIT, pdFALSE, pdFALSE, portMAX_DELAY);\n\n    if (bits & WIFI_CONNECTED_BIT) {\n        ESP_LOGI(\"WIFI\", \"Connected successfully\");\n        return ESP_OK;\n    } else {\n        ESP_LOGE(\"WIFI\", \"Connection failed\");\n        return ESP_FAIL;\n    }\n}\n```\n\n### BLE GATT Server Example\n\n```c\n#include \"esp_bt.h\"\n#include \"esp_gap_ble_api.h\"\n#include \"esp_gatts_api.h\"\n#include \"esp_bt_main.h\"\n\n#define GATTS_SERVICE_UUID   0x00FF\n#define GATTS_CHAR_UUID      0xFF01\n#define GATTS_NUM_HANDLE     4\n\nstatic uint8_t service_uuid[16] = {\n    0xfb, 0x34, 0x9b, 0x5f, 0x80, 0x00, 0x00, 0x80,\n    0x00, 0x10, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00,\n};\n\nstatic esp_gatt_char_prop_t char_property =\n    ESP_GATT_CHAR_PROP_BIT_READ |\n    ESP_GATT_CHAR_PROP_BIT_WRITE |\n    ESP_GATT_CHAR_PROP_BIT_NOTIFY;\n\nstatic uint8_t char_value[20] = {0};\n\nstatic void gatts_event_handler(esp_gatts_cb_event_t event,\n                               esp_gatt_if_t gatts_if,\n                               esp_ble_gatts_cb_param_t *param) {\n    switch (event) {\n        case ESP_GATTS_REG_EVT:\n            ESP_LOGI(\"BLE\", \"GATT server registered, status %d\", param->reg.status);\n\n            esp_ble_gap_set_device_name(\"ESP32_TIMER\");\n\n            esp_ble_gap_config_adv_data_raw(adv_data, sizeof(adv_data));\n\n            esp_ble_gatts_create_service(gatts_if, &service_id, GATTS_NUM_HANDLE);\n            break;\n\n        case ESP_GATTS_WRITE_EVT:\n            ESP_LOGI(\"BLE\", \"Write event, value length %d\", param->write.len);\n            if (param->write.len \u003C= sizeof(char_value)) {\n                memcpy(char_value, param->write.value, param->write.len);\n                \u002F\u002F Process received data\n                handle_ble_command(char_value, param->write.len);\n            }\n\n            \u002F\u002F Send response if needed\n            if (param->write.need_rsp) {\n                esp_ble_gatts_send_response(gatts_if, param->write.conn_id,\n                                           param->write.trans_id, ESP_GATT_OK, NULL);\n            }\n            break;\n\n        case ESP_GATTS_READ_EVT:\n            ESP_LOGI(\"BLE\", \"Read event\");\n            esp_gatt_rsp_t rsp;\n            memset(&rsp, 0, sizeof(esp_gatt_rsp_t));\n            rsp.attr_value.handle = param->read.handle;\n            rsp.attr_value.len = sizeof(char_value);\n            memcpy(rsp.attr_value.value, char_value, sizeof(char_value));\n\n            esp_ble_gatts_send_response(gatts_if, param->read.conn_id,\n                                       param->read.trans_id, ESP_GATT_OK, &rsp);\n            break;\n\n        default:\n            break;\n    }\n}\n\nesp_err_t ble_init(void) {\n    esp_err_t ret;\n\n    ESP_ERROR_CHECK(esp_bt_controller_mem_release(ESP_BT_MODE_CLASSIC_BT));\n\n    esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT();\n    ret = esp_bt_controller_init(&bt_cfg);\n    if (ret) {\n        ESP_LOGE(\"BLE\", \"Bluetooth controller init failed\");\n        return ret;\n    }\n\n    ret = esp_bt_controller_enable(ESP_BT_MODE_BLE);\n    if (ret) {\n        ESP_LOGE(\"BLE\", \"Bluetooth controller enable failed\");\n        return ret;\n    }\n\n    ret = esp_bluedroid_init();\n    if (ret) {\n        ESP_LOGE(\"BLE\", \"Bluedroid init failed\");\n        return ret;\n    }\n\n    ret = esp_bluedroid_enable();\n    if (ret) {\n        ESP_LOGE(\"BLE\", \"Bluedroid enable failed\");\n        return ret;\n    }\n\n    esp_ble_gatts_register_callback(gatts_event_handler);\n    esp_ble_gatts_app_register(0);\n\n    return ESP_OK;\n}\n```\n\n## MQTT Integration\n\n### MQTT Client with WiFi (esp-mqtt)\n\n```c\n#include \"mqtt_client.h\"\n\nstatic esp_mqtt_client_handle_t mqtt_client = NULL;\n\nstatic void mqtt_event_handler(void *handler_args, esp_event_base_t base,\n                               int32_t event_id, void *event_data) {\n    esp_mqtt_event_handle_t event = (esp_mqtt_event_handle_t)event_data;\n\n    switch ((esp_mqtt_event_id_t)event_id) {\n        case MQTT_EVENT_CONNECTED:\n            ESP_LOGI(\"MQTT\", \"Connected to broker\");\n\n            \u002F\u002F Subscribe to topics\n            esp_mqtt_client_subscribe(mqtt_client, \"productivity\u002Ftimer\u002Fcontrol\u002F#\", 1);\n            esp_mqtt_client_subscribe(mqtt_client, \"productivity\u002Falert\u002Fvisual\u002F#\", 1);\n\n            \u002F\u002F Publish online status\n            esp_mqtt_client_publish(mqtt_client, \"productivity\u002Fdevice\u002Fstatus\",\n                                   \"online\", 0, 1, 1);\n            break;\n\n        case MQTT_EVENT_DISCONNECTED:\n            ESP_LOGW(\"MQTT\", \"Disconnected from broker\");\n            break;\n\n        case MQTT_EVENT_DATA:\n            ESP_LOGI(\"MQTT\", \"Received: %.*s = %.*s\",\n                    event->topic_len, event->topic,\n                    event->data_len, event->data);\n\n            \u002F\u002F Route message to handler\n            handle_mqtt_message(event->topic, event->topic_len,\n                              event->data, event->data_len);\n            break;\n\n        case MQTT_EVENT_ERROR:\n            ESP_LOGE(\"MQTT\", \"Error: type=%d\", event->error_handle->error_type);\n            break;\n\n        default:\n            break;\n    }\n}\n\nesp_err_t mqtt_init(void) {\n    \u002F\u002F MQTT configuration\n    esp_mqtt_client_config_t mqtt_cfg = {\n        .broker.address.uri = \"mqtt:\u002F\u002F192.168.1.100:1883\",  \u002F\u002F TCP MQTT\n        .credentials.client_id = \"esp32_tembed\",\n        .session.keepalive = 60,\n        .network.reconnect_timeout_ms = 5000,\n        .network.disable_auto_reconnect = false,\n    };\n\n    mqtt_client = esp_mqtt_client_init(&mqtt_cfg);\n    if (mqtt_client == NULL) {\n        ESP_LOGE(\"MQTT\", \"Failed to initialize client\");\n        return ESP_FAIL;\n    }\n\n    esp_mqtt_client_register_event(mqtt_client, ESP_EVENT_ANY_ID,\n                                   mqtt_event_handler, NULL);\n\n    esp_err_t ret = esp_mqtt_client_start(mqtt_client);\n    if (ret != ESP_OK) {\n        ESP_LOGE(\"MQTT\", \"Failed to start client\");\n    }\n\n    return ret;\n}\n\n\u002F\u002F Publish with QoS\nvoid mqtt_publish_timer_state(uint32_t remaining_seconds) {\n    char payload[64];\n    snprintf(payload, sizeof(payload),\n             \"{\\\"remaining\\\":%lu,\\\"timestamp\\\":%llu}\",\n             remaining_seconds, esp_timer_get_time() \u002F 1000000);\n\n    esp_mqtt_client_publish(mqtt_client,\n                           \"productivity\u002Ftimer\u002Fstate\u002Fcurrent\",\n                           payload, 0, 1, 0);  \u002F\u002F QoS 1, no retain\n}\n```\n\n## Peripheral Drivers\n\n### SPI Display Driver Pattern\n\n```c\n#include \"driver\u002Fspi_master.h\"\n#include \"driver\u002Fgpio.h\"\n\n#define LCD_HOST       SPI2_HOST\n#define LCD_MOSI_PIN   GPIO_NUM_35\n#define LCD_SCLK_PIN   GPIO_NUM_36\n#define LCD_CS_PIN     GPIO_NUM_37\n#define LCD_DC_PIN     GPIO_NUM_34\n#define LCD_RST_PIN    GPIO_NUM_38\n#define LCD_BL_PIN     GPIO_NUM_33\n\nstatic spi_device_handle_t spi_device;\n\nesp_err_t lcd_spi_init(void) {\n    \u002F\u002F Configure GPIO\n    gpio_config_t io_conf = {\n        .pin_bit_mask = (1ULL \u003C\u003C LCD_DC_PIN) | (1ULL \u003C\u003C LCD_RST_PIN) | (1ULL \u003C\u003C LCD_BL_PIN),\n        .mode = GPIO_MODE_OUTPUT,\n        .pull_up_en = GPIO_PULLUP_DISABLE,\n        .pull_down_en = GPIO_PULLDOWN_DISABLE,\n        .intr_type = GPIO_INTR_DISABLE,\n    };\n    gpio_config(&io_conf);\n\n    \u002F\u002F SPI bus configuration\n    spi_bus_config_t buscfg = {\n        .mosi_io_num = LCD_MOSI_PIN,\n        .miso_io_num = -1,  \u002F\u002F Display only (no MISO)\n        .sclk_io_num = LCD_SCLK_PIN,\n        .quadwp_io_num = -1,\n        .quadhd_io_num = -1,\n        .max_transfer_sz = 320 * 240 * 2 + 8,  \u002F\u002F Full screen buffer + overhead\n    };\n\n    ESP_ERROR_CHECK(spi_bus_initialize(LCD_HOST, &buscfg, SPI_DMA_CH_AUTO));\n\n    \u002F\u002F SPI device configuration\n    spi_device_interface_config_t devcfg = {\n        .clock_speed_hz = 40 * 1000 * 1000,  \u002F\u002F 40 MHz\n        .mode = 0,\n        .spics_io_num = LCD_CS_PIN,\n        .queue_size = 7,\n        .pre_cb = NULL,\n        .post_cb = NULL,\n    };\n\n    ESP_ERROR_CHECK(spi_bus_add_device(LCD_HOST, &devcfg, &spi_device));\n\n    \u002F\u002F Reset display\n    gpio_set_level(LCD_RST_PIN, 0);\n    vTaskDelay(pdMS_TO_TICKS(100));\n    gpio_set_level(LCD_RST_PIN, 1);\n    vTaskDelay(pdMS_TO_TICKS(100));\n\n    return ESP_OK;\n}\n\nvoid lcd_send_cmd(uint8_t cmd) {\n    spi_transaction_t t = {\n        .length = 8,\n        .tx_buffer = &cmd,\n        .user = (void *)0,  \u002F\u002F D\u002FC = 0 for command\n    };\n    gpio_set_level(LCD_DC_PIN, 0);\n    spi_device_polling_transmit(spi_device, &t);\n}\n\nvoid lcd_send_data(const uint8_t *data, size_t len) {\n    if (len == 0) return;\n\n    spi_transaction_t t = {\n        .length = len * 8,\n        .tx_buffer = data,\n        .user = (void *)1,  \u002F\u002F D\u002FC = 1 for data\n    };\n    gpio_set_level(LCD_DC_PIN, 1);\n    spi_device_polling_transmit(spi_device, &t);\n}\n\n\u002F\u002F DMA transfer for large buffers (non-blocking)\nvoid lcd_send_framebuffer(const uint16_t *buffer, size_t pixel_count) {\n    static spi_transaction_t trans[6];\n    static int trans_in_flight = 0;\n\n    \u002F\u002F Wait for previous transactions to complete\n    while (trans_in_flight) {\n        spi_transaction_t *rtrans;\n        spi_device_get_trans_result(spi_device, &rtrans, portMAX_DELAY);\n        trans_in_flight--;\n    }\n\n    gpio_set_level(LCD_DC_PIN, 1);\n\n    \u002F\u002F Queue transaction\n    trans[0].length = pixel_count * 16;\n    trans[0].tx_buffer = buffer;\n    spi_device_queue_trans(spi_device, &trans[0], portMAX_DELAY);\n    trans_in_flight++;\n}\n```\n\n### I2C Sensor Reading\n\n```c\n#include \"driver\u002Fi2c.h\"\n\n#define I2C_MASTER_NUM      I2C_NUM_0\n#define I2C_MASTER_SDA      GPIO_NUM_21\n#define I2C_MASTER_SCL      GPIO_NUM_22\n#define I2C_MASTER_FREQ_HZ  400000\n\nesp_err_t i2c_master_init(void) {\n    i2c_config_t conf = {\n        .mode = I2C_MODE_MASTER,\n        .sda_io_num = I2C_MASTER_SDA,\n        .scl_io_num = I2C_MASTER_SCL,\n        .sda_pullup_en = GPIO_PULLUP_ENABLE,\n        .scl_pullup_en = GPIO_PULLUP_ENABLE,\n        .master.clk_speed = I2C_MASTER_FREQ_HZ,\n    };\n\n    ESP_ERROR_CHECK(i2c_param_config(I2C_MASTER_NUM, &conf));\n    return i2c_driver_install(I2C_MASTER_NUM, conf.mode, 0, 0, 0);\n}\n\n\u002F\u002F Read sensor register\nesp_err_t sensor_read_register(uint8_t sensor_addr, uint8_t reg_addr,\n                               uint8_t *data, size_t len) {\n    return i2c_master_write_read_device(I2C_MASTER_NUM, sensor_addr,\n                                       &reg_addr, 1, data, len,\n                                       pdMS_TO_TICKS(1000));\n}\n```\n\n### GPIO Interrupt with Debouncing (Rotary Encoder)\n\n```c\n#include \"driver\u002Fgpio.h\"\n\n#define ROTARY_A_PIN    GPIO_NUM_3\n#define ROTARY_B_PIN    GPIO_NUM_46\n#define ROTARY_BTN_PIN  GPIO_NUM_0\n\nstatic volatile int32_t encoder_count = 0;\nstatic SemaphoreHandle_t encoder_mutex;\n\nvoid IRAM_ATTR rotary_isr_handler(void *arg) {\n    static uint8_t last_state = 0;\n    static int64_t last_interrupt_time = 0;\n\n    \u002F\u002F Debounce: 1ms\n    int64_t now = esp_timer_get_time();\n    if ((now - last_interrupt_time) \u003C 1000) {\n        return;\n    }\n    last_interrupt_time = now;\n\n    uint8_t a = gpio_get_level(ROTARY_A_PIN);\n    uint8_t b = gpio_get_level(ROTARY_B_PIN);\n    uint8_t state = (a \u003C\u003C 1) | b;\n\n    \u002F\u002F Quadrature decoding\n    int8_t dir = 0;\n    if (last_state == 0b00 && state == 0b01) dir = 1;\n    else if (last_state == 0b01 && state == 0b11) dir = 1;\n    else if (last_state == 0b11 && state == 0b10) dir = 1;\n    else if (last_state == 0b10 && state == 0b00) dir = 1;\n    else if (last_state == 0b00 && state == 0b10) dir = -1;\n    else if (last_state == 0b10 && state == 0b11) dir = -1;\n    else if (last_state == 0b11 && state == 0b01) dir = -1;\n    else if (last_state == 0b01 && state == 0b00) dir = -1;\n\n    encoder_count += dir;\n    last_state = state;\n}\n\nesp_err_t rotary_encoder_init(void) {\n    encoder_mutex = xSemaphoreCreateMutex();\n\n    \u002F\u002F Configure GPIO\n    gpio_config_t io_conf = {\n        .pin_bit_mask = (1ULL \u003C\u003C ROTARY_A_PIN) | (1ULL \u003C\u003C ROTARY_B_PIN),\n        .mode = GPIO_MODE_INPUT,\n        .pull_up_en = GPIO_PULLUP_ENABLE,\n        .intr_type = GPIO_INTR_ANYEDGE,\n    };\n    gpio_config(&io_conf);\n\n    \u002F\u002F Install ISR service\n    gpio_install_isr_service(0);\n    gpio_isr_handler_add(ROTARY_A_PIN, rotary_isr_handler, NULL);\n    gpio_isr_handler_add(ROTARY_B_PIN, rotary_isr_handler, NULL);\n\n    return ESP_OK;\n}\n\nint32_t rotary_encoder_get_count(void) {\n    int32_t count;\n    xSemaphoreTake(encoder_mutex, portMAX_DELAY);\n    count = encoder_count;\n    xSemaphoreGive(encoder_mutex);\n    return count;\n}\n```\n\n### WS2812B RGB LED Control (RMT)\n\n```c\n#include \"driver\u002Frmt_tx.h\"\n#include \"led_strip_encoder.h\"\n\n#define LED_GPIO        GPIO_NUM_4\n#define LED_COUNT       8\n#define LED_RMT_RES_HZ  (10 * 1000 * 1000)  \u002F\u002F 10 MHz\n\nstatic rmt_channel_handle_t led_chan = NULL;\nstatic rmt_encoder_handle_t led_encoder = NULL;\n\ntypedef struct {\n    uint8_t g;\n    uint8_t r;\n    uint8_t b;\n} rgb_t;\n\nesp_err_t ws2812_init(void) {\n    \u002F\u002F RMT TX channel config\n    rmt_tx_channel_config_t tx_chan_config = {\n        .clk_src = RMT_CLK_SRC_DEFAULT,\n        .gpio_num = LED_GPIO,\n        .mem_block_symbols = 64,\n        .resolution_hz = LED_RMT_RES_HZ,\n        .trans_queue_depth = 4,\n    };\n    ESP_ERROR_CHECK(rmt_new_tx_channel(&tx_chan_config, &led_chan));\n\n    \u002F\u002F LED strip encoder\n    led_strip_encoder_config_t encoder_config = {\n        .resolution = LED_RMT_RES_HZ,\n    };\n    ESP_ERROR_CHECK(rmt_new_led_strip_encoder(&encoder_config, &led_encoder));\n\n    ESP_ERROR_CHECK(rmt_enable(led_chan));\n\n    return ESP_OK;\n}\n\nvoid ws2812_set_colors(const rgb_t *colors, size_t count) {\n    rmt_transmit_config_t tx_config = {\n        .loop_count = 0,\n    };\n\n    ESP_ERROR_CHECK(rmt_transmit(led_chan, led_encoder, colors,\n                                 count * sizeof(rgb_t), &tx_config));\n}\n\n\u002F\u002F Example: Smooth color transition\nvoid led_breathe_effect(void) {\n    rgb_t leds[LED_COUNT];\n\n    for (int brightness = 0; brightness \u003C 255; brightness += 5) {\n        for (int i = 0; i \u003C LED_COUNT; i++) {\n            leds[i].r = brightness;\n            leds[i].g = 0;\n            leds[i].b = brightness \u002F 2;\n        }\n        ws2812_set_colors(leds, LED_COUNT);\n        vTaskDelay(pdMS_TO_TICKS(20));\n    }\n}\n```\n\n## Power Management\n\n### Deep Sleep with Wake Sources\n\n```c\n#include \"esp_sleep.h\"\n#include \"driver\u002Frtc_io.h\"\n\n\u002F\u002F Configure deep sleep with multiple wake sources\nvoid enter_deep_sleep(uint32_t sleep_seconds) {\n    ESP_LOGI(\"POWER\", \"Entering deep sleep for %lu seconds\", sleep_seconds);\n\n    \u002F\u002F Timer wake\n    esp_sleep_enable_timer_wakeup(sleep_seconds * 1000000ULL);\n\n    \u002F\u002F GPIO wake (button press on GPIO0)\n    esp_sleep_enable_ext0_wakeup(GPIO_NUM_0, 0);  \u002F\u002F Wake on LOW\n\n    \u002F\u002F GPIO wake (any of multiple pins)\n    const uint64_t ext1_mask = (1ULL \u003C\u003C GPIO_NUM_1) | (1ULL \u003C\u003C GPIO_NUM_2);\n    esp_sleep_enable_ext1_wakeup(ext1_mask, ESP_EXT1_WAKEUP_ANY_HIGH);\n\n    \u002F\u002F Disable WiFi\u002FBT before sleep\n    esp_wifi_stop();\n    esp_bluedroid_disable();\n    esp_bt_controller_disable();\n\n    \u002F\u002F Enter deep sleep\n    esp_deep_sleep_start();\n}\n\n\u002F\u002F Check wake cause on boot\nvoid check_wake_cause(void) {\n    esp_sleep_wakeup_cause_t cause = esp_sleep_get_wakeup_cause();\n\n    switch (cause) {\n        case ESP_SLEEP_WAKEUP_TIMER:\n            ESP_LOGI(\"POWER\", \"Woke from timer\");\n            break;\n        case ESP_SLEEP_WAKEUP_EXT0:\n            ESP_LOGI(\"POWER\", \"Woke from EXT0 (button)\");\n            break;\n        case ESP_SLEEP_WAKEUP_EXT1:\n            ESP_LOGI(\"POWER\", \"Woke from EXT1, pins: 0x%llx\",\n                    esp_sleep_get_ext1_wakeup_status());\n            break;\n        default:\n            ESP_LOGI(\"POWER\", \"Power-on reset\");\n            break;\n    }\n}\n```\n\n### Light Sleep for Power Saving\n\n```c\n\u002F\u002F Enter light sleep (wakes on GPIO or timer)\nvoid enter_light_sleep(uint32_t sleep_ms) {\n    esp_sleep_enable_timer_wakeup(sleep_ms * 1000);\n    esp_sleep_enable_gpio_wakeup();\n\n    ESP_LOGI(\"POWER\", \"Entering light sleep\");\n    esp_light_sleep_start();\n    ESP_LOGI(\"POWER\", \"Woke from light sleep\");\n}\n\n\u002F\u002F Automatic light sleep (modem sleep)\nvoid enable_auto_light_sleep(void) {\n    \u002F\u002F Automatically enter light sleep when idle\n    esp_pm_config_t pm_config = {\n        .max_freq_mhz = 240,\n        .min_freq_mhz = 80,\n        .light_sleep_enable = true,\n    };\n    ESP_ERROR_CHECK(esp_pm_configure(&pm_config));\n}\n```\n\n## Memory Optimization\n\n### Flash vs RAM Placement\n\n```c\n\u002F\u002F Store constant data in flash (saves RAM)\nstatic const uint8_t DRAM_ATTR lookup_table[256] = { \u002F* ... *\u002F };\n\n\u002F\u002F Keep frequently accessed data in RAM\nstatic DRAM_ATTR uint8_t frame_buffer[320 * 240 * 2];\n\n\u002F\u002F Place ISR code in IRAM for fast access\nvoid IRAM_ATTR gpio_fast_isr(void *arg) {\n    \u002F\u002F Time-critical interrupt code\n}\n\n\u002F\u002F Place large read-only data in flash\nstatic const char TAG[] = \"MAIN\";  \u002F\u002F Automatically in flash\n\n\u002F\u002F Explicitly place string in flash\nESP_LOGI(TAG, \"This string is in flash\");\n```\n\n### Memory Monitoring\n\n```c\nvoid print_memory_info(void) {\n    ESP_LOGI(\"MEM\", \"Free heap: %lu bytes\", esp_get_free_heap_size());\n    ESP_LOGI(\"MEM\", \"Minimum free heap: %lu bytes\", esp_get_minimum_free_heap_size());\n    ESP_LOGI(\"MEM\", \"Largest free block: %lu bytes\", heap_caps_get_largest_free_block(MALLOC_CAP_8BIT));\n\n    \u002F\u002F PSRAM info (ESP32-S3 can have external PSRAM)\n    ESP_LOGI(\"MEM\", \"Free PSRAM: %lu bytes\", heap_caps_get_free_size(MALLOC_CAP_SPIRAM));\n}\n\n\u002F\u002F Allocate from PSRAM if available\nvoid *buffer = heap_caps_malloc(1024 * 1024, MALLOC_CAP_SPIRAM);\nif (buffer == NULL) {\n    ESP_LOGE(\"MEM\", \"Failed to allocate PSRAM\");\n}\n```\n\n### Custom Partition Tables\n\n```csv\n# partitions.csv - Optimize flash layout\n# Name,   Type, SubType, Offset,  Size,     Flags\nnvs,      data, nvs,     0x9000,  0x4000,\notadata,  data, ota,     0xd000,  0x2000,\nphy_init, data, phy,     0xf000,  0x1000,\nfactory,  app,  factory, 0x10000, 1M,\nota_0,    app,  ota_0,   ,        1M,\nota_1,    app,  ota_1,   ,        1M,\nstorage,  data, spiffs,  ,        1M,\n```\n\n## OTA Firmware Updates\n\n### HTTPS OTA Update\n\n```c\n#include \"esp_https_ota.h\"\n#include \"esp_ota_ops.h\"\n\n#define FIRMWARE_URL \"https:\u002F\u002Fexample.com\u002Ffirmware.bin\"\n\nesp_err_t perform_ota_update(void) {\n    ESP_LOGI(\"OTA\", \"Starting OTA update\");\n\n    esp_http_client_config_t config = {\n        .url = FIRMWARE_URL,\n        .cert_pem = NULL,  \u002F\u002F Use server_cert_pem for production\n        .timeout_ms = 5000,\n        .keep_alive_enable = true,\n    };\n\n    esp_https_ota_config_t ota_config = {\n        .http_config = &config,\n    };\n\n    esp_https_ota_handle_t https_ota_handle = NULL;\n    esp_err_t err = esp_https_ota_begin(&ota_config, &https_ota_handle);\n    if (err != ESP_OK) {\n        ESP_LOGE(\"OTA\", \"OTA begin failed\");\n        return err;\n    }\n\n    \u002F\u002F Get image info\n    esp_app_desc_t new_app_info;\n    err = esp_https_ota_get_img_desc(https_ota_handle, &new_app_info);\n    if (err != ESP_OK) {\n        ESP_LOGE(\"OTA\", \"Failed to get image descriptor\");\n        esp_https_ota_abort(https_ota_handle);\n        return err;\n    }\n\n    ESP_LOGI(\"OTA\", \"New firmware version: %s\", new_app_info.version);\n\n    \u002F\u002F Download and write firmware\n    while (1) {\n        err = esp_https_ota_perform(https_ota_handle);\n        if (err != ESP_ERR_HTTPS_OTA_IN_PROGRESS) {\n            break;\n        }\n\n        \u002F\u002F Progress reporting\n        int progress = esp_https_ota_get_image_len_read(https_ota_handle);\n        ESP_LOGI(\"OTA\", \"Downloaded: %d bytes\", progress);\n    }\n\n    if (err != ESP_OK) {\n        ESP_LOGE(\"OTA\", \"OTA failed: %s\", esp_err_to_name(err));\n        esp_https_ota_abort(https_ota_handle);\n        return err;\n    }\n\n    \u002F\u002F Finalize OTA\n    err = esp_https_ota_finish(https_ota_handle);\n    if (err == ESP_OK) {\n        ESP_LOGI(\"OTA\", \"OTA successful, restarting...\");\n        vTaskDelay(pdMS_TO_TICKS(1000));\n        esp_restart();\n    } else {\n        ESP_LOGE(\"OTA\", \"OTA finish failed\");\n    }\n\n    return err;\n}\n```\n\n## Debugging & Logging\n\n### Log Levels and Tags\n\n```c\n#include \"esp_log.h\"\n\nstatic const char *TAG = \"MAIN\";\n\nvoid logging_examples(void) {\n    \u002F\u002F Set log level for specific tag\n    esp_log_level_set(\"WIFI\", ESP_LOG_WARN);\n    esp_log_level_set(\"MQTT\", ESP_LOG_INFO);\n\n    \u002F\u002F Different log levels\n    ESP_LOGE(TAG, \"Error: %d\", error_code);         \u002F\u002F Red\n    ESP_LOGW(TAG, \"Warning: %s\", warning_msg);      \u002F\u002F Yellow\n    ESP_LOGI(TAG, \"Info: operation complete\");      \u002F\u002F Green\n    ESP_LOGD(TAG, \"Debug: value=%d\", debug_val);    \u002F\u002F Normal (only if DEBUG)\n    ESP_LOGV(TAG, \"Verbose: detailed trace\");       \u002F\u002F Normal (only if VERBOSE)\n\n    \u002F\u002F Conditional compilation (saves flash space)\n    #if CONFIG_LOG_MAXIMUM_LEVEL >= ESP_LOG_DEBUG\n    ESP_LOGD(TAG, \"This is only compiled in debug builds\");\n    #endif\n}\n```\n\n### Watchdog Timer Configuration\n\n```c\n#include \"esp_task_wdt.h\"\n\n#define WDT_TIMEOUT_S  5\n\nvoid watchdog_init(void) {\n    \u002F\u002F Configure task watchdog\n    esp_task_wdt_config_t wdt_config = {\n        .timeout_ms = WDT_TIMEOUT_S * 1000,\n        .idle_core_mask = (1 \u003C\u003C 0) | (1 \u003C\u003C 1),  \u002F\u002F Monitor both cores\n        .trigger_panic = true,\n    };\n    ESP_ERROR_CHECK(esp_task_wdt_init(&wdt_config));\n\n    \u002F\u002F Subscribe current task\n    ESP_ERROR_CHECK(esp_task_wdt_add(NULL));\n}\n\nvoid long_running_task(void *pvParameters) {\n    watchdog_init();\n\n    while (1) {\n        do_work();\n\n        \u002F\u002F Reset watchdog\n        esp_task_wdt_reset();\n\n        vTaskDelay(pdMS_TO_TICKS(1000));\n    }\n}\n```\n\n### Stack Overflow Detection\n\n```c\n\u002F\u002F In sdkconfig or menuconfig:\n\u002F\u002F CONFIG_FREERTOS_WATCHPOINT_END_OF_STACK=y\n\u002F\u002F CONFIG_FREERTOS_CHECK_STACKOVERFLOW_CANARY=y\n\nvoid app_main(void) {\n    \u002F\u002F Monitor stack usage\n    UBaseType_t stack_high_water = uxTaskGetStackHighWaterMark(NULL);\n    ESP_LOGI(\"STACK\", \"Free stack: %lu bytes\", stack_high_water * sizeof(StackType_t));\n}\n```\n\n## T-Embed Specific Patterns\n\nSee `references\u002Ft_embed_hardware.md` for complete T-Embed ESP32-S3 hardware specifications, pinout, and initialization examples.\n\n## Resources\n\nThis skill includes reference documentation and example code:\n\n### references\u002F\n\n- `freertos_patterns.md` - Advanced FreeRTOS patterns and best practices\n- `wifi_ble_advanced.md` - Advanced WiFi\u002FBLE configuration and troubleshooting\n- `t_embed_hardware.md` - Complete T-Embed hardware reference\n- `power_optimization.md` - Detailed power consumption optimization strategies\n\n### scripts\u002F\n\n- `create_component.sh` - Generate new ESP-IDF component boilerplate\n- `partition_calculator.py` - Calculate optimal partition layout\n\n### assets\u002F\n\n- `component_template\u002F` - ESP-IDF component template structure\n- `platformio_template\u002F` - PlatformIO project template for ESP32-S3\n\n## Development Environment Setup\n\n```bash\n# Install ESP-IDF (recommended: v5.3.x or v5.1.x LTS)\ngit clone -b v5.3 --recursive https:\u002F\u002Fgithub.com\u002Fespressif\u002Fesp-idf.git\ncd esp-idf\n.\u002Finstall.sh esp32,esp32s3\n\n# Activate IDF environment\n. .\u002Fexport.sh\n\n# Or use PlatformIO\npip install platformio\npio platform install espressif32@6.5.0\n```\n\n## Common Troubleshooting\n\n**Task watchdog timeout**: Increase task priority or add `esp_task_wdt_reset()` calls\n\n**Stack overflow**: Increase task stack size or optimize local variable usage\n\n**WiFi disconnects**: Implement reconnection logic in event handler, check power supply\n\n**BLE pairing fails**: Verify security settings, check MTU size\n\n**MQTT messages dropped**: Increase queue sizes, check network stability, use QoS 1\n\n**Display flicker**: Use double buffering, ensure adequate SPI clock speed\n\n**Deep sleep current high**: Disable all peripherals, check GPIO pull configurations\n\nRefer to `references\u002F` files for detailed troubleshooting and optimization guides.\n","# ESP32 Embedded Development\n\n## Overview\n\nProvides comprehensive ESP-IDF 5.3.x development guidance for ESP32\u002FESP32-S3 microcontrollers, covering real-time operating system patterns, wireless networking, peripheral drivers, and production-grade firmware development.\n\n**Use this skill when:**\n- Developing ESP32\u002FESP32-S3 firmware with ESP-IDF framework\n- Implementing FreeRTOS tasks, queues, semaphores, or mutexes\n- Configuring WiFi station\u002FAP modes or BLE GATT services\n- Integrating MQTT over WiFi\u002FWebSocket\n- Working with SPI, I2C, UART, GPIO, ADC, or PWM peripherals\n- Optimizing power consumption with sleep modes\n- Implementing OTA firmware updates\n- Debugging memory issues or optimizing flash\u002FRAM usage\n- Working with T-Embed hardware (ESP32-S3, 1.9\" display, rotary encoder, RGB LEDs)\n\n## Quick Start\n\n### Project Structure\n\nESP-IDF projects follow this standard structure:\n\n```\nproject\u002F\n├── main\u002F\n│   ├── CMakeLists.txt\n│   ├── main.c (or .cpp)\n│   └── Kconfig.projbuild (optional)\n├── components\u002F\n│   └── custom_component\u002F\n│       ├── CMakeLists.txt\n│       ├── include\u002F\n│       └── src\u002F\n├── CMakeLists.txt\n├── sdkconfig\n└── partitions.csv (optional)\n```\n\n### Essential idf.py Commands\n\n```bash\n# Set target chip\nidf.py set-target esp32s3\n\n# Configure project (menuconfig)\nidf.py menuconfig\n\n# Build project\nidf.py build\n\n# Flash and monitor\nidf.py -p \u002Fdev\u002FttyUSB0 flash monitor\n\n# Clean build\nidf.py fullclean\n\n# Size analysis\nidf.py size-components\nidf.py size-files\n```\n\n### Component Registration\n\n```cmake\n# components\u002Fmy_component\u002FCMakeLists.txt\nidf_component_register(\n    SRCS \"src\u002Fmy_component.c\"\n    INCLUDE_DIRS \"include\"\n    REQUIRES driver nvs_flash esp_wifi\n)\n```\n\n## FreeRTOS Task Management\n\n### Task Creation Patterns\n\n```c\n#include \"freertos\u002FFreeRTOS.h\"\n#include \"freertos\u002Ftask.h\"\n#include \"freertos\u002Fqueue.h\"\n#include \"freertos\u002Fsemphr.h\"\n\n\u002F\u002F Task priorities (0 = lowest, configMAX_PRIORITIES-1 = highest)\n\u002F\u002F ESP-IDF reserves priority 19+ for system tasks\n#define NETWORK_TASK_PRIORITY    5  \u002F\u002F Network tasks\n#define DISPLAY_TASK_PRIORITY    4  \u002F\u002F UI updates\n#define SENSOR_TASK_PRIORITY     3  \u002F\u002F Sensor reading\n#define LED_TASK_PRIORITY        2  \u002F\u002F LED animations\n#define IDLE_TASK_PRIORITY       1  \u002F\u002F Background tasks\n\n\u002F\u002F Recommended stack sizes\n#define NETWORK_STACK_SIZE  4096  \u002F\u002F Network\u002FMQTT tasks\n#define DISPLAY_STACK_SIZE  3072  \u002F\u002F Display rendering\n#define SENSOR_STACK_SIZE   2048  \u002F\u002F Sensor tasks\n#define LED_STACK_SIZE      2048  \u002F\u002F LED control\n\n\u002F\u002F Task handle for later control\nstatic TaskHandle_t display_task_handle = NULL;\n\nvoid display_task(void *pvParameters) {\n    TickType_t last_wake_time = xTaskGetTickCount();\n    const TickType_t frequency = pdMS_TO_TICKS(33); \u002F\u002F 30 FPS\n\n    while (1) {\n        \u002F\u002F Update display\n        update_display();\n\n        \u002F\u002F Delay until next frame (absolute timing)\n        vTaskDelayUntil(&last_wake_time, frequency);\n    }\n}\n\n\u002F\u002F Create task pinned to specific core (ESP32-S3 has 2 cores)\nxTaskCreatePinnedToCore(\n    display_task,           \u002F\u002F Task function\n    \"display_task\",         \u002F\u002F Name\n    DISPLAY_STACK_SIZE,     \u002F\u002F Stack size\n    NULL,                   \u002F\u002F Parameters\n    DISPLAY_TASK_PRIORITY,  \u002F\u002F Priority\n    &display_task_handle,   \u002F\u002F Task handle\n    1                       \u002F\u002F Core ID (0 or 1, or tskNO_AFFINITY)\n);\n```\n\n### Queue Communication\n\n```c\n\u002F\u002F Create queue (typically as global or passed via parameters)\nstatic QueueHandle_t event_queue = NULL;\n\ntypedef struct {\n    uint8_t event_type;\n    uint32_t value;\n    uint64_t timestamp;\n} event_data_t;\n\nvoid init_queues(void) {\n    event_queue = xQueueCreate(10, sizeof(event_data_t));\n    if (event_queue == NULL) {\n        ESP_LOGE(\"INIT\", \"Failed to create event queue\");\n    }\n}\n\n\u002F\u002F Producer task\nvoid sensor_task(void *pvParameters) {\n    event_data_t event;\n\n    while (1) {\n        event.event_type = SENSOR_EVENT;\n        event.value = read_sensor();\n        event.timestamp = esp_timer_get_time();\n\n        \u002F\u002F Send to queue (wait up to 100ms if full)\n        if (xQueueSend(event_queue, &event, pdMS_TO_TICKS(100)) != pdPASS) {\n            ESP_LOGW(\"SENSOR\", \"Queue full, event dropped\");\n        }\n\n        vTaskDelay(pdMS_TO_TICKS(1000));\n    }\n}\n\n\u002F\u002F Consumer task\nvoid processing_task(void *pvParameters) {\n    event_data_t event;\n\n    while (1) {\n        \u002F\u002F Wait indefinitely for event\n        if (xQueueReceive(event_queue, &event, portMAX_DELAY) == pdPASS) {\n            process_event(&event);\n        }\n    }\n}\n```\n\n### Mutex and Semaphore Patterns\n\n```c\n\u002F\u002F Mutex for protecting shared resources\nstatic SemaphoreHandle_t i2c_mutex = NULL;\n\nvoid init_synchronization(void) {\n    i2c_mutex = xSemaphoreCreateMutex();\n}\n\nesp_err_t safe_i2c_read(uint8_t addr, uint8_t *data, size_t len) {\n    esp_err_t ret = ESP_FAIL;\n\n    \u002F\u002F Take mutex (wait up to 1 second)\n    if (xSemaphoreTake(i2c_mutex, pdMS_TO_TICKS(1000)) == pdTRUE) {\n        ret = i2c_master_read_from_device(I2C_NUM_0, addr, data, len, pdMS_TO_TICKS(100));\n        xSemaphoreGive(i2c_mutex);\n    } else {\n        ESP_LOGE(\"I2C\", \"Failed to acquire mutex\");\n    }\n\n    return ret;\n}\n\n\u002F\u002F Binary semaphore for task synchronization\nstatic SemaphoreHandle_t sync_semaphore = NULL;\n\nvoid init_sync(void) {\n    sync_semaphore = xSemaphoreCreateBinary();\n}\n\n\u002F\u002F ISR gives semaphore\nvoid IRAM_ATTR gpio_isr_handler(void *arg) {\n    BaseType_t higher_priority_task_woken = pdFALSE;\n    xSemaphoreGiveFromISR(sync_semaphore, &higher_priority_task_woken);\n\n    if (higher_priority_task_woken) {\n        portYIELD_FROM_ISR();\n    }\n}\n\n\u002F\u002F Task waits for semaphore\nvoid event_handler_task(void *pvParameters) {\n    while (1) {\n        if (xSemaphoreTake(sync_semaphore, portMAX_DELAY) == pdTRUE) {\n            handle_interrupt_event();\n        }\n    }\n}\n```\n\n## WiFi & BLE Networking\n\n### WiFi Station Mode (Complete Example)\n\n```c\n#include \"esp_wifi.h\"\n#include \"esp_event.h\"\n#include \"esp_netif.h\"\n#include \"nvs_flash.h\"\n\n#define WIFI_SSID      \"your_ssid\"\n#define WIFI_PASSWORD  \"your_password\"\n#define MAX_RETRY      5\n\nstatic EventGroupHandle_t wifi_event_group;\nstatic const int WIFI_CONNECTED_BIT = BIT0;\nstatic const int WIFI_FAIL_BIT = BIT1;\nstatic int retry_count = 0;\n\nstatic void wifi_event_handler(void *arg, esp_event_base_t event_base,\n                               int32_t event_id, void *event_data) {\n    if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_START) {\n        esp_wifi_connect();\n        ESP_LOGI(\"WIFI\", \"Station started, connecting...\");\n    } else if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_DISCONNECTED) {\n        if (retry_count \u003C MAX_RETRY) {\n            esp_wifi_connect();\n            retry_count++;\n            ESP_LOGI(\"WIFI\", \"Retry connection %d\u002F%d\", retry_count, MAX_RETRY);\n        } else {\n            xEventGroupSetBits(wifi_event_group, WIFI_FAIL_BIT);\n            ESP_LOGE(\"WIFI\", \"Failed to connect after %d retries\", MAX_RETRY);\n        }\n    } else if (event_base == IP_EVENT && event_id == IP_EVENT_STA_GOT_IP) {\n        ip_event_got_ip_t *event = (ip_event_got_ip_t *)event_data;\n        ESP_LOGI(\"WIFI\", \"Got IP: \" IPSTR, IP2STR(&event->ip_info.ip));\n        retry_count = 0;\n        xEventGroupSetBits(wifi_event_group, WIFI_CONNECTED_BIT);\n    }\n}\n\nesp_err_t wifi_init_sta(void) {\n    wifi_event_group = xEventGroupCreate();\n\n    \u002F\u002F Initialize network interface\n    ESP_ERROR_CHECK(esp_netif_init());\n    ESP_ERROR_CHECK(esp_event_loop_create_default());\n    esp_netif_create_default_wifi_sta();\n\n    \u002F\u002F WiFi configuration\n    wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();\n    ESP_ERROR_CHECK(esp_wifi_init(&cfg));\n\n    \u002F\u002F Register event handlers\n    ESP_ERROR_CHECK(esp_event_handler_instance_register(\n        WIFI_EVENT, ESP_EVENT_ANY_ID, &wifi_event_handler, NULL, NULL));\n    ESP_ERROR_CHECK(esp_event_handler_instance_register(\n        IP_EVENT, IP_EVENT_STA_GOT_IP, &wifi_event_handler, NULL, NULL));\n\n    \u002F\u002F Configure WiFi\n    wifi_config_t wifi_config = {\n        .sta = {\n            .ssid = WIFI_SSID,\n            .password = WIFI_PASSWORD,\n            .threshold.authmode = WIFI_AUTH_WPA2_PSK,\n            .pmf_cfg = {\n                .capable = true,\n                .required = false\n            },\n        },\n    };\n\n    ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA));\n    ESP_ERROR_CHECK(esp_wifi_set_config(WIFI_IF_STA, &wifi_config));\n    ESP_ERROR_CHECK(esp_wifi_start());\n\n    \u002F\u002F Wait for connection or failure\n    EventBits_t bits = xEventGroupWaitBits(wifi_event_group,\n        WIFI_CONNECTED_BIT | WIFI_FAIL_BIT, pdFALSE, pdFALSE, portMAX_DELAY);\n\n    if (bits & WIFI_CONNECTED_BIT) {\n        ESP_LOGI(\"WIFI\", \"Connected successfully\");\n        return ESP_OK;\n    } else {\n        ESP_LOGE(\"WIFI\", \"Connection failed\");\n        return ESP_FAIL;\n    }\n}\n```\n\n### BLE GATT Server Example\n\n```c\n#include \"esp_bt.h\"\n#include \"esp_gap_ble_api.h\"\n#include \"esp_gatts_api.h\"\n#include \"esp_bt_main.h\"\n\n#define GATTS_SERVICE_UUID   0x00FF\n#define GATTS_CHAR_UUID      0xFF01\n#define GATTS_NUM_HANDLE     4\n\nstatic uint8_t service_uuid[16] = {\n    0xfb, 0x34, 0x9b, 0x5f, 0x80, 0x00, 0x00, 0x80,\n    0x00, 0x10, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00,\n};\n\nstatic esp_gatt_char_prop_t char_property =\n    ESP_GATT_CHAR_PROP_BIT_READ |\n    ESP_GATT_CHAR_PROP_BIT_WRITE |\n    ESP_GATT_CHAR_PROP_BIT_NOTIFY;\n\nstatic uint8_t char_value[20] = {0};\n\nstatic void gatts_event_handler(esp_gatts_cb_event_t event,\n                               esp_gatt_if_t gatts_if,\n                               esp_ble_gatts_cb_param_t *param) {\n    switch (event) {\n        case ESP_GATTS_REG_EVT:\n            ESP_LOGI(\"BLE\", \"GATT server registered, status %d\", param->reg.status);\n\n            esp_ble_gap_set_device_name(\"ESP32_TIMER\");\n\n            esp_ble_gap_config_adv_data_raw(adv_data, sizeof(adv_data));\n\n            esp_ble_gatts_create_service(gatts_if, &service_id, GATTS_NUM_HANDLE);\n            break;\n\n        case ESP_GATTS_WRITE_EVT:\n            ESP_LOGI(\"BLE\", \"Write event, value length %d\", param->write.len);\n            if (param->write.len \u003C= sizeof(char_value)) {\n                memcpy(char_value, param->write.value, param->write.len);\n                \u002F\u002F Process received data\n                handle_ble_command(char_value, param->write.len);\n            }\n\n            \u002F\u002F Send response if needed\n            if (param->write.need_rsp) {\n                esp_ble_gatts_send_response(gatts_if, param->write.conn_id,\n                                           param->write.trans_id, ESP_GATT_OK, NULL);\n            }\n            break;\n\n        case ESP_GATTS_READ_EVT:\n            ESP_LOGI(\"BLE\", \"Read event\");\n            esp_gatt_rsp_t rsp;\n            memset(&rsp, 0, sizeof(esp_gatt_rsp_t));\n            rsp.attr_value.handle = param->read.handle;\n            rsp.attr_value.len = sizeof(char_value);\n            memcpy(rsp.attr_value.value, char_value, sizeof(char_value));\n\n            esp_ble_gatts_send_response(gatts_if, param->read.conn_id,\n                                       param->read.trans_id, ESP_GATT_OK, &rsp);\n            break;\n\n        default:\n            break;\n    }\n}\n\nesp_err_t ble_init(void) {\n    esp_err_t ret;\n\n    ESP_ERROR_CHECK(esp_bt_controller_mem_release(ESP_BT_MODE_CLASSIC_BT));\n\n    esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT();\n    ret = esp_bt_controller_init(&bt_cfg);\n    if (ret) {\n        ESP_LOGE(\"BLE\", \"Bluetooth controller init failed\");\n        return ret;\n    }\n\n    ret = esp_bt_controller_enable(ESP_BT_MODE_BLE);\n    if (ret) {\n        ESP_LOGE(\"BLE\", \"Bluetooth controller enable failed\");\n        return ret;\n    }\n\n    ret = esp_bluedroid_init();\n    if (ret) {\n        ESP_LOGE(\"BLE\", \"Bluedroid init failed\");\n        return ret;\n    }\n\n    ret = esp_bluedroid_enable();\n    if (ret) {\n        ESP_LOGE(\"BLE\", \"Bluedroid enable failed\");\n        return ret;\n    }\n\n    esp_ble_gatts_register_callback(gatts_event_handler);\n    esp_ble_gatts_app_register(0);\n\n    return ESP_OK;\n}\n```\n\n## MQTT Integration\n\n### MQTT Client with WiFi (esp-mqtt)\n\n```c\n#include \"mqtt_client.h\"\n\nstatic esp_mqtt_client_handle_t mqtt_client = NULL;\n\nstatic void mqtt_event_handler(void *handler_args, esp_event_base_t base,\n                               int32_t event_id, void *event_data) {\n    esp_mqtt_event_handle_t event = (esp_mqtt_event_handle_t)event_data;\n\n    switch ((esp_mqtt_event_id_t)event_id) {\n        case MQTT_EVENT_CONNECTED:\n            ESP_LOGI(\"MQTT\", \"Connected to broker\");\n\n            \u002F\u002F Subscribe to topics\n            esp_mqtt_client_subscribe(mqtt_client, \"productivity\u002Ftimer\u002Fcontrol\u002F#\", 1);\n            esp_mqtt_client_subscribe(mqtt_client, \"productivity\u002Falert\u002Fvisual\u002F#\", 1);\n\n            \u002F\u002F Publish online status\n            esp_mqtt_client_publish(mqtt_client, \"productivity\u002Fdevice\u002Fstatus\",\n                                   \"online\", 0, 1, 1);\n            break;\n\n        case MQTT_EVENT_DISCONNECTED:\n            ESP_LOGW(\"MQTT\", \"Disconnected from broker\");\n            break;\n\n        case MQTT_EVENT_DATA:\n            ESP_LOGI(\"MQTT\", \"Received: %.*s = %.*s\",\n                    event->topic_len, event->topic,\n                    event->data_len, event->data);\n\n            \u002F\u002F Route message to handler\n            handle_mqtt_message(event->topic, event->topic_len,\n                              event->data, event->data_len);\n            break;\n\n        case MQTT_EVENT_ERROR:\n            ESP_LOGE(\"MQTT\", \"Error: type=%d\", event->error_handle->error_type);\n            break;\n\n        default:\n            break;\n    }\n}\n\nesp_err_t mqtt_init(void) {\n    \u002F\u002F MQTT configuration\n    esp_mqtt_client_config_t mqtt_cfg = {\n        .broker.address.uri = \"mqtt:\u002F\u002F192.168.1.100:1883\",  \u002F\u002F TCP MQTT\n        .credentials.client_id = \"esp32_tembed\",\n        .session.keepalive = 60,\n        .network.reconnect_timeout_ms = 5000,\n        .network.disable_auto_reconnect = false,\n    };\n\n    mqtt_client = esp_mqtt_client_init(&mqtt_cfg);\n    if (mqtt_client == NULL) {\n        ESP_LOGE(\"MQTT\", \"Failed to initialize client\");\n        return ESP_FAIL;\n    }\n\n    esp_mqtt_client_register_event(mqtt_client, ESP_EVENT_ANY_ID,\n                                   mqtt_event_handler, NULL);\n\n    esp_err_t ret = esp_mqtt_client_start(mqtt_client);\n    if (ret != ESP_OK) {\n        ESP_LOGE(\"MQTT\", \"Failed to start client\");\n    }\n\n    return ret;\n}\n\n\u002F\u002F Publish with QoS\nvoid mqtt_publish_timer_state(uint32_t remaining_seconds) {\n    char payload[64];\n    snprintf(payload, sizeof(payload),\n             \"{\\\"remaining\\\":%lu,\\\"timestamp\\\":%llu}\",\n             remaining_seconds, esp_timer_get_time() \u002F 1000000);\n\n    esp_mqtt_client_publish(mqtt_client,\n                           \"productivity\u002Ftimer\u002Fstate\u002Fcurrent\",\n                           payload, 0, 1, 0);  \u002F\u002F QoS 1, no retain\n}\n```\n\n## Peripheral Drivers\n\n### SPI Display Driver Pattern\n\n```c\n#include \"driver\u002Fspi_master.h\"\n#include \"driver\u002Fgpio.h\"\n\n#define LCD_HOST       SPI2_HOST\n#define LCD_MOSI_PIN   GPIO_NUM_35\n#define LCD_SCLK_PIN   GPIO_NUM_36\n#define LCD_CS_PIN     GPIO_NUM_37\n#define LCD_DC_PIN     GPIO_NUM_34\n#define LCD_RST_PIN    GPIO_NUM_38\n#define LCD_BL_PIN     GPIO_NUM_33\n\nstatic spi_device_handle_t spi_device;\n\nesp_err_t lcd_spi_init(void) {\n    \u002F\u002F Configure GPIO\n    gpio_config_t io_conf = {\n        .pin_bit_mask = (1ULL \u003C\u003C LCD_DC_PIN) | (1ULL \u003C\u003C LCD_RST_PIN) | (1ULL \u003C\u003C LCD_BL_PIN),\n        .mode = GPIO_MODE_OUTPUT,\n        .pull_up_en = GPIO_PULLUP_DISABLE,\n        .pull_down_en = GPIO_PULLDOWN_DISABLE,\n        .intr_type = GPIO_INTR_DISABLE,\n    };\n    gpio_config(&io_conf);\n\n    \u002F\u002F SPI bus configuration\n    spi_bus_config_t buscfg = {\n        .mosi_io_num = LCD_MOSI_PIN,\n        .miso_io_num = -1,  \u002F\u002F Display only (no MISO)\n        .sclk_io_num = LCD_SCLK_PIN,\n        .quadwp_io_num = -1,\n        .quadhd_io_num = -1,\n        .max_transfer_sz = 320 * 240 * 2 + 8,  \u002F\u002F Full screen buffer + overhead\n    };\n\n    ESP_ERROR_CHECK(spi_bus_initialize(LCD_HOST, &buscfg, SPI_DMA_CH_AUTO));\n\n    \u002F\u002F SPI device configuration\n    spi_device_interface_config_t devcfg = {\n        .clock_speed_hz = 40 * 1000 * 1000,  \u002F\u002F 40 MHz\n        .mode = 0,\n        .spics_io_num = LCD_CS_PIN,\n        .queue_size = 7,\n        .pre_cb = NULL,\n        .post_cb = NULL,\n    };\n\n    ESP_ERROR_CHECK(spi_bus_add_device(LCD_HOST, &devcfg, &spi_device));\n\n    \u002F\u002F Reset display\n    gpio_set_level(LCD_RST_PIN, 0);\n    vTaskDelay(pdMS_TO_TICKS(100));\n    gpio_set_level(LCD_RST_PIN, 1);\n    vTaskDelay(pdMS_TO_TICKS(100));\n\n    return ESP_OK;\n}\n\nvoid lcd_send_cmd(uint8_t cmd) {\n    spi_transaction_t t = {\n        .length = 8,\n        .tx_buffer = &cmd,\n        .user = (void *)0,  \u002F\u002F D\u002FC = 0 for command\n    };\n    gpio_set_level(LCD_DC_PIN, 0);\n    spi_device_polling_transmit(spi_device, &t);\n}\n\nvoid lcd_send_data(const uint8_t *data, size_t len) {\n    if (len == 0) return;\n\n    spi_transaction_t t = {\n        .length = len * 8,\n        .tx_buffer = data,\n        .user = (void *)1,  \u002F\u002F D\u002FC = 1 for data\n    };\n    gpio_set_level(LCD_DC_PIN, 1);\n    spi_device_polling_transmit(spi_device, &t);\n}\n\n\u002F\u002F DMA transfer for large buffers (non-blocking)\nvoid lcd_send_framebuffer(const uint16_t *buffer, size_t pixel_count) {\n    static spi_transaction_t trans[6];\n    static int trans_in_flight = 0;\n\n    \u002F\u002F Wait for previous transactions to complete\n    while (trans_in_flight) {\n        spi_transaction_t *rtrans;\n        spi_device_get_trans_result(spi_device, &rtrans, portMAX_DELAY);\n        trans_in_flight--;\n    }\n\n    gpio_set_level(LCD_DC_PIN, 1);\n\n    \u002F\u002F Queue transaction\n    trans[0].length = pixel_count * 16;\n    trans[0].tx_buffer = buffer;\n    spi_device_queue_trans(spi_device, &trans[0], portMAX_DELAY);\n    trans_in_flight++;\n}\n```\n\n### I2C Sensor Reading\n\n```c\n#include \"driver\u002Fi2c.h\"\n\n#define I2C_MASTER_NUM      I2C_NUM_0\n#define I2C_MASTER_SDA      GPIO_NUM_21\n#define I2C_MASTER_SCL      GPIO_NUM_22\n#define I2C_MASTER_FREQ_HZ  400000\n\nesp_err_t i2c_master_init(void) {\n    i2c_config_t conf = {\n        .mode = I2C_MODE_MASTER,\n        .sda_io_num = I2C_MASTER_SDA,\n        .scl_io_num = I2C_MASTER_SCL,\n        .sda_pullup_en = GPIO_PULLUP_ENABLE,\n        .scl_pullup_en = GPIO_PULLUP_ENABLE,\n        .master.clk_speed = I2C_MASTER_FREQ_HZ,\n    };\n\n    ESP_ERROR_CHECK(i2c_param_config(I2C_MASTER_NUM, &conf));\n    return i2c_driver_install(I2C_MASTER_NUM, conf.mode, 0, 0, 0);\n}\n\n\u002F\u002F Read sensor register\nesp_err_t sensor_read_register(uint8_t sensor_addr, uint8_t reg_addr,\n                               uint8_t *data, size_t len) {\n    return i2c_master_write_read_device(I2C_MASTER_NUM, sensor_addr,\n                                       &reg_addr, 1, data, len,\n                                       pdMS_TO_TICKS(1000));\n}\n```\n\n### GPIO Interrupt with Debouncing (Rotary Encoder)\n\n```c\n#include \"driver\u002Fgpio.h\"\n\n#define ROTARY_A_PIN    GPIO_NUM_3\n#define ROTARY_B_PIN    GPIO_NUM_46\n#define ROTARY_BTN_PIN  GPIO_NUM_0\n\nstatic volatile int32_t encoder_count = 0;\nstatic SemaphoreHandle_t encoder_mutex;\n\nvoid IRAM_ATTR rotary_isr_handler(void *arg) {\n    static uint8_t last_state = 0;\n    static int64_t last_interrupt_time = 0;\n\n    \u002F\u002F Debounce: 1ms\n    int64_t now = esp_timer_get_time();\n    if ((now - last_interrupt_time) \u003C 1000) {\n        return;\n    }\n    last_interrupt_time = now;\n\n    uint8_t a = gpio_get_level(ROTARY_A_PIN);\n    uint8_t b = gpio_get_level(ROTARY_B_PIN);\n    uint8_t state = (a \u003C\u003C 1) | b;\n\n    \u002F\u002F Quadrature decoding\n    int8_t dir = 0;\n    if (last_state == 0b00 && state == 0b01) dir = 1;\n    else if (last_state == 0b01 && state == 0b11) dir = 1;\n    else if (last_state == 0b11 && state == 0b10) dir = 1;\n    else if (last_state == 0b10 && state == 0b00) dir = 1;\n    else if (last_state == 0b00 && state == 0b10) dir = -1;\n    else if (last_state == 0b10 && state == 0b11) dir = -1;\n    else if (last_state == 0b11 && state == 0b01) dir = -1;\n    else if (last_state == 0b01 && state == 0b00) dir = -1;\n\n    encoder_count += dir;\n    last_state = state;\n}\n\nesp_err_t rotary_encoder_init(void) {\n    encoder_mutex = xSemaphoreCreateMutex();\n\n    \u002F\u002F Configure GPIO\n    gpio_config_t io_conf = {\n        .pin_bit_mask = (1ULL \u003C\u003C ROTARY_A_PIN) | (1ULL \u003C\u003C ROTARY_B_PIN),\n        .mode = GPIO_MODE_INPUT,\n        .pull_up_en = GPIO_PULLUP_ENABLE,\n        .intr_type = GPIO_INTR_ANYEDGE,\n    };\n    gpio_config(&io_conf);\n\n    \u002F\u002F Install ISR service\n    gpio_install_isr_service(0);\n    gpio_isr_handler_add(ROTARY_A_PIN, rotary_isr_handler, NULL);\n    gpio_isr_handler_add(ROTARY_B_PIN, rotary_isr_handler, NULL);\n\n    return ESP_OK;\n}\n\nint32_t rotary_encoder_get_count(void) {\n    int32_t count;\n    xSemaphoreTake(encoder_mutex, portMAX_DELAY);\n    count = encoder_count;\n    xSemaphoreGive(encoder_mutex);\n    return count;\n}\n```\n\n### WS2812B RGB LED Control (RMT)\n\n```c\n#include \"driver\u002Frmt_tx.h\"\n#include \"led_strip_encoder.h\"\n\n#define LED_GPIO        GPIO_NUM_4\n#define LED_COUNT       8\n#define LED_RMT_RES_HZ  (10 * 1000 * 1000)  \u002F\u002F 10 MHz\n\nstatic rmt_channel_handle_t led_chan = NULL;\nstatic rmt_encoder_handle_t led_encoder = NULL;\n\ntypedef struct {\n    uint8_t g;\n    uint8_t r;\n    uint8_t b;\n} rgb_t;\n\nesp_err_t ws2812_init(void) {\n    \u002F\u002F RMT TX channel config\n    rmt_tx_channel_config_t tx_chan_config = {\n        .clk_src = RMT_CLK_SRC_DEFAULT,\n        .gpio_num = LED_GPIO,\n        .mem_block_symbols = 64,\n        .resolution_hz = LED_RMT_RES_HZ,\n        .trans_queue_depth = 4,\n    };\n    ESP_ERROR_CHECK(rmt_new_tx_channel(&tx_chan_config, &led_chan));\n\n    \u002F\u002F LED strip encoder\n    led_strip_encoder_config_t encoder_config = {\n        .resolution = LED_RMT_RES_HZ,\n    };\n    ESP_ERROR_CHECK(rmt_new_led_strip_encoder(&encoder_config, &led_encoder));\n\n    ESP_ERROR_CHECK(rmt_enable(led_chan));\n\n    return ESP_OK;\n}\n\nvoid ws2812_set_colors(const rgb_t *colors, size_t count) {\n    rmt_transmit_config_t tx_config = {\n        .loop_count = 0,\n    };\n\n    ESP_ERROR_CHECK(rmt_transmit(led_chan, led_encoder, colors,\n                                 count * sizeof(rgb_t), &tx_config));\n}\n\n\u002F\u002F Example: Smooth color transition\nvoid led_breathe_effect(void) {\n    rgb_t leds[LED_COUNT];\n\n    for (int brightness = 0; brightness \u003C 255; brightness += 5) {\n        for (int i = 0; i \u003C LED_COUNT; i++) {\n            leds[i].r = brightness;\n            leds[i].g = 0;\n            leds[i].b = brightness \u002F 2;\n        }\n        ws2812_set_colors(leds, LED_COUNT);\n        vTaskDelay(pdMS_TO_TICKS(20));\n    }\n}\n```\n\n## Power Management\n\n### Deep Sleep with Wake Sources\n\n```c\n#include \"esp_sleep.h\"\n#include \"driver\u002Frtc_io.h\"\n\n\u002F\u002F Configure deep sleep with multiple wake sources\nvoid enter_deep_sleep(uint32_t sleep_seconds) {\n    ESP_LOGI(\"POWER\", \"Entering deep sleep for %lu seconds\", sleep_seconds);\n\n    \u002F\u002F Timer wake\n    esp_sleep_enable_timer_wakeup(sleep_seconds * 1000000ULL);\n\n    \u002F\u002F GPIO wake (button press on GPIO0)\n    esp_sleep_enable_ext0_wakeup(GPIO_NUM_0, 0);  \u002F\u002F Wake on LOW\n\n    \u002F\u002F GPIO wake (any of multiple pins)\n    const uint64_t ext1_mask = (1ULL \u003C\u003C GPIO_NUM_1) | (1ULL \u003C\u003C GPIO_NUM_2);\n    esp_sleep_enable_ext1_wakeup(ext1_mask, ESP_EXT1_WAKEUP_ANY_HIGH);\n\n    \u002F\u002F Disable WiFi\u002FBT before sleep\n    esp_wifi_stop();\n    esp_bluedroid_disable();\n    esp_bt_controller_disable();\n\n    \u002F\u002F Enter deep sleep\n    esp_deep_sleep_start();\n}\n\n\u002F\u002F Check wake cause on boot\nvoid check_wake_cause(void) {\n    esp_sleep_wakeup_cause_t cause = esp_sleep_get_wakeup_cause();\n\n    switch (cause) {\n        case ESP_SLEEP_WAKEUP_TIMER:\n            ESP_LOGI(\"POWER\", \"Woke from timer\");\n            break;\n        case ESP_SLEEP_WAKEUP_EXT0:\n            ESP_LOGI(\"POWER\", \"Woke from EXT0 (button)\");\n            break;\n        case ESP_SLEEP_WAKEUP_EXT1:\n            ESP_LOGI(\"POWER\", \"Woke from EXT1, pins: 0x%llx\",\n                    esp_sleep_get_ext1_wakeup_status());\n            break;\n        default:\n            ESP_LOGI(\"POWER\", \"Power-on reset\");\n            break;\n    }\n}\n```\n\n### Light Sleep for Power Saving\n\n```c\n\u002F\u002F Enter light sleep (wakes on GPIO or timer)\nvoid enter_light_sleep(uint32_t sleep_ms) {\n    esp_sleep_enable_timer_wakeup(sleep_ms * 1000);\n    esp_sleep_enable_gpio_wakeup();\n\n    ESP_LOGI(\"POWER\", \"Entering light sleep\");\n    esp_light_sleep_start();\n    ESP_LOGI(\"POWER\", \"Woke from light sleep\");\n}\n\n\u002F\u002F Automatic light sleep (modem sleep)\nvoid enable_auto_light_sleep(void) {\n    \u002F\u002F Automatically enter light sleep when idle\n    esp_pm_config_t pm_config = {\n        .max_freq_mhz = 240,\n        .min_freq_mhz = 80,\n        .light_sleep_enable = true,\n    };\n    ESP_ERROR_CHECK(esp_pm_configure(&pm_config));\n}\n```\n\n## Memory Optimization\n\n### Flash vs RAM Placement\n\n```c\n\u002F\u002F Store constant data in flash (saves RAM)\nstatic const uint8_t DRAM_ATTR lookup_table[256] = { \u002F* ... *\u002F };\n\n\u002F\u002F Keep frequently accessed data in RAM\nstatic DRAM_ATTR uint8_t frame_buffer[320 * 240 * 2];\n\n\u002F\u002F Place ISR code in IRAM for fast access\nvoid IRAM_ATTR gpio_fast_isr(void *arg) {\n    \u002F\u002F Time-critical interrupt code\n}\n\n\u002F\u002F Place large read-only data in flash\nstatic const char TAG[] = \"MAIN\";  \u002F\u002F Automatically in flash\n\n\u002F\u002F Explicitly place string in flash\nESP_LOGI(TAG, \"This string is in flash\");\n```\n\n### Memory Monitoring\n\n```c\nvoid print_memory_info(void) {\n    ESP_LOGI(\"MEM\", \"Free heap: %lu bytes\", esp_get_free_heap_size());\n    ESP_LOGI(\"MEM\", \"Minimum free heap: %lu bytes\", esp_get_minimum_free_heap_size());\n    ESP_LOGI(\"MEM\", \"Largest free block: %lu bytes\", heap_caps_get_largest_free_block(MALLOC_CAP_8BIT));\n\n    \u002F\u002F PSRAM info (ESP32-S3 can have external PSRAM)\n    ESP_LOGI(\"MEM\", \"Free PSRAM: %lu bytes\", heap_caps_get_free_size(MALLOC_CAP_SPIRAM));\n}\n\n\u002F\u002F Allocate from PSRAM if available\nvoid *buffer = heap_caps_malloc(1024 * 1024, MALLOC_CAP_SPIRAM);\nif (buffer == NULL) {\n    ESP_LOGE(\"MEM\", \"Failed to allocate PSRAM\");\n}\n```\n\n### Custom Partition Tables\n\n```csv\n# partitions.csv - Optimize flash layout\n# Name,   Type, SubType, Offset,  Size,     Flags\nnvs,      data, nvs,     0x9000,  0x4000,\notadata,  data, ota,     0xd000,  0x2000,\nphy_init, data, phy,     0xf000,  0x1000,\nfactory,  app,  factory, 0x10000, 1M,\nota_0,    app,  ota_0,   ,        1M,\nota_1,    app,  ota_1,   ,        1M,\nstorage,  data, spiffs,  ,        1M,\n```\n\n## OTA Firmware Updates\n\n### HTTPS OTA Update\n\n```c\n#include \"esp_https_ota.h\"\n#include \"esp_ota_ops.h\"\n\n#define FIRMWARE_URL \"https:\u002F\u002Fexample.com\u002Ffirmware.bin\"\n\nesp_err_t perform_ota_update(void) {\n    ESP_LOGI(\"OTA\", \"Starting OTA update\");\n\n    esp_http_client_config_t config = {\n        .url = FIRMWARE_URL,\n        .cert_pem = NULL,  \u002F\u002F Use server_cert_pem for production\n        .timeout_ms = 5000,\n        .keep_alive_enable = true,\n    };\n\n    esp_https_ota_config_t ota_config = {\n        .http_config = &config,\n    };\n\n    esp_https_ota_handle_t https_ota_handle = NULL;\n    esp_err_t err = esp_https_ota_begin(&ota_config, &https_ota_handle);\n    if (err != ESP_OK) {\n        ESP_LOGE(\"OTA\", \"OTA begin failed\");\n        return err;\n    }\n\n    \u002F\u002F Get image info\n    esp_app_desc_t new_app_info;\n    err = esp_https_ota_get_img_desc(https_ota_handle, &new_app_info);\n    if (err != ESP_OK) {\n        ESP_LOGE(\"OTA\", \"Failed to get image descriptor\");\n        esp_https_ota_abort(https_ota_handle);\n        return err;\n    }\n\n    ESP_LOGI(\"OTA\", \"New firmware version: %s\", new_app_info.version);\n\n    \u002F\u002F Download and write firmware\n    while (1) {\n        err = esp_https_ota_perform(https_ota_handle);\n        if (err != ESP_ERR_HTTPS_OTA_IN_PROGRESS) {\n            break;\n        }\n\n        \u002F\u002F Progress reporting\n        int progress = esp_https_ota_get_image_len_read(https_ota_handle);\n        ESP_LOGI(\"OTA\", \"Downloaded: %d bytes\", progress);\n    }\n\n    if (err != ESP_OK) {\n        ESP_LOGE(\"OTA\", \"OTA failed: %s\", esp_err_to_name(err));\n        esp_https_ota_abort(https_ota_handle);\n        return err;\n    }\n\n    \u002F\u002F Finalize OTA\n    err = esp_https_ota_finish(https_ota_handle);\n    if (err == ESP_OK) {\n        ESP_LOGI(\"OTA\", \"OTA successful, restarting...\");\n        vTaskDelay(pdMS_TO_TICKS(1000));\n        esp_restart();\n    } else {\n        ESP_LOGE(\"OTA\", \"OTA finish failed\");\n    }\n\n    return err;\n}\n```\n\n## Debugging & Logging\n\n### Log Levels and Tags\n\n```c\n#include \"esp_log.h\"\n\nstatic const char *TAG = \"MAIN\";\n\nvoid logging_examples(void) {\n    \u002F\u002F Set log level for specific tag\n    esp_log_level_set(\"WIFI\", ESP_LOG_WARN);\n    esp_log_level_set(\"MQTT\", ESP_LOG_INFO);\n\n    \u002F\u002F Different log levels\n    ESP_LOGE(TAG, \"Error: %d\", error_code);         \u002F\u002F Red\n    ESP_LOGW(TAG, \"Warning: %s\", warning_msg);      \u002F\u002F Yellow\n    ESP_LOGI(TAG, \"Info: operation complete\");      \u002F\u002F Green\n    ESP_LOGD(TAG, \"Debug: value=%d\", debug_val);    \u002F\u002F Normal (only if DEBUG)\n    ESP_LOGV(TAG, \"Verbose: detailed trace\");       \u002F\u002F Normal (only if VERBOSE)\n\n    \u002F\u002F Conditional compilation (saves flash space)\n    #if CONFIG_LOG_MAXIMUM_LEVEL >= ESP_LOG_DEBUG\n    ESP_LOGD(TAG, \"This is only compiled in debug builds\");\n    #endif\n}\n```\n\n### Watchdog Timer Configuration\n\n```c\n#include \"esp_task_wdt.h\"\n\n#define WDT_TIMEOUT_S  5\n\nvoid watchdog_init(void) {\n    \u002F\u002F Configure task watchdog\n    esp_task_wdt_config_t wdt_config = {\n        .timeout_ms = WDT_TIMEOUT_S * 1000,\n        .idle_core_mask = (1 \u003C\u003C 0) | (1 \u003C\u003C 1),  \u002F\u002F Monitor both cores\n        .trigger_panic = true,\n    };\n    ESP_ERROR_CHECK(esp_task_wdt_init(&wdt_config));\n\n    \u002F\u002F Subscribe current task\n    ESP_ERROR_CHECK(esp_task_wdt_add(NULL));\n}\n\nvoid long_running_task(void *pvParameters) {\n    watchdog_init();\n\n    while (1) {\n        do_work();\n\n        \u002F\u002F Reset watchdog\n        esp_task_wdt_reset();\n\n        vTaskDelay(pdMS_TO_TICKS(1000));\n    }\n}\n```\n\n### Stack Overflow Detection\n\n```c\n\u002F\u002F In sdkconfig or menuconfig:\n\u002F\u002F CONFIG_FREERTOS_WATCHPOINT_END_OF_STACK=y\n\u002F\u002F CONFIG_FREERTOS_CHECK_STACKOVERFLOW_CANARY=y\n\nvoid app_main(void) {\n    \u002F\u002F Monitor stack usage\n    UBaseType_t stack_high_water = uxTaskGetStackHighWaterMark(NULL);\n    ESP_LOGI(\"STACK\", \"Free stack: %lu bytes\", stack_high_water * sizeof(StackType_t));\n}\n```\n\n## T-Embed Specific Patterns\n\nSee `references\u002Ft_embed_hardware.md` for complete T-Embed ESP32-S3 hardware specifications, pinout, and initialization examples.\n\n## Resources\n\nThis skill includes reference documentation and example code:\n\n### references\u002F\n\n- `freertos_patterns.md` - Advanced FreeRTOS patterns and best practices\n- `wifi_ble_advanced.md` - Advanced WiFi\u002FBLE configuration and troubleshooting\n- `t_embed_hardware.md` - Complete T-Embed hardware reference\n- `power_optimization.md` - Detailed power consumption optimization strategies\n\n### scripts\u002F\n\n- `create_component.sh` - Generate new ESP-IDF component boilerplate\n- `partition_calculator.py` - Calculate optimal partition layout\n\n### assets\u002F\n\n- `component_template\u002F` - ESP-IDF component template structure\n- `platformio_template\u002F` - PlatformIO project template for ESP32-S3\n\n## Development Environment Setup\n\n```bash\n# Install ESP-IDF (recommended: v5.3.x or v5.1.x LTS)\ngit clone -b v5.3 --recursive https:\u002F\u002Fgithub.com\u002Fespressif\u002Fesp-idf.git\ncd esp-idf\n.\u002Finstall.sh esp32,esp32s3\n\n# Activate IDF environment\n. .\u002Fexport.sh\n\n# Or use PlatformIO\npip install platformio\npio platform install espressif32@6.5.0\n```\n\n## Common Troubleshooting\n\n**Task watchdog timeout**: Increase task priority or add `esp_task_wdt_reset()` calls\n\n**Stack overflow**: Increase task stack size or optimize local variable usage\n\n**WiFi disconnects**: Implement reconnection logic in event handler, check power supply\n\n**BLE pairing fails**: Verify security settings, check MTU size\n\n**MQTT messages dropped**: Increase queue sizes, check network stability, use QoS 1\n\n**Display flicker**: Use double buffering, ensure adequate SPI clock speed\n\n**Deep sleep current high**: Disable all peripherals, check GPIO pull configurations\n\nRefer to `references\u002F` files for detailed troubleshooting and optimization guides.\n",{"name":5,"description":7},"main","7850740bd837adb32f0a109ab2af82482196c6f2","skills\u002F_collections\u002Frghamilton3-dotfiles\u002Fdot_claude\u002Fskills\u002Fesp32-embedded-dev",1,"https:\u002F\u002Fgithub.com\u002Fshengdabai\u002FTony-Claude-Code-Skills","https:\u002F\u002Fzturnsgo.com","https:\u002F\u002Fgithub.com\u002Fshengdabai","https:\u002F\u002Fzturnsgo.com\u002F","AI × education creator — producer, not consumer. Taught 6,000+ learners; shipping learning tools & daily essays with Claude Code, practicing @xiaolai's way 🥋","2026-11-01 21:28:23",{"source":8,"skillName":5,"commands":55,"prompt":65,"zipAvailable":66},[56,59,62],{"tool":57,"command":58},"npx","npx skills add shengdabai\u002FTony-Claude-Code-Skills --skill esp32-embedded-dev",{"tool":60,"command":61},"bunx","bunx skills add shengdabai\u002FTony-Claude-Code-Skills --skill esp32-embedded-dev",{"tool":63,"command":64},"pnpm","pnpm dlx skills add shengdabai\u002FTony-Claude-Code-Skills --skill esp32-embedded-dev","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fshengdabai\u002FTony-Claude-Code-Skills\u002Fblob\u002Fmain\u002Fskills\u002F_collections\u002Frghamilton3-dotfiles\u002Fdot_claude\u002Fskills\u002Fesp32-embedded-dev\u002FSKILL.md",true,[68,74,78,81,84,88,91,97,101,105,109,115],{"path":69,"resourceType":70,"resourceTypeDesc":71,"sizeBytes":72,"sourceHtmlUrl":73},"assets\u002Fcomponent_template\u002FCMakeLists.txt","ASSET","资产文件",100,"https:\u002F\u002Fgithub.com\u002Fshengdabai\u002FTony-Claude-Code-Skills\u002Fblob\u002Fmain\u002Fskills\u002F_collections\u002Frghamilton3-dotfiles\u002Fdot_claude\u002Fskills\u002Fesp32-embedded-dev\u002Fassets\u002Fcomponent_template\u002FCMakeLists.txt",{"path":75,"resourceType":70,"resourceTypeDesc":71,"sizeBytes":76,"sourceHtmlUrl":77},"assets\u002Fcomponent_template\u002Finclude\u002F.keep",0,"https:\u002F\u002Fgithub.com\u002Fshengdabai\u002FTony-Claude-Code-Skills\u002Fblob\u002Fmain\u002Fskills\u002F_collections\u002Frghamilton3-dotfiles\u002Fdot_claude\u002Fskills\u002Fesp32-embedded-dev\u002Fassets\u002Fcomponent_template\u002Finclude\u002F.keep",{"path":79,"resourceType":70,"resourceTypeDesc":71,"sizeBytes":76,"sourceHtmlUrl":80},"assets\u002Fcomponent_template\u002Fsrc\u002F.keep","https:\u002F\u002Fgithub.com\u002Fshengdabai\u002FTony-Claude-Code-Skills\u002Fblob\u002Fmain\u002Fskills\u002F_collections\u002Frghamilton3-dotfiles\u002Fdot_claude\u002Fskills\u002Fesp32-embedded-dev\u002Fassets\u002Fcomponent_template\u002Fsrc\u002F.keep",{"path":82,"resourceType":70,"resourceTypeDesc":71,"sizeBytes":76,"sourceHtmlUrl":83},"assets\u002Fplatformio_template\u002Finclude\u002F.keep","https:\u002F\u002Fgithub.com\u002Fshengdabai\u002FTony-Claude-Code-Skills\u002Fblob\u002Fmain\u002Fskills\u002F_collections\u002Frghamilton3-dotfiles\u002Fdot_claude\u002Fskills\u002Fesp32-embedded-dev\u002Fassets\u002Fplatformio_template\u002Finclude\u002F.keep",{"path":85,"resourceType":70,"resourceTypeDesc":71,"sizeBytes":86,"sourceHtmlUrl":87},"assets\u002Fplatformio_template\u002Fplatformio.ini",415,"https:\u002F\u002Fgithub.com\u002Fshengdabai\u002FTony-Claude-Code-Skills\u002Fblob\u002Fmain\u002Fskills\u002F_collections\u002Frghamilton3-dotfiles\u002Fdot_claude\u002Fskills\u002Fesp32-embedded-dev\u002Fassets\u002Fplatformio_template\u002Fplatformio.ini",{"path":89,"resourceType":70,"resourceTypeDesc":71,"sizeBytes":76,"sourceHtmlUrl":90},"assets\u002Fplatformio_template\u002Fsrc\u002F.keep","https:\u002F\u002Fgithub.com\u002Fshengdabai\u002FTony-Claude-Code-Skills\u002Fblob\u002Fmain\u002Fskills\u002F_collections\u002Frghamilton3-dotfiles\u002Fdot_claude\u002Fskills\u002Fesp32-embedded-dev\u002Fassets\u002Fplatformio_template\u002Fsrc\u002F.keep",{"path":92,"resourceType":93,"resourceTypeDesc":94,"sizeBytes":95,"sourceHtmlUrl":96},"references\u002Ffreertos_patterns.md","REFERENCE","参考文档",14965,"https:\u002F\u002Fgithub.com\u002Fshengdabai\u002FTony-Claude-Code-Skills\u002Fblob\u002Fmain\u002Fskills\u002F_collections\u002Frghamilton3-dotfiles\u002Fdot_claude\u002Fskills\u002Fesp32-embedded-dev\u002Freferences\u002Ffreertos_patterns.md",{"path":98,"resourceType":93,"resourceTypeDesc":94,"sizeBytes":99,"sourceHtmlUrl":100},"references\u002Fpower_optimization.md",13064,"https:\u002F\u002Fgithub.com\u002Fshengdabai\u002FTony-Claude-Code-Skills\u002Fblob\u002Fmain\u002Fskills\u002F_collections\u002Frghamilton3-dotfiles\u002Fdot_claude\u002Fskills\u002Fesp32-embedded-dev\u002Freferences\u002Fpower_optimization.md",{"path":102,"resourceType":93,"resourceTypeDesc":94,"sizeBytes":103,"sourceHtmlUrl":104},"references\u002Ft_embed_hardware.md",11793,"https:\u002F\u002Fgithub.com\u002Fshengdabai\u002FTony-Claude-Code-Skills\u002Fblob\u002Fmain\u002Fskills\u002F_collections\u002Frghamilton3-dotfiles\u002Fdot_claude\u002Fskills\u002Fesp32-embedded-dev\u002Freferences\u002Ft_embed_hardware.md",{"path":106,"resourceType":93,"resourceTypeDesc":94,"sizeBytes":107,"sourceHtmlUrl":108},"references\u002Fwifi_ble_advanced.md",11976,"https:\u002F\u002Fgithub.com\u002Fshengdabai\u002FTony-Claude-Code-Skills\u002Fblob\u002Fmain\u002Fskills\u002F_collections\u002Frghamilton3-dotfiles\u002Fdot_claude\u002Fskills\u002Fesp32-embedded-dev\u002Freferences\u002Fwifi_ble_advanced.md",{"path":110,"resourceType":111,"resourceTypeDesc":112,"sizeBytes":113,"sourceHtmlUrl":114},"scripts\u002Fexecutable_literal_create_component.sh","SCRIPT","脚本",5852,"https:\u002F\u002Fgithub.com\u002Fshengdabai\u002FTony-Claude-Code-Skills\u002Fblob\u002Fmain\u002Fskills\u002F_collections\u002Frghamilton3-dotfiles\u002Fdot_claude\u002Fskills\u002Fesp32-embedded-dev\u002Fscripts\u002Fexecutable_literal_create_component.sh",{"path":116,"resourceType":111,"resourceTypeDesc":112,"sizeBytes":117,"sourceHtmlUrl":118},"scripts\u002Fexecutable_partition_calculator.py",7859,"https:\u002F\u002Fgithub.com\u002Fshengdabai\u002FTony-Claude-Code-Skills\u002Fblob\u002Fmain\u002Fskills\u002F_collections\u002Frghamilton3-dotfiles\u002Fdot_claude\u002Fskills\u002Fesp32-embedded-dev\u002Fscripts\u002Fexecutable_partition_calculator.py",[120,129,137,145,153,161],{"skillNo":121,"name":122,"nameZh":6,"description":123,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":124,"sourceHtmlUrl":125,"categories":126,"keywords":127,"publishedAt":128},"01M73H7XKBHE1ETQDZT94MF9HH","seedance-prompt-en","Write effective prompts for Jimeng Seedance 2.0 multimodal AI video generation. Use when users want to create video prompts using text, images, videos, and audio inputs with the @ reference system. Covers camera movements, effects replication, video extension, editing, music beat-matching, e-commerce ads, short dramas, and educational content.","https:\u002F\u002Fgithub.com\u002Fshengdabai\u002FTony-Claude-Code-Skills\u002Fblob\u002Fmain\u002Fskills\u002Fseedance-prompt-en\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fshengdabai\u002FTony-Claude-Code-Skills\u002Fblob\u002Fmain\u002Fskills\u002Fseedance-prompt-en\u002FSKILL.md",[],[],"2026-11-11 15:11:14",{"skillNo":130,"name":131,"nameZh":6,"description":132,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":133,"sourceHtmlUrl":134,"categories":135,"keywords":136,"publishedAt":128},"01M73GRE9998Q1DZWC71N41JWG","onepage-pdf","Convert an HTML page into a single continuous-page PDF (one tall page, no pagination breaks), preserving desktop layout, backgrounds and selectable text. Use when the user asks to turn an HTML file\u002Freport\u002Fproposal into a \"single-page PDF\", \"long PDF\", \"不分页 PDF\", \"单页 PDF\", \"长图式 PDF\", or complains that an HTML-to-PDF export breaks into pages or cuts content. Supports optional string redaction with leak verification.","https:\u002F\u002Fgithub.com\u002Fshengdabai\u002FTony-Claude-Code-Skills\u002Fblob\u002Fmain\u002Fskills\u002Fonepage-pdf\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fshengdabai\u002FTony-Claude-Code-Skills\u002Fblob\u002Fmain\u002Fskills\u002Fonepage-pdf\u002FSKILL.md",[],[],{"skillNo":138,"name":139,"nameZh":6,"description":140,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":141,"sourceHtmlUrl":142,"categories":143,"keywords":144,"publishedAt":128},"01M73GQG1KZDADVPV3MHAT1J5A","native-feel-cross-platform-desktop","Use when the user is designing, prototyping, or rewriting a desktop app that must run on multiple OSes (macOS + Windows, optionally Linux) AND feel indistinguishable from a native app to its users — fast launch, native windowing, native input handling, native materials. Trigger words include \"cross-platform desktop\", \"Electron alternative\", \"Tauri vs native\", \"WebView wrapper\", \"near-native performance\", \"Raycast architecture\", \"WebKit\u002FWebView2 quirks\", \"WKWebView\", \"system tray app\", \"global hotkey app\", \"launcher app\". Do NOT trigger this skill for pure web apps, pure mobile apps, or for greenfield projects that have no native-feel requirement.","https:\u002F\u002Fgithub.com\u002Fshengdabai\u002FTony-Claude-Code-Skills\u002Fblob\u002Fmain\u002Fskills\u002Fnative-feel-cross-platform-desktop\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fshengdabai\u002FTony-Claude-Code-Skills\u002Fblob\u002Fmain\u002Fskills\u002Fnative-feel-cross-platform-desktop\u002FSKILL.md",[],[],{"skillNo":146,"name":147,"nameZh":6,"description":148,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":149,"sourceHtmlUrl":150,"categories":151,"keywords":152,"publishedAt":128},"01M73G87PDNSMKG2FHWCYER6N8","gstack","Router for the gstack skill suite. (gstack)","https:\u002F\u002Fgithub.com\u002Fshengdabai\u002FTony-Claude-Code-Skills\u002Fblob\u002Fmain\u002Fskills\u002Fgstack\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fshengdabai\u002FTony-Claude-Code-Skills\u002Fblob\u002Fmain\u002Fskills\u002Fgstack\u002FSKILL.md",[],[],{"skillNo":154,"name":155,"nameZh":6,"description":156,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":157,"sourceHtmlUrl":158,"categories":159,"keywords":160,"publishedAt":128},"01M73G3EAQWKCM8DB8D0N0QSVG","fireworks-tech-graph","Use when the user wants to create any technical diagram - architecture, data flow, flowchart, sequence, agent\u002Fmemory, or concept map - and export as SVG+PNG. Trigger on: \"画图\" \"帮我画\" \"生成图\" \"做个图\" \"架构图\" \"流程图\" \"可视化一下\" \"出图\" \"generate diagram\" \"draw diagram\" \"visualize\" or any system\u002Fflow description the user wants illustrated.","https:\u002F\u002Fgithub.com\u002Fshengdabai\u002FTony-Claude-Code-Skills\u002Fblob\u002Fmain\u002Fskills\u002Ffireworks-tech-graph\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fshengdabai\u002FTony-Claude-Code-Skills\u002Fblob\u002Fmain\u002Fskills\u002Ffireworks-tech-graph\u002FSKILL.md",[],[],{"skillNo":162,"name":163,"nameZh":6,"description":164,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":165,"categories":166,"keywords":167,"publishedAt":128},"01M73G086AXAH9DW1H5G5N3CPB","dbs-video-extract","接收抖音、小红书、微信视频号等短视频链接或分享文案，查询作品／账号数据并提取语音文字稿，按作者和标题归档为 Markdown。用户希望完整解析短视频、取得数据或文字稿时使用；运行前检查 TikHub 与轻抖使用凭证，缺少时用新手能理解的方式引导购买和安全配置。","https:\u002F\u002Fgithub.com\u002Fshengdabai\u002FTony-Claude-Code-Skills\u002Fblob\u002Fmain\u002Fskills\u002Fdbs-video-extract\u002FSKILL.md",[],[]]