Z-Uno2 default digitalWrite behaviour

Discussion about Z-Uno product. Visit http://z-uno.z-wave.me for more details.
Post Reply
principia
Posts: 14
Joined: 28 Sep 2021 19:33

Z-Uno2 default digitalWrite behaviour

Post by principia »

I'm using Z-Uno2 with 3.0.8. The digitalWrite function only sets the addressed pin high if the value 1 is passed, e.g. digitalWrite(BUILTIN_LED, 1) and sets the pin if any other non-zero value is used. This means that when a Z-Wave switch value of 255 is received

Code: Select all

digitalWrite(BUILTIN_LED, switchValue & 0x01)
has to be used. All other Arduino implementations work using

Code: Select all

digitalWrite(BUILTIN_LED, switchValue)
.
I've looked at the source code in LLCore.c:

Code: Select all

void digitalWrite(uint8_t pin, uint8_t mode) {
    uint8_t						real_port;
    uint8_t						real_pin;

    real_port = getRealPort(pin);
    real_pin = getRealPin(pin);
    if (mode == true)
        GPIO_PinOutSet(real_port, real_pin);
    else
        GPIO_PinOutClear(real_port, real_pin);
}
The equivalent in other implementations is:

Code: Select all

void digitalWrite(uint8_t pin, uint8_t mode) {
    uint8_t						real_port;
    uint8_t						real_pin;

    real_port = getRealPort(pin);
    real_pin = getRealPin(pin);
    if (mode == 0)
        GPIO_PinOutClear(real_port, real_pin);
    else
        GPIO_PinOutSet(real_port, real_pin);
}
it would be helpful to change the function so that existing Arduino code does not break. I know we should use LOW and HIGH but that's only really useful in simple invocations of digitalWrite ;)
User avatar
PoltoS
Posts: 7588
Joined: 26 Jan 2011 19:36

Re: Z-Uno2 default digitalWrite behaviour

Post by PoltoS »

You are correct, we will fix it.
Post Reply