Z-Uno2 default digitalWrite behaviour
Posted: 12 Dec 2021 12:51
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 has to be used. All other Arduino implementations work using .
I've looked at the source code in LLCore.c:
The equivalent in other implementations is:
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 
Code: Select all
digitalWrite(BUILTIN_LED, switchValue & 0x01)
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);
}
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);
}
