Skip to content

Fix Leafony AP03 PB5 pin mapping to D4 - #3094

Merged
fpistm merged 1 commit into
stm32duino:mainfrom
taltalp:fix/leafony-ap03-pb5
Oct 12, 2026
Merged

fpistm merged 1 commit into
stm32duino:mainfrom
taltalp:fix/leafony-ap03-pb5

Conversation

@taltalp

@taltalp taltalp commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Change the Leafony AP03 PB5 definition from 1 to 4.

In variant_LEAFONY_AP03.cpp, digitalPin[1] is PA_2 and digitalPin[4] is PB_5. However, the header defines PB5 as 1, so calls such as pinMode(PB5, ...) target PA2 (the default Serial TX pin) instead of PB5.

This one-line change makes the header consistent with the pin mapping table. PB5_ALT1 also inherits the corrected definition.

Validation

  • Confirmed the incorrect mapping in upstream main at 21c906e95078b1a8ee5a5a68059cda1fc33945f0.
  • Compared all 18 GPIO macros defined as numeric pin indices with digitalPin[]. PB5 was the only mismatch before the fix; all 18 match after the fix.
  • Built the minimal sketch below with PlatformIO ststm32@19.3.0, Arduino STM32 Core 2.10.1, and the standard board = leafony_ap03 definition. Both static_assert checks failed before the fix. The same sketch built successfully after applying the one-line change to an isolated copy of the framework.
  • Build validation used the released Core 2.10.1 with the same change applied. The full upstream main branch was not built, and GPIO behavior has not been tested on hardware. The runtime check in setup() was compiled but not executed.
#include <Arduino.h>

static_assert(PB5 == 4, "PB5 must refer to D4");
static_assert(PB5 != PA2, "PB5 must not alias PA2");

void setup()
{
  if (digitalPinToPinName(PB5) != PB_5) {
    while (true) {}
  }
  pinMode(PB5, INPUT);
}

void loop() {}

Code formatting

The change replaces a single digit and preserves the existing formatting. CI and AStyle results will be available in the PR checks.

Map PB5 to D4, matching digitalPin[4] = PB_5.
The previous value 1 aliases PA2 and targets the wrong GPIO.

Signed-off-by: Shuya Nakagawa <taltalpmh@gmail.com>
@fpistm

fpistm commented Oct 12, 2026

Copy link
Copy Markdown
Member

@taltalp
Please update all your comment in english.

@taltalp taltalp changed the title Leafony AP03のPB5ピン定義をD4に修正 Fix Leafony AP03 PB5 pin mapping to D4 Oct 12, 2026

@fpistm fpistm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the fix.

@fpistm
fpistm force-pushed the main branch 2 times, most recently from 288ec52 to 0845fd7 Compare October 12, 2026 14:10
@fpistm
fpistm merged commit 6c0b5f2 into stm32duino:main Oct 12, 2026
30 checks passed
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.

2 participants