[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M70FSQD7J21SB6VEGXPX90GM":3,"skill-same:01M70FSQD7J21SB6VEGXPX90GM":105},{"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":23,"publishedAt":44,"linkOnly":45,"markdownContent":46,"markdownBody":47,"frontMatter":48,"refName":49,"commitSha":50,"skillDirectory":51,"forksCount":52,"repositoryHtmlUrl":53,"repositoryHomepageUrl":54,"ownerHtmlUrl":55,"ownerBlogUrl":56,"ownerDescription":57,"updatedAt":58,"install":59,"resources":72},"01M70FSQD7J21SB6VEGXPX90GM","rp2350-micropython",null,"Expert RP2350 development with MicroPython, covering Pimoroni Presto hardware, touchscreen interfaces, RGB lighting control, BLE server implementation, and display rendering. Use when developing for RP2350 boards, implementing touch UI, managing BLE communication, or working with RGB backlights.","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\u002Fdot_claude\u002Fskills\u002Frp2350-micropython\u002FSKILL.md",[18],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000023","Skill与智能体开发","SCENARIO","使用场景",[24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43],"rp2350 micropython","development","implementation","control","with","lighting","use","touch","touch ui","ble","for","presto","ui","rendering","communication","server","display","when","implementing","expert","2026-11-10 10:12:30",false,"---\nname: rp2350-micropython\ndescription: Expert RP2350 development with MicroPython, covering Pimoroni Presto hardware, touchscreen interfaces, RGB lighting control, BLE server implementation, and display rendering. Use when developing for RP2350 boards, implementing touch UI, managing BLE communication, or working with RGB backlights.\n---\n\n# RP2350\u002FPimoroni Presto MicroPython Development\n\n## Overview\n\nThis skill provides comprehensive guidance for developing embedded applications on RP2350-based hardware (particularly the Pimoroni Presto) using MicroPython. It covers hardware interfaces, async programming patterns, memory-efficient display rendering, BLE server implementation, MQTT communication, and ADHD-friendly UI design.\n\n## When to Use This Skill\n\nUse this skill when:\n\n- Developing for RP2350 or Pimoroni Presto boards\n- Implementing touchscreen interfaces with gesture detection\n- Creating BLE GATT servers for peripheral role\n- Building MQTT clients for IoT communication\n- Controlling RGB backlights with PWM and animations\n- Rendering graphics on memory-constrained displays\n- Implementing async\u002Fconcurrent task patterns\n- Designing ADHD-friendly visual interfaces\n- Managing WiFi connectivity with auto-reconnect\n- Optimizing memory usage for framebuffer operations\n\n## Hardware Context\n\nThe Pimoroni Presto is an RP2350-based development board featuring:\n\n- **Processor**: Dual ARM Cortex-M33 @ 150MHz with 520KB RAM\n- **Display**: 480×480 IPS touchscreen (typically ST7789 controller)\n- **Touch**: Capacitive touch (CST816S or FT6236)\n- **RGB Backlight**: PWM-controlled 3-channel LED\n- **Connectivity**: BLE built-in, WiFi via external module (board-dependent)\n- **Memory**: 4MB flash, 520KB SRAM (limited for full framebuffers)\n\n## Core Capabilities\n\n### 1. Touch Input Handling\n\nUse `scripts\u002Ftouch_handler.py` for debounced touch polling and gesture detection.\n\n**Key Classes:**\n- `TouchHandler`: Debounced touch polling with TOUCH_DOWN, TOUCH_UP, TOUCH_DRAG events\n- `TouchEvent`: Event objects with coordinates and timestamps\n- `GestureDetector`: Swipe and tap gesture recognition\n\n**Usage:**\n```python\nfrom touch_handler import TouchHandler, GestureDetector\n\ntouch = TouchHandler(touch_device, debounce_ms=50)\ngesture = GestureDetector(min_swipe_distance=50)\n\nwhile True:\n    event = touch.poll()\n    if event:\n        if event.type == TouchHandler.TOUCH_DOWN:\n            gesture.start(event.x, event.y)\n        elif event.type == TouchHandler.TOUCH_UP:\n            detected = gesture.end(event.x, event.y)\n            if detected == GestureDetector.SWIPE_LEFT:\n                handle_swipe_left()\n```\n\n### 2. BLE GATT Server\n\nUse `scripts\u002Fble_gatt_server.py` for peripheral role with custom services.\n\n**Key Classes:**\n- `BLETimerServer`: Complete BLE server with timer and battery services\n- Pre-defined UUIDs for timer state, control, and battery level\n- Connection management and automatic re-advertising\n\n**Usage:**\n```python\nfrom ble_gatt_server import BLETimerServer, TIMER_CMD_START, TIMER_CMD_PAUSE\n\nble = BLETimerServer(\"Presto-Timer\")\nble.start_advertising()\n\nwhile True:\n    # Update clients with current state\n    ble.update_timer_state(remaining_seconds=300, is_running=True)\n\n    # Check for commands from clients\n    command = ble.get_command()\n    if command == TIMER_CMD_START:\n        start_timer()\n    elif command == TIMER_CMD_PAUSE:\n        pause_timer()\n```\n\n### 3. MQTT Communication\n\nUse `scripts\u002Fmqtt_client.py` for reliable MQTT with auto-reconnect.\n\n**Key Classes:**\n- `ReliableMQTTClient`: MQTT client with auto-reconnect and offline queuing\n- `WiFiManager`: WiFi connection manager with signal strength monitoring\n\n**Usage:**\n```python\nfrom mqtt_client import ReliableMQTTClient, WiFiManager\n\ndef message_callback(topic, msg):\n    print(f\"Received: {topic} -> {msg}\")\n\n# Connect WiFi\nwifi = WiFiManager(\"SSID\", \"password\", hostname=\"presto-001\")\nwifi.connect()\n\n# Setup MQTT\nmqtt = ReliableMQTTClient(\n    client_id=\"presto-001\",\n    broker=\"192.168.1.100\",\n    callback=message_callback\n)\n\nmqtt.connect()\nmqtt.subscribe(\"productivity\u002Ftimer\u002Fcontrol\u002F#\")\n\nwhile True:\n    mqtt.publish(\"productivity\u002Fstatus\", \"online\")\n    mqtt.check_msg()  # Non-blocking message check\n    time.sleep(1)\n```\n\n### 4. RGB Backlight Control\n\nUse `scripts\u002Frgb_backlight.py` for PWM-based color control with animations.\n\n**Key Classes:**\n- `RGBBacklight`: PWM-based RGB control with color transitions\n- `PresetColors`: ADHD-friendly color constants\n- Methods for fading, pulsing, rainbow cycling, and urgency gradients\n\n**Usage:**\n```python\nfrom rgb_backlight import RGBBacklight, PresetColors\n\nrgb = RGBBacklight(red_pin=16, green_pin=17, blue_pin=18)\n\n# Instant color change\nrgb.set_color(255, 0, 0)  # Red\n\n# Smooth fade\nrgb.fade_to(0, 255, 0, duration_ms=1000)  # Fade to green\n\n# Pulse effect\nrgb.pulse(PresetColors.FOCUS_BLUE, period_ms=2000, iterations=5)\n\n# Urgency gradient (timer countdown)\nr, g, b = rgb.urgency_gradient(remaining_seconds=300, total_seconds=1500)\nrgb.fade_to(r, g, b, duration_ms=500)\n```\n\n## Development Workflow\n\n### Step 1: Hardware Initialization\n\nRefer to `references\u002Fpresto_hardware.md` for complete pin configurations and initialization sequences.\n\n**Critical Considerations:**\n- Verify GPIO pin assignments for your specific board (check schematic)\n- SPI clock speed: Use maximum 62.5MHz for ST7789 displays\n- I2C frequency: 400kHz for touch controllers\n- PWM frequency: 1000Hz typical for RGB backlight\n\n**Example Initialization:**\n```python\nfrom machine import Pin, SPI, I2C, PWM\n\n# Display SPI\nspi = SPI(1, baudrate=62_500_000, polarity=0, phase=0,\n          sck=Pin(10), mosi=Pin(11))\ndc = Pin(8, Pin.OUT)\ncs = Pin(9, Pin.OUT)\nrst = Pin(12, Pin.OUT)\n\n# Touch I2C\ni2c = I2C(1, scl=Pin(15), sda=Pin(14), freq=400000)\n\n# RGB Backlight PWM\nrgb_r = PWM(Pin(16))\nrgb_g = PWM(Pin(17))\nrgb_b = PWM(Pin(18))\n\nrgb_r.freq(1000)\nrgb_g.freq(1000)\nrgb_b.freq(1000)\n```\n\n### Step 2: Implement Async Architecture\n\nFor responsive applications with multiple concurrent tasks, use asyncio patterns from `references\u002Fmicropython_async.md`.\n\n**Typical Task Structure:**\n- **UI Task**: Poll touch input every 10ms, handle gestures\n- **Timer Task**: Countdown logic every 1 second\n- **BLE Sync Task**: Update BLE clients every 500ms\n- **MQTT Task**: Check messages every 100ms, reconnect if needed\n- **Display Task**: Update display every 100ms (10 FPS)\n- **Backlight Task**: Update RGB based on state every 5 seconds\n\n**Example Async Application:**\n```python\nimport asyncio\nfrom touch_handler import TouchHandler\nfrom ble_gatt_server import BLETimerServer\nfrom mqtt_client import ReliableMQTTClient, WiFiManager\nfrom rgb_backlight import RGBBacklight\n\nasync def touch_task(touch, state):\n    while True:\n        event = touch.poll()\n        if event and event.type == TouchHandler.TOUCH_DOWN:\n            state.toggle()\n        await asyncio.sleep_ms(10)\n\nasync def ble_task(ble, state):\n    while True:\n        ble.update_timer_state(state.remaining, state.running)\n        command = ble.get_command()\n        if command is not None:\n            state.handle_command(command)\n        await asyncio.sleep_ms(500)\n\nasync def backlight_task(rgb, state):\n    while True:\n        if state.running:\n            r, g, b = rgb.urgency_gradient(state.remaining, state.total)\n            rgb.fade_to(r, g, b, duration_ms=500)\n        await asyncio.sleep(5)\n\nasync def main():\n    # Initialize hardware\n    touch = TouchHandler(touch_device)\n    ble = BLETimerServer(\"Presto\")\n    rgb = RGBBacklight(16, 17, 18)\n    state = AppState()\n\n    ble.start_advertising()\n\n    # Run all tasks concurrently\n    await asyncio.gather(\n        touch_task(touch, state),\n        ble_task(ble, state),\n        backlight_task(rgb, state)\n    )\n\nasyncio.run(main())\n```\n\n### Step 3: Optimize Display Rendering\n\n**Critical Memory Constraint:**\nA full 480×480 RGB565 framebuffer requires ~460KB, nearly exhausting available RAM.\n\n**Solutions (choose based on UI complexity):**\n\n**Option 1: Tile-Based Rendering** (for complex full-screen graphics)\n- Render display in 60×60 tiles (~7KB per tile)\n- Update one tile at a time\n- See `TiledDisplay` class in `references\u002Fdisplay_rendering.md`\n\n**Option 2: Partial Updates** (for simple UIs with distinct regions)\n- Create small buffers for specific UI elements\n- Timer display: 100×100 buffer\n- Status bar: 200×30 buffer\n- Only update changed regions\n- See `PartialUpdateDisplay` in `references\u002Fdisplay_rendering.md`\n\n**Option 3: Reduced Color Depth** (for minimal graphics)\n- Use 1-bit monochrome for simple timer displays\n- Use 8-bit grayscale (10× less memory than RGB565)\n\nRefer to `references\u002Fdisplay_rendering.md` for complete implementation details, drawing primitives, and animation techniques.\n\n### Step 4: Implement ADHD-Friendly UI\n\nFollow these principles when designing the interface:\n\n**Visual Hierarchy:**\n- Large, simple elements (big touch targets)\n- High contrast colors (white on black, vivid colors)\n- Minimal clutter (one primary action per screen)\n\n**Color Coding:**\n- **Idle**: Gray `(64, 64, 64)` - low intensity\n- **Focus**: Blue `(30, 144, 255)` - calm, engaging\n- **Break**: Green `(50, 205, 50)` - restful\n- **Urgent**: Red `(220, 20, 60)` - attention-grabbing\n- **Paused**: Amber `(255, 191, 0)` - intermediate state\n\nUse the `PresetColors` class from `rgb_backlight.py` for consistency.\n\n**Progressive Disclosure:**\n- Default view: Large timer digits, minimal information\n- Tap to expand: Show progress bar, stats, controls\n- Gestures for quick actions: Swipe to pause, double-tap to reset\n\n**Smooth Transitions:**\n- Always fade between colors (300-500ms duration)\n- Use easing functions for animations\n- Avoid jarring changes that break hyperfocus\n\n## Common Patterns\n\n### Pattern: Timer Countdown with Visual Feedback\n\nCombine timer logic, BLE sync, and RGB backlight:\n\n```python\nclass TimerState:\n    def __init__(self, duration_seconds):\n        self.total = duration_seconds\n        self.remaining = duration_seconds\n        self.running = False\n\nasync def timer_countdown(state):\n    while True:\n        if state.running and state.remaining > 0:\n            state.remaining -= 1\n        await asyncio.sleep(1)\n\nasync def visual_feedback(state, rgb):\n    while True:\n        if state.running:\n            r, g, b = rgb.urgency_gradient(state.remaining, state.total)\n            rgb.fade_to(r, g, b, duration_ms=500)\n        await asyncio.sleep(5)\n\nasync def ble_sync(state, ble):\n    while True:\n        ble.update_timer_state(state.remaining, state.running)\n        await asyncio.sleep_ms(500)\n```\n\n### Pattern: Touch-Based Timer Control\n\nStart\u002Fpause timer with tap, reset with long press:\n\n```python\nasync def touch_control(touch, gesture, state):\n    touch_start_time = 0\n\n    while True:\n        event = touch.poll()\n\n        if event:\n            if event.type == TouchHandler.TOUCH_DOWN:\n                gesture.start(event.x, event.y)\n                touch_start_time = time.ticks_ms()\n\n            elif event.type == TouchHandler.TOUCH_UP:\n                duration = time.ticks_diff(time.ticks_ms(), touch_start_time)\n\n                if duration > 1000:\n                    # Long press: reset timer\n                    state.remaining = state.total\n                    state.running = False\n                else:\n                    # Tap: toggle running\n                    detected = gesture.end(event.x, event.y)\n                    if detected == GestureDetector.TAP:\n                        state.running = not state.running\n\n        await asyncio.sleep_ms(10)\n```\n\n### Pattern: MQTT Command Handling\n\nSubscribe to control topics and update state:\n\n```python\ndef mqtt_callback(topic, msg):\n    \"\"\"Handle incoming MQTT messages.\"\"\"\n    global app_state\n\n    topic_str = topic.decode()\n    msg_str = msg.decode()\n\n    if topic_str == \"productivity\u002Ftimer\u002Fcontrol\u002Fstart\":\n        app_state.running = True\n    elif topic_str == \"productivity\u002Ftimer\u002Fcontrol\u002Fpause\":\n        app_state.running = False\n    elif topic_str == \"productivity\u002Ftimer\u002Fcontrol\u002Freset\":\n        app_state.remaining = app_state.total\n\nmqtt = ReliableMQTTClient(\n    client_id=\"presto-001\",\n    broker=\"192.168.1.100\",\n    callback=mqtt_callback\n)\n\nmqtt.subscribe(\"productivity\u002Ftimer\u002Fcontrol\u002F#\")\n```\n\n## Performance Optimization\n\n### Memory Management\n\n**Critical Rules:**\n1. Force garbage collection before allocating large buffers\n2. Delete large objects immediately after use\n3. Reuse buffers instead of creating new ones\n4. Monitor memory with `gc.mem_free()` during development\n\n**Example:**\n```python\nimport gc\n\n# Before allocating framebuffer\ngc.collect()\nprint(f\"Free before: {gc.mem_free()}\")\n\n# Use buffer\nbuffer = bytearray(100 * 100 * 2)\n# ... use buffer ...\ndel buffer\n\n# Clean up\ngc.collect()\nprint(f\"Free after: {gc.mem_free()}\")\n```\n\n### Task Scheduling\n\nBalance responsiveness vs CPU usage with appropriate sleep times:\n\n- **Touch input**: 10ms (100 checks\u002Fsecond) - high responsiveness\n- **Display updates**: 100ms (10 FPS) - smooth enough for UI\n- **BLE sync**: 500ms - adequate for state updates\n- **MQTT check**: 100ms - responsive to commands\n- **Backlight updates**: 5000ms - slow changes prevent distraction\n\n## Troubleshooting\n\n### Touch Not Responding\n\n1. Verify I2C connection: `i2c.scan()` should show touch controller address\n2. Check touch controller I2C address (typically 0x15 for CST816S)\n3. Verify GPIO pins match schematic\n4. Add pull-up resistors to SDA\u002FSCL if needed (typically 4.7kΩ)\n\n### BLE Connection Drops\n\n1. Reduce BLE notification frequency (increase sleep time in sync task)\n2. Check for WiFi\u002FBLE interference (shared radio on some modules)\n3. Verify keepalive interval matches client expectations\n4. Monitor connection events in `_irq_handler`\n\n### Display Artifacts or Tearing\n\n1. Reduce SPI clock speed if using long cables\n2. Implement double buffering for small regions\n3. Use partial updates instead of full screen redraws\n4. Ensure display CS line is properly controlled\n\n### Memory Exhaustion\n\n1. Check `gc.mem_free()` at critical points\n2. Reduce framebuffer size (use tiles or partial updates)\n3. Call `gc.collect()` before large allocations\n4. Monitor for memory leaks (allocations without deletion)\n\n## Resources\n\nThis skill includes:\n\n### scripts\u002F\nExecutable Python modules for core functionality:\n- `touch_handler.py`: Touch input and gesture detection\n- `ble_gatt_server.py`: BLE GATT server implementation\n- `mqtt_client.py`: Reliable MQTT client with auto-reconnect\n- `rgb_backlight.py`: RGB LED control with animations\n\n### references\u002F\nDetailed documentation for hardware and software:\n- `presto_hardware.md`: Complete hardware reference, pinout, initialization\n- `micropython_async.md`: Asyncio patterns and concurrent task management\n- `display_rendering.md`: Memory-efficient rendering techniques and UI design\n\nAll scripts are production-ready and can be used directly or customized for specific applications.\n","# RP2350\u002FPimoroni Presto MicroPython Development\n\n## Overview\n\nThis skill provides comprehensive guidance for developing embedded applications on RP2350-based hardware (particularly the Pimoroni Presto) using MicroPython. It covers hardware interfaces, async programming patterns, memory-efficient display rendering, BLE server implementation, MQTT communication, and ADHD-friendly UI design.\n\n## When to Use This Skill\n\nUse this skill when:\n\n- Developing for RP2350 or Pimoroni Presto boards\n- Implementing touchscreen interfaces with gesture detection\n- Creating BLE GATT servers for peripheral role\n- Building MQTT clients for IoT communication\n- Controlling RGB backlights with PWM and animations\n- Rendering graphics on memory-constrained displays\n- Implementing async\u002Fconcurrent task patterns\n- Designing ADHD-friendly visual interfaces\n- Managing WiFi connectivity with auto-reconnect\n- Optimizing memory usage for framebuffer operations\n\n## Hardware Context\n\nThe Pimoroni Presto is an RP2350-based development board featuring:\n\n- **Processor**: Dual ARM Cortex-M33 @ 150MHz with 520KB RAM\n- **Display**: 480×480 IPS touchscreen (typically ST7789 controller)\n- **Touch**: Capacitive touch (CST816S or FT6236)\n- **RGB Backlight**: PWM-controlled 3-channel LED\n- **Connectivity**: BLE built-in, WiFi via external module (board-dependent)\n- **Memory**: 4MB flash, 520KB SRAM (limited for full framebuffers)\n\n## Core Capabilities\n\n### 1. Touch Input Handling\n\nUse `scripts\u002Ftouch_handler.py` for debounced touch polling and gesture detection.\n\n**Key Classes:**\n- `TouchHandler`: Debounced touch polling with TOUCH_DOWN, TOUCH_UP, TOUCH_DRAG events\n- `TouchEvent`: Event objects with coordinates and timestamps\n- `GestureDetector`: Swipe and tap gesture recognition\n\n**Usage:**\n```python\nfrom touch_handler import TouchHandler, GestureDetector\n\ntouch = TouchHandler(touch_device, debounce_ms=50)\ngesture = GestureDetector(min_swipe_distance=50)\n\nwhile True:\n    event = touch.poll()\n    if event:\n        if event.type == TouchHandler.TOUCH_DOWN:\n            gesture.start(event.x, event.y)\n        elif event.type == TouchHandler.TOUCH_UP:\n            detected = gesture.end(event.x, event.y)\n            if detected == GestureDetector.SWIPE_LEFT:\n                handle_swipe_left()\n```\n\n### 2. BLE GATT Server\n\nUse `scripts\u002Fble_gatt_server.py` for peripheral role with custom services.\n\n**Key Classes:**\n- `BLETimerServer`: Complete BLE server with timer and battery services\n- Pre-defined UUIDs for timer state, control, and battery level\n- Connection management and automatic re-advertising\n\n**Usage:**\n```python\nfrom ble_gatt_server import BLETimerServer, TIMER_CMD_START, TIMER_CMD_PAUSE\n\nble = BLETimerServer(\"Presto-Timer\")\nble.start_advertising()\n\nwhile True:\n    # Update clients with current state\n    ble.update_timer_state(remaining_seconds=300, is_running=True)\n\n    # Check for commands from clients\n    command = ble.get_command()\n    if command == TIMER_CMD_START:\n        start_timer()\n    elif command == TIMER_CMD_PAUSE:\n        pause_timer()\n```\n\n### 3. MQTT Communication\n\nUse `scripts\u002Fmqtt_client.py` for reliable MQTT with auto-reconnect.\n\n**Key Classes:**\n- `ReliableMQTTClient`: MQTT client with auto-reconnect and offline queuing\n- `WiFiManager`: WiFi connection manager with signal strength monitoring\n\n**Usage:**\n```python\nfrom mqtt_client import ReliableMQTTClient, WiFiManager\n\ndef message_callback(topic, msg):\n    print(f\"Received: {topic} -> {msg}\")\n\n# Connect WiFi\nwifi = WiFiManager(\"SSID\", \"password\", hostname=\"presto-001\")\nwifi.connect()\n\n# Setup MQTT\nmqtt = ReliableMQTTClient(\n    client_id=\"presto-001\",\n    broker=\"192.168.1.100\",\n    callback=message_callback\n)\n\nmqtt.connect()\nmqtt.subscribe(\"productivity\u002Ftimer\u002Fcontrol\u002F#\")\n\nwhile True:\n    mqtt.publish(\"productivity\u002Fstatus\", \"online\")\n    mqtt.check_msg()  # Non-blocking message check\n    time.sleep(1)\n```\n\n### 4. RGB Backlight Control\n\nUse `scripts\u002Frgb_backlight.py` for PWM-based color control with animations.\n\n**Key Classes:**\n- `RGBBacklight`: PWM-based RGB control with color transitions\n- `PresetColors`: ADHD-friendly color constants\n- Methods for fading, pulsing, rainbow cycling, and urgency gradients\n\n**Usage:**\n```python\nfrom rgb_backlight import RGBBacklight, PresetColors\n\nrgb = RGBBacklight(red_pin=16, green_pin=17, blue_pin=18)\n\n# Instant color change\nrgb.set_color(255, 0, 0)  # Red\n\n# Smooth fade\nrgb.fade_to(0, 255, 0, duration_ms=1000)  # Fade to green\n\n# Pulse effect\nrgb.pulse(PresetColors.FOCUS_BLUE, period_ms=2000, iterations=5)\n\n# Urgency gradient (timer countdown)\nr, g, b = rgb.urgency_gradient(remaining_seconds=300, total_seconds=1500)\nrgb.fade_to(r, g, b, duration_ms=500)\n```\n\n## Development Workflow\n\n### Step 1: Hardware Initialization\n\nRefer to `references\u002Fpresto_hardware.md` for complete pin configurations and initialization sequences.\n\n**Critical Considerations:**\n- Verify GPIO pin assignments for your specific board (check schematic)\n- SPI clock speed: Use maximum 62.5MHz for ST7789 displays\n- I2C frequency: 400kHz for touch controllers\n- PWM frequency: 1000Hz typical for RGB backlight\n\n**Example Initialization:**\n```python\nfrom machine import Pin, SPI, I2C, PWM\n\n# Display SPI\nspi = SPI(1, baudrate=62_500_000, polarity=0, phase=0,\n          sck=Pin(10), mosi=Pin(11))\ndc = Pin(8, Pin.OUT)\ncs = Pin(9, Pin.OUT)\nrst = Pin(12, Pin.OUT)\n\n# Touch I2C\ni2c = I2C(1, scl=Pin(15), sda=Pin(14), freq=400000)\n\n# RGB Backlight PWM\nrgb_r = PWM(Pin(16))\nrgb_g = PWM(Pin(17))\nrgb_b = PWM(Pin(18))\n\nrgb_r.freq(1000)\nrgb_g.freq(1000)\nrgb_b.freq(1000)\n```\n\n### Step 2: Implement Async Architecture\n\nFor responsive applications with multiple concurrent tasks, use asyncio patterns from `references\u002Fmicropython_async.md`.\n\n**Typical Task Structure:**\n- **UI Task**: Poll touch input every 10ms, handle gestures\n- **Timer Task**: Countdown logic every 1 second\n- **BLE Sync Task**: Update BLE clients every 500ms\n- **MQTT Task**: Check messages every 100ms, reconnect if needed\n- **Display Task**: Update display every 100ms (10 FPS)\n- **Backlight Task**: Update RGB based on state every 5 seconds\n\n**Example Async Application:**\n```python\nimport asyncio\nfrom touch_handler import TouchHandler\nfrom ble_gatt_server import BLETimerServer\nfrom mqtt_client import ReliableMQTTClient, WiFiManager\nfrom rgb_backlight import RGBBacklight\n\nasync def touch_task(touch, state):\n    while True:\n        event = touch.poll()\n        if event and event.type == TouchHandler.TOUCH_DOWN:\n            state.toggle()\n        await asyncio.sleep_ms(10)\n\nasync def ble_task(ble, state):\n    while True:\n        ble.update_timer_state(state.remaining, state.running)\n        command = ble.get_command()\n        if command is not None:\n            state.handle_command(command)\n        await asyncio.sleep_ms(500)\n\nasync def backlight_task(rgb, state):\n    while True:\n        if state.running:\n            r, g, b = rgb.urgency_gradient(state.remaining, state.total)\n            rgb.fade_to(r, g, b, duration_ms=500)\n        await asyncio.sleep(5)\n\nasync def main():\n    # Initialize hardware\n    touch = TouchHandler(touch_device)\n    ble = BLETimerServer(\"Presto\")\n    rgb = RGBBacklight(16, 17, 18)\n    state = AppState()\n\n    ble.start_advertising()\n\n    # Run all tasks concurrently\n    await asyncio.gather(\n        touch_task(touch, state),\n        ble_task(ble, state),\n        backlight_task(rgb, state)\n    )\n\nasyncio.run(main())\n```\n\n### Step 3: Optimize Display Rendering\n\n**Critical Memory Constraint:**\nA full 480×480 RGB565 framebuffer requires ~460KB, nearly exhausting available RAM.\n\n**Solutions (choose based on UI complexity):**\n\n**Option 1: Tile-Based Rendering** (for complex full-screen graphics)\n- Render display in 60×60 tiles (~7KB per tile)\n- Update one tile at a time\n- See `TiledDisplay` class in `references\u002Fdisplay_rendering.md`\n\n**Option 2: Partial Updates** (for simple UIs with distinct regions)\n- Create small buffers for specific UI elements\n- Timer display: 100×100 buffer\n- Status bar: 200×30 buffer\n- Only update changed regions\n- See `PartialUpdateDisplay` in `references\u002Fdisplay_rendering.md`\n\n**Option 3: Reduced Color Depth** (for minimal graphics)\n- Use 1-bit monochrome for simple timer displays\n- Use 8-bit grayscale (10× less memory than RGB565)\n\nRefer to `references\u002Fdisplay_rendering.md` for complete implementation details, drawing primitives, and animation techniques.\n\n### Step 4: Implement ADHD-Friendly UI\n\nFollow these principles when designing the interface:\n\n**Visual Hierarchy:**\n- Large, simple elements (big touch targets)\n- High contrast colors (white on black, vivid colors)\n- Minimal clutter (one primary action per screen)\n\n**Color Coding:**\n- **Idle**: Gray `(64, 64, 64)` - low intensity\n- **Focus**: Blue `(30, 144, 255)` - calm, engaging\n- **Break**: Green `(50, 205, 50)` - restful\n- **Urgent**: Red `(220, 20, 60)` - attention-grabbing\n- **Paused**: Amber `(255, 191, 0)` - intermediate state\n\nUse the `PresetColors` class from `rgb_backlight.py` for consistency.\n\n**Progressive Disclosure:**\n- Default view: Large timer digits, minimal information\n- Tap to expand: Show progress bar, stats, controls\n- Gestures for quick actions: Swipe to pause, double-tap to reset\n\n**Smooth Transitions:**\n- Always fade between colors (300-500ms duration)\n- Use easing functions for animations\n- Avoid jarring changes that break hyperfocus\n\n## Common Patterns\n\n### Pattern: Timer Countdown with Visual Feedback\n\nCombine timer logic, BLE sync, and RGB backlight:\n\n```python\nclass TimerState:\n    def __init__(self, duration_seconds):\n        self.total = duration_seconds\n        self.remaining = duration_seconds\n        self.running = False\n\nasync def timer_countdown(state):\n    while True:\n        if state.running and state.remaining > 0:\n            state.remaining -= 1\n        await asyncio.sleep(1)\n\nasync def visual_feedback(state, rgb):\n    while True:\n        if state.running:\n            r, g, b = rgb.urgency_gradient(state.remaining, state.total)\n            rgb.fade_to(r, g, b, duration_ms=500)\n        await asyncio.sleep(5)\n\nasync def ble_sync(state, ble):\n    while True:\n        ble.update_timer_state(state.remaining, state.running)\n        await asyncio.sleep_ms(500)\n```\n\n### Pattern: Touch-Based Timer Control\n\nStart\u002Fpause timer with tap, reset with long press:\n\n```python\nasync def touch_control(touch, gesture, state):\n    touch_start_time = 0\n\n    while True:\n        event = touch.poll()\n\n        if event:\n            if event.type == TouchHandler.TOUCH_DOWN:\n                gesture.start(event.x, event.y)\n                touch_start_time = time.ticks_ms()\n\n            elif event.type == TouchHandler.TOUCH_UP:\n                duration = time.ticks_diff(time.ticks_ms(), touch_start_time)\n\n                if duration > 1000:\n                    # Long press: reset timer\n                    state.remaining = state.total\n                    state.running = False\n                else:\n                    # Tap: toggle running\n                    detected = gesture.end(event.x, event.y)\n                    if detected == GestureDetector.TAP:\n                        state.running = not state.running\n\n        await asyncio.sleep_ms(10)\n```\n\n### Pattern: MQTT Command Handling\n\nSubscribe to control topics and update state:\n\n```python\ndef mqtt_callback(topic, msg):\n    \"\"\"Handle incoming MQTT messages.\"\"\"\n    global app_state\n\n    topic_str = topic.decode()\n    msg_str = msg.decode()\n\n    if topic_str == \"productivity\u002Ftimer\u002Fcontrol\u002Fstart\":\n        app_state.running = True\n    elif topic_str == \"productivity\u002Ftimer\u002Fcontrol\u002Fpause\":\n        app_state.running = False\n    elif topic_str == \"productivity\u002Ftimer\u002Fcontrol\u002Freset\":\n        app_state.remaining = app_state.total\n\nmqtt = ReliableMQTTClient(\n    client_id=\"presto-001\",\n    broker=\"192.168.1.100\",\n    callback=mqtt_callback\n)\n\nmqtt.subscribe(\"productivity\u002Ftimer\u002Fcontrol\u002F#\")\n```\n\n## Performance Optimization\n\n### Memory Management\n\n**Critical Rules:**\n1. Force garbage collection before allocating large buffers\n2. Delete large objects immediately after use\n3. Reuse buffers instead of creating new ones\n4. Monitor memory with `gc.mem_free()` during development\n\n**Example:**\n```python\nimport gc\n\n# Before allocating framebuffer\ngc.collect()\nprint(f\"Free before: {gc.mem_free()}\")\n\n# Use buffer\nbuffer = bytearray(100 * 100 * 2)\n# ... use buffer ...\ndel buffer\n\n# Clean up\ngc.collect()\nprint(f\"Free after: {gc.mem_free()}\")\n```\n\n### Task Scheduling\n\nBalance responsiveness vs CPU usage with appropriate sleep times:\n\n- **Touch input**: 10ms (100 checks\u002Fsecond) - high responsiveness\n- **Display updates**: 100ms (10 FPS) - smooth enough for UI\n- **BLE sync**: 500ms - adequate for state updates\n- **MQTT check**: 100ms - responsive to commands\n- **Backlight updates**: 5000ms - slow changes prevent distraction\n\n## Troubleshooting\n\n### Touch Not Responding\n\n1. Verify I2C connection: `i2c.scan()` should show touch controller address\n2. Check touch controller I2C address (typically 0x15 for CST816S)\n3. Verify GPIO pins match schematic\n4. Add pull-up resistors to SDA\u002FSCL if needed (typically 4.7kΩ)\n\n### BLE Connection Drops\n\n1. Reduce BLE notification frequency (increase sleep time in sync task)\n2. Check for WiFi\u002FBLE interference (shared radio on some modules)\n3. Verify keepalive interval matches client expectations\n4. Monitor connection events in `_irq_handler`\n\n### Display Artifacts or Tearing\n\n1. Reduce SPI clock speed if using long cables\n2. Implement double buffering for small regions\n3. Use partial updates instead of full screen redraws\n4. Ensure display CS line is properly controlled\n\n### Memory Exhaustion\n\n1. Check `gc.mem_free()` at critical points\n2. Reduce framebuffer size (use tiles or partial updates)\n3. Call `gc.collect()` before large allocations\n4. Monitor for memory leaks (allocations without deletion)\n\n## Resources\n\nThis skill includes:\n\n### scripts\u002F\nExecutable Python modules for core functionality:\n- `touch_handler.py`: Touch input and gesture detection\n- `ble_gatt_server.py`: BLE GATT server implementation\n- `mqtt_client.py`: Reliable MQTT client with auto-reconnect\n- `rgb_backlight.py`: RGB LED control with animations\n\n### references\u002F\nDetailed documentation for hardware and software:\n- `presto_hardware.md`: Complete hardware reference, pinout, initialization\n- `micropython_async.md`: Asyncio patterns and concurrent task management\n- `display_rendering.md`: Memory-efficient rendering techniques and UI design\n\nAll scripts are production-ready and can be used directly or customized for specific applications.\n",{"name":5,"description":7},"main","7850740bd837adb32f0a109ab2af82482196c6f2","skills\u002F_collections\u002Fdot_claude\u002Fskills\u002Frp2350-micropython",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":60,"prompt":70,"zipAvailable":71},[61,64,67],{"tool":62,"command":63},"npx","npx skills add shengdabai\u002FTony-Claude-Code-Skills --skill rp2350-micropython",{"tool":65,"command":66},"bunx","bunx skills add shengdabai\u002FTony-Claude-Code-Skills --skill rp2350-micropython",{"tool":68,"command":69},"pnpm","pnpm dlx skills add shengdabai\u002FTony-Claude-Code-Skills --skill rp2350-micropython","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fshengdabai\u002FTony-Claude-Code-Skills\u002Fblob\u002Fmain\u002Fskills\u002F_collections\u002Fdot_claude\u002Fskills\u002Frp2350-micropython\u002FSKILL.md",true,[73,79,83,87,93,97,101],{"path":74,"resourceType":75,"resourceTypeDesc":76,"sizeBytes":77,"sourceHtmlUrl":78},"references\u002Fdisplay_rendering.md","REFERENCE","参考文档",16262,"https:\u002F\u002Fgithub.com\u002Fshengdabai\u002FTony-Claude-Code-Skills\u002Fblob\u002Fmain\u002Fskills\u002F_collections\u002Fdot_claude\u002Fskills\u002Frp2350-micropython\u002Freferences\u002Fdisplay_rendering.md",{"path":80,"resourceType":75,"resourceTypeDesc":76,"sizeBytes":81,"sourceHtmlUrl":82},"references\u002Fmicropython_async.md",14948,"https:\u002F\u002Fgithub.com\u002Fshengdabai\u002FTony-Claude-Code-Skills\u002Fblob\u002Fmain\u002Fskills\u002F_collections\u002Fdot_claude\u002Fskills\u002Frp2350-micropython\u002Freferences\u002Fmicropython_async.md",{"path":84,"resourceType":75,"resourceTypeDesc":76,"sizeBytes":85,"sourceHtmlUrl":86},"references\u002Fpresto_hardware.md",7448,"https:\u002F\u002Fgithub.com\u002Fshengdabai\u002FTony-Claude-Code-Skills\u002Fblob\u002Fmain\u002Fskills\u002F_collections\u002Fdot_claude\u002Fskills\u002Frp2350-micropython\u002Freferences\u002Fpresto_hardware.md",{"path":88,"resourceType":89,"resourceTypeDesc":90,"sizeBytes":91,"sourceHtmlUrl":92},"scripts\u002Fble_gatt_server.py","SCRIPT","脚本",6926,"https:\u002F\u002Fgithub.com\u002Fshengdabai\u002FTony-Claude-Code-Skills\u002Fblob\u002Fmain\u002Fskills\u002F_collections\u002Fdot_claude\u002Fskills\u002Frp2350-micropython\u002Fscripts\u002Fble_gatt_server.py",{"path":94,"resourceType":89,"resourceTypeDesc":90,"sizeBytes":95,"sourceHtmlUrl":96},"scripts\u002Fmqtt_client.py",8978,"https:\u002F\u002Fgithub.com\u002Fshengdabai\u002FTony-Claude-Code-Skills\u002Fblob\u002Fmain\u002Fskills\u002F_collections\u002Fdot_claude\u002Fskills\u002Frp2350-micropython\u002Fscripts\u002Fmqtt_client.py",{"path":98,"resourceType":89,"resourceTypeDesc":90,"sizeBytes":99,"sourceHtmlUrl":100},"scripts\u002Frgb_backlight.py",8245,"https:\u002F\u002Fgithub.com\u002Fshengdabai\u002FTony-Claude-Code-Skills\u002Fblob\u002Fmain\u002Fskills\u002F_collections\u002Fdot_claude\u002Fskills\u002Frp2350-micropython\u002Fscripts\u002Frgb_backlight.py",{"path":102,"resourceType":89,"resourceTypeDesc":90,"sizeBytes":103,"sourceHtmlUrl":104},"scripts\u002Ftouch_handler.py",4616,"https:\u002F\u002Fgithub.com\u002Fshengdabai\u002FTony-Claude-Code-Skills\u002Fblob\u002Fmain\u002Fskills\u002F_collections\u002Fdot_claude\u002Fskills\u002Frp2350-micropython\u002Fscripts\u002Ftouch_handler.py",[106,115,123,131,139,147],{"skillNo":107,"name":108,"nameZh":6,"description":109,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":110,"sourceHtmlUrl":111,"categories":112,"keywords":113,"publishedAt":114},"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":116,"name":117,"nameZh":6,"description":118,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":119,"sourceHtmlUrl":120,"categories":121,"keywords":122,"publishedAt":114},"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":124,"name":125,"nameZh":6,"description":126,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":127,"sourceHtmlUrl":128,"categories":129,"keywords":130,"publishedAt":114},"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":132,"name":133,"nameZh":6,"description":134,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":135,"sourceHtmlUrl":136,"categories":137,"keywords":138,"publishedAt":114},"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":140,"name":141,"nameZh":6,"description":142,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":143,"sourceHtmlUrl":144,"categories":145,"keywords":146,"publishedAt":114},"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":148,"name":149,"nameZh":6,"description":150,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":151,"categories":152,"keywords":153,"publishedAt":114},"01M73G086AXAH9DW1H5G5N3CPB","dbs-video-extract","接收抖音、小红书、微信视频号等短视频链接或分享文案，查询作品／账号数据并提取语音文字稿，按作者和标题归档为 Markdown。用户希望完整解析短视频、取得数据或文字稿时使用；运行前检查 TikHub 与轻抖使用凭证，缺少时用新手能理解的方式引导购买和安全配置。","https:\u002F\u002Fgithub.com\u002Fshengdabai\u002FTony-Claude-Code-Skills\u002Fblob\u002Fmain\u002Fskills\u002Fdbs-video-extract\u002FSKILL.md",[],[]]