After the last sensor has been converted, you could simply disable the callback, putting the system in the same state it was initially. I.e., when your function is entered, you set up the callback, convert all the values, and disable the callback afterwards.
However, there is a problem with this too. Whatever delays you put into an object will delay the whole patch. If the delay is longer than a k-rate period the patch essentially becomes useless as it can't complete it's tasks within the allotted k-rate period.
I would rewrite the object so that it reads one sensor per k-rate cycle (depending on how fast the ADC interrupt actually runs). Thus, instead of the i and j loops, you would have i and j variables which are updated once per k-rate cycle.
Basically, the object the would do the following:
- Read the previously converted value from adcvalues.
- Calculate the next sensor to read, and output its address to the gpio pins.
- Exit, thus in practice waiting a k-rate period for the conversion to take place, after which the object's code is called again and the converted value read.
If the ADC routine produces a new adcvalues update more seldom than once per k-rate period, you'd need to add yet another state variable and more code to wait for more than one k-rate period between writing the sensor address and reading adcvalues. I think that's why one of the code snippets referenced above only reads the value every second k rate cycle.
I think trying to force extra ADC conversions from your object will cause a conflict between the ADC interrupt and your object. ADC conversion takes time, which is why it's relegated to an interrupt and not done on the fly.
If the resulting scan rate is too slow (assuming you can read adcvalues once per k-rate period, it gives you a scan rate of 3000/225 = 13.333 Hz, as noted above), I'd suggest modifying the hardware to read more than one sensor at a time, using more ADC channels.
The basic issue here is that AD conversion takes time, and when converting a large number of sensors, it scales up. This is a problem which has plagued designers of synths with a large number of knobs since the Prophet-5.
A secondary issue is that in an Axoloti object, you need to do your stuff and get out without any delays, as any delays will disrupt the whole patch. The reason for this is that all objects are called in the same call chain, rather than being separate processes (which is the most efficient way of executing code, as there is no interprocess communication, but it does require the programmer to think in terms of the code executing in a number of states, rather than one long sequence).