Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
microbit-carlos opened this issue Nov 9, 2022 · 1 comment

Comments

@microbit-carlos
Copy link
Contributor

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.

@microbit-carlos
Copy link
Contributor Author

The resolution of this issue should result in NRF52Pin::getAnalogPeriodUs() to not return DEVICE_NOT_SUPPORTED, so this should be fixed with a future CODAL update:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant