Skip to content

pin.get_analog_period_microseconds() returns -1 if the pin has not been used yet with write_analog() #143

Open
@microbit-carlos

Description

@microbit-carlos

In comparison V1 returns the configured period (default is 20ms).

V1:

>>> pin0.get_analog_period_microseconds()
20000

V2:

>>> pin0.get_analog_period_microseconds()
-1
>>> pin0.write_analog(512)
>>> pin0.get_analog_period_microseconds()
20000

Looks like this is by design? as CODAL is not providing the data:

int microbit_hal_pin_get_analog_period_us(int pin) {
int period = pin_obj[pin]->getAnalogPeriodUs();
if (period != DEVICE_NOT_SUPPORTED) {
return period;
} else {
return -1;
}
}

So if we cannot support this V1 compatibility we might need to update the docs.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions