* read() is now readinto() and takes the buffer to write into.
* readinto() returns the number of valid samples.
* readinto() can be interrupted by ctrl-c.
* readinto() API doesn't support signed numbers because it never did.
* sample_rate is now required in the constructor because supported
values will vary per-port.
* 16 bit values are full range. 12 bit samples from RP2040 are stretched
in the same way they are for AnalogIn.
Fixes#7226
Because this must be treated like an in-use pin for all other purposes,
unfortunately a special case must be added in shared-bindings.
Multiple AnalogIn objects for VOLTAGE_MONITOR can be created (because
in use tracking isn't working) but this causes no harm.
Testing performed: Read the monitor, then imported wifi. When the
pin state was insufficiently restored, the second step would fail
with debug messages about do_ioctl timeout.
```
import analogio, board
a = analogio.AnalogIn(board.VOLTAGE_MONITOR)
print(a.value)
import wifi
```
Closes: #7020
This is the lwip no-os version of SO_REUSEADDR, which is set on all
listening sockets in the espressif port; do so here as well,
it makes running servers easier. The "address in use" error does
not occur.
You might wonder how this fixes a problem with PulseIn, when the
changes aren't to any of those files! PulseIn is implemented in terms of
StateMachine, which had some assumptions about the relation between
the index of a pin object in mcu_pin_global_dict_table and its "pin
number". This was true, until some pins were removed from the
microcontroller module on Pico W.
Closes: #7078
Weirdly we have to stop the AP too (which we never started),
or cyw43_tcpip_link_status still reports that STA is connected.
As long as AP mode isn't implemented, this doesn't matter and
we can just do it.
Foamyguy discovered that trying to send >2920 bytes at once consistently
failed. I further discovered that sometimes trying to send >1460 bytes
would fail too. By "fail", I mean that it would take a very long time
(around 200 * 50ms) before erroneously reporting that all bytes were
written.
In my testing, this change causes larger writes to successfully
send either 2920 or 1460 bytes (possibly after doing some 50ms waits
for a previous packet to clear).
The documentation of socket.send always stated that it COULD send fewer
bytes than requested, but adafruit_httpserver assumed that the number
of requested bytes were always sent, so after this change alone,
adafruit_httpserver will still not work properly.
Closes: #7077 (albeit fixes are needed in adafruit_httpserver too)