Cornell University ECE4760
Access point and web server
as Control Panel
Pi Pico RP2040

Access point and web server
The access point example code in the WIFI section of the picoW examples runs as-is, but I hacked it out of the examples build-structure to compile alone, then added a VGA driver. The code brings up a stand-alone WIFI access point, with DHCP server, DNS server and web server. The supplied code serves one page, with one clickable link that toggles the picoW on-board LED. I added a bunch of comments, generalized the query-string parser (query-string is the part of URL after the ? character), and adding ability to serve several pages of html. Since there is no file system, and no outside connection to the internet, the page request processing had to be quite simple, but supports run-time modifiable pages, text, html forms, hyperlinks, and javascript. The javascript, of course, runs on the browser.

This example is intended to show how to set up simple web pages for process control, not to produce a general web server. Web pages are written in raw HTML. Simple text has the usual formatting tags and can be modifed on the fly by the server for text-based output. The example has input interactors in the form of text input, graphic sliders to set numerical values, and drop down menus. Simple SVG graphics can be embedded as can javascript.

As a first test, I wanted to see if a cell phone could act a a reasonable user interface to code running on the picoW. In this case the application code was just a video thread running on core1 which displayed the status of the server and browser variables. LWIP is running on core0. My Android phone connected to the picoW with no complaints. The code runs without a serial monitor or VGA attached, but obviously then you can only interact via browser.
Demo functionality:

Three screens are shown below refecting different views of the program state. First is a browser window running on my cellphone and after pressing the submit buttion. Notice that there is no internet connection and that the IP I chose for the server is 192.168.4.1. The page is ledtest. The second image shows page 2 of the browser interface. The third image is the server-attached VGA screen showing the status of all the browser and console variables.

---

---

CODE, ZIP of project
Note that you will need to delete the build directory and specify a new one.

VGA driver and LWIP considerations
Both the VGA driver written by Hunter Adams (and converted to 256 colors by Bruce) and the LWIP supplied as part of the C SDK use significant hardware to accelerate operations. The VGA driver uses 4 DMA channels and all 4 state machines in one PIO. The LWIP uses 2 DMA channels and two PIO state machines. LWIP defaults to PIO1 (see cyw43_bus_pio_spi.c), so the VGA must use PIO0. The LWIP uses the claim mechanism to grab DMA channels. This means that any unused channel may be grabbed. The VGA driver was modified to use the claim system so that it does not step on the channels used by LWIP. Once this small change was made, the two libraries played nicely together.


Copyright Cornell University July 30, 2023