Skip to content

Refactor button#383

Merged
hathach merged 5 commits intomasterfrom
refactor-button
Feb 2, 2026
Merged

Refactor button#383
hathach merged 5 commits intomasterfrom
refactor-button

Conversation

@hathach
Copy link
Member

@hathach hathach commented Feb 2, 2026

This pull request standardizes button naming conventions across all board header files, replaces the _PINNUM macro with a unified PINNUM macro, and updates documentation to reflect these changes. It also updates build instructions and corrects references in documentation.

Button and Pin Macro Standardization:

Core Board Logic Updates:

  • Updates button initialization logic in boards.c and boards.h to use BUTTON_DFU and BUTTON_DFU_OTA instead of the older macros, ensuring correct initialization and detection of both DFU buttons. [1] [2] [3] [4]

Documentation Improvements:

  • Adds a new AGENTS.md file with clear style and build/verify instructions, including CMake and Make commands for supported boards.
  • Updates the board list reference in README.md to point to supported_boards.md instead of the outdated path.

These changes improve code consistency, maintainability, and documentation clarity across the project.

Copilot AI review requested due to automatic review settings February 2, 2026 09:50
# Conflicts:
#	src/boards/nice_nano/board.h
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR standardizes board button definitions around BUTTON_DFU / BUTTON_DFU_OTA, introduces a shared PINNUM macro for pin numbering, and improves documentation by adding a generated supported_boards.md plus agent build instructions.

Changes:

  • Add tools/gen_boards.py and supported_boards.md to auto-generate and document the list of supported boards from src/boards/*/board.h.
  • Replace legacy button macros in all nRF52 board headers with BUTTON_DFU / BUTTON_DFU_OTA, and migrate pin calculations to a shared PINNUM macro in boards.h (updating boards.c / boards.h and main.c accordingly).
  • Update docs (README.md, AGENTS.md) to reference the new board list and to describe preferred build/verify workflows; remove the feather_nrf52833_express board definition.

Reviewed changes

Copilot reviewed 61 out of 61 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tools/gen_boards.py New script that parses src/boards/*/board.h for UF2/USB metadata and generates supported_boards.md, grouping Adafruit vs 3rd-party boards and escaping Markdown-sensitive characters.
supported_boards.md New generated Markdown table enumerating all supported boards, product names, VID:PID pairs, and URLs based on the board headers.
src/main.c Updates DFU-mode selection logic to treat “OTA button” as BUTTON_DFU_OTA instead of the legacy BUTTON_FRESET macro.
src/boards/boards.h Introduces global PINNUM(port, pin) and includes board.h after defining it; replaces the old BUTTON_1/BUTTON_2 alias logic with (currently broken) BUTTON_DFU_OTA alias logic; updates button helper declarations to use BUTTON_DFU / BUTTON_DFU_OTA.
src/boards/boards.c Switches button init/usage from BUTTON_FRESET to BUTTON_DFU_OTA, and from old button macros to the new naming; the rest of board initialization (LEDs, NeoPixel, DCDC, UICR, timers, SysTick) is unchanged.
src/boards/m60_keyboard/board.h Refactors LEDs to use PINNUM, renames BUTTON_1/BUTTON_2 to BUTTON_DFU/BUTTON_DFU_OTA, and keeps the existing LDO control and UF2/USB metadata.
src/boards/m60_keyboard/pinconfig.c Reformats the bootloader config array and updates the ESC-button comment and GPIO config to reference BUTTON_DFU_OTA and PINNUM, keeping the regulator control logic intact.
src/boards/xiao_nrf52840_ble/board.h Removes the local _PINNUM macro in favor of PINNUM, and renames button macros to BUTTON_DFU / BUTTON_DFU_OTA while preserving pin assignments and USB/UF2 metadata.
src/boards/xiao_nrf52840_ble_sense/board.h Same pattern as above: use PINNUM for LEDs and rename button macros to BUTTON_DFU / BUTTON_DFU_OTA, with existing USB/UF2 definitions preserved.
src/boards/waveshare_nrf52840_eval/board.h Drops _PINNUM, uses PINNUM for LED/button pins, and renames BUTTON_1/BUTTON_2 to BUTTON_DFU/BUTTON_DFU_OTA without changing behavior.
src/boards/t1000_e/board.h Uses PINNUM for LED and DFU button pins and renames buttons to BUTTON_DFU / BUTTON_DFU_OTA (second button remains documented as unusable reset).
src/boards/sparkfun_nrf52840_micromod/board.h Converts LED/button pin definitions to PINNUM and renames button macros to the new scheme, preserving USB IDs and UF2 strings.
src/boards/raytac_mdbt50q_rx/board.h Switches LED and button pins to PINNUM and replaces BUTTON_1/BUTTON_2 with BUTTON_DFU / BUTTON_DFU_OTA.
src/boards/raytac_mdbt50q_db_40/board.h Adds a local PINNUM and uses it for LED and button pins; renames BUTTON_1/BUTTON_2 to BUTTON_DFU/BUTTON_DFU_OTA while keeping BUTTON_3/BUTTON_4.
src/boards/pitaya_go/board.h Updates LED and DFU button definitions to use PINNUM and the standardized button macro names; keeps RGB and UF2 info unchanged.
src/boards/pillbug/board.h Uses PINNUM for LED and assigns RESET/NC pins to BUTTON_DFU/BUTTON_DFU_OTA instead of the legacy numbered button macros.
src/boards/pca10100/board.h Rewrites button definitions from BUTTON_1/BUTTON_2 to BUTTON_DFU/BUTTON_DFU_OTA while leaving numeric pin values and LED/USB metadata as-is.
src/boards/pca10059/board.h Converts button definitions to BUTTON_DFU/BUTTON_DFU_OTA using PINNUM, and leaves LED/USB descriptors intact.
src/boards/pca10056/board.h Same logical change as pca10100: reuse 11/12 pins as BUTTON_DFU / BUTTON_DFU_OTA instead of numbered buttons.
src/boards/particle_xenon/board.h Removes _PINNUM, uses PINNUM for LED/RGB pins, and renames BUTTON_FRESET to BUTTON_DFU_OTA to match the new naming convention.
src/boards/particle_boron/board.h Same pattern as Xenon: LED pins switched to PINNUM, DFU-related buttons now BUTTON_DFU / BUTTON_DFU_OTA.
src/boards/particle_argon/board.h Same refactor as other Particle boards, adjusting only macro names and using PINNUM.
src/boards/omnimo_nrf52840/board.h Refactors LED and neopixel pins to PINNUM, and replaces BUTTON_1/BUTTON_2 with BUTTON_DFU / BUTTON_DFU_OTA.
src/boards/ohs2020_badge/board.h Drops _PINNUM, uses PINNUM, and standardizes button macro names without changing pin assignments or behavior.
src/boards/nrfmicro/board.h Switches LED pin to PINNUM and renames two DFU-related buttons to BUTTON_DFU / BUTTON_DFU_OTA with the same pins.
src/boards/nrf52840_m2/board.h Uses PINNUM for LED/RGB pins, renames the two existing buttons to BUTTON_DFU/BUTTON_DFU_OTA, and leaves all UF2/USB metadata identical.
src/boards/nrf52840_bboard/board.h Keeps numeric pins for LEDs, maps reset-related pins to BUTTON_DFU/BUTTON_DFU_OTA, and simplifies to only the new button macros.
src/boards/nice_nano/board.h Uses PINNUM for LED and defines DFU pins with BUTTON_DFU / BUTTON_DFU_OTA instead of BUTTON_1/BUTTON_2.
src/boards/nRF52840_connect_kit/board.h Updates LED/RGB pins to PINNUM and renames buttons while leaving semantics unchanged.
src/boards/mikoto/board.h Same pattern as nice_nano and pillbug: switch to PINNUM and new button macro names.
src/boards/metro_nrf52840_express/board.h Uses PINNUM for LED/neopixel pins and renames numbered buttons to BUTTON_DFU / BUTTON_DFU_OTA.
src/boards/mdk_nrf52840_dongle/board.h Switches LEDs to PINNUM and standardizes the previously “none connected” buttons as BUTTON_DFU / BUTTON_DFU_OTA placeholders.
src/boards/mbn52832dk/board.h Changes numbered button macros to BUTTON_DFU/BUTTON_DFU_OTA while preserving numeric pin values and UART configuration.
src/boards/feather_nrf52832/board.h Replaces BUTTON_1/BUTTON_2 with BUTTON_DFU / BUTTON_DFU_OTA for the same GPIO numbers; LEDs and UART remain unchanged.
src/boards/electronut_labs_papyr/board.h Standardizes buttons to BUTTON_DFU / BUTTON_DFU_OTA and keeps LED and USB/UF2 metadata intact.
src/boards/ebyte_e73_tbb/board.h Changes BUTTON_1/BUTTON_2 to BUTTON_DFU / BUTTON_DFU_OTA, preserving the detailed DFU comments and UART config.
src/boards/ebyte_e104_bt5032a/board.h Similarly converts DISC/WKP pins to BUTTON_DFU / BUTTON_DFU_OTA while preserving the documentation of the DFU sequence.
src/boards/clue_nrf52840/board.h Uses PINNUM for LED/display pins and standardizes BUTTON_DFU / BUTTON_DFU_OTA.
src/boards/circuitplayground_nrf52840/board.h Refactors LEDs and 10 NeoPixels to use PINNUM and switches buttons to the new naming.
src/boards/challenger_840_ble/board.h Moves to PINNUM for LEDs/buttons, renames buttons, and keeps LDO control and NeoPixel config the same.
src/boards/bluemicro_nrf52840/board.h Drops _PINNUM, uses PINNUM, and standardizes the reset-related pins as DFU buttons.
src/boards/bluemicro_nrf52833/board.h Same as above for the 52833 variant, including LED/neopixel pins using PINNUM.
src/boards/bast_ble/board.h Introduces a local PINNUM (duplicate of the shared one) and adopts BUTTON_DFU / BUTTON_DFU_OTA for the button pins.
src/boards/arduino_nano_33_ble/board.h Uses PINNUM and renames numbered board buttons to DFU button macros, keeping USB IDs and UF2 metadata.
src/boards/arcade_feather_nrf52840_express/board.h Same pattern as feather_nrf52840_express: use PINNUM, standardize button names, and keep Feather UF2/USB info.
src/boards/aramcon_badge_2019/board.h Uses PINNUM for LED/neopixel pins and switches numbered buttons over to BUTTON_DFU / BUTTON_DFU_OTA.
src/boards/aramcon2_badge/board.h Same as ARAMCON 2019 badge: use PINNUM and standard DFU button macros.
src/boards/ae_bl652_bo/board.h Renames the two numeric buttons to BUTTON_DFU / BUTTON_DFU_OTA; LEDs and UART config unchanged.
src/boards/adm_b_nrf52840_1/board.h Refactors LED and button pins to use PINNUM, and renames buttons to the DFU macros.
src/boards/itsybitsy_nrf52840_express/board.h Uses PINNUM for LEDs, standardizes button names, updates the UF2 index URL to a specific product page, and simplifies the include guard.
src/boards/ikigaisense_vita/board.h Converts to PINNUM for LEDs and buttons and uses BUTTON_DFU / BUTTON_DFU_OTA for existing buttons.
src/boards/feather_nrf52840_sense_tft/board.h Uses PINNUM for LED/display pins and renames the two button macros to BUTTON_DFU/BUTTON_DFU_OTA.
src/boards/feather_nrf52840_sense/board.h Same refactor as the TFT variant: PINNUM plus standardized button macros.
src/boards/feather_nrf52840_express/board.h Removes the local _PINNUM macro, uses PINNUM from boards.h, and renames BUTTON_1/BUTTON_2 to BUTTON_DFU / BUTTON_DFU_OTA.
src/boards/feather_nrf52833_express/board.h, board.cmake, board.mk, pinconfig.c Entire board directory removed, eliminating definition and build configuration for the feather_nrf52833_express board.
README.md Changes the “complete list of all boards” link from /src/boards to /supported_boards.md to point at the new generated overview.
AGENTS.md New agent-focused instructions emphasizing .clang-format usage and CMake/Make build commands for feather_nrf52832 and feather_nrf52840_express.
Comments suppressed due to low confidence (1)

src/boards/feather_nrf52833_express/board.h:1

  • This change removes the entire feather_nrf52833_express board definition (board.h/board.cmake/board.mk/pinconfig.c), which effectively drops support for that board but is not mentioned in the PR description about button/pin macro refactoring. Please confirm whether this board is intentionally being removed; if so, consider explicitly calling it out in the PR description and any user-facing documentation that previously referred to it, or otherwise keep the board and update its button macros to the new naming scheme.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@hathach hathach merged commit 5a11529 into master Feb 2, 2026
98 checks passed
@hathach hathach deleted the refactor-button branch February 2, 2026 10:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant