0.94.0 - A KVM switch over RS-232 or by its hotkey, and SparkFun boards

One ESP-KVM in front of a KVM switch reaches several machines. Until now it could pick the machine in two ways: a wire on the switch's select button, or TESmart's commands over the network. This release adds two more, both from ekozan's request in #107. They are in Settings > Power > KVM switch.
Over RS-232
Rack switches often have an RS-232 control port. Its signals are ±12 V, so a MAX3232 module goes in between: its TTL side to the device, TX, RX and ground to the switch.
For a TESmart switch the device sends the same 6 bytes it sends over the network, at 9600 baud. With RX wired it also asks which machine is on, so pressing the switch's own buttons shows up in the console. The HKS801-E23 from #107 takes these commands.
Any other switch gets a command copied from its manual. {n} is the machine number, {nn} the same in two digits, \r is Enter. A switch that wants sw i02 and Enter for the second machine gets sw i{nn}\r. Such a switch answers nothing, so the console shows the machine it asked for last.
The serial console to the target has its own port, so both work at once.
By hotkey
Most cheap switches have no control port. They watch the keyboard for a hotkey instead, often Scroll Lock twice and the number. ESP-KVM is a keyboard, so it types that: scrolllock scrolllock {n} by default, or ctrl+alt+{n} for Ctrl, Alt and the number.
Many switches read hotkeys only on their keyboard port. The device has to go there, and the virtual drive does not pass through that port. Some switches also want a plain keyboard: the device is a keyboard, mouse and disk in one, and they ignore it.
The machines are in the Power menu as before. Buttons on the box, schedules, MQTT and POST /api/v1/power/switch can switch too.
SparkFun IoT RedBoard ESP32-P4
Images for both models, PoE and Wi-Fi. Both are rev 3.x with 32 MB of PSRAM, and the C790's 22-pin ribbon plugs straight into the camera connector. I built them from SparkFun's open schematics.
Each board needed something new in the firmware. The PoE board has no 50 MHz clock for its Ethernet PHY: the P4 makes it on GPIO 23, and the board loops it back to the clock input on GPIO 32. On the Wi-Fi board the C5 co-processor's enable goes through a transistor, so a high pin holds the C5 in reset, the opposite of what esp-hosted expects. The firmware pulses that pin itself before Wi-Fi starts.
Fixes
- Dashcam restart loop. With the dashcam on and clips kept in memory (the default), the device restarted every half a minute or so once it began saving a clip, say after the screen stayed one colour for 30 s. The task that watches for those events ran out of stack while it wrote the clip's first file. Seen on an M5Stack PoE-P4.
- A TC358743 that resets on its own. After a reset, say on a dip in its supply, the HDMI chip comes back with its reset values: no EDID, hotplug low, CSI off. The source sees no monitor, and the picture stayed gone until the device restarted. The device now reads back a register it always sets. If it holds the reset value again, the device sets the chip up from scratch, and the source sees the monitor come back, as after replugging the cable.
- 500 mA. The device asked the target's USB port for 100 mA. Boards powered from that port, such as the JetKVM Mini, need more once video and the network run. Now it asks for 500 mA, the most a USB 2.0 port gives.
Release: v.0.94.0.
Comments