Skip to content

Prog_Mode

Mike edited this page May 2, 2023 · 3 revisions

Handle the Prog-Mode

In order to set the Physical Address of your device you must define a Prog-Button and Prog-LED.

Type Method
Prog-Button Calling buttonPin
Build Flag
Prog-LED Calling ledPin
Build Flag
Callbacks

Prog-Button

The default Pin for the Button is always 0!
The Stack handles the creation of a Interrupt and toggling the Prog-Mode.
There are two ways to define the pin for the Prog-Button.

Calling buttonPin
// pin or GPIO programming button is connected to. Default is 0
knx.buttonPin(PROG_BUTTON_PIN);
// Is the interrupt created in RISING or FALLING signal? Default is RISING
knx.buttonPinInterruptOn(PROG_BUTTON_PIN_INTERRUPT_ON);
Build Flag Button

You can also set the Pin with a build flag:

build_flags = 
	-DPIO_FRAMEWORK_ARDUINO_ENABLE_RTTI
	-DLWIP_DONT_PROVIDE_BYTEORDER_FUNCTIONS
	-DMASK_VERSION=0x07B0
	-DKNX_BUTTON=24

Prog-LED

The default Pin for the LED is always LED_BUILDIN!
There are three ways to set/handle the Prog-LED.

Calling ledPin
// pin or GPIO the programming led is connected to. Default is LED_BUILDIN
knx.ledPin(PROG_LED_PIN);
// is the led active on HIGH or low? Default is LOW
knx.ledPinActiveOn(PROG_LED_PIN_ACTIVE_ON);
Build Flag LED

You can also set the Pin with a build flag:

build_flags = 
	-DPIO_FRAMEWORK_ARDUINO_ENABLE_RTTI
	-DLWIP_DONT_PROVIDE_BYTEORDER_FUNCTIONS
	-DMASK_VERSION=0x07B0
	-DKNX_LED=24
Callbacks

If you want to display the prog mode other than just a led pin you can add callbacks to setProgLedOnCallback and setProgLedOffCallback.
This way you can handle the prog mode display by your own.
For example with an NeoPixel:

void progLedOff() {
    pixels.clear();
    pixels.show();
}

void progLedOn() {
    pixels.setPixelColor(0, pixels.Color(255, 0, 0));
    pixels.show();
}

knx.setProgLedOffCallback(progLedOff);
knx.setProgLedOnCallback(progLedOn);