Add basis for TCP/IP stack. The stack implements Netdever interface for
the top-end, and calls into a Netlinker interface on the bottom-end.
Each TCP/IP stack instance represents a L3/L4 endpoint with an IP
address. The Netlinker is bound when creating the stack. E.g.:
spi, cs, wlreg, irq := cyw43439.PicoWSpi(0)
cyw43 := cyw43439.NewDevice(spi, cs, wlreg, irq, irq)
stack := tcpip.NewStack(cyw43)
netdev.UseNetdev(stack)
Here, the cyw43439 driver is the Netlinker for the stack. The new stack
is a Netdever, so we tell the "net" package to use the stack as the
netdev. The stack manages L3/L4 socket connections, ultimately calling
into the Netlinker to send/recv L2 Ethernet pkts.
This adds three new L2 (intermediate) drivers for bridge/bond/vlan.
Theses drivers are incomplete but illustrate how to stack L2 drivers.
Here are some examples of how these driver would stack with the cy243439
driver:
Bridge: bridge two cyw43 devices together, connecting the two LANs:
cyw43_0 := cyw43439.NewDevice(...)
cyw43_1 := cyw43439.NewDevice(...)
bridge := NewBridge([]netlink.Netlinker{cyw43_0, cyw43_1})
stack := tcpip.NewStack(bridge)
netdev.UseNetdev(stack)
Bond: bond two cyw43 devices together, creating one logical device.
The first physical device is primary, the second is backup (fail-over)
device:
cyw43_0 := cyw43439.NewDevice(...) // primary
cyw43_1 := cyw43439.NewDevice(...) // secondary (backup)
bond := NewBond([]netlink.Netlinker{cyw43_0, cyw43_1})
stack := tcpip.NewStack(bond)
netdev.UseNetdev(stack)
Vlan: add tagged VLAN ID=100 to cyw43:
cyw43 := cyw43439.NewDevice(...)
vlan100 := NewVlan(100, cyw43)
stack := tcpip.NewStack(vlan100)
netdev.UseNetdev(stack)
This moves the netdev/netlink namespace out of drivers and into their
own packages. Also, defines netdev and netlink as L3/L4 and L2 OSI
layers, respectively. Move some L3 functionality from netlink to
netdev (GetIPAddr).
For netlink, add ConnectParams for NetConnect to pass in L2 connection
parameters (ssid, pass, auth_type, etc). Also adds connection mode
(STA, AP, etc).
For netlink, add SendEth and RecvEthFunc funcs to handle L2 send/recv of
Ethernet pkts.
Tested with a rp2040.
TODO: add the ability to set the absolute humidity for more accurate
sensor details. The formula for that is rather complex, so I've left
this as a future addition.
Replace DrawRGBBitmap8 with DrawBitmap, following the change in the
previous commit.
This improves performance from 86fps to 100fps! I didn't investigate
why, but I suspect it's because it now needs only a single store instead
of two to update a pixel.
Same as for st7735 in the previous commit.
In addition, this avoids allocating a big chunk of memory on _every_
draw operation (even SetPixel) and instead reuses it across draw
operations. This makes the driver a whole lot more efficient.
Using RGB444 instead of RGB565 can speed up graphics operations by up to
25%, especially on slow screens. But for full support, all parts of the
driver need to be aware of the color format.
It's possible to do this using a regular configuration variable, but
it's unlikely to be very efficient. Hence the usage of generics.
This has been optimized for working with SPI displays like the ST7789.
By working directly in the native color format of the display, graphics
operations can be much, _much_ faster.
Also, this makes it easier to use a different color format like RGB444
simply by changing the generic type.
The previoius behavior was that entirely black pixels were treated as
white, and anything else as black. That's at least counter-intuitive.
This patch changes the behavior to actually look at the color values and
use a cutoff around medium gray: darker colors are treated as black, and
lighter colors are treated as white.
This is a backwards incompatible change, but I think this behavior makes
a lot more sense.
This commit updates rotation behavior to match other displays.
For more information, see: https://github.com/tinygo-org/drivers/pull/550
This changes the signature of `SetRotation` but I don't think any
existing code will be affected by this change.
named channel, do the same for RegionSettings, and then change RegionSettings to
just Settings to avoid the redundant naming.
Signed-off-by: deadprogram <ron@hybridgroup.com>
For details, see: https://github.com/tinygo-org/tinygo/pull/3927
This change just means we need to be more careful to use the right type,
now that types like C.uint32_t don't match to the Go equivalent (like
uint32).