Closed tfry-git closed 1 year ago
Memory usage change @ 04f127541f158381d63418c35be36b92c5d34e1e
Board | flash | % | RAM for global variables | % |
---|---|---|---|---|
arduino:mbed_giga:giga |
0 - 0 | 0.0 - 0.0 | 0 - 0 | 0.0 - 0.0 |
Memory usage change @ 82ae24a2a9b46e92b58b212c72abb0127644ee17
Board | flash | % | RAM for global variables | % |
---|---|---|---|---|
arduino:mbed_giga:giga |
0 - 0 | 0.0 - 0.0 | 0 - 0 | 0.0 - 0.0 |
Hi @tfry-git :coffee: :wave:
Can you please provide an example show-casing how you'd use this feature?
Can you please provide an example show-casing how you'd use this feature?
For clarification: Do you want an example of how I would actually use this (in order to judge, whether the proposed change makes sense), or do you want me to provide a user visible example for inclusion in examples-dir?
I'll happily provide the second, if that's what you mean.
As for the first: My actual use-case is a library for audio synthesis (Mozzi). Note that Mozzi is cross platform, and the user-facing API already exists, so from the Mozzi point of view this PR is about enabling an implementation on the Giga. More specifically, we have a function uint16_t mozziAnalogRead(uint8_t pin)
. This behaves similar to analogRead()
, but with the difference that it does not wait blocking for a conversion to happen, but rather returns a cached value (and ensures that an actual reading will be taken as soon as possible). The rationale is, that in our context a blocking delay is typically prohibitive (buffer underrun), but readings are going to be taken repeatedly, anyway.
Regarding the API, none of the other existing platform ports require prior specification of the pins that will be used in mozziAnalogRead()
, it's fully implicit. We want the same existing code base to work on the Giga, unchanged. I.e. the semantics are roughly:
mozziAnalogRead() -> update list of pins to sample -> trigger hardware-specific non-blocking readings of these pins -> cache the resulting values -> to be returned in a subsequent call of mozziAnalogRead()
Regarding possible way to accomplish this, I see the following options:
Hi @tfry-git :coffee: :wave:
Judging by the current state of your PR I consider it non-invasive, hence would be happy to merge.
For clarification: Do you want an example of how I would actually use this (in order to judge, whether the proposed change makes sense), or do you want me to provide a user visible example for inclusion in examples-dir?
I'll happily provide the second, if that's what you mean.
Yes, this would be about the second option. If you could add such an example to this PR I'll be happy to merge :bow: .
Example added.
Memory usage change @ 4c365697fd74d2220439ad40bb84a61baa181f77
Board | flash | % | RAM for global variables | % |
---|---|---|---|---|
arduino:mbed_giga:giga |
0 - 0 | 0.0 - 0.0 | 0 - 0 | 0.0 - 0.0 |
Arguably, in user code, the list of pins to sample will typically be known and fixed at compile-time.
However, when wrapping this into a library (Mozzi; for the purpose of providing a cross-platform analog read mechanism), it will be very helpful to have a way to adjust the pins to sample after construction.