Re: [PIC] Learning C
"Harold Hallikainen" <[email protected]>
| Newsgroups | gmane.comp.hardware.microcontrollers.pic |
|---|---|
| Message-ID | <[email protected]> |
On Tue, November 19, 2024 6:44 pm, Justin Richards wrote: > An example is the choice of an esp8266 dynamically or statically > generating > table elements of a web page. > > Statically means I have to update two or more sections of code to make > changes, where as dynamically requires making changing to only one > section. > > The static option is more obvious and readable when later revisited but > onerous to make changes where the dynamic code is quicker, less error > prone but more obfuscated. > I've used the Microchip TCP/IP stack a lot in several products. In these products, there is a command interpreter that accepts commands over TCP and a web interface that also has controls. At first, I was using standard HTML FORM stuff and GET queries for the web interface, but I found I was writing everything twice. Once for the command interpreter and once for the web interface. In the last several products, I've put javascript in the web interface that POSTS text commands that are then passed to the same command interpreter that accepts commands over TCP. I only have to write the code once! Similarly, when I first started writing this stuff, I would write a binary blob to external flash with the system configuration. But, when I added features, the blob did not work anymore. So, I changed to saving configuration as text-based commands that are ALSO passed through the command interpreter on system start. Finally, for logging, at first I would save a Unix time stamp in each log record, then convert that to local time when displaying the log. This required the system to know the time zone offset and whether DST was used, and when. Really complicated. In more recent designs, the displayed log table has a column for the Unix time stamp and a column for local time. After the table is loaded by the browser, JavaScript converts the time stamp column to local time and puts it in the local time column. Now my microcontroller need not know anything about time zones. Live and learn! Harold https://w6iwi.org -- Not sent from an iPhone.