Markdown Converter
Agent skill for markdown-converter
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Sign in to like and favorite skills
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
This is a Raspberry Pi Pico 2 (RP2350) firmware project implementing a multi-application system controlled by DIP switches. The firmware allows switching between different hardware control applications at boot time based on physical switch positions.
The project includes both the firmware and a Python host library (
picohost) for controlling devices from a host computer.
# Initialize submodules first (if not already done) git submodule update --init lib/cJSON git submodule update --init lib/BNO08x_Pico_Library git submodule update --init pico-sdk cd pico-sdk && git submodule update --init && cd .. # Build for Pico 2 (default target) ./build.sh # Manual build process mkdir build && cd build PICO_BOARD=pico2 cmake .. PICO_BOARD=pico2 make -j$(nproc) # Clean build artifacts ./clean.sh
The build produces
build/pico_multi.uf2 which can be flashed to the Pico by copying it while in BOOTSEL mode.
# Flash multiple Picos at once python3 flash_picos.py --uf2 build/pico_multi.uf2 # Flash with custom parameters python3 flash_picos.py --uf2 build/pico_multi.uf2 --baud 115200 --timeout 10 # Monitor serial output (adjust /dev/ttyACM0 as needed) minicom -D /dev/ttyACM0 -b 115200 # Install Python host library for device control pip install -e ./picohost # Run device-specific test scripts python3 picohost/test_motor.py # Test motor control python3 picohost/test_tempmon.py # Test temperature monitoring python3 picohost/test_imu.py # Test IMU sensor
# Install build dependencies (Ubuntu/Debian) sudo apt update sudo apt install build-essential pkg-config libusb-1.0-0-dev cmake # Install picotool from source cd ~/ git clone https://github.com/raspberrypi/picotool.git cd picotool mkdir build && cd build cmake .. && make sudo cp picotool /usr/local/bin/ # Set up udev rules for non-root access echo 'SUBSYSTEM=="usb", ATTRS{idVendor}=="2e8a", MODE="0666"' | sudo tee /etc/udev/rules.d/99-pico.rules sudo udevadm control --reload-rules && sudo udevadm trigger # Install Python dependencies pip3 install pyserial
The firmware implements a multi-app dispatch system in
src/main.c:
app_init() - One-time initializationapp_server() - Command processing from JSON inputapp_op() - Continuous operations in main loopapp_status() - Periodic status reporting (every 200ms)Create app source files following the pattern:
// app_name.h void app_name_init(uint8_t app_id); void app_name_server(uint8_t app_id, const char *line); void app_name_op(uint8_t app_id); void app_name_status(uint8_t app_id); // app_name.c void app_name_init(uint8_t app_id) { // Initialize hardware for this app } void app_name_server(uint8_t app_id, const char *line) { // Process JSON commands using eigsep_command } void app_name_op(uint8_t app_id) { // Continuous operations } void app_name_status(uint8_t app_id) { // Send status updates using send_json() }
Add app ID to
src/pico_multi.h (e.g., #define APP_NEWAPP 6)
Add app to dispatch switches in
src/main.c (init, server, op, status)
Update
CMakeLists.txt to include new source files
Create corresponding Python host class in
picohost/ following existing patterns
src/main.c - DIP switch reading and app dispatchsrc/motor.c - Stepper motor control (APP_MOTOR = 0)src/tempctrl.c - Temperature controller (APP_TEMPCTRL = 1)src/tempmon.c - Temperature monitoring (APP_TEMPMON = 2)src/imu.c - IMU sensor interface (APP_IMU = 3)src/lidar.c - Lidar sensor interface (APP_LIDAR = 4)src/rfswitch.c - RF switch control (APP_RFSWITCH = 5)lib/eigsep_command/ using cJSON librarypicohost/ package with device-specific classesAll applications use a JSON-based command/response protocol over USB serial at 115200 baud:
{"cmd": "command_name", "param1": value1, ...}\n{"status": "ok/error", "data": {...}}\nExample using Python host library:
from picohost import MotorDevice with MotorDevice() as motor: motor.set_azimuth_position(1000) motor.set_elevation_position(500) print(motor.get_status())
Python script for flashing and configuring multiple Picos:
picotool to flash via USB serial numberdevices_info.json with device configurationsComplete Python package for controlling Pico devices:
The project includes several libraries:
pico-sdk/ subdirectorysrc/ directory and fully integratedSTATUS_CADENCE_MS)